KVIrc  4.9.2
DeveloperAPIs
PopupEditorWindow.h
Go to the documentation of this file.
1 #ifndef _POPUPEDITOR_H_
2 #define _POPUPEDITOR_H_
3 //=============================================================================
4 //
5 // File : PopupEditorWindow.h
6 // Creation date : Mon Dec 23 2002 20:24:55 CEST by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "KviWindow.h"
28 #include "KviCString.h"
29 
30 #include <QTreeWidget>
31 #include <QWidget>
32 #include <QLineEdit>
33 #include <QPushButton>
34 #include <QMenu>
35 
36 class KviKvsPopupMenu;
38 class KviScriptEditor;
39 class MenuTreeWidgetItem;
40 
41 // PopupTreeWidgetItem
42 class PopupTreeWidgetItem : public QTreeWidgetItem
43 {
44 public:
45  enum Type
46  {
54  };
55 
56 public:
57  PopupTreeWidgetItem(QTreeWidget * pTreeWidget, PopupTreeWidgetItem * after, Type t);
59 
60 public:
62  QString m_szText;
63  QString m_szCondition;
64  QString m_szIcon;
65  QString m_szCode;
66  QString m_szId;
67 
68 private:
69  void init();
70 
71 public:
72  void setItemText(const QString & szText);
73  void setCondition(const QString & szCondition);
74  void setIcon(const QString & szIcon);
75  void setCode(const QString & szCode);
76  void setId(const QString & szId);
77 };
78 
79 class SinglePopupEditor : public QWidget
80 {
81  Q_OBJECT
82 public:
83  SinglePopupEditor(QWidget * par);
85 
86 protected:
87  QPushButton * m_pMenuButton;
91  QTreeWidget * m_pTreeWidget;
92  QLineEdit * m_pNameEditor;
94  QLineEdit * m_pTextEditor;
95  QLineEdit * m_pIdEditor;
96  QLineEdit * m_pIconEditor;
97  QLineEdit * m_pConditionEditor;
98  QLineEdit * m_pExtNameEditor;
99  QMenu * m_pContextPopup;
100 
101 public:
102  void edit(MenuTreeWidgetItem * it);
104 
105 protected:
106  // theItem is the item above the first item that has to be inserted
107  void populateMenu(KviKvsPopupMenu * pop, PopupTreeWidgetItem * par, PopupTreeWidgetItem * theItem = 0);
108  void saveLastSelectedItem();
118 protected slots:
119  void contextCut();
120  void contextCopy();
121  void contextRemove();
122  void contextPasteBelow();
123  void contextPasteAbove();
124  void contextPasteInside();
128  void contextNewItemBelow();
129  void contextNewItemAbove();
130  void contextNewItemInside();
131  void contextNewMenuBelow();
132  void contextNewMenuAbove();
133  void contextNewMenuInside();
134  void contextNewExtMenuBelow();
135  void contextNewExtMenuAbove();
137  void contextNewLabelBelow();
138  void contextNewLabelAbove();
139  void contextNewLabelInside();
140  void contextNewPrologue();
141  void contextNewEpilogue();
142  void selectionChanged();
143  void customContextMenuRequested(const QPoint & pnt);
144  void testPopup();
146 };
147 
148 class MenuTreeWidgetItem : public QTreeWidgetItem
149 {
150 public:
151  MenuTreeWidgetItem(QTreeWidget * par, KviKvsPopupMenu * popup);
153 
154 public:
156 
157 public:
158  KviKvsPopupMenu * popup() { return m_pPopup; };
159 public:
160  void replacePopup(KviKvsPopupMenu * popup);
161 };
162 
163 class PopupEditorWidget : public QWidget
164 {
165  Q_OBJECT
166 public:
167  PopupEditorWidget(QWidget * par);
169 
170 public:
172  QTreeWidget * m_pTreeWidget;
177  bool m_bSaving;
178 
179 public:
180  void commit();
181  void exportPopups(bool);
182 protected slots:
183  void currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem * prev);
184  void customContextMenuRequested(const QPoint & pnt);
185  void newPopup();
186  void exportAll();
187  void exportSelected();
188  void exportCurrentPopup();
189  void removeCurrentPopup();
190  void popupRefresh(const QString & szName);
191 
192 protected:
193  void showEvent(QShowEvent * e);
194  void getExportPopupBuffer(QString & buffer, MenuTreeWidgetItem * it);
195 
196 private:
197  void oneTimeSetup();
198  void saveLastEditedItem();
199  void getUniquePopupName(MenuTreeWidgetItem * it, QString & buffer);
200 };
201 
203 {
204  Q_OBJECT
205 public:
208 
209 protected:
211 
212 protected:
213  virtual QPixmap * myIconPtr();
214  virtual void fillCaptionBuffers();
215  virtual void getConfigGroupName(QString & szName);
216  virtual void saveProperties(KviConfigurationFile *);
217  virtual void loadProperties(KviConfigurationFile *);
218 protected slots:
219  void cancelClicked();
220  void okClicked();
221  void applyClicked();
222 };
223 
224 #endif //_POPUPEDITOR_H_
QString m_szCode
Definition: PopupEditorWindow.h:65
void contextPasteAbove()
Definition: PopupEditorWindow.cpp:657
void okClicked()
Definition: PopupEditorWindow.cpp:1445
void currentItemChanged(QTreeWidgetItem *it, QTreeWidgetItem *prev)
Definition: PopupEditorWindow.cpp:1326
bool m_bOneTimeSetupDone
Definition: PopupEditorWindow.h:174
~PopupEditorWindow()
Definition: PopupEditorWindow.cpp:1440
virtual void loadProperties(KviConfigurationFile *)
Definition: PopupEditorWindow.cpp:1480
PopupTreeWidgetItem * findMatchingItem(KviKvsPopupMenuItem *it, PopupTreeWidgetItem *item)
Definition: PopupEditorWindow.cpp:295
KviKvsPopupMenu * getMenu()
Definition: PopupEditorWindow.cpp:803
~MenuTreeWidgetItem()
Definition: PopupEditorWindow.cpp:1057
virtual void saveProperties(KviConfigurationFile *)
Definition: PopupEditorWindow.cpp:1476
Definition: PopupEditorWindow.h:51
void edit(MenuTreeWidgetItem *it)
Definition: PopupEditorWindow.cpp:1013
QMenu * m_pContextPopup
Definition: PopupEditorWindow.h:99
void setCode(const QString &szCode)
Definition: PopupEditorWindow.cpp:136
void commit()
Definition: PopupEditorWindow.cpp:1340
void setId(const QString &szId)
Definition: PopupEditorWindow.cpp:151
void contextNewEpilogue()
Definition: PopupEditorWindow.cpp:599
void contextNewSeparatorAbove()
Definition: PopupEditorWindow.cpp:486
QMenu * m_pContextPopup
Definition: PopupEditorWindow.h:175
MenuTreeWidgetItem(QTreeWidget *par, KviKvsPopupMenu *popup)
Definition: PopupEditorWindow.cpp:1049
QLineEdit * m_pIdEditor
Definition: PopupEditorWindow.h:95
void contextNewMenuInside()
Definition: PopupEditorWindow.cpp:526
Definition: KviScriptEditor.h:43
void contextCopy()
Definition: PopupEditorWindow.cpp:618
virtual QPixmap * myIconPtr()
Definition: PopupEditorWindow.cpp:1461
QString m_szIcon
Definition: PopupEditorWindow.h:64
void contextNewItemInside()
Definition: PopupEditorWindow.cpp:511
PopupTreeWidgetItem * newItemAbove(PopupTreeWidgetItem *it, PopupTreeWidgetItem::Type t)
Definition: PopupEditorWindow.cpp:574
Definition: KviConfigurationFile.h:48
virtual void fillCaptionBuffers()
Definition: PopupEditorWindow.cpp:1466
Definition: PopupEditorWindow.h:53
void setCondition(const QString &szCondition)
Definition: PopupEditorWindow.cpp:120
void contextNewLabelInside()
Definition: PopupEditorWindow.cpp:555
void saveLastSelectedItem()
Definition: PopupEditorWindow.cpp:682
void contextNewExtMenuInside()
Definition: PopupEditorWindow.cpp:540
Definition: KviKvsPopupMenu.h:75
QTreeWidget * m_pTreeWidget
Definition: PopupEditorWindow.h:91
QLineEdit * m_pExtNameEditor
Definition: PopupEditorWindow.h:98
void addItemToMenu(KviKvsPopupMenu *pop, PopupTreeWidgetItem *par)
Definition: PopupEditorWindow.cpp:748
void contextNewItemBelow()
Definition: PopupEditorWindow.cpp:501
void contextNewLabelAbove()
Definition: PopupEditorWindow.cpp:550
void testModeMenuItemClicked(KviKvsPopupMenuItem *it)
Definition: PopupEditorWindow.cpp:360
~SinglePopupEditor()
Definition: PopupEditorWindow.cpp:270
void setIcon(const QString &szIcon)
Definition: PopupEditorWindow.cpp:156
QString m_szText
Definition: PopupEditorWindow.h:62
QMenu * m_pEmptyContextPopup
Definition: PopupEditorWindow.h:176
#define e
Definition: detector.cpp:69
SinglePopupEditor * m_pEditor
Definition: PopupEditorWindow.h:171
void contextCut()
Definition: PopupEditorWindow.cpp:628
QLineEdit * m_pNameEditor
Definition: PopupEditorWindow.h:92
void cancelClicked()
Definition: PopupEditorWindow.cpp:1456
KviScriptEditor * m_pEditor
Definition: PopupEditorWindow.h:93
void removeCurrentPopup()
Definition: PopupEditorWindow.cpp:1288
KviKvsPopupMenu * m_pClipboard
Definition: PopupEditorWindow.h:88
void customContextMenuRequested(const QPoint &pnt)
Definition: PopupEditorWindow.cpp:382
Type
Definition: PopupEditorWindow.h:45
void contextNewSeparatorBelow()
Definition: PopupEditorWindow.cpp:491
void popupRefresh(const QString &szName)
Definition: PopupEditorWindow.cpp:1135
Definition: PopupEditorWindow.h:48
PopupTreeWidgetItem * m_pLastSelectedItem
Definition: PopupEditorWindow.h:90
void exportPopups(bool)
Definition: PopupEditorWindow.cpp:1250
void contextNewPrologue()
Definition: PopupEditorWindow.cpp:593
SinglePopupEditor(QWidget *par)
Definition: PopupEditorWindow.cpp:178
void exportCurrentPopup()
Definition: PopupEditorWindow.cpp:1210
KviKvsPopupMenu * m_pPopup
Definition: PopupEditorWindow.h:155
void contextNewSeparatorInside()
Definition: PopupEditorWindow.cpp:496
void contextNewMenuBelow()
Definition: PopupEditorWindow.cpp:516
KviKvsPopupMenu * popup()
Definition: PopupEditorWindow.h:158
void showEvent(QShowEvent *e)
Definition: PopupEditorWindow.cpp:1334
void init()
Definition: PopupEditorWindow.cpp:71
QPushButton * m_pMenuButton
Definition: PopupEditorWindow.h:87
void contextNewMenuAbove()
Definition: PopupEditorWindow.cpp:521
Definition: PopupEditorWindow.h:50
void populateMenu(KviKvsPopupMenu *pop, PopupTreeWidgetItem *par, PopupTreeWidgetItem *theItem=0)
Definition: PopupEditorWindow.cpp:925
void contextNewExtMenuAbove()
Definition: PopupEditorWindow.cpp:536
void createNewItemAboveLastSelected(PopupTreeWidgetItem::Type t)
Definition: PopupEditorWindow.cpp:469
Definition: PopupEditorWindow.h:202
QTreeWidget * m_pTreeWidget
Definition: PopupEditorWindow.h:172
void saveLastEditedItem()
Definition: PopupEditorWindow.cpp:1308
PopupTreeWidgetItem(QTreeWidget *pTreeWidget, PopupTreeWidgetItem *after, Type t)
Definition: PopupEditorWindow.cpp:57
PopupTreeWidgetItem * newItemInside(PopupTreeWidgetItem *it, PopupTreeWidgetItem::Type t)
Definition: PopupEditorWindow.cpp:581
PopupTreeWidgetItem * newItemBelow(PopupTreeWidgetItem *it, PopupTreeWidgetItem::Type t)
Definition: PopupEditorWindow.cpp:567
Definition: KviKvsPopupMenu.h:270
Definition: PopupEditorWindow.h:79
Definition: PopupEditorWindow.h:52
void contextNewItemAbove()
Definition: PopupEditorWindow.cpp:506
Type m_type
Definition: PopupEditorWindow.h:61
void exportAll()
Definition: PopupEditorWindow.cpp:1238
QHashIterator< int, QFile * > t(getDict)
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
void contextNewExtMenuBelow()
Definition: PopupEditorWindow.cpp:531
void contextRemove()
Definition: PopupEditorWindow.cpp:639
QString m_szId
Definition: PopupEditorWindow.h:66
PopupTreeWidgetItem * newItem(PopupTreeWidgetItem *par, PopupTreeWidgetItem *after, PopupTreeWidgetItem::Type t)
Definition: PopupEditorWindow.cpp:560
MenuTreeWidgetItem * m_pLastEditedItem
Definition: PopupEditorWindow.h:173
QString m_szCondition
Definition: PopupEditorWindow.h:63
Definition: PopupEditorWindow.h:148
PopupEditorWidget * m_pEditor
Definition: PopupEditorWindow.h:210
QLineEdit * m_pConditionEditor
Definition: PopupEditorWindow.h:97
void contextPasteInside()
Definition: PopupEditorWindow.cpp:666
void contextNewLabelBelow()
Definition: PopupEditorWindow.cpp:545
void exportSelected()
Definition: PopupEditorWindow.cpp:1244
Definition: PopupEditorWindow.h:47
void getExportPopupBuffer(QString &buffer, MenuTreeWidgetItem *it)
void applyClicked()
Definition: PopupEditorWindow.cpp:1451
void createNewItemInsideLastSelected(PopupTreeWidgetItem::Type t)
Definition: PopupEditorWindow.cpp:479
void testPopup()
Definition: PopupEditorWindow.cpp:277
Contains the KviWindow class.
QLineEdit * m_pTextEditor
Definition: PopupEditorWindow.h:94
Definition: PopupEditorWindow.h:163
Definition: PopupEditorWindow.h:42
void oneTimeSetup()
Definition: PopupEditorWindow.cpp:1108
KviKvsPopupMenu * m_pTestPopup
Definition: PopupEditorWindow.h:89
void contextPasteBelow()
Definition: PopupEditorWindow.cpp:649
QLineEdit * m_pIconEditor
Definition: PopupEditorWindow.h:96
void getUniquePopupName(MenuTreeWidgetItem *it, QString &buffer)
Definition: PopupEditorWindow.cpp:1378
PopupEditorWidget(QWidget *par)
Definition: PopupEditorWindow.cpp:1068
void newPopup()
Definition: PopupEditorWindow.cpp:1300
void createNewItemBelowLastSelected(PopupTreeWidgetItem::Type t)
Definition: PopupEditorWindow.cpp:474
void customContextMenuRequested(const QPoint &pnt)
Definition: PopupEditorWindow.cpp:1178
void selectionChanged()
Definition: PopupEditorWindow.cpp:819
void setItemText(const QString &szText)
Definition: PopupEditorWindow.cpp:104
void replacePopup(KviKvsPopupMenu *popup)
Definition: PopupEditorWindow.cpp:1062
bool m_bSaving
Definition: PopupEditorWindow.h:177
PopupEditorWindow()
Definition: PopupEditorWindow.cpp:1411
Definition: PopupEditorWindow.h:49
virtual void getConfigGroupName(QString &szName)
Definition: PopupEditorWindow.cpp:1471