Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 11835 → Rev 11836

/trunk/Scribus/scribus/guidesdelegate.cpp
4,15 → 4,16
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include <QDoubleSpinBox>
#include <QModelIndex>
 
#include "scrspinbox.h"
#include "scribusdoc.h"
#include "guidesdelegate.h"
 
 
GuidesDelegate::GuidesDelegate(QObject *parent)
: QItemDelegate(parent),
m_docUnitDecimals(0)
m_doc(0)
{
}
 
20,9 → 21,7
const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const
{
QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
editor->setRange(0, 1000);
editor->setDecimals(m_docUnitDecimals);
ScrSpinBox *editor = new ScrSpinBox(0, 1000, parent, m_doc?m_doc->unitIndex():0);
return editor;
}
 
30,7 → 29,7
const QModelIndex &index) const
{
double value = index.model()->data(index, Qt::DisplayRole).toDouble();
QDoubleSpinBox *w = static_cast<QDoubleSpinBox*>(editor);
ScrSpinBox *w = static_cast<ScrSpinBox*>(editor);
w->setValue(value);
}
 
38,7 → 37,7
QAbstractItemModel *model,
const QModelIndex &index) const
{
QDoubleSpinBox *w = static_cast<QDoubleSpinBox*>(editor);
ScrSpinBox *w = static_cast<ScrSpinBox*>(editor);
w->interpretText();
double value = w->value();
model->setData(index, value);
51,7 → 50,7
editor->setGeometry(option.rect);
}
 
void GuidesDelegate::unitChange(int docUnitDecimals)
void GuidesDelegate::setDoc(ScribusDoc * doc)
{
m_docUnitDecimals = docUnitDecimals;
m_doc = doc;
}
/trunk/Scribus/scribus/guidemanager.cpp
104,6 → 104,7
void GuideManager::setDoc(ScribusDoc* doc)
{
m_Doc=doc;
qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->setDoc(doc);
if (!m_Doc)
currentPage = 0;
tabWidget->setEnabled(doc ? true : false);
258,7 → 259,7
// models display
horizontalModel->unitChange(docUnitIndex, docUnitDecimals);
verticalModel->unitChange(docUnitIndex, docUnitDecimals);
qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->unitChange(docUnitDecimals);
qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->setDoc(m_Doc);
}
 
void GuideManager::delHorButton_clicked()
/trunk/Scribus/scribus/guidesdelegate.h
9,9 → 9,11
 
#include <QItemDelegate>
 
class ScribusDoc;
 
 
/*! \brief A delegate/editor for guides model.
It's based on the QDoubleSpinBox widget. User cannot enter
It's based on the ScrSpinBox widget. User cannot enter
any others (ugly and bad) values.
\author Petr Vanek <petr@scribus.info>
*/
37,9 → 39,10
const QModelIndex &index) const;
 
void unitChange(int docUnitDecimals);
void setDoc(ScribusDoc * doc);
 
private:
int m_docUnitDecimals;
ScribusDoc *m_doc;
};
 
#endif