Ran am2cmake.
[basket4.git] / src / tagsedit.h
bloba8e384e80640e385c3358b42c2ce408969f590f9
1 /***************************************************************************
2 * Copyright (C) 2005 by S�astien Laot *
3 * slaout@linux62.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef TAGEDIT_H
22 #define TAGEDIT_H
24 #include <kdialogbase.h>
25 #include <kcombobox.h>
26 #include <q3listview.h>
27 #include <q3valuelist.h>
28 //Added by qt3to4:
29 #include <QLabel>
30 #include <QMouseEvent>
31 #include <QKeyEvent>
33 class Q3GroupBox;
34 class QLineEdit;
35 class QCheckBox;
36 class KPushButton;
37 class KKeyButton;
38 class KIconButton;
39 class KFontCombo;
40 class QLabel;
41 class KShortcut;
43 class KColorCombo2;
45 class FontSizeCombo;
47 class Tag;
48 class State;
50 class StateCopy
52 public:
53 typedef Q3ValueList<StateCopy*> List;
54 StateCopy(State *old = 0);
55 ~StateCopy();
56 State *oldState;
57 State *newState;
58 void copyBack();
61 class TagCopy
63 public:
64 typedef Q3ValueList<TagCopy*> List;
65 TagCopy(Tag *old = 0);
66 ~TagCopy();
67 Tag *oldTag;
68 Tag *newTag;
69 StateCopy::List stateCopies;
70 void copyBack();
71 bool isMultiState();
74 class TagListViewItem : public Q3ListViewItem
76 public:
77 TagListViewItem(Q3ListView *parent, TagCopy *tagCopy);
78 TagListViewItem(Q3ListViewItem *parent, TagCopy *tagCopy);
79 TagListViewItem(Q3ListView *parent, Q3ListViewItem *after, TagCopy *tagCopy);
80 TagListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after, TagCopy *tagCopy);
81 TagListViewItem(Q3ListView *parent, StateCopy *stateCopy);
82 TagListViewItem(Q3ListViewItem *parent, StateCopy *stateCopy);
83 TagListViewItem(Q3ListView *parent, Q3ListViewItem *after, StateCopy *stateCopy);
84 TagListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after, StateCopy *stateCopy);
85 ~TagListViewItem();
86 TagCopy* tagCopy() { return m_tagCopy; }
87 StateCopy* stateCopy() { return m_stateCopy; }
88 bool isEmblemObligatory();
89 TagListViewItem* lastChild();
90 TagListViewItem* prevSibling();
91 TagListViewItem* parent() const; // Reimplemented to cast the return value
92 int width(const QFontMetrics &fontMetrics, const Q3ListView *listView, int column) const;
93 void setup();
94 void paintCell(QPainter *painter, const QColorGroup &colorGroup, int column, int width, int align);
96 private:
97 TagCopy *m_tagCopy;
98 StateCopy *m_stateCopy;
101 class TagListView : public Q3ListView
103 Q_OBJECT
104 public:
105 TagListView(QWidget *parent = 0, const char *name = 0, WFlags flags = 0);
106 ~TagListView();
107 void keyPressEvent(QKeyEvent *event);
108 void contentsMouseDoubleClickEvent(QMouseEvent *event);
109 void contentsMousePressEvent(QMouseEvent *event);
110 void contentsMouseReleaseEvent(QMouseEvent *event);
111 TagListViewItem* currentItem() const; // Reimplemented to cast the return value
112 TagListViewItem* firstChild() const; // Reimplemented to cast the return value
113 TagListViewItem* lastItem() const; // Reimplemented to cast the return value
114 signals:
115 void deletePressed();
116 void doubleClickedItem();
120 * @author S�astien Laot
122 class TagsEditDialog : public KDialogBase
124 Q_OBJECT
125 public:
126 TagsEditDialog(QWidget *parent = 0, State *stateToEdit = 0, bool addNewTag = false);
127 ~TagsEditDialog();
128 State::List deletedStates() { return m_deletedStates; }
129 State::List addedStates() { return m_addedStates; }
130 TagListViewItem* itemForState(State *state);
131 private slots:
132 void newTag();
133 void newState();
134 void moveUp();
135 void moveDown();
136 void deleteTag();
137 void renameIt();
138 void capturedShortcut(const KShortcut &shortcut);
139 void removeShortcut();
140 void removeEmblem();
141 void modified();
142 void currentItemChanged(Q3ListViewItem *item);
143 void slotCancel();
144 void slotOk();
145 void selectUp();
146 void selectDown();
147 void selectLeft();
148 void selectRight();
149 void resetTreeSizeHint();
150 private:
151 void loadBlankState();
152 void loadStateFrom(State *state);
153 void loadTagFrom(Tag *tag);
154 void saveStateTo(State *state);
155 void saveTagTo(Tag *tag);
156 void ensureCurrentItemVisible();
157 TagListView *m_tags;
158 KPushButton *m_moveUp;
159 KPushButton *m_moveDown;
160 KPushButton *m_deleteTag;
161 QLineEdit *m_tagName;
162 KKeyButton *m_shortcut;
163 QPushButton *m_removeShortcut;
164 QCheckBox *m_inherit;
165 Q3GroupBox *m_tagBox;
166 Q3GroupBox *m_stateBox;
167 QLabel *m_stateNameLabel;
168 QLineEdit *m_stateName;
169 KIconButton *m_emblem;
170 QPushButton *m_removeEmblem;
171 QPushButton *m_bold;
172 QPushButton *m_underline;
173 QPushButton *m_italic;
174 QPushButton *m_strike;
175 KColorCombo2 *m_textColor;
176 KFontCombo *m_font;
177 FontSizeCombo *m_fontSize;
178 KColorCombo2 *m_backgroundColor;
179 QLineEdit *m_textEquivalent;
180 QCheckBox *m_onEveryLines;
182 TagCopy::List m_tagCopies;
183 State::List m_deletedStates;
184 State::List m_addedStates;
186 bool m_loading;
189 #endif // TAGEDIT_H