Rev 10229 | Rev 12043 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10205 | subik | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | #include <QModelIndex> |
||
8 | |||
11836 | subik | 9 | #include "scrspinbox.h" |
10 | #include "scribusdoc.h" |
||
10205 | subik | 11 | #include "guidesdelegate.h" |
12 | |||
13 | |||
14 | GuidesDelegate::GuidesDelegate(QObject *parent) |
||
10229 | subik | 15 | : QItemDelegate(parent), |
11836 | subik | 16 | m_doc(0) |
10205 | subik | 17 | { |
18 | } |
||
19 | |||
20 | QWidget * GuidesDelegate::createEditor(QWidget *parent, |
||
21 | const QStyleOptionViewItem &/* option */, |
||
22 | const QModelIndex &/* index */) const |
||
23 | { |
||
11836 | subik | 24 | ScrSpinBox *editor = new ScrSpinBox(0, 1000, parent, m_doc?m_doc->unitIndex():0); |
10205 | subik | 25 | return editor; |
26 | } |
||
27 | |||
28 | void GuidesDelegate::setEditorData(QWidget *editor, |
||
29 | const QModelIndex &index) const |
||
30 | { |
||
31 | double value = index.model()->data(index, Qt::DisplayRole).toDouble(); |
||
11836 | subik | 32 | ScrSpinBox *w = static_cast<ScrSpinBox*>(editor); |
10205 | subik | 33 | w->setValue(value); |
34 | } |
||
35 | |||
36 | void GuidesDelegate::setModelData(QWidget *editor, |
||
37 | QAbstractItemModel *model, |
||
38 | const QModelIndex &index) const |
||
39 | { |
||
11836 | subik | 40 | ScrSpinBox *w = static_cast<ScrSpinBox*>(editor); |
10205 | subik | 41 | w->interpretText(); |
42 | double value = w->value(); |
||
43 | model->setData(index, value); |
||
44 | } |
||
45 | |||
46 | void GuidesDelegate::updateEditorGeometry(QWidget *editor, |
||
47 | const QStyleOptionViewItem &option, |
||
48 | const QModelIndex &/* index */) const |
||
49 | { |
||
50 | editor->setGeometry(option.rect); |
||
51 | } |
||
10229 | subik | 52 | |
11836 | subik | 53 | void GuidesDelegate::setDoc(ScribusDoc * doc) |
10229 | subik | 54 | { |
11836 | subik | 55 | m_doc = doc; |
10229 | subik | 56 | } |