Crossfire Server, Trunk
CREPlayerRepliesDelegate.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
14 #include "CREPlayerRepliesPanel.h"
15 
16 #include <QApplication>
17 
18 CREPlayerRepliesDelegate::CREPlayerRepliesDelegate(QObject* parent) : QStyledItemDelegate(parent)
19 {
20 }
21 
23 {
24 }
25 
26 QWidget* CREPlayerRepliesDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const
27 {
28  return new CREPlayerRepliesPanel(parent);
29 }
30 
31 void CREPlayerRepliesDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
32 {
33  CREPlayerRepliesPanel* edit = qobject_cast<CREPlayerRepliesPanel*>(editor);
34  if (!edit)
35  return;
36  edit->setData(index.data(Qt::EditRole).value<QList<QStringList>>());
37 }
38 
39 void CREPlayerRepliesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
40 {
41  CREPlayerRepliesPanel* edit = qobject_cast<CREPlayerRepliesPanel*>(editor);
42  if (!edit)
43  return;
44  model->setData(index, QVariant::fromValue(edit->data()), Qt::EditRole);
45 }
46 
47 void CREPlayerRepliesDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem&, const QModelIndex&) const
48 {
49  if (!qApp->activeWindow())
50  return;
51  QRect r(qApp->activeWindow()->geometry());
52  r.setLeft(r.left() + r.width() * .1);
53  r.setWidth(r.width() * .8);
54  r.setTop(r.top() + r.height() * .1);
55  r.setHeight(r.height() * .8);
56  editor->setGeometry(r);
57 }
CREPlayerRepliesDelegate::~CREPlayerRepliesDelegate
virtual ~CREPlayerRepliesDelegate()
Definition: CREPlayerRepliesDelegate.cpp:22
CREPlayerRepliesPanel::data
QList< QStringList > data() const
Definition: CREPlayerRepliesPanel.cpp:135
CREPlayerRepliesPanel.h
CREPlayerRepliesPanel::setData
void setData(const QList< QStringList > &data)
Definition: CREPlayerRepliesPanel.cpp:123
CREPlayerRepliesDelegate::createEditor
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: CREPlayerRepliesDelegate.cpp:26
CREPlayerRepliesDelegate::updateEditorGeometry
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: CREPlayerRepliesDelegate.cpp:47
CREPlayerRepliesDelegate.h
CREPlayerRepliesPanel
Definition: CREPlayerRepliesPanel.h:23
npc_dialog.index
int index
Definition: npc_dialog.py:102
CREPlayerRepliesDelegate::setModelData
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Definition: CREPlayerRepliesDelegate.cpp:39
CREPlayerRepliesDelegate::CREPlayerRepliesDelegate
CREPlayerRepliesDelegate(QObject *parent)
Definition: CREPlayerRepliesDelegate.cpp:18
CREPlayerRepliesDelegate::setEditorData
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override
Definition: CREPlayerRepliesDelegate.cpp:31
ring_occidental_mages.r
r
Definition: ring_occidental_mages.py:6