Crossfire Server, Trunk
CREStringListDelegate.cpp
Go to the documentation of this file.
2 #include "CREStringListPanel.h"
3 
4 CREStringListDelegate::CREStringListDelegate(QObject* parent) : QStyledItemDelegate(parent)
5 {
6 }
7 
9 {
10 }
11 
12 QWidget* CREStringListDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const
13 {
14  return new CREStringListPanel(parent);
15 }
16 
17 void CREStringListDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
18 {
19  CREStringListPanel* edit = qobject_cast<CREStringListPanel*>(editor);
20  if (!edit)
21  return;
22  edit->setData(index.data(Qt::EditRole).value<QStringList>());
23 }
24 
25 void CREStringListDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
26 {
27  CREStringListPanel* edit = qobject_cast<CREStringListPanel*>(editor);
28  if (!edit)
29  return;
30  model->setData(index, QVariant::fromValue(edit->data()), Qt::EditRole);
31 }
32 
33 void CREStringListDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem&, const QModelIndex&) const
34 {
35  if (!qApp->activeWindow())
36  return;
37  QRect r(qApp->activeWindow()->geometry());
38  r.setLeft(r.left() + r.width() * .1);
39  r.setWidth(r.width() * .8);
40  r.setTop(r.top() + r.height() * .1);
41  r.setHeight(r.height() * .8);
42  editor->setGeometry(r);
43 }
CREStringListPanel::data
QStringList data() const
Definition: CREStringListPanel.cpp:46
CREStringListPanel
Definition: CREStringListPanel.h:12
CREStringListDelegate::updateEditorGeometry
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: CREStringListDelegate.cpp:33
CREStringListDelegate.h
CREStringListPanel::setData
void setData(const QStringList &list)
Definition: CREStringListPanel.cpp:38
CREStringListDelegate::setEditorData
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override
Definition: CREStringListDelegate.cpp:17
CREStringListDelegate::CREStringListDelegate
CREStringListDelegate(QObject *parent)
Definition: CREStringListDelegate.cpp:4
CREStringListDelegate::setModelData
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Definition: CREStringListDelegate.cpp:25
npc_dialog.index
int index
Definition: npc_dialog.py:102
CREStringListDelegate::createEditor
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: CREStringListDelegate.cpp:12
CREStringListDelegate::~CREStringListDelegate
virtual ~CREStringListDelegate()
Definition: CREStringListDelegate.cpp:8
CREStringListPanel.h
ring_occidental_mages.r
r
Definition: ring_occidental_mages.py:6