Subversion Repositories Scribus

Rev

Rev 11836 | Rev 12175 | 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
        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
}
10229 subik 51
 
11836 subik 52
void GuidesDelegate::setDoc(ScribusDoc * doc)
10229 subik 53
{
11836 subik 54
        m_doc = doc;
10229 subik 55
}