KVIrc  4.9.2
DeveloperAPIs
AliasEditorWindow.h
Go to the documentation of this file.
1 #ifndef _ALIASEDITOR_H_
2 #define _ALIASEDITOR_H_
3 //=============================================================================
4 //
5 // File : AliasEditorWindow.h
6 // Creation date : Mon Dec 23 2002 14:35: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 #include "KviPointerList.h"
30 #include "KviHeapObject.h"
31 
32 #include <QWidget>
33 #include <QLineEdit>
34 #include <QStringList>
35 #include <QPushButton>
36 #include <QLabel>
37 #include <QTreeWidget>
38 #include <QMenu>
39 
40 class QSplitter;
41 class KviScriptEditor;
42 
43 class AliasEditorTreeWidgetItem : public QTreeWidgetItem, public KviHeapObject
44 {
45 public:
46  enum Type
47  {
50  };
51 
52 public:
53  AliasEditorTreeWidgetItem(QTreeWidget * pTreeWidget, Type eType, const QString & szName);
54  AliasEditorTreeWidgetItem(AliasEditorTreeWidgetItem * pParentItem, Type eType, const QString & szName);
56 
57 protected:
58  Type m_eType;
60  QString m_szName;
61  QString m_szBuffer;
62  int m_cPos;
63 
64 public:
65  inline const QString & name() { return m_szName; };
66  void setName(const QString & szName);
67  inline Type type() { return m_eType; };
68  void setType(Type t);
69  inline bool isAlias() { return m_eType == Alias; };
70  inline bool isNamespace() { return m_eType == Namespace; };
73  inline void setBuffer(const QString & szBuffer) { m_szBuffer = szBuffer; };
74  inline const QString & buffer() { return m_szBuffer; };
75  inline const int & cursorPosition() { return m_cPos; };
76 
77  void setCursorPosition(const int & cPos) { m_cPos = cPos; };
78 };
79 
80 class AliasEditorTreeWidget : public QTreeWidget
81 {
82  Q_OBJECT
83 public:
84  AliasEditorTreeWidget(QWidget *);
86 };
87 
88 class AliasEditorWidget : public QWidget
89 {
90  Q_OBJECT
91 public:
92  AliasEditorWidget(QWidget * par);
94 
95 public:
98  QLabel * m_pNameLabel;
99  QPushButton * m_pRenameButton;
103  QSplitter * m_pSplitter;
104  QString m_szDir;
105  bool m_bSaving;
106 
107 public:
108  //bool modified(){ return m_bModified; };
109  void commit();
110  void exportAliases(bool, bool = false);
112 
115  static void splitFullAliasOrNamespaceName(const QString & szFullName, QStringList & lNamespaces, QString & szName);
116 protected slots:
117  void currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *);
118  void renameItem();
119  void newAlias();
120  void customContextMenuRequested(const QPoint pnt);
121  void newNamespace();
122  void newItem(QString & szName, AliasEditorTreeWidgetItem::Type eType);
123 
124  void exportAll();
125  void exportSelectedSepFiles();
126  void exportSelected();
127 
128  void removeSelectedItems();
129  void slotFind();
130  void slotCollapseNamespaces();
131  void slotFindWord(const QString &);
132  void slotReplaceAll(const QString & before, const QString & after);
133  void itemRenamed(QTreeWidgetItem * it, int col);
134  void aliasRefresh(const QString & szName);
135 
136 protected:
139  void searchReplace(const QString & szSearch, bool bReplace = false, const QString & szReplace = "n");
140 
141  void getExportAliasBuffer(QString & buffer, AliasEditorTreeWidgetItem * it);
142  void oneTimeSetup();
143  void saveLastEditedItem();
148  void appendSelectedItemsRecursive(KviPointerList<AliasEditorTreeWidgetItem> * l, QTreeWidgetItem * pStartFrom);
149 
150  void openParentItems(QTreeWidgetItem * it);
151  void activateItem(QTreeWidgetItem * it);
152 
153  bool removeItem(AliasEditorTreeWidgetItem * it, bool * pbYesToAll, bool bDeleteEmptyTree);
155 
156  QString askForAliasName(const QString & szAction, const QString & szText, const QString & szInitialText);
157  QString askForNamespaceName(const QString & szAction, const QString & szText, const QString & szInitialText);
158  //
159  bool itemExists(QTreeWidgetItem * pSearchFor);
160  bool namespaceExists(QString & szFullItemName);
161  bool aliasExists(QString & szFullItemName);
164  bool hasSelectedItems();
166 
168  AliasEditorTreeWidgetItem * findTopLevelItem(const QString & szName);
169  AliasEditorTreeWidgetItem * createFullItem(const QString & szFullName);
170  AliasEditorTreeWidgetItem * findItem(const QString & szName);
172 };
173 
175 {
176  Q_OBJECT
177 public:
180 
181 protected:
183 
184 protected:
185  virtual QPixmap * myIconPtr();
186  virtual void getConfigGroupName(QString & szName);
187  virtual void saveProperties(KviConfigurationFile *);
188  virtual void loadProperties(KviConfigurationFile *);
189 protected slots:
190  void cancelClicked();
191  void okClicked();
192  void applyClicked();
193 };
194 
195 #endif //_ALIASEDITOR_H_
void saveProperties(KviConfigurationFile *)
Definition: AliasEditorWindow.cpp:889
bool namespaceExists(QString &szFullItemName)
Definition: AliasEditorWindow.cpp:422
AliasEditorTreeWidgetItem * findItem(const QString &szName)
Definition: AliasEditorWindow.cpp:220
void customContextMenuRequested(const QPoint pnt)
Definition: AliasEditorWindow.cpp:574
bool isNamespace()
Definition: AliasEditorWindow.h:70
QString buildFullItemName(AliasEditorTreeWidgetItem *it)
Definition: AliasEditorWindow.cpp:187
QString askForAliasName(const QString &szAction, const QString &szText, const QString &szInitialText)
Definition: AliasEditorWindow.cpp:1027
QPushButton * m_pRenameButton
Definition: AliasEditorWindow.h:99
void appendAllItems(KviPointerList< AliasEditorTreeWidgetItem > *l, AliasEditorTreeWidgetItem::Type)
Definition: AliasEditorWindow.cpp:377
Definition: KviHeapObject.h:124
~AliasEditorWindow()
Definition: AliasEditorWindow.cpp:1273
AliasEditorWidget * m_pEditor
Definition: AliasEditorWindow.h:182
void okClicked()
Definition: AliasEditorWindow.cpp:1278
bool removeItem(AliasEditorTreeWidgetItem *it, bool *pbYesToAll, bool bDeleteEmptyTree)
Definition: AliasEditorWindow.cpp:968
~AliasEditorTreeWidgetItem()
Definition: AliasEditorWindow.h:55
AliasEditorTreeWidgetItem * findTopLevelItem(const QString &szName)
Definition: AliasEditorWindow.cpp:208
void getUniqueItemName(AliasEditorTreeWidgetItem *item, QString &buffer, AliasEditorTreeWidgetItem::Type eType)
void commit()
Definition: AliasEditorWindow.cpp:1223
void slotFindWord(const QString &)
Definition: AliasEditorWindow.cpp:677
Definition: AliasEditorWindow.h:174
Definition: KviScriptEditor.h:43
#define l
Definition: detector.cpp:76
int m_cPos
Definition: AliasEditorWindow.h:62
AliasEditorWindow()
Definition: AliasEditorWindow.cpp:1241
Definition: KviConfigurationFile.h:48
void cancelClicked()
Definition: AliasEditorWindow.cpp:1289
void openParentItems(QTreeWidgetItem *it)
Definition: AliasEditorWindow.cpp:1165
Type
Definition: AliasEditorWindow.h:46
void removeSelectedItems()
Definition: AliasEditorWindow.cpp:1014
AliasEditorWidget(QWidget *par)
Definition: AliasEditorWindow.cpp:117
Type type()
Definition: AliasEditorWindow.h:67
void aliasRefresh(const QString &szName)
Definition: AliasEditorWindow.cpp:305
bool hasSelectedItems()
Definition: AliasEditorWindow.cpp:362
bool aliasExists(QString &szFullItemName)
Definition: AliasEditorWindow.cpp:407
void setName(const QString &szName)
Definition: AliasEditorWindow.cpp:86
void appendSelectedItemsRecursive(KviPointerList< AliasEditorTreeWidgetItem > *l, QTreeWidgetItem *pStartFrom)
Definition: AliasEditorWindow.cpp:946
virtual void getConfigGroupName(QString &szName)
Definition: AliasEditorWindow.cpp:1299
void appendSelectedItems(KviPointerList< AliasEditorTreeWidgetItem > *l)
Definition: AliasEditorWindow.cpp:937
const QString & buffer()
Definition: AliasEditorWindow.h:74
~AliasEditorTreeWidget()
Definition: AliasEditorWindow.cpp:111
void newNamespace()
Definition: AliasEditorWindow.cpp:1190
virtual void saveProperties(KviConfigurationFile *)
Definition: AliasEditorWindow.cpp:1304
void saveLastEditedItem()
Definition: AliasEditorWindow.cpp:520
QSplitter * m_pSplitter
Definition: AliasEditorWindow.h:103
bool itemExists(QTreeWidgetItem *pSearchFor)
Definition: AliasEditorWindow.cpp:367
void setCursorPosition(const int &cPos)
Definition: AliasEditorWindow.h:77
void currentItemChanged(QTreeWidgetItem *it, QTreeWidgetItem *)
Definition: AliasEditorWindow.cpp:532
AliasEditorTreeWidgetItem * m_pParentItem
Definition: AliasEditorWindow.h:59
AliasEditorTreeWidget * m_pTreeWidget
Definition: AliasEditorWindow.h:97
KviPointerList< AliasEditorTreeWidgetItem > * m_pAliases
Definition: AliasEditorWindow.h:137
virtual void loadProperties(KviConfigurationFile *)
Definition: AliasEditorWindow.cpp:1309
QMenu * m_pContextPopup
Definition: AliasEditorWindow.h:102
void exportAll()
Definition: AliasEditorWindow.cpp:727
void slotCollapseNamespaces()
Definition: AliasEditorWindow.cpp:696
bool m_bSaving
Definition: AliasEditorWindow.h:105
void exportAliases(bool, bool=false)
Definition: AliasEditorWindow.cpp:801
void loadProperties(KviConfigurationFile *)
Definition: AliasEditorWindow.cpp:898
AliasEditorTreeWidgetItem(QTreeWidget *pTreeWidget, Type eType, const QString &szName)
Definition: AliasEditorWindow.cpp:63
void appendAllItemsRecursive(KviPointerList< AliasEditorTreeWidgetItem > *l, QTreeWidgetItem *pStartFrom, AliasEditorTreeWidgetItem::Type)
Definition: AliasEditorWindow.cpp:392
bool isAlias()
Definition: AliasEditorWindow.h:69
void applyClicked()
Definition: AliasEditorWindow.cpp:1284
AliasEditorTreeWidgetItem * createFullItem(const QString &szFullName)
Definition: AliasEditorWindow.cpp:249
void oneTimeSetup()
Definition: AliasEditorWindow.cpp:279
AliasEditorTreeWidget(QWidget *)
Definition: AliasEditorWindow.cpp:100
void recursiveCollapseNamespaces(AliasEditorTreeWidgetItem *it)
Definition: AliasEditorWindow.cpp:682
void exportSelected()
Definition: AliasEditorWindow.cpp:737
QHashIterator< int, QFile * > t(getDict)
Definition: AliasEditorWindow.h:80
void searchReplace(const QString &szSearch, bool bReplace=false, const QString &szReplace="n")
Definition: AliasEditorWindow.cpp:636
static void splitFullAliasOrNamespaceName(const QString &szFullName, QStringList &lNamespaces, QString &szName)
Definition: AliasEditorWindow.h:49
C++ Template based double linked pointer list class.
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
const int & cursorPosition()
Definition: AliasEditorWindow.h:75
QString askForNamespaceName(const QString &szAction, const QString &szText, const QString &szInitialText)
Definition: AliasEditorWindow.cpp:1096
QString m_szName
Definition: AliasEditorWindow.h:60
Heap Object.
QString m_szBuffer
Definition: AliasEditorWindow.h:61
void setType(Type t)
Definition: AliasEditorWindow.cpp:91
const QString & name()
Definition: AliasEditorWindow.h:65
void getExportAliasBuffer(QString &buffer, AliasEditorTreeWidgetItem *it)
Definition: AliasEditorWindow.cpp:714
void slotFind()
Definition: AliasEditorWindow.cpp:655
QString m_szDir
Definition: AliasEditorWindow.h:104
Definition: AliasEditorWindow.h:88
void removeItemChildren(AliasEditorTreeWidgetItem *it)
Definition: AliasEditorWindow.cpp:956
void exportSelectedSepFiles()
Definition: AliasEditorWindow.cpp:732
void buildAliasesFile(KviPointerList< AliasEditorTreeWidgetItem > *l, QString &szBuffer)
Definition: AliasEditorWindow.cpp:878
AliasEditorTreeWidgetItem * m_pLastClickedItem
Definition: AliasEditorWindow.h:101
void newItem(QString &szName, AliasEditorTreeWidgetItem::Type eType)
Definition: AliasEditorWindow.cpp:1198
QLabel * m_pNameLabel
Definition: AliasEditorWindow.h:98
void exportSelectionInSinglesFiles(KviPointerList< AliasEditorTreeWidgetItem > *l)
Definition: AliasEditorWindow.cpp:742
Type m_eType
Definition: AliasEditorWindow.h:55
Contains the KviWindow class.
void setBuffer(const QString &szBuffer)
Definition: AliasEditorWindow.h:73
Definition: AliasEditorWindow.h:43
void buildFullItemPath(AliasEditorTreeWidgetItem *it, QString &szBuffer)
Definition: AliasEditorWindow.cpp:169
void activateItem(QTreeWidgetItem *it)
Definition: AliasEditorWindow.cpp:1174
AliasEditorTreeWidgetItem * parentItem()
Definition: AliasEditorWindow.h:72
char szBuffer[4096]
Definition: winamp.cpp:77
KviScriptEditor * m_pEditor
Definition: AliasEditorWindow.h:96
void renameItem()
Definition: AliasEditorWindow.cpp:437
void newAlias()
Definition: AliasEditorWindow.cpp:1182
void setParentItem(AliasEditorTreeWidgetItem *it)
Definition: AliasEditorWindow.h:71
~AliasEditorWidget()
Definition: AliasEditorWindow.cpp:163
void itemRenamed(QTreeWidgetItem *it, int col)
Definition: AliasEditorWindow.cpp:344
void appendSelectedAliasItems(KviPointerList< AliasEditorTreeWidgetItem > *l)
Definition: AliasEditorWindow.cpp:910
virtual QPixmap * myIconPtr()
Definition: AliasEditorWindow.cpp:1294
void appendSelectedAliasItemsRecursive(KviPointerList< AliasEditorTreeWidgetItem > *l, QTreeWidgetItem *pStartFrom)
Definition: AliasEditorWindow.cpp:926
Definition: AliasEditorWindow.h:48
void slotReplaceAll(const QString &before, const QString &after)
Definition: AliasEditorWindow.cpp:708
AliasEditorTreeWidgetItem * m_pLastEditedItem
Definition: AliasEditorWindow.h:100