File: tagsedit.h

package info (click to toggle)
basket 1.0.2-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 14,272 kB
  • ctags: 3,211
  • sloc: cpp: 28,424; sh: 9,518; perl: 2,730; makefile: 235
file content (185 lines) | stat: -rw-r--r-- 5,840 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/***************************************************************************
 *   Copyright (C) 2005 by S´┐Żastien Laot                                 *
 *   slaout@linux62.org                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef TAGEDIT_H
#define TAGEDIT_H

#include <kdialogbase.h>
#include <kcombobox.h>
#include <qlistview.h>
#include <qvaluelist.h>

class QGroupBox;
class QLineEdit;
class QCheckBox;
class KPushButton;
class KKeyButton;
class KIconButton;
class KFontCombo;
class QLabel;
class KShortcut;

class KColorCombo2;

class FontSizeCombo;

class Tag;
class State;

class StateCopy
{
  public:
	typedef QValueList<StateCopy*> List;
	StateCopy(State *old = 0);
	~StateCopy();
	State *oldState;
	State *newState;
	void copyBack();
};

class TagCopy
{
  public:
	typedef QValueList<TagCopy*> List;
	TagCopy(Tag *old = 0);
	~TagCopy();
	Tag *oldTag;
	Tag *newTag;
	StateCopy::List stateCopies;
	void copyBack();
	bool isMultiState();
};

class TagListViewItem : public QListViewItem
{
  public:
	TagListViewItem(QListView     *parent, TagCopy *tagCopy);
	TagListViewItem(QListViewItem *parent, TagCopy *tagCopy);
	TagListViewItem(QListView     *parent, QListViewItem *after, TagCopy *tagCopy);
	TagListViewItem(QListViewItem *parent, QListViewItem *after, TagCopy *tagCopy);
	TagListViewItem(QListView     *parent, StateCopy *stateCopy);
	TagListViewItem(QListViewItem *parent, StateCopy *stateCopy);
	TagListViewItem(QListView     *parent, QListViewItem *after, StateCopy *stateCopy);
	TagListViewItem(QListViewItem *parent, QListViewItem *after, StateCopy *stateCopy);
	~TagListViewItem();
	TagCopy*   tagCopy()   { return m_tagCopy;   }
	StateCopy* stateCopy() { return m_stateCopy; }
	bool isEmblemObligatory();
	TagListViewItem* lastChild();
	TagListViewItem* prevSibling();
	TagListViewItem* parent() const; // Reimplemented to cast the return value
	int width(const QFontMetrics &fontMetrics, const QListView *listView, int column) const;
	void setup();
	void paintCell(QPainter *painter, const QColorGroup &colorGroup, int column, int width, int align);

  private:
	TagCopy   *m_tagCopy;
	StateCopy *m_stateCopy;
};

class TagListView : public QListView
{
  Q_OBJECT
  public:
	TagListView(QWidget *parent = 0, const char *name = 0, WFlags flags = 0);
	~TagListView();
	void keyPressEvent(QKeyEvent *event);
	void contentsMouseDoubleClickEvent(QMouseEvent *event);
	void contentsMousePressEvent(QMouseEvent *event);
	void contentsMouseReleaseEvent(QMouseEvent *event);
	TagListViewItem* currentItem() const; // Reimplemented to cast the return value
	TagListViewItem* firstChild() const; // Reimplemented to cast the return value
	TagListViewItem* lastItem() const; // Reimplemented to cast the return value
  signals:
	void deletePressed();
	void doubleClickedItem();
};

/**
  * @author S´┐Żastien Laot
  */
class TagsEditDialog : public KDialogBase
{
  Q_OBJECT
  public:
	TagsEditDialog(QWidget *parent = 0, State *stateToEdit = 0, bool addNewTag = false);
	~TagsEditDialog();
	State::List deletedStates() { return m_deletedStates; }
	State::List addedStates()   { return m_addedStates;   }
	TagListViewItem* itemForState(State *state);
  private slots:
	void newTag();
	void newState();
	void moveUp();
	void moveDown();
	void deleteTag();
	void renameIt();
	void capturedShortcut(const KShortcut &shortcut);
	void removeShortcut();
	void removeEmblem();
	void modified();
	void currentItemChanged(QListViewItem *item);
	void slotCancel();
	void slotOk();
	void selectUp();
	void selectDown();
	void selectLeft();
	void selectRight();
	void resetTreeSizeHint();
  private:
	void loadBlankState();
	void loadStateFrom(State *state);
	void loadTagFrom(Tag *tag);
	void saveStateTo(State *state);
	void saveTagTo(Tag *tag);
	void ensureCurrentItemVisible();
	TagListView   *m_tags;
	KPushButton   *m_moveUp;
	KPushButton   *m_moveDown;
	KPushButton   *m_deleteTag;
	QLineEdit     *m_tagName;
	KKeyButton    *m_shortcut;
	QPushButton   *m_removeShortcut;
	QCheckBox     *m_inherit;
	QGroupBox     *m_tagBox;
	QGroupBox     *m_stateBox;
	QLabel        *m_stateNameLabel;
	QLineEdit     *m_stateName;
	KIconButton   *m_emblem;
	QPushButton   *m_removeEmblem;
	QPushButton   *m_bold;
	QPushButton   *m_underline;
	QPushButton   *m_italic;
	QPushButton   *m_strike;
	KColorCombo2  *m_textColor;
	KFontCombo    *m_font;
	FontSizeCombo *m_fontSize;
	KColorCombo2  *m_backgroundColor;
	QLineEdit     *m_textEquivalent;
	QCheckBox     *m_onEveryLines;

	TagCopy::List m_tagCopies;
	State::List   m_deletedStates;
	State::List   m_addedStates;

	bool m_loading;
};

#endif // TAGEDIT_H