Rev 10229 | Go to most recent revision | Details | 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 <QDoubleSpinBox> |
||
8 | #include <QModelIndex> |
||
9 | |||
10 | #include "guidesdelegate.h" |
||
11 | |||
12 | |||
13 | GuidesDelegate::GuidesDelegate(QObject *parent) |
||
14 | : QItemDelegate(parent) |
||
15 | { |
||
16 | } |
||
17 | |||
18 | QWidget * GuidesDelegate::createEditor(QWidget *parent, |
||
19 | const QStyleOptionViewItem &/* option */, |
||
20 | const QModelIndex &/* index */) const |
||
21 | { |
||
22 | QDoubleSpinBox *editor = new QDoubleSpinBox(parent); |
||
23 | editor->setRange(0, 1000); |
||
24 | return editor; |
||
25 | } |
||
26 | |||
27 | void GuidesDelegate::setEditorData(QWidget *editor, |
||
28 | const QModelIndex &index) const |
||
29 | { |
||
30 | double value = index.model()->data(index, Qt::DisplayRole).toDouble(); |
||
31 | QDoubleSpinBox *w = static_cast<QDoubleSpinBox*>(editor); |
||
32 | w->setValue(value); |
||
33 | } |
||
34 | |||
35 | void GuidesDelegate::setModelData(QWidget *editor, |
||
36 | QAbstractItemModel *model, |
||
37 | const QModelIndex &index) const |
||
38 | { |
||
39 | QDoubleSpinBox *w = static_cast<QDoubleSpinBox*>(editor); |
||
40 | w->interpretText(); |
||
41 | double value = w->value(); |
||
42 | model->setData(index, value); |
||
43 | } |
||
44 | |||
45 | void GuidesDelegate::updateEditorGeometry(QWidget *editor, |
||
46 | const QStyleOptionViewItem &option, |
||
47 | const QModelIndex &/* index */) const |
||
48 | { |
||
49 | editor->setGeometry(option.rect); |
||
50 | } |