MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / scripts / kconfig / qconf.h
blob7c03927d4c7c23d126f510369e8ada72eb6e36a2
1 /*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
6 #include <qlistview.h>
7 #if QT_VERSION >= 300
8 #include <qsettings.h>
9 #else
10 class QSettings { };
11 #endif
13 class ConfigList;
14 class ConfigItem;
15 class ConfigLineEdit;
16 class ConfigMainWindow;
19 class ConfigSettings : public QSettings {
20 public:
21 ConfigSettings();
23 #if QT_VERSION >= 300
24 void readListSettings();
25 QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok);
26 bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value);
27 #endif
29 bool showAll;
30 bool showName;
31 bool showRange;
32 bool showData;
35 class ConfigView : public QVBox {
36 Q_OBJECT
37 typedef class QVBox Parent;
38 public:
39 ConfigView(QWidget* parent, ConfigMainWindow* cview, ConfigSettings* configSettings);
40 ~ConfigView(void);
41 static void updateList(ConfigItem* item);
42 static void updateListAll(void);
44 public:
45 ConfigList* list;
46 ConfigLineEdit* lineEdit;
48 static ConfigView* viewList;
49 ConfigView* nextView;
52 enum colIdx {
53 promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
55 enum listMode {
56 singleMode, menuMode, symbolMode, fullMode
59 class ConfigList : public QListView {
60 Q_OBJECT
61 typedef class QListView Parent;
62 public:
63 ConfigList(ConfigView* p, ConfigMainWindow* cview, ConfigSettings *configSettings);
64 void reinit(void);
65 ConfigView* parent(void) const
67 return (ConfigView*)Parent::parent();
70 protected:
71 ConfigMainWindow* cview;
73 void keyPressEvent(QKeyEvent *e);
74 void contentsMousePressEvent(QMouseEvent *e);
75 void contentsMouseReleaseEvent(QMouseEvent *e);
76 void contentsMouseMoveEvent(QMouseEvent *e);
77 void contentsMouseDoubleClickEvent(QMouseEvent *e);
78 void focusInEvent(QFocusEvent *e);
79 public slots:
80 void setRootMenu(struct menu *menu);
82 void updateList(ConfigItem *item);
83 void setValue(ConfigItem* item, tristate val);
84 void changeValue(ConfigItem* item);
85 void updateSelection(void);
86 signals:
87 void menuSelected(struct menu *menu);
88 void parentSelected(void);
89 void gotFocus(void);
91 public:
92 void updateListAll(void)
94 updateAll = true;
95 updateList(NULL);
96 updateAll = false;
98 ConfigList* listView()
100 return this;
102 ConfigItem* firstChild() const
104 return (ConfigItem *)Parent::firstChild();
106 int mapIdx(colIdx idx)
108 return colMap[idx];
110 void addColumn(colIdx idx, const QString& label)
112 colMap[idx] = Parent::addColumn(label);
113 colRevMap[colMap[idx]] = idx;
115 void removeColumn(colIdx idx)
117 int col = colMap[idx];
118 if (col >= 0) {
119 Parent::removeColumn(col);
120 colRevMap[col] = colMap[idx] = -1;
123 void setAllOpen(bool open);
124 void setParentMenu(void);
126 template <class P>
127 void ConfigList::updateMenuList(P*, struct menu*);
129 bool updateAll;
131 QPixmap symbolYesPix, symbolModPix, symbolNoPix;
132 QPixmap choiceYesPix, choiceNoPix;
133 QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
135 bool showAll, showName, showRange, showData;
136 enum listMode mode;
137 struct menu *rootEntry;
138 QColorGroup disabledColorGroup;
139 QColorGroup inactivedColorGroup;
141 private:
142 int colMap[colNr];
143 int colRevMap[colNr];
146 class ConfigItem : public QListViewItem {
147 typedef class QListViewItem Parent;
148 public:
149 ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v)
150 : Parent(parent, after), menu(m), visible(v), goParent(false)
152 init();
154 ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
155 : Parent(parent, after), menu(m), visible(v), goParent(false)
157 init();
159 ConfigItem(QListView *parent, ConfigItem *after, bool v)
160 : Parent(parent, after), menu(0), visible(v), goParent(true)
162 init();
164 ~ConfigItem(void);
165 void init(void);
166 #if QT_VERSION >= 300
167 void okRename(int col);
168 #endif
169 void updateMenu(void);
170 void testUpdateMenu(bool v);
171 ConfigList* listView() const
173 return (ConfigList*)Parent::listView();
175 ConfigItem* firstChild() const
177 return (ConfigItem *)Parent::firstChild();
179 ConfigItem* nextSibling() const
181 return (ConfigItem *)Parent::nextSibling();
183 void setText(colIdx idx, const QString& text)
185 Parent::setText(listView()->mapIdx(idx), text);
187 QString text(colIdx idx) const
189 return Parent::text(listView()->mapIdx(idx));
191 void setPixmap(colIdx idx, const QPixmap& pm)
193 Parent::setPixmap(listView()->mapIdx(idx), pm);
195 const QPixmap* pixmap(colIdx idx) const
197 return Parent::pixmap(listView()->mapIdx(idx));
199 void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);
201 ConfigItem* nextItem;
202 struct menu *menu;
203 bool visible;
204 bool goParent;
207 class ConfigLineEdit : public QLineEdit {
208 Q_OBJECT
209 typedef class QLineEdit Parent;
210 public:
211 ConfigLineEdit(ConfigView* parent)
212 : Parent(parent)
214 ConfigView* parent(void) const
216 return (ConfigView*)Parent::parent();
218 void show(ConfigItem *i);
219 void keyPressEvent(QKeyEvent *e);
221 public:
222 ConfigItem *item;
225 class ConfigMainWindow : public QMainWindow {
226 Q_OBJECT
227 public:
228 ConfigMainWindow(void);
229 public slots:
230 void setHelp(QListViewItem* item);
231 void changeMenu(struct menu *);
232 void listFocusChanged(void);
233 void goBack(void);
234 void loadConfig(void);
235 void saveConfig(void);
236 void saveConfigAs(void);
237 void showSingleView(void);
238 void showSplitView(void);
239 void showFullView(void);
240 void setShowAll(bool);
241 void setShowDebug(bool);
242 void setShowRange(bool);
243 void setShowName(bool);
244 void setShowData(bool);
245 void showIntro(void);
246 void showAbout(void);
247 void saveSettings(void);
249 protected:
250 void closeEvent(QCloseEvent *e);
252 ConfigView *menuView;
253 ConfigList *menuList;
254 ConfigView *configView;
255 ConfigList *configList;
256 QTextView *helpText;
257 QToolBar *toolBar;
258 QAction *backAction;
259 QSplitter* split1;
260 QSplitter* split2;
262 bool showDebug;