author | kergoth <kergoth> | 2003-06-17 17:03:49 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-06-17 17:03:49 (UTC) |
commit | 16e53b2a2e94742f3b55ee73700bb264e36638d4 (patch) (unidiff) | |
tree | 4f2b65a635d25c1ce0cfeea7953623c2bf7d9534 /scripts/kconfig/qconf.cc | |
parent | 384b7f1a42f9f2f101dc8fe11c3625055d96f672 (diff) | |
download | opie-16e53b2a2e94742f3b55ee73700bb264e36638d4.zip opie-16e53b2a2e94742f3b55ee73700bb264e36638d4.tar.gz opie-16e53b2a2e94742f3b55ee73700bb264e36638d4.tar.bz2 |
Update LinuxKernelConf version to 1.4.
-rw-r--r-- | scripts/kconfig/qconf.cc | 405 |
1 files changed, 253 insertions, 152 deletions
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index bed541d..52419ad 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
@@ -1,766 +1,831 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> | 2 | * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> |
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qmainwindow.h> | 7 | #include <qmainwindow.h> |
8 | #include <qtoolbar.h> | 8 | #include <qtoolbar.h> |
9 | #include <qvbox.h> | 9 | #include <qvbox.h> |
10 | #include <qsplitter.h> | 10 | #include <qsplitter.h> |
11 | #include <qlistview.h> | 11 | #include <qlistview.h> |
12 | #include <qtextview.h> | 12 | #include <qtextview.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qmenubar.h> | 14 | #include <qmenubar.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qaction.h> | 16 | #include <qaction.h> |
17 | #include <qheader.h> | 17 | #include <qheader.h> |
18 | #include <qfiledialog.h> | 18 | #include <qfiledialog.h> |
19 | #include <qregexp.h> | 19 | #include <qregexp.h> |
20 | #if QT_VERSION >= 300 | 20 | #if QT_VERSION >= 300 |
21 | #include <qsettings.h> | 21 | #include <qsettings.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | 25 | ||
26 | #include "lkc.h" | 26 | #include "lkc.h" |
27 | #include "qconf.h" | 27 | #include "qconf.h" |
28 | 28 | ||
29 | #include "qconf.moc" | 29 | #include "qconf.moc" |
30 | #include "images.c" | 30 | #include "images.c" |
31 | 31 | ||
32 | static QApplication *configApp; | 32 | static QApplication *configApp; |
33 | #if QT_VERSION >= 300 | 33 | #if QT_VERSION >= 300 |
34 | static QSettings *configSettings; | 34 | static QSettings *configSettings; |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | /* | 37 | /* |
38 | * update all the children of a menu entry | 38 | * update all the children of a menu entry |
39 | * removes/adds the entries from the parent widget as necessary | 39 | * removes/adds the entries from the parent widget as necessary |
40 | * | 40 | * |
41 | * parent: either the menu list widget or a menu entry widget | 41 | * parent: either the menu list widget or a menu entry widget |
42 | * menu: entry to be updated | 42 | * menu: entry to be updated |
43 | */ | 43 | */ |
44 | template <class P> | 44 | template <class P> |
45 | static void updateMenuList(P* parent, struct menu* menu) | 45 | void ConfigList::updateMenuList(P* parent, struct menu* menu) |
46 | { | 46 | { |
47 | struct menu* child; | 47 | struct menu* child; |
48 | ConfigList* list = parent->listView(); | ||
49 | ConfigItem* item; | 48 | ConfigItem* item; |
50 | ConfigItem* last; | 49 | ConfigItem* last; |
51 | bool visible; | 50 | bool visible; |
52 | bool showAll = list->showAll; | ||
53 | enum listMode mode = list->mode; | ||
54 | enum prop_type type; | 51 | enum prop_type type; |
55 | 52 | ||
56 | if (!menu) { | 53 | if (!menu) { |
57 | while ((item = parent->firstChild())) | 54 | while ((item = parent->firstChild())) |
58 | delete item; | 55 | delete item; |
59 | return; | 56 | return; |
60 | } | 57 | } |
61 | 58 | ||
62 | last = 0; | 59 | last = parent->firstChild(); |
60 | if (last && !last->goParent) | ||
61 | last = 0; | ||
63 | for (child = menu->list; child; child = child->next) { | 62 | for (child = menu->list; child; child = child->next) { |
64 | item = last ? last->nextSibling() : parent->firstChild(); | 63 | item = last ? last->nextSibling() : parent->firstChild(); |
65 | type = child->prompt ? child->prompt->type : P_UNKNOWN; | 64 | type = child->prompt ? child->prompt->type : P_UNKNOWN; |
66 | 65 | ||
67 | switch (mode) { | 66 | switch (mode) { |
68 | case menuMode: | 67 | case menuMode: |
69 | if (type != P_ROOTMENU) | 68 | if (!(child->flags & MENU_ROOT)) |
70 | goto hide; | 69 | goto hide; |
71 | break; | 70 | break; |
72 | case symbolMode: | 71 | case symbolMode: |
73 | if (type == P_ROOTMENU) | 72 | if (child->flags & MENU_ROOT) |
74 | goto hide; | 73 | goto hide; |
75 | break; | 74 | break; |
76 | default: | 75 | default: |
77 | break; | 76 | break; |
78 | } | 77 | } |
79 | 78 | ||
80 | visible = menu_is_visible(child); | 79 | visible = menu_is_visible(child); |
81 | if (showAll || visible) { | 80 | if (showAll || visible) { |
82 | if (!item || item->menu != child) | 81 | if (!item || item->menu != child) |
83 | item = new ConfigItem(parent, last, child, visible); | 82 | item = new ConfigItem(parent, last, child, visible); |
84 | else { | 83 | else |
85 | item->visible = visible; | 84 | item->testUpdateMenu(visible); |
86 | if (item->updateNeeded()) { | ||
87 | ConfigItem* i = (ConfigItem*)child->data; | ||
88 | for (; i; i = i->nextItem) { | ||
89 | i->updateMenu(); | ||
90 | } | ||
91 | } else if (list->updateAll) | ||
92 | item->updateMenu(); | ||
93 | } | ||
94 | 85 | ||
95 | if (mode == fullMode || mode == menuMode || | 86 | if (mode == fullMode || mode == menuMode || type != P_MENU) |
96 | (type != P_MENU && type != P_ROOTMENU)) | ||
97 | updateMenuList(item, child); | 87 | updateMenuList(item, child); |
98 | else | 88 | else |
99 | updateMenuList(item, 0); | 89 | updateMenuList(item, 0); |
100 | last = item; | 90 | last = item; |
101 | continue; | 91 | continue; |
102 | } | 92 | } |
103 | hide: | 93 | hide: |
104 | if (item && item->menu == child) { | 94 | if (item && item->menu == child) { |
105 | last = parent->firstChild(); | 95 | last = parent->firstChild(); |
106 | if (last == item) | 96 | if (last == item) |
107 | last = 0; | 97 | last = 0; |
108 | else while (last->nextSibling() != item) | 98 | else while (last->nextSibling() != item) |
109 | last = last->nextSibling(); | 99 | last = last->nextSibling(); |
110 | delete item; | 100 | delete item; |
111 | } | 101 | } |
112 | } | 102 | } |
113 | } | 103 | } |
114 | 104 | ||
115 | #if QT_VERSION >= 300 | 105 | #if QT_VERSION >= 300 |
116 | /* | 106 | /* |
117 | * set the new data | 107 | * set the new data |
118 | * TODO check the value | 108 | * TODO check the value |
119 | */ | 109 | */ |
120 | void ConfigItem::okRename(int col) | 110 | void ConfigItem::okRename(int col) |
121 | { | 111 | { |
122 | Parent::okRename(col); | 112 | Parent::okRename(col); |
123 | sym_set_string_value(menu->sym, text(dataColIdx).latin1()); | 113 | sym_set_string_value(menu->sym, text(dataColIdx).latin1()); |
124 | } | 114 | } |
125 | #endif | 115 | #endif |
126 | 116 | ||
127 | /* | 117 | /* |
128 | * update the displayed of a menu entry | 118 | * update the displayed of a menu entry |
129 | */ | 119 | */ |
130 | void ConfigItem::updateMenu(void) | 120 | void ConfigItem::updateMenu(void) |
131 | { | 121 | { |
132 | ConfigList* list; | 122 | ConfigList* list; |
133 | struct symbol* sym; | 123 | struct symbol* sym; |
124 | struct property *prop; | ||
134 | QString prompt; | 125 | QString prompt; |
135 | int type; | 126 | int type; |
136 | enum prop_type ptype; | ||
137 | tristate expr; | 127 | tristate expr; |
138 | 128 | ||
139 | list = listView(); | 129 | list = listView(); |
130 | if (goParent) { | ||
131 | setPixmap(promptColIdx, list->menuBackPix); | ||
132 | prompt = ".."; | ||
133 | goto set_prompt; | ||
134 | } | ||
140 | 135 | ||
141 | sym = menu->sym; | 136 | sym = menu->sym; |
142 | if (!sym) { | 137 | prop = menu->prompt; |
143 | setText(promptColIdx, menu_get_prompt(menu)); | 138 | prompt = menu_get_prompt(menu); |
144 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 139 | |
145 | if ((ptype == P_ROOTMENU || ptype == P_MENU) && | 140 | if (prop) switch (prop->type) { |
146 | (list->mode == singleMode || list->mode == symbolMode)) | 141 | case P_MENU: |
142 | if (list->mode == singleMode || list->mode == symbolMode) { | ||
143 | /* a menuconfig entry is displayed differently | ||
144 | * depending whether it's at the view root or a child. | ||
145 | */ | ||
146 | if (sym && list->rootEntry == menu) | ||
147 | break; | ||
147 | setPixmap(promptColIdx, list->menuPix); | 148 | setPixmap(promptColIdx, list->menuPix); |
148 | else | 149 | } else { |
150 | if (sym) | ||
151 | break; | ||
149 | setPixmap(promptColIdx, 0); | 152 | setPixmap(promptColIdx, 0); |
150 | return; | 153 | } |
154 | goto set_prompt; | ||
155 | case P_COMMENT: | ||
156 | setPixmap(promptColIdx, 0); | ||
157 | goto set_prompt; | ||
158 | default: | ||
159 | ; | ||
151 | } | 160 | } |
161 | if (!sym) | ||
162 | goto set_prompt; | ||
152 | 163 | ||
153 | setText(nameColIdx, sym->name); | 164 | setText(nameColIdx, sym->name); |
154 | 165 | ||
155 | type = sym_get_type(sym); | 166 | type = sym_get_type(sym); |
156 | switch (type) { | 167 | switch (type) { |
157 | case S_BOOLEAN: | 168 | case S_BOOLEAN: |
158 | case S_TRISTATE: | 169 | case S_TRISTATE: |
159 | char ch; | 170 | char ch; |
160 | 171 | ||
161 | prompt = menu_get_prompt(menu); | ||
162 | if (!sym_is_changable(sym) && !list->showAll) { | 172 | if (!sym_is_changable(sym) && !list->showAll) { |
173 | setPixmap(promptColIdx, 0); | ||
163 | setText(noColIdx, 0); | 174 | setText(noColIdx, 0); |
164 | setText(modColIdx, 0); | 175 | setText(modColIdx, 0); |
165 | setText(yesColIdx, 0); | 176 | setText(yesColIdx, 0); |
166 | break; | 177 | break; |
167 | } | 178 | } |
168 | expr = sym_get_tristate_value(sym); | 179 | expr = sym_get_tristate_value(sym); |
169 | switch (expr) { | 180 | switch (expr) { |
170 | case yes: | 181 | case yes: |
171 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | 182 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) |
172 | setPixmap(promptColIdx, list->choiceYesPix); | 183 | setPixmap(promptColIdx, list->choiceYesPix); |
173 | else | 184 | else |
174 | setPixmap(promptColIdx, list->symbolYesPix); | 185 | setPixmap(promptColIdx, list->symbolYesPix); |
175 | setText(yesColIdx, "Y"); | 186 | setText(yesColIdx, "Y"); |
176 | ch = 'Y'; | 187 | ch = 'Y'; |
177 | break; | 188 | break; |
178 | case mod: | 189 | case mod: |
179 | setPixmap(promptColIdx, list->symbolModPix); | 190 | setPixmap(promptColIdx, list->symbolModPix); |
180 | setText(modColIdx, "M"); | 191 | setText(modColIdx, "M"); |
181 | ch = 'M'; | 192 | ch = 'M'; |
182 | break; | 193 | break; |
183 | default: | 194 | default: |
184 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) | 195 | if (sym_is_choice_value(sym) && type == S_BOOLEAN) |
185 | setPixmap(promptColIdx, list->choiceNoPix); | 196 | setPixmap(promptColIdx, list->choiceNoPix); |
186 | else | 197 | else |
187 | setPixmap(promptColIdx, list->symbolNoPix); | 198 | setPixmap(promptColIdx, list->symbolNoPix); |
188 | setText(noColIdx, "N"); | 199 | setText(noColIdx, "N"); |
189 | ch = 'N'; | 200 | ch = 'N'; |
190 | break; | 201 | break; |
191 | } | 202 | } |
192 | if (expr != no) | 203 | if (expr != no) |
193 | setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); | 204 | setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); |
194 | if (expr != mod) | 205 | if (expr != mod) |
195 | setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); | 206 | setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); |
196 | if (expr != yes) | 207 | if (expr != yes) |
197 | setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); | 208 | setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); |
198 | 209 | ||
199 | setText(dataColIdx, QChar(ch)); | 210 | setText(dataColIdx, QChar(ch)); |
200 | break; | 211 | break; |
201 | case S_INT: | 212 | case S_INT: |
202 | case S_HEX: | 213 | case S_HEX: |
203 | case S_STRING: | 214 | case S_STRING: |
204 | const char* data; | 215 | const char* data; |
205 | 216 | ||
206 | data = sym_get_string_value(sym); | 217 | data = sym_get_string_value(sym); |
207 | #if QT_VERSION >= 300 | 218 | #if QT_VERSION >= 300 |
208 | int i = list->mapIdx(dataColIdx); | 219 | int i = list->mapIdx(dataColIdx); |
209 | if (i >= 0) | 220 | if (i >= 0) |
210 | setRenameEnabled(i, TRUE); | 221 | setRenameEnabled(i, TRUE); |
211 | #endif | 222 | #endif |
212 | setText(dataColIdx, data); | 223 | setText(dataColIdx, data); |
213 | if (type == S_STRING) | 224 | if (type == S_STRING) |
214 | prompt.sprintf("%s: %s", menu_get_prompt(menu), data); | 225 | prompt.sprintf("%s: %s", prompt.latin1(), data); |
215 | else | 226 | else |
216 | prompt.sprintf("(%s) %s", data, menu_get_prompt(menu)); | 227 | prompt.sprintf("(%s) %s", data, prompt.latin1()); |
217 | break; | 228 | break; |
218 | } | 229 | } |
219 | if (!sym_has_value(sym) && visible) | 230 | if (!sym_has_value(sym) && visible) |
220 | prompt += " (NEW)"; | 231 | prompt += " (NEW)"; |
232 | set_prompt: | ||
221 | setText(promptColIdx, prompt); | 233 | setText(promptColIdx, prompt); |
222 | } | 234 | } |
223 | 235 | ||
224 | bool ConfigItem::updateNeeded(void) | 236 | void ConfigItem::testUpdateMenu(bool v) |
225 | { | 237 | { |
226 | struct symbol* sym = menu->sym; | 238 | ConfigItem* i; |
227 | if (sym) | 239 | |
228 | sym_calc_value(sym); | 240 | visible = v; |
241 | if (!menu) | ||
242 | return; | ||
243 | |||
244 | sym_calc_value(menu->sym); | ||
229 | if (menu->flags & MENU_CHANGED) { | 245 | if (menu->flags & MENU_CHANGED) { |
246 | /* the menu entry changed, so update all list items */ | ||
230 | menu->flags &= ~MENU_CHANGED; | 247 | menu->flags &= ~MENU_CHANGED; |
231 | return true; | 248 | for (i = (ConfigItem*)menu->data; i; i = i->nextItem) |
232 | } | 249 | i->updateMenu(); |
233 | return false; | 250 | } else if (listView()->updateAll) |
251 | updateMenu(); | ||
234 | } | 252 | } |
235 | 253 | ||
236 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) | 254 | void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) |
237 | { | 255 | { |
238 | ConfigList* list = listView(); | 256 | ConfigList* list = listView(); |
239 | 257 | ||
240 | if (visible) { | 258 | if (visible) { |
241 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) | 259 | if (isSelected() && !list->hasFocus() && list->mode == menuMode) |
242 | Parent::paintCell(p, list->inactivedColorGroup, column, width, align); | 260 | Parent::paintCell(p, list->inactivedColorGroup, column, width, align); |
243 | else | 261 | else |
244 | Parent::paintCell(p, cg, column, width, align); | 262 | Parent::paintCell(p, cg, column, width, align); |
245 | } else | 263 | } else |
246 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); | 264 | Parent::paintCell(p, list->disabledColorGroup, column, width, align); |
247 | } | 265 | } |
248 | 266 | ||
249 | /* | 267 | /* |
250 | * construct a menu entry | 268 | * construct a menu entry |
251 | */ | 269 | */ |
252 | void ConfigItem::init(void) | 270 | void ConfigItem::init(void) |
253 | { | 271 | { |
254 | ConfigList* list = listView(); | 272 | if (menu) { |
255 | nextItem = (ConfigItem*)menu->data; | 273 | ConfigList* list = listView(); |
256 | menu->data = this; | 274 | nextItem = (ConfigItem*)menu->data; |
275 | menu->data = this; | ||
257 | 276 | ||
258 | if (list->mode != fullMode) | 277 | if (list->mode != fullMode) |
259 | setOpen(TRUE); | 278 | setOpen(TRUE); |
260 | if (menu->sym) | ||
261 | sym_calc_value(menu->sym); | 279 | sym_calc_value(menu->sym); |
280 | } | ||
262 | updateMenu(); | 281 | updateMenu(); |
263 | } | 282 | } |
264 | 283 | ||
265 | /* | 284 | /* |
266 | * destruct a menu entry | 285 | * destruct a menu entry |
267 | */ | 286 | */ |
268 | ConfigItem::~ConfigItem(void) | 287 | ConfigItem::~ConfigItem(void) |
269 | { | 288 | { |
270 | ConfigItem** ip = &(ConfigItem*)menu->data; | 289 | if (menu) { |
271 | for (; *ip; ip = &(*ip)->nextItem) { | 290 | ConfigItem** ip = (ConfigItem**)&menu->data; |
272 | if (*ip == this) { | 291 | for (; *ip; ip = &(*ip)->nextItem) { |
273 | *ip = nextItem; | 292 | if (*ip == this) { |
274 | break; | 293 | *ip = nextItem; |
294 | break; | ||
295 | } | ||
275 | } | 296 | } |
276 | } | 297 | } |
277 | } | 298 | } |
278 | 299 | ||
279 | void ConfigLineEdit::show(ConfigItem* i) | 300 | void ConfigLineEdit::show(ConfigItem* i) |
280 | { | 301 | { |
281 | item = i; | 302 | item = i; |
282 | if (sym_get_string_value(item->menu->sym)) | 303 | if (sym_get_string_value(item->menu->sym)) |
283 | setText(sym_get_string_value(item->menu->sym)); | 304 | setText(sym_get_string_value(item->menu->sym)); |
284 | else | 305 | else |
285 | setText(0); | 306 | setText(0); |
286 | Parent::show(); | 307 | Parent::show(); |
287 | setFocus(); | 308 | setFocus(); |
288 | } | 309 | } |
289 | 310 | ||
290 | void ConfigLineEdit::keyPressEvent(QKeyEvent* e) | 311 | void ConfigLineEdit::keyPressEvent(QKeyEvent* e) |
291 | { | 312 | { |
292 | switch (e->key()) { | 313 | switch (e->key()) { |
293 | case Key_Escape: | 314 | case Key_Escape: |
294 | break; | 315 | break; |
295 | case Key_Return: | 316 | case Key_Return: |
296 | case Key_Enter: | 317 | case Key_Enter: |
297 | sym_set_string_value(item->menu->sym, text().latin1()); | 318 | sym_set_string_value(item->menu->sym, text().latin1()); |
298 | parent()->updateList(item); | 319 | parent()->updateList(item); |
299 | break; | 320 | break; |
300 | default: | 321 | default: |
301 | Parent::keyPressEvent(e); | 322 | Parent::keyPressEvent(e); |
302 | return; | 323 | return; |
303 | } | 324 | } |
304 | e->accept(); | 325 | e->accept(); |
305 | parent()->list->setFocus(); | 326 | parent()->list->setFocus(); |
306 | hide(); | 327 | hide(); |
307 | } | 328 | } |
308 | 329 | ||
309 | ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv) | 330 | ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv) |
310 | : Parent(p), cview(cv), | 331 | : Parent(p), cview(cv), |
311 | updateAll(false), | 332 | updateAll(false), |
312 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), | 333 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), |
313 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), | 334 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), |
335 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), | ||
314 | showAll(false), showName(false), showRange(false), showData(false), | 336 | showAll(false), showName(false), showRange(false), showData(false), |
315 | rootEntry(0) | 337 | rootEntry(0) |
316 | { | 338 | { |
317 | int i; | 339 | int i; |
318 | 340 | ||
319 | setSorting(-1); | 341 | setSorting(-1); |
320 | setRootIsDecorated(TRUE); | 342 | setRootIsDecorated(TRUE); |
321 | disabledColorGroup = palette().active(); | 343 | disabledColorGroup = palette().active(); |
322 | disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); | 344 | disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); |
323 | inactivedColorGroup = palette().active(); | 345 | inactivedColorGroup = palette().active(); |
324 | inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); | 346 | inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); |
325 | 347 | ||
326 | connect(this, SIGNAL(selectionChanged(void)), | 348 | connect(this, SIGNAL(selectionChanged(void)), |
327 | SLOT(updateSelection(void))); | 349 | SLOT(updateSelection(void))); |
328 | 350 | ||
329 | for (i = 0; i < colNr; i++) | 351 | for (i = 0; i < colNr; i++) |
330 | colMap[i] = colRevMap[i] = -1; | 352 | colMap[i] = colRevMap[i] = -1; |
331 | addColumn(promptColIdx, "Option"); | 353 | addColumn(promptColIdx, "Option"); |
332 | 354 | ||
333 | reinit(); | 355 | reinit(); |
334 | } | 356 | } |
335 | 357 | ||
336 | void ConfigList::reinit(void) | 358 | void ConfigList::reinit(void) |
337 | { | 359 | { |
338 | removeColumn(dataColIdx); | 360 | removeColumn(dataColIdx); |
339 | removeColumn(yesColIdx); | 361 | removeColumn(yesColIdx); |
340 | removeColumn(modColIdx); | 362 | removeColumn(modColIdx); |
341 | removeColumn(noColIdx); | 363 | removeColumn(noColIdx); |
342 | removeColumn(nameColIdx); | 364 | removeColumn(nameColIdx); |
343 | 365 | ||
344 | if (showName) | 366 | if (showName) |
345 | addColumn(nameColIdx, "Name"); | 367 | addColumn(nameColIdx, "Name"); |
346 | if (showRange) { | 368 | if (showRange) { |
347 | addColumn(noColIdx, "N"); | 369 | addColumn(noColIdx, "N"); |
348 | addColumn(modColIdx, "M"); | 370 | addColumn(modColIdx, "M"); |
349 | addColumn(yesColIdx, "Y"); | 371 | addColumn(yesColIdx, "Y"); |
350 | } | 372 | } |
351 | if (showData) | 373 | if (showData) |
352 | addColumn(dataColIdx, "Value"); | 374 | addColumn(dataColIdx, "Value"); |
353 | 375 | ||
354 | updateListAll(); | 376 | updateListAll(); |
355 | } | 377 | } |
356 | 378 | ||
357 | void ConfigList::updateSelection(void) | 379 | void ConfigList::updateSelection(void) |
358 | { | 380 | { |
359 | struct menu *menu; | 381 | struct menu *menu; |
360 | enum prop_type type; | 382 | enum prop_type type; |
361 | 383 | ||
362 | ConfigItem* item = (ConfigItem*)selectedItem(); | 384 | ConfigItem* item = (ConfigItem*)selectedItem(); |
363 | if (!item) | 385 | if (!item) |
364 | return; | 386 | return; |
365 | 387 | ||
366 | cview->setHelp(item); | 388 | cview->setHelp(item); |
367 | 389 | ||
368 | menu = item->menu; | 390 | menu = item->menu; |
391 | if (!menu) | ||
392 | return; | ||
369 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 393 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
370 | if (mode == menuMode && (type == P_MENU || type == P_ROOTMENU)) | 394 | if (mode == menuMode && type == P_MENU) |
371 | emit menuSelected(menu); | 395 | emit menuSelected(menu); |
372 | } | 396 | } |
373 | 397 | ||
374 | void ConfigList::updateList(ConfigItem* item) | 398 | void ConfigList::updateList(ConfigItem* item) |
375 | { | 399 | { |
376 | (void)item;// unused so far | 400 | ConfigItem* last = 0; |
401 | |||
402 | if (!rootEntry) | ||
403 | goto update; | ||
404 | |||
405 | if (rootEntry != &rootmenu && (mode == singleMode || | ||
406 | (mode == symbolMode && rootEntry->parent != &rootmenu))) { | ||
407 | item = firstChild(); | ||
408 | if (!item) | ||
409 | item = new ConfigItem(this, 0, true); | ||
410 | last = item; | ||
411 | } | ||
412 | if (mode == singleMode && rootEntry->sym && rootEntry->prompt) { | ||
413 | item = last ? last->nextSibling() : firstChild(); | ||
414 | if (!item) | ||
415 | item = new ConfigItem(this, last, rootEntry, true); | ||
416 | |||
417 | updateMenuList(item, rootEntry); | ||
418 | triggerUpdate(); | ||
419 | return; | ||
420 | } | ||
421 | update: | ||
377 | updateMenuList(this, rootEntry); | 422 | updateMenuList(this, rootEntry); |
378 | triggerUpdate(); | 423 | triggerUpdate(); |
379 | } | 424 | } |
380 | 425 | ||
381 | void ConfigList::setAllOpen(bool open) | 426 | void ConfigList::setAllOpen(bool open) |
382 | { | 427 | { |
383 | QListViewItemIterator it(this); | 428 | QListViewItemIterator it(this); |
384 | 429 | ||
385 | for (; it.current(); it++) | 430 | for (; it.current(); it++) |
386 | it.current()->setOpen(open); | 431 | it.current()->setOpen(open); |
387 | } | 432 | } |
388 | 433 | ||
389 | void ConfigList::setValue(ConfigItem* item, tristate val) | 434 | void ConfigList::setValue(ConfigItem* item, tristate val) |
390 | { | 435 | { |
391 | struct symbol* sym; | 436 | struct symbol* sym; |
392 | int type; | 437 | int type; |
393 | tristate oldval; | 438 | tristate oldval; |
394 | 439 | ||
395 | sym = item->menu->sym; | 440 | sym = item->menu ? item->menu->sym : 0; |
396 | if (!sym) | 441 | if (!sym) |
397 | return; | 442 | return; |
398 | 443 | ||
399 | type = sym_get_type(sym); | 444 | type = sym_get_type(sym); |
400 | switch (type) { | 445 | switch (type) { |
401 | case S_BOOLEAN: | 446 | case S_BOOLEAN: |
402 | case S_TRISTATE: | 447 | case S_TRISTATE: |
403 | oldval = sym_get_tristate_value(sym); | 448 | oldval = sym_get_tristate_value(sym); |
404 | 449 | ||
405 | if (!sym_set_tristate_value(sym, val)) | 450 | if (!sym_set_tristate_value(sym, val)) |
406 | return; | 451 | return; |
407 | if (oldval == no && item->menu->list) | 452 | if (oldval == no && item->menu->list) |
408 | item->setOpen(TRUE); | 453 | item->setOpen(TRUE); |
409 | parent()->updateList(item); | 454 | parent()->updateList(item); |
410 | break; | 455 | break; |
411 | } | 456 | } |
412 | } | 457 | } |
413 | 458 | ||
414 | void ConfigList::changeValue(ConfigItem* item) | 459 | void ConfigList::changeValue(ConfigItem* item) |
415 | { | 460 | { |
416 | struct symbol* sym; | 461 | struct symbol* sym; |
417 | struct menu* menu; | 462 | struct menu* menu; |
418 | int type, oldexpr, newexpr; | 463 | int type, oldexpr, newexpr; |
419 | 464 | ||
420 | menu = item->menu; | 465 | menu = item->menu; |
466 | if (!menu) | ||
467 | return; | ||
421 | sym = menu->sym; | 468 | sym = menu->sym; |
422 | if (!sym) { | 469 | if (!sym) { |
423 | if (item->menu->list) | 470 | if (item->menu->list) |
424 | item->setOpen(!item->isOpen()); | 471 | item->setOpen(!item->isOpen()); |
425 | return; | 472 | return; |
426 | } | 473 | } |
427 | 474 | ||
428 | type = sym_get_type(sym); | 475 | type = sym_get_type(sym); |
429 | switch (type) { | 476 | switch (type) { |
430 | case S_BOOLEAN: | 477 | case S_BOOLEAN: |
431 | case S_TRISTATE: | 478 | case S_TRISTATE: |
432 | oldexpr = sym_get_tristate_value(sym); | 479 | oldexpr = sym_get_tristate_value(sym); |
433 | newexpr = sym_toggle_tristate_value(sym); | 480 | newexpr = sym_toggle_tristate_value(sym); |
434 | if (item->menu->list) { | 481 | if (item->menu->list) { |
435 | if (oldexpr == newexpr) | 482 | if (oldexpr == newexpr) |
436 | item->setOpen(!item->isOpen()); | 483 | item->setOpen(!item->isOpen()); |
437 | else if (oldexpr == no) | 484 | else if (oldexpr == no) |
438 | item->setOpen(TRUE); | 485 | item->setOpen(TRUE); |
439 | } | 486 | } |
440 | if (oldexpr != newexpr) | 487 | if (oldexpr != newexpr) |
441 | parent()->updateList(item); | 488 | parent()->updateList(item); |
442 | break; | 489 | break; |
443 | case S_INT: | 490 | case S_INT: |
444 | case S_HEX: | 491 | case S_HEX: |
445 | case S_STRING: | 492 | case S_STRING: |
446 | #if QT_VERSION >= 300 | 493 | #if QT_VERSION >= 300 |
447 | if (colMap[dataColIdx] >= 0) | 494 | if (colMap[dataColIdx] >= 0) |
448 | item->startRename(colMap[dataColIdx]); | 495 | item->startRename(colMap[dataColIdx]); |
449 | else | 496 | else |
450 | #endif | 497 | #endif |
451 | parent()->lineEdit->show(item); | 498 | parent()->lineEdit->show(item); |
452 | break; | 499 | break; |
453 | } | 500 | } |
454 | } | 501 | } |
455 | 502 | ||
456 | void ConfigList::setRootMenu(struct menu *menu) | 503 | void ConfigList::setRootMenu(struct menu *menu) |
457 | { | 504 | { |
458 | enum prop_type type; | 505 | enum prop_type type; |
459 | 506 | ||
460 | if (rootEntry == menu) | 507 | if (rootEntry == menu) |
461 | return; | 508 | return; |
462 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; | 509 | type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; |
463 | if (type != P_MENU && type != P_ROOTMENU) | 510 | if (type != P_MENU) |
464 | return; | 511 | return; |
465 | updateMenuList(this, 0); | 512 | updateMenuList(this, 0); |
466 | rootEntry = menu; | 513 | rootEntry = menu; |
467 | updateListAll(); | 514 | updateListAll(); |
468 | setSelected(currentItem(), hasFocus()); | 515 | setSelected(currentItem(), hasFocus()); |
469 | } | 516 | } |
470 | 517 | ||
471 | void ConfigList::setParentMenu(void) | 518 | void ConfigList::setParentMenu(void) |
472 | { | 519 | { |
473 | ConfigItem* item; | 520 | ConfigItem* item; |
474 | struct menu *oldroot, *newroot; | 521 | struct menu *oldroot; |
475 | 522 | ||
476 | oldroot = rootEntry; | 523 | oldroot = rootEntry; |
477 | newroot = menu_get_parent_menu(oldroot); | 524 | if (rootEntry == &rootmenu) |
478 | if (newroot == oldroot) | ||
479 | return; | 525 | return; |
480 | setRootMenu(newroot); | 526 | setRootMenu(menu_get_parent_menu(rootEntry->parent)); |
481 | 527 | ||
482 | QListViewItemIterator it(this); | 528 | QListViewItemIterator it(this); |
483 | for (; (item = (ConfigItem*)it.current()); it++) { | 529 | for (; (item = (ConfigItem*)it.current()); it++) { |
484 | if (item->menu == oldroot) { | 530 | if (item->menu == oldroot) { |
485 | setCurrentItem(item); | 531 | setCurrentItem(item); |
486 | ensureItemVisible(item); | 532 | ensureItemVisible(item); |
487 | break; | 533 | break; |
488 | } | 534 | } |
489 | } | 535 | } |
490 | } | 536 | } |
491 | 537 | ||
492 | void ConfigList::keyPressEvent(QKeyEvent* ev) | 538 | void ConfigList::keyPressEvent(QKeyEvent* ev) |
493 | { | 539 | { |
494 | QListViewItem* i = currentItem(); | 540 | QListViewItem* i = currentItem(); |
495 | ConfigItem* item; | 541 | ConfigItem* item; |
496 | struct menu *menu; | 542 | struct menu *menu; |
497 | enum prop_type type; | 543 | enum prop_type type; |
498 | 544 | ||
499 | if (ev->key() == Key_Escape && mode != fullMode) { | 545 | if (ev->key() == Key_Escape && mode != fullMode) { |
500 | emit parentSelected(); | 546 | emit parentSelected(); |
501 | ev->accept(); | 547 | ev->accept(); |
502 | return; | 548 | return; |
503 | } | 549 | } |
504 | 550 | ||
505 | if (!i) { | 551 | if (!i) { |
506 | Parent::keyPressEvent(ev); | 552 | Parent::keyPressEvent(ev); |
507 | return; | 553 | return; |
508 | } | 554 | } |
509 | item = (ConfigItem*)i; | 555 | item = (ConfigItem*)i; |
510 | 556 | ||
511 | switch (ev->key()) { | 557 | switch (ev->key()) { |
512 | case Key_Return: | 558 | case Key_Return: |
513 | case Key_Enter: | 559 | case Key_Enter: |
560 | if (item->goParent) { | ||
561 | emit parentSelected(); | ||
562 | break; | ||
563 | } | ||
514 | menu = item->menu; | 564 | menu = item->menu; |
565 | if (!menu) | ||
566 | break; | ||
515 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 567 | type = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
516 | if ((type == P_MENU || type == P_ROOTMENU) && mode != fullMode) { | 568 | if (type == P_MENU && rootEntry != menu && |
569 | mode != fullMode && mode != menuMode) { | ||
517 | emit menuSelected(menu); | 570 | emit menuSelected(menu); |
518 | break; | 571 | break; |
519 | } | 572 | } |
520 | case Key_Space: | 573 | case Key_Space: |
521 | changeValue(item); | 574 | changeValue(item); |
522 | break; | 575 | break; |
523 | case Key_N: | 576 | case Key_N: |
524 | setValue(item, no); | 577 | setValue(item, no); |
525 | break; | 578 | break; |
526 | case Key_M: | 579 | case Key_M: |
527 | setValue(item, mod); | 580 | setValue(item, mod); |
528 | break; | 581 | break; |
529 | case Key_Y: | 582 | case Key_Y: |
530 | setValue(item, yes); | 583 | setValue(item, yes); |
531 | break; | 584 | break; |
532 | default: | 585 | default: |
533 | Parent::keyPressEvent(ev); | 586 | Parent::keyPressEvent(ev); |
534 | return; | 587 | return; |
535 | } | 588 | } |
536 | ev->accept(); | 589 | ev->accept(); |
537 | } | 590 | } |
538 | 591 | ||
539 | void ConfigList::contentsMousePressEvent(QMouseEvent* e) | 592 | void ConfigList::contentsMousePressEvent(QMouseEvent* e) |
540 | { | 593 | { |
541 | //QPoint p(contentsToViewport(e->pos())); | 594 | //QPoint p(contentsToViewport(e->pos())); |
542 | //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); | 595 | //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); |
543 | Parent::contentsMousePressEvent(e); | 596 | Parent::contentsMousePressEvent(e); |
544 | } | 597 | } |
545 | 598 | ||
546 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) | 599 | void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) |
547 | { | 600 | { |
548 | QPoint p(contentsToViewport(e->pos())); | 601 | QPoint p(contentsToViewport(e->pos())); |
549 | ConfigItem* item = (ConfigItem*)itemAt(p); | 602 | ConfigItem* item = (ConfigItem*)itemAt(p); |
550 | struct menu *menu; | 603 | struct menu *menu; |
604 | enum prop_type ptype; | ||
551 | const QPixmap* pm; | 605 | const QPixmap* pm; |
552 | int idx, x; | 606 | int idx, x; |
553 | 607 | ||
554 | if (!item) | 608 | if (!item) |
555 | goto skip; | 609 | goto skip; |
556 | 610 | ||
557 | menu = item->menu; | 611 | menu = item->menu; |
558 | x = header()->offset() + p.x(); | 612 | x = header()->offset() + p.x(); |
559 | idx = colRevMap[header()->sectionAt(x)]; | 613 | idx = colRevMap[header()->sectionAt(x)]; |
560 | switch (idx) { | 614 | switch (idx) { |
561 | case promptColIdx: | 615 | case promptColIdx: |
562 | pm = item->pixmap(promptColIdx); | 616 | pm = item->pixmap(promptColIdx); |
563 | if (pm) { | 617 | if (pm) { |
564 | int off = header()->sectionPos(0) + itemMargin() + | 618 | int off = header()->sectionPos(0) + itemMargin() + |
565 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); | 619 | treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); |
566 | if (x >= off && x < off + pm->width()) { | 620 | if (x >= off && x < off + pm->width()) { |
567 | if (menu->sym) | 621 | if (item->goParent) { |
568 | changeValue(item); | 622 | emit parentSelected(); |
569 | else | 623 | break; |
624 | } else if (!menu) | ||
625 | break; | ||
626 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | ||
627 | if (ptype == P_MENU && rootEntry != menu && | ||
628 | mode != fullMode && mode != menuMode) | ||
570 | emit menuSelected(menu); | 629 | emit menuSelected(menu); |
630 | else | ||
631 | changeValue(item); | ||
571 | } | 632 | } |
572 | } | 633 | } |
573 | break; | 634 | break; |
574 | case noColIdx: | 635 | case noColIdx: |
575 | setValue(item, no); | 636 | setValue(item, no); |
576 | break; | 637 | break; |
577 | case modColIdx: | 638 | case modColIdx: |
578 | setValue(item, mod); | 639 | setValue(item, mod); |
579 | break; | 640 | break; |
580 | case yesColIdx: | 641 | case yesColIdx: |
581 | setValue(item, yes); | 642 | setValue(item, yes); |
582 | break; | 643 | break; |
583 | case dataColIdx: | 644 | case dataColIdx: |
584 | changeValue(item); | 645 | changeValue(item); |
585 | break; | 646 | break; |
586 | } | 647 | } |
587 | 648 | ||
588 | skip: | 649 | skip: |
589 | //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); | 650 | //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); |
590 | Parent::contentsMouseReleaseEvent(e); | 651 | Parent::contentsMouseReleaseEvent(e); |
591 | } | 652 | } |
592 | 653 | ||
593 | void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) | 654 | void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) |
594 | { | 655 | { |
595 | //QPoint p(contentsToViewport(e->pos())); | 656 | //QPoint p(contentsToViewport(e->pos())); |
596 | //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); | 657 | //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); |
597 | Parent::contentsMouseMoveEvent(e); | 658 | Parent::contentsMouseMoveEvent(e); |
598 | } | 659 | } |
599 | 660 | ||
600 | void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) | 661 | void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) |
601 | { | 662 | { |
602 | QPoint p(contentsToViewport(e->pos())); | 663 | QPoint p(contentsToViewport(e->pos())); |
603 | ConfigItem* item = (ConfigItem*)itemAt(p); | 664 | ConfigItem* item = (ConfigItem*)itemAt(p); |
604 | struct menu *menu; | 665 | struct menu *menu; |
605 | enum prop_type ptype; | 666 | enum prop_type ptype; |
606 | 667 | ||
607 | if (!item) | 668 | if (!item) |
608 | goto skip; | 669 | goto skip; |
670 | if (item->goParent) { | ||
671 | emit parentSelected(); | ||
672 | goto skip; | ||
673 | } | ||
609 | menu = item->menu; | 674 | menu = item->menu; |
675 | if (!menu) | ||
676 | goto skip; | ||
610 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; | 677 | ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; |
611 | if ((ptype == P_ROOTMENU || ptype == P_MENU) && | 678 | if (ptype == P_MENU && (mode == singleMode || mode == symbolMode)) |
612 | (mode == singleMode || mode == symbolMode)) | ||
613 | emit menuSelected(menu); | 679 | emit menuSelected(menu); |
614 | else if (menu->sym) | 680 | else if (menu->sym) |
615 | changeValue(item); | 681 | changeValue(item); |
616 | 682 | ||
617 | skip: | 683 | skip: |
618 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); | 684 | //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); |
619 | Parent::contentsMouseDoubleClickEvent(e); | 685 | Parent::contentsMouseDoubleClickEvent(e); |
620 | } | 686 | } |
621 | 687 | ||
622 | void ConfigList::focusInEvent(QFocusEvent *e) | 688 | void ConfigList::focusInEvent(QFocusEvent *e) |
623 | { | 689 | { |
624 | Parent::focusInEvent(e); | 690 | Parent::focusInEvent(e); |
625 | 691 | ||
626 | QListViewItem* item = currentItem(); | 692 | QListViewItem* item = currentItem(); |
627 | if (!item) | 693 | if (!item) |
628 | return; | 694 | return; |
629 | 695 | ||
630 | setSelected(item, TRUE); | 696 | setSelected(item, TRUE); |
631 | emit gotFocus(); | 697 | emit gotFocus(); |
632 | } | 698 | } |
633 | 699 | ||
634 | ConfigView* ConfigView::viewList; | 700 | ConfigView* ConfigView::viewList; |
635 | 701 | ||
636 | ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview) | 702 | ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview) |
637 | : Parent(parent) | 703 | : Parent(parent) |
638 | { | 704 | { |
639 | list = new ConfigList(this, cview); | 705 | list = new ConfigList(this, cview); |
640 | lineEdit = new ConfigLineEdit(this); | 706 | lineEdit = new ConfigLineEdit(this); |
641 | lineEdit->hide(); | 707 | lineEdit->hide(); |
642 | 708 | ||
643 | this->nextView = viewList; | 709 | this->nextView = viewList; |
644 | viewList = this; | 710 | viewList = this; |
645 | } | 711 | } |
646 | 712 | ||
647 | ConfigView::~ConfigView(void) | 713 | ConfigView::~ConfigView(void) |
648 | { | 714 | { |
649 | ConfigView** vp; | 715 | ConfigView** vp; |
650 | 716 | ||
651 | for (vp = &viewList; *vp; vp = &(*vp)->nextView) { | 717 | for (vp = &viewList; *vp; vp = &(*vp)->nextView) { |
652 | if (*vp == this) { | 718 | if (*vp == this) { |
653 | *vp = nextView; | 719 | *vp = nextView; |
654 | break; | 720 | break; |
655 | } | 721 | } |
656 | } | 722 | } |
657 | } | 723 | } |
658 | 724 | ||
659 | void ConfigView::updateList(ConfigItem* item) | 725 | void ConfigView::updateList(ConfigItem* item) |
660 | { | 726 | { |
661 | ConfigView* v; | 727 | ConfigView* v; |
662 | 728 | ||
663 | for (v = viewList; v; v = v->nextView) | 729 | for (v = viewList; v; v = v->nextView) |
664 | v->list->updateList(item); | 730 | v->list->updateList(item); |
665 | } | 731 | } |
666 | 732 | ||
667 | void ConfigView::updateListAll(void) | 733 | void ConfigView::updateListAll(void) |
668 | { | 734 | { |
669 | ConfigView* v; | 735 | ConfigView* v; |
670 | 736 | ||
671 | for (v = viewList; v; v = v->nextView) | 737 | for (v = viewList; v; v = v->nextView) |
672 | v->list->updateListAll(); | 738 | v->list->updateListAll(); |
673 | } | 739 | } |
674 | 740 | ||
675 | /* | 741 | /* |
676 | * Construct the complete config widget | 742 | * Construct the complete config widget |
677 | */ | 743 | */ |
678 | ConfigMainWindow::ConfigMainWindow(void) | 744 | ConfigMainWindow::ConfigMainWindow(void) |
679 | { | 745 | { |
680 | ConfigView* view; | ||
681 | QMenuBar* menu; | 746 | QMenuBar* menu; |
682 | QSplitter* split1; | 747 | QSplitter* split1; |
683 | QSplitter* split2; | 748 | QSplitter* split2; |
684 | bool ok; | 749 | bool ok; |
685 | int x, y, width, height; | 750 | int x, y, width, height; |
686 | 751 | ||
687 | QWidget *d = configApp->desktop(); | 752 | QWidget *d = configApp->desktop(); |
688 | 753 | ||
689 | #if QT_VERSION >= 300 | 754 | #if QT_VERSION >= 300 |
690 | width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64); | 755 | width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64); |
691 | height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64); | 756 | height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64); |
692 | resize(width, height); | 757 | resize(width, height); |
693 | x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok); | 758 | x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok); |
694 | if (ok) | 759 | if (ok) |
695 | y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok); | 760 | y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok); |
696 | if (ok) | 761 | if (ok) |
697 | move(x, y); | 762 | move(x, y); |
698 | #else | 763 | #else |
699 | width = d->width() - 64; | 764 | width = d->width() - 64; |
700 | height = d->height() - 64; | 765 | height = d->height() - 64; |
701 | resize(width, height); | 766 | resize(width, height); |
702 | #endif | 767 | #endif |
703 | 768 | ||
704 | showDebug = false; | 769 | showDebug = false; |
705 | 770 | ||
706 | split1 = new QSplitter(this); | 771 | split1 = new QSplitter(this); |
707 | split1->setOrientation(QSplitter::Horizontal); | 772 | split1->setOrientation(QSplitter::Horizontal); |
708 | setCentralWidget(split1); | 773 | setCentralWidget(split1); |
709 | 774 | ||
710 | view = new ConfigView(split1, this); | 775 | menuView = new ConfigView(split1, this); |
711 | menuList = view->list; | 776 | menuList = menuView->list; |
712 | 777 | ||
713 | split2 = new QSplitter(split1); | 778 | split2 = new QSplitter(split1); |
714 | split2->setOrientation(QSplitter::Vertical); | 779 | split2->setOrientation(QSplitter::Vertical); |
715 | 780 | ||
716 | // create config tree | 781 | // create config tree |
717 | view = new ConfigView(split2, this); | 782 | configView = new ConfigView(split2, this); |
718 | configList = view->list; | 783 | configList = configView->list; |
719 | 784 | ||
720 | helpText = new QTextView(split2); | 785 | helpText = new QTextView(split2); |
721 | helpText->setTextFormat(Qt::RichText); | 786 | helpText->setTextFormat(Qt::RichText); |
722 | 787 | ||
723 | setTabOrder(configList, helpText); | 788 | setTabOrder(configList, helpText); |
724 | configList->setFocus(); | 789 | configList->setFocus(); |
725 | 790 | ||
726 | menu = menuBar(); | 791 | menu = menuBar(); |
727 | toolBar = new QToolBar("Tools", this); | 792 | toolBar = new QToolBar("Tools", this); |
728 | 793 | ||
729 | backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); | 794 | backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); |
730 | connect(backAction, SIGNAL(activated()), SLOT(goBack())); | 795 | connect(backAction, SIGNAL(activated()), SLOT(goBack())); |
731 | backAction->setEnabled(FALSE); | 796 | backAction->setEnabled(FALSE); |
732 | QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); | 797 | QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); |
733 | connect(quitAction, SIGNAL(activated()), SLOT(close())); | 798 | connect(quitAction, SIGNAL(activated()), SLOT(close())); |
734 | QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); | 799 | QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); |
735 | connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); | 800 | connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); |
736 | QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); | 801 | QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); |
737 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); | 802 | connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); |
738 | QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); | 803 | QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this); |
739 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); | 804 | connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); |
740 | QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); | 805 | QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this); |
741 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); | 806 | connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); |
742 | QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); | 807 | QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this); |
743 | connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); | 808 | connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); |
744 | QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); | 809 | QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); |
745 | connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); | 810 | connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); |
746 | 811 | ||
747 | QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); | 812 | QAction *showNameAction = new QAction(NULL, "Show Name", 0, this); |
748 | showNameAction->setToggleAction(TRUE); | 813 | showNameAction->setToggleAction(TRUE); |
749 | showNameAction->setOn(configList->showName); | 814 | showNameAction->setOn(configList->showName); |
750 | connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool))); | 815 | connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool))); |
751 | QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); | 816 | QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this); |
752 | showRangeAction->setToggleAction(TRUE); | 817 | showRangeAction->setToggleAction(TRUE); |
753 | showRangeAction->setOn(configList->showRange); | 818 | showRangeAction->setOn(configList->showRange); |
754 | connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool))); | 819 | connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool))); |
755 | QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); | 820 | QAction *showDataAction = new QAction(NULL, "Show Data", 0, this); |
756 | showDataAction->setToggleAction(TRUE); | 821 | showDataAction->setToggleAction(TRUE); |
757 | showDataAction->setOn(configList->showData); | 822 | showDataAction->setOn(configList->showData); |
758 | connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool))); | 823 | connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool))); |
759 | QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); | 824 | QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this); |
760 | showAllAction->setToggleAction(TRUE); | 825 | showAllAction->setToggleAction(TRUE); |
761 | showAllAction->setOn(configList->showAll); | 826 | showAllAction->setOn(configList->showAll); |
762 | connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); | 827 | connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool))); |
763 | QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); | 828 | QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this); |
764 | showDebugAction->setToggleAction(TRUE); | 829 | showDebugAction->setToggleAction(TRUE); |
765 | showDebugAction->setOn(showDebug); | 830 | showDebugAction->setOn(showDebug); |
766 | connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); | 831 | connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); |
@@ -773,431 +838,467 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
773 | // init tool bar | 838 | // init tool bar |
774 | backAction->addTo(toolBar); | 839 | backAction->addTo(toolBar); |
775 | toolBar->addSeparator(); | 840 | toolBar->addSeparator(); |
776 | loadAction->addTo(toolBar); | 841 | loadAction->addTo(toolBar); |
777 | saveAction->addTo(toolBar); | 842 | saveAction->addTo(toolBar); |
778 | toolBar->addSeparator(); | 843 | toolBar->addSeparator(); |
779 | singleViewAction->addTo(toolBar); | 844 | singleViewAction->addTo(toolBar); |
780 | splitViewAction->addTo(toolBar); | 845 | splitViewAction->addTo(toolBar); |
781 | fullViewAction->addTo(toolBar); | 846 | fullViewAction->addTo(toolBar); |
782 | 847 | ||
783 | // create config menu | 848 | // create config menu |
784 | QPopupMenu* config = new QPopupMenu(this); | 849 | QPopupMenu* config = new QPopupMenu(this); |
785 | menu->insertItem("&File", config); | 850 | menu->insertItem("&File", config); |
786 | loadAction->addTo(config); | 851 | loadAction->addTo(config); |
787 | saveAction->addTo(config); | 852 | saveAction->addTo(config); |
788 | saveAsAction->addTo(config); | 853 | saveAsAction->addTo(config); |
789 | config->insertSeparator(); | 854 | config->insertSeparator(); |
790 | quitAction->addTo(config); | 855 | quitAction->addTo(config); |
791 | 856 | ||
792 | // create options menu | 857 | // create options menu |
793 | QPopupMenu* optionMenu = new QPopupMenu(this); | 858 | QPopupMenu* optionMenu = new QPopupMenu(this); |
794 | menu->insertItem("&Option", optionMenu); | 859 | menu->insertItem("&Option", optionMenu); |
795 | showNameAction->addTo(optionMenu); | 860 | showNameAction->addTo(optionMenu); |
796 | showRangeAction->addTo(optionMenu); | 861 | showRangeAction->addTo(optionMenu); |
797 | showDataAction->addTo(optionMenu); | 862 | showDataAction->addTo(optionMenu); |
798 | optionMenu->insertSeparator(); | 863 | optionMenu->insertSeparator(); |
799 | showAllAction->addTo(optionMenu); | 864 | showAllAction->addTo(optionMenu); |
800 | showDebugAction->addTo(optionMenu); | 865 | showDebugAction->addTo(optionMenu); |
801 | 866 | ||
802 | // create help menu | 867 | // create help menu |
803 | QPopupMenu* helpMenu = new QPopupMenu(this); | 868 | QPopupMenu* helpMenu = new QPopupMenu(this); |
804 | menu->insertSeparator(); | 869 | menu->insertSeparator(); |
805 | menu->insertItem("&Help", helpMenu); | 870 | menu->insertItem("&Help", helpMenu); |
806 | showIntroAction->addTo(helpMenu); | 871 | showIntroAction->addTo(helpMenu); |
807 | showAboutAction->addTo(helpMenu); | 872 | showAboutAction->addTo(helpMenu); |
808 | 873 | ||
809 | connect(configList, SIGNAL(menuSelected(struct menu *)), | 874 | connect(configList, SIGNAL(menuSelected(struct menu *)), |
810 | SLOT(changeMenu(struct menu *))); | 875 | SLOT(changeMenu(struct menu *))); |
811 | connect(configList, SIGNAL(parentSelected()), | 876 | connect(configList, SIGNAL(parentSelected()), |
812 | SLOT(goBack())); | 877 | SLOT(goBack())); |
813 | connect(menuList, SIGNAL(menuSelected(struct menu *)), | 878 | connect(menuList, SIGNAL(menuSelected(struct menu *)), |
814 | SLOT(changeMenu(struct menu *))); | 879 | SLOT(changeMenu(struct menu *))); |
815 | 880 | ||
816 | connect(configList, SIGNAL(gotFocus(void)), | 881 | connect(configList, SIGNAL(gotFocus(void)), |
817 | SLOT(listFocusChanged(void))); | 882 | SLOT(listFocusChanged(void))); |
818 | connect(menuList, SIGNAL(gotFocus(void)), | 883 | connect(menuList, SIGNAL(gotFocus(void)), |
819 | SLOT(listFocusChanged(void))); | 884 | SLOT(listFocusChanged(void))); |
820 | 885 | ||
821 | //showFullView(); | ||
822 | showSplitView(); | 886 | showSplitView(); |
823 | } | 887 | } |
824 | 888 | ||
825 | static QString print_filter(const char *str) | 889 | static QString print_filter(const char *str) |
826 | { | 890 | { |
827 | QRegExp re("[<>&\"\\n]"); | 891 | QRegExp re("[<>&\"\\n]"); |
828 | QString res = str; | 892 | QString res = str; |
829 | for (int i = 0; (i = res.find(re, i)) >= 0;) { | 893 | for (int i = 0; (i = res.find(re, i)) >= 0;) { |
830 | switch (res[i].latin1()) { | 894 | switch (res[i].latin1()) { |
831 | case '<': | 895 | case '<': |
832 | res.replace(i, 1, "<"); | 896 | res.replace(i, 1, "<"); |
833 | i += 4; | 897 | i += 4; |
834 | break; | 898 | break; |
835 | case '>': | 899 | case '>': |
836 | res.replace(i, 1, ">"); | 900 | res.replace(i, 1, ">"); |
837 | i += 4; | 901 | i += 4; |
838 | break; | 902 | break; |
839 | case '&': | 903 | case '&': |
840 | res.replace(i, 1, "&"); | 904 | res.replace(i, 1, "&"); |
841 | i += 5; | 905 | i += 5; |
842 | break; | 906 | break; |
843 | case '"': | 907 | case '"': |
844 | res.replace(i, 1, """); | 908 | res.replace(i, 1, """); |
845 | i += 6; | 909 | i += 6; |
846 | break; | 910 | break; |
847 | case '\n': | 911 | case '\n': |
848 | res.replace(i, 1, "<br>"); | 912 | res.replace(i, 1, "<br>"); |
849 | i += 4; | 913 | i += 4; |
850 | break; | 914 | break; |
851 | } | 915 | } |
852 | } | 916 | } |
853 | return res; | 917 | return res; |
854 | } | 918 | } |
855 | 919 | ||
856 | static void expr_print_help(void *data, const char *str) | 920 | static void expr_print_help(void *data, const char *str) |
857 | { | 921 | { |
858 | ((QString*)data)->append(print_filter(str)); | 922 | ((QString*)data)->append(print_filter(str)); |
859 | } | 923 | } |
860 | 924 | ||
861 | /* | 925 | /* |
862 | * display a new help entry as soon as a new menu entry is selected | 926 | * display a new help entry as soon as a new menu entry is selected |
863 | */ | 927 | */ |
864 | void ConfigMainWindow::setHelp(QListViewItem* item) | 928 | void ConfigMainWindow::setHelp(QListViewItem* item) |
865 | { | 929 | { |
866 | struct symbol* sym; | 930 | struct symbol* sym; |
867 | struct menu* menu; | 931 | struct menu* menu = 0; |
868 | 932 | ||
869 | configList->parent()->lineEdit->hide(); | 933 | configList->parent()->lineEdit->hide(); |
870 | if (item) { | 934 | if (item) |
871 | QString head, debug, help; | ||
872 | menu = ((ConfigItem*)item)->menu; | 935 | menu = ((ConfigItem*)item)->menu; |
873 | sym = menu->sym; | 936 | if (!menu) { |
874 | if (sym) { | 937 | helpText->setText(NULL); |
875 | if (menu->prompt) { | 938 | return; |
876 | head += "<big><b>"; | 939 | } |
877 | head += print_filter(menu->prompt->text); | 940 | |
878 | head += "</b></big>"; | 941 | QString head, debug, help; |
879 | if (sym->name) { | 942 | menu = ((ConfigItem*)item)->menu; |
880 | head += " ("; | 943 | sym = menu->sym; |
881 | head += print_filter(sym->name); | 944 | if (sym) { |
882 | head += ")"; | 945 | if (menu->prompt) { |
883 | } | 946 | head += "<big><b>"; |
884 | } else if (sym->name) { | 947 | head += print_filter(menu->prompt->text); |
885 | head += "<big><b>"; | 948 | head += "</b></big>"; |
949 | if (sym->name) { | ||
950 | head += " ("; | ||
886 | head += print_filter(sym->name); | 951 | head += print_filter(sym->name); |
887 | head += "</b></big>"; | 952 | head += ")"; |
888 | } | 953 | } |
889 | head += "<br><br>"; | 954 | } else if (sym->name) { |
890 | 955 | head += "<big><b>"; | |
891 | if (showDebug) { | 956 | head += print_filter(sym->name); |
892 | debug += "type: "; | 957 | head += "</b></big>"; |
893 | debug += print_filter(sym_type_name(sym->type)); | 958 | } |
959 | head += "<br><br>"; | ||
960 | |||
961 | if (showDebug) { | ||
962 | debug += "type: "; | ||
963 | debug += print_filter(sym_type_name(sym->type)); | ||
964 | if (sym_is_choice(sym)) | ||
965 | debug += " (choice)"; | ||
966 | debug += "<br>"; | ||
967 | if (sym->rev_dep.expr) { | ||
968 | debug += "reverse dep: "; | ||
969 | expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE); | ||
894 | debug += "<br>"; | 970 | debug += "<br>"; |
895 | for (struct property *prop = sym->prop; prop; prop = prop->next) { | 971 | } |
896 | switch (prop->type) { | 972 | for (struct property *prop = sym->prop; prop; prop = prop->next) { |
897 | case P_PROMPT: | 973 | switch (prop->type) { |
898 | debug += "prompt: "; | 974 | case P_PROMPT: |
899 | debug += print_filter(prop->text); | 975 | case P_MENU: |
900 | debug += "<br>"; | 976 | debug += "prompt: "; |
901 | if (prop->visible.expr) { | 977 | debug += print_filter(prop->text); |
902 | debug += " dep: "; | 978 | debug += "<br>"; |
903 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | 979 | break; |
904 | debug += "<br>"; | 980 | case P_DEFAULT: |
905 | } | 981 | debug += "default: "; |
906 | break; | 982 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
907 | case P_DEFAULT: | 983 | debug += "<br>"; |
908 | debug += "default: "; | 984 | break; |
909 | if (sym_is_choice(sym)) | 985 | case P_CHOICE: |
910 | debug += print_filter(prop->def->name); | 986 | if (sym_is_choice(sym)) { |
911 | else { | 987 | debug += "choice: "; |
912 | sym_calc_value(prop->def); | 988 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); |
913 | debug += print_filter(sym_get_string_value(prop->def)); | ||
914 | } | ||
915 | debug += "<br>"; | ||
916 | if (prop->visible.expr) { | ||
917 | debug += " dep: "; | ||
918 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | ||
919 | debug += "<br>"; | ||
920 | } | ||
921 | break; | ||
922 | case P_CHOICE: | ||
923 | break; | ||
924 | default: | ||
925 | debug += "unknown property: "; | ||
926 | debug += prop_get_type_name(prop->type); | ||
927 | debug += "<br>"; | 989 | debug += "<br>"; |
928 | } | 990 | } |
991 | break; | ||
992 | case P_SELECT: | ||
993 | debug += "select: "; | ||
994 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
995 | debug += "<br>"; | ||
996 | break; | ||
997 | case P_RANGE: | ||
998 | debug += "range: "; | ||
999 | expr_print(prop->expr, expr_print_help, &debug, E_NONE); | ||
1000 | debug += "<br>"; | ||
1001 | break; | ||
1002 | default: | ||
1003 | debug += "unknown property: "; | ||
1004 | debug += prop_get_type_name(prop->type); | ||
1005 | debug += "<br>"; | ||
929 | } | 1006 | } |
930 | debug += "<br>"; | 1007 | if (prop->visible.expr) { |
931 | } | 1008 | debug += " dep: "; |
932 | 1009 | expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE); | |
933 | help = print_filter(sym->help); | ||
934 | } else if (menu->prompt) { | ||
935 | head += "<big><b>"; | ||
936 | head += print_filter(menu->prompt->text); | ||
937 | head += "</b></big><br><br>"; | ||
938 | if (showDebug) { | ||
939 | if (menu->prompt->visible.expr) { | ||
940 | debug += " dep: "; | ||
941 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); | ||
942 | debug += "<br>"; | 1010 | debug += "<br>"; |
943 | } | 1011 | } |
944 | } | 1012 | } |
1013 | debug += "<br>"; | ||
1014 | } | ||
1015 | |||
1016 | help = print_filter(sym->help); | ||
1017 | } else if (menu->prompt) { | ||
1018 | head += "<big><b>"; | ||
1019 | head += print_filter(menu->prompt->text); | ||
1020 | head += "</b></big><br><br>"; | ||
1021 | if (showDebug) { | ||
1022 | if (menu->prompt->visible.expr) { | ||
1023 | debug += " dep: "; | ||
1024 | expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE); | ||
1025 | debug += "<br><br>"; | ||
1026 | } | ||
945 | } | 1027 | } |
946 | helpText->setText(head + debug + help); | ||
947 | return; | ||
948 | } | 1028 | } |
949 | helpText->setText(NULL); | 1029 | if (showDebug) |
1030 | debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno); | ||
1031 | helpText->setText(head + debug + help); | ||
950 | } | 1032 | } |
951 | 1033 | ||
952 | void ConfigMainWindow::loadConfig(void) | 1034 | void ConfigMainWindow::loadConfig(void) |
953 | { | 1035 | { |
954 | QString s = QFileDialog::getOpenFileName(".config", NULL, this); | 1036 | QString s = QFileDialog::getOpenFileName(".config", NULL, this); |
955 | if (s.isNull()) | 1037 | if (s.isNull()) |
956 | return; | 1038 | return; |
957 | if (conf_read(s.latin1())) | 1039 | if (conf_read(s.latin1())) |
958 | QMessageBox::information(this, "qconf", "Unable to load configuration!"); | 1040 | QMessageBox::information(this, "qconf", "Unable to load configuration!"); |
959 | ConfigView::updateListAll(); | 1041 | ConfigView::updateListAll(); |
960 | } | 1042 | } |
961 | 1043 | ||
962 | void ConfigMainWindow::saveConfig(void) | 1044 | void ConfigMainWindow::saveConfig(void) |
963 | { | 1045 | { |
964 | if (conf_write(NULL)) | 1046 | if (conf_write(NULL)) |
965 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); | 1047 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); |
966 | } | 1048 | } |
967 | 1049 | ||
968 | void ConfigMainWindow::saveConfigAs(void) | 1050 | void ConfigMainWindow::saveConfigAs(void) |
969 | { | 1051 | { |
970 | QString s = QFileDialog::getSaveFileName(".config", NULL, this); | 1052 | QString s = QFileDialog::getSaveFileName(".config", NULL, this); |
971 | if (s.isNull()) | 1053 | if (s.isNull()) |
972 | return; | 1054 | return; |
973 | if (conf_write(s.latin1())) | 1055 | if (conf_write(s.latin1())) |
974 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); | 1056 | QMessageBox::information(this, "qconf", "Unable to save configuration!"); |
975 | } | 1057 | } |
976 | 1058 | ||
977 | void ConfigMainWindow::changeMenu(struct menu *menu) | 1059 | void ConfigMainWindow::changeMenu(struct menu *menu) |
978 | { | 1060 | { |
979 | configList->setRootMenu(menu); | 1061 | configList->setRootMenu(menu); |
980 | backAction->setEnabled(TRUE); | 1062 | backAction->setEnabled(TRUE); |
981 | } | 1063 | } |
982 | 1064 | ||
983 | void ConfigMainWindow::listFocusChanged(void) | 1065 | void ConfigMainWindow::listFocusChanged(void) |
984 | { | 1066 | { |
985 | if (menuList->hasFocus()) { | 1067 | if (menuList->hasFocus()) { |
986 | if (menuList->mode == menuMode) | 1068 | if (menuList->mode == menuMode) |
987 | configList->clearSelection(); | 1069 | configList->clearSelection(); |
988 | setHelp(menuList->selectedItem()); | 1070 | setHelp(menuList->selectedItem()); |
989 | } else if (configList->hasFocus()) { | 1071 | } else if (configList->hasFocus()) { |
990 | setHelp(configList->selectedItem()); | 1072 | setHelp(configList->selectedItem()); |
991 | } | 1073 | } |
992 | } | 1074 | } |
993 | 1075 | ||
994 | void ConfigMainWindow::goBack(void) | 1076 | void ConfigMainWindow::goBack(void) |
995 | { | 1077 | { |
996 | ConfigItem* item; | 1078 | ConfigItem* item; |
997 | 1079 | ||
998 | configList->setParentMenu(); | 1080 | configList->setParentMenu(); |
999 | if (configList->rootEntry == &rootmenu) | 1081 | if (configList->rootEntry == &rootmenu) |
1000 | backAction->setEnabled(FALSE); | 1082 | backAction->setEnabled(FALSE); |
1001 | item = (ConfigItem*)menuList->selectedItem(); | 1083 | item = (ConfigItem*)menuList->selectedItem(); |
1002 | while (item) { | 1084 | while (item) { |
1003 | if (item->menu == configList->rootEntry) { | 1085 | if (item->menu == configList->rootEntry) { |
1004 | menuList->setSelected(item, TRUE); | 1086 | menuList->setSelected(item, TRUE); |
1005 | break; | 1087 | break; |
1006 | } | 1088 | } |
1007 | item = (ConfigItem*)item->parent(); | 1089 | item = (ConfigItem*)item->parent(); |
1008 | } | 1090 | } |
1009 | } | 1091 | } |
1010 | 1092 | ||
1011 | void ConfigMainWindow::showSingleView(void) | 1093 | void ConfigMainWindow::showSingleView(void) |
1012 | { | 1094 | { |
1013 | menuList->hide(); | 1095 | menuView->hide(); |
1014 | menuList->setRootMenu(0); | 1096 | menuList->setRootMenu(0); |
1015 | configList->mode = singleMode; | 1097 | configList->mode = singleMode; |
1016 | if (configList->rootEntry == &rootmenu) | 1098 | if (configList->rootEntry == &rootmenu) |
1017 | configList->updateListAll(); | 1099 | configList->updateListAll(); |
1018 | else | 1100 | else |
1019 | configList->setRootMenu(&rootmenu); | 1101 | configList->setRootMenu(&rootmenu); |
1020 | configList->setAllOpen(TRUE); | 1102 | configList->setAllOpen(TRUE); |
1021 | configList->setFocus(); | 1103 | configList->setFocus(); |
1022 | } | 1104 | } |
1023 | 1105 | ||
1024 | void ConfigMainWindow::showSplitView(void) | 1106 | void ConfigMainWindow::showSplitView(void) |
1025 | { | 1107 | { |
1026 | configList->mode = symbolMode; | 1108 | configList->mode = symbolMode; |
1027 | if (configList->rootEntry == &rootmenu) | 1109 | if (configList->rootEntry == &rootmenu) |
1028 | configList->updateListAll(); | 1110 | configList->updateListAll(); |
1029 | else | 1111 | else |
1030 | configList->setRootMenu(&rootmenu); | 1112 | configList->setRootMenu(&rootmenu); |
1031 | configList->setAllOpen(TRUE); | 1113 | configList->setAllOpen(TRUE); |
1032 | configApp->processEvents(); | 1114 | configApp->processEvents(); |
1033 | menuList->mode = menuMode; | 1115 | menuList->mode = menuMode; |
1034 | menuList->setRootMenu(&rootmenu); | 1116 | menuList->setRootMenu(&rootmenu); |
1035 | menuList->show(); | ||
1036 | menuList->setAllOpen(TRUE); | 1117 | menuList->setAllOpen(TRUE); |
1118 | menuView->show(); | ||
1037 | menuList->setFocus(); | 1119 | menuList->setFocus(); |
1038 | } | 1120 | } |
1039 | 1121 | ||
1040 | void ConfigMainWindow::showFullView(void) | 1122 | void ConfigMainWindow::showFullView(void) |
1041 | { | 1123 | { |
1042 | menuList->hide(); | 1124 | menuView->hide(); |
1043 | menuList->setRootMenu(0); | 1125 | menuList->setRootMenu(0); |
1044 | configList->mode = fullMode; | 1126 | configList->mode = fullMode; |
1045 | if (configList->rootEntry == &rootmenu) | 1127 | if (configList->rootEntry == &rootmenu) |
1046 | configList->updateListAll(); | 1128 | configList->updateListAll(); |
1047 | else | 1129 | else |
1048 | configList->setRootMenu(&rootmenu); | 1130 | configList->setRootMenu(&rootmenu); |
1049 | configList->setAllOpen(FALSE); | 1131 | configList->setAllOpen(FALSE); |
1050 | configList->setFocus(); | 1132 | configList->setFocus(); |
1051 | } | 1133 | } |
1052 | 1134 | ||
1053 | void ConfigMainWindow::setShowAll(bool b) | 1135 | void ConfigMainWindow::setShowAll(bool b) |
1054 | { | 1136 | { |
1055 | if (configList->showAll == b) | 1137 | if (configList->showAll == b) |
1056 | return; | 1138 | return; |
1057 | configList->showAll = b; | 1139 | configList->showAll = b; |
1058 | configList->updateListAll(); | 1140 | configList->updateListAll(); |
1059 | menuList->showAll = b; | 1141 | menuList->showAll = b; |
1060 | menuList->updateListAll(); | 1142 | menuList->updateListAll(); |
1061 | } | 1143 | } |
1062 | 1144 | ||
1063 | void ConfigMainWindow::setShowDebug(bool b) | 1145 | void ConfigMainWindow::setShowDebug(bool b) |
1064 | { | 1146 | { |
1065 | if (showDebug == b) | 1147 | if (showDebug == b) |
1066 | return; | 1148 | return; |
1067 | showDebug = b; | 1149 | showDebug = b; |
1068 | } | 1150 | } |
1069 | 1151 | ||
1070 | void ConfigMainWindow::setShowName(bool b) | 1152 | void ConfigMainWindow::setShowName(bool b) |
1071 | { | 1153 | { |
1072 | if (configList->showName == b) | 1154 | if (configList->showName == b) |
1073 | return; | 1155 | return; |
1074 | configList->showName = b; | 1156 | configList->showName = b; |
1075 | configList->reinit(); | 1157 | configList->reinit(); |
1158 | menuList->showName = b; | ||
1159 | menuList->reinit(); | ||
1076 | } | 1160 | } |
1077 | 1161 | ||
1078 | void ConfigMainWindow::setShowRange(bool b) | 1162 | void ConfigMainWindow::setShowRange(bool b) |
1079 | { | 1163 | { |
1080 | if (configList->showRange == b) | 1164 | if (configList->showRange == b) |
1081 | return; | 1165 | return; |
1082 | configList->showRange = b; | 1166 | configList->showRange = b; |
1083 | configList->reinit(); | 1167 | configList->reinit(); |
1168 | menuList->showRange = b; | ||
1169 | menuList->reinit(); | ||
1084 | } | 1170 | } |
1085 | 1171 | ||
1086 | void ConfigMainWindow::setShowData(bool b) | 1172 | void ConfigMainWindow::setShowData(bool b) |
1087 | { | 1173 | { |
1088 | if (configList->showData == b) | 1174 | if (configList->showData == b) |
1089 | return; | 1175 | return; |
1090 | configList->showData = b; | 1176 | configList->showData = b; |
1091 | configList->reinit(); | 1177 | configList->reinit(); |
1178 | menuList->showData = b; | ||
1179 | menuList->reinit(); | ||
1092 | } | 1180 | } |
1093 | 1181 | ||
1094 | /* | 1182 | /* |
1095 | * ask for saving configuration before quitting | 1183 | * ask for saving configuration before quitting |
1096 | * TODO ask only when something changed | 1184 | * TODO ask only when something changed |
1097 | */ | 1185 | */ |
1098 | void ConfigMainWindow::closeEvent(QCloseEvent* e) | 1186 | void ConfigMainWindow::closeEvent(QCloseEvent* e) |
1099 | { | 1187 | { |
1100 | if (!sym_change_count) { | 1188 | if (!sym_change_count) { |
1101 | e->accept(); | 1189 | e->accept(); |
1102 | return; | 1190 | return; |
1103 | } | 1191 | } |
1104 | QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, | 1192 | QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, |
1105 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); | 1193 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); |
1106 | mb.setButtonText(QMessageBox::Yes, "&Save Changes"); | 1194 | mb.setButtonText(QMessageBox::Yes, "&Save Changes"); |
1107 | mb.setButtonText(QMessageBox::No, "&Discard Changes"); | 1195 | mb.setButtonText(QMessageBox::No, "&Discard Changes"); |
1108 | mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); | 1196 | mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); |
1109 | switch (mb.exec()) { | 1197 | switch (mb.exec()) { |
1110 | case QMessageBox::Yes: | 1198 | case QMessageBox::Yes: |
1111 | conf_write(NULL); | 1199 | conf_write(NULL); |
1112 | case QMessageBox::No: | 1200 | case QMessageBox::No: |
1113 | e->accept(); | 1201 | e->accept(); |
1114 | break; | 1202 | break; |
1115 | case QMessageBox::Cancel: | 1203 | case QMessageBox::Cancel: |
1116 | e->ignore(); | 1204 | e->ignore(); |
1117 | break; | 1205 | break; |
1118 | } | 1206 | } |
1119 | } | 1207 | } |
1120 | 1208 | ||
1121 | void ConfigMainWindow::showIntro(void) | 1209 | void ConfigMainWindow::showIntro(void) |
1122 | { | 1210 | { |
1123 | static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" | 1211 | static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n" |
1124 | "For each option, a blank box indicates the feature is disabled, a check\n" | 1212 | "For each option, a blank box indicates the feature is disabled, a check\n" |
1125 | "indicates it is enabled, and a dot indicates that it is to be compiled\n" | 1213 | "indicates it is enabled, and a dot indicates that it is to be compiled\n" |
1126 | "as a module. Clicking on the box will cycle through the three states.\n\n" | 1214 | "as a module. Clicking on the box will cycle through the three states.\n\n" |
1127 | "If you do not see an option (e.g., a device driver) that you believe\n" | 1215 | "If you do not see an option (e.g., a device driver) that you believe\n" |
1128 | "should be present, try turning on Show All Options under the Options menu.\n" | 1216 | "should be present, try turning on Show All Options under the Options menu.\n" |
1129 | "Although there is no cross reference yet to help you figure out what other\n" | 1217 | "Although there is no cross reference yet to help you figure out what other\n" |
1130 | "options must be enabled to support the option you are interested in, you can\n" | 1218 | "options must be enabled to support the option you are interested in, you can\n" |
1131 | "still view the help of a grayed-out option.\n\n" | 1219 | "still view the help of a grayed-out option.\n\n" |
1132 | "Toggling Show Debug Info under the Options menu will show the dependencies,\n" | 1220 | "Toggling Show Debug Info under the Options menu will show the dependencies,\n" |
1133 | "which you can then match by examining other options.\n\n"; | 1221 | "which you can then match by examining other options.\n\n"; |
1134 | 1222 | ||
1135 | QMessageBox::information(this, "qconf", str); | 1223 | QMessageBox::information(this, "qconf", str); |
1136 | } | 1224 | } |
1137 | 1225 | ||
1138 | void ConfigMainWindow::showAbout(void) | 1226 | void ConfigMainWindow::showAbout(void) |
1139 | { | 1227 | { |
1140 | static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" | 1228 | static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" |
1141 | "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; | 1229 | "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; |
1142 | 1230 | ||
1143 | QMessageBox::information(this, "qconf", str); | 1231 | QMessageBox::information(this, "qconf", str); |
1144 | } | 1232 | } |
1145 | 1233 | ||
1146 | void fixup_rootmenu(struct menu *menu) | 1234 | void fixup_rootmenu(struct menu *menu) |
1147 | { | 1235 | { |
1148 | struct menu *child; | 1236 | struct menu *child; |
1237 | static int menu_cnt = 0; | ||
1149 | 1238 | ||
1150 | if (!menu->prompt || menu->prompt->type != P_MENU) | 1239 | menu->flags |= MENU_ROOT; |
1151 | return; | 1240 | for (child = menu->list; child; child = child->next) { |
1152 | menu->prompt->type = P_ROOTMENU; | 1241 | if (child->prompt && child->prompt->type == P_MENU) { |
1153 | for (child = menu->list; child; child = child->next) | 1242 | menu_cnt++; |
1154 | fixup_rootmenu(child); | 1243 | fixup_rootmenu(child); |
1244 | menu_cnt--; | ||
1245 | } else if (!menu_cnt) | ||
1246 | fixup_rootmenu(child); | ||
1247 | } | ||
1248 | } | ||
1249 | |||
1250 | static const char *progname; | ||
1251 | |||
1252 | static void usage(void) | ||
1253 | { | ||
1254 | printf("%s <config>\n", progname); | ||
1255 | exit(0); | ||
1155 | } | 1256 | } |
1156 | 1257 | ||
1157 | int main(int ac, char** av) | 1258 | int main(int ac, char** av) |
1158 | { | 1259 | { |
1159 | ConfigMainWindow* v; | 1260 | ConfigMainWindow* v; |
1160 | const char *name; | 1261 | const char *name; |
1161 | 1262 | ||
1162 | #ifndef LKC_DIRECT_LINK | 1263 | #ifndef LKC_DIRECT_LINK |
1163 | kconfig_load(); | 1264 | kconfig_load(); |
1164 | #endif | 1265 | #endif |
1165 | 1266 | ||
1267 | progname = av[0]; | ||
1166 | configApp = new QApplication(ac, av); | 1268 | configApp = new QApplication(ac, av); |
1167 | #if QT_VERSION >= 300 | 1269 | #if QT_VERSION >= 300 |
1168 | configSettings = new QSettings; | 1270 | configSettings = new QSettings; |
1169 | #endif | 1271 | #endif |
1170 | if (ac > 1 && av[1][0] == '-') { | 1272 | if (ac > 1 && av[1][0] == '-') { |
1171 | switch (av[1][1]) { | 1273 | switch (av[1][1]) { |
1172 | case 'a': | ||
1173 | //showAll = 1; | ||
1174 | break; | ||
1175 | case 'h': | 1274 | case 'h': |
1176 | case '?': | 1275 | case '?': |
1177 | printf("%s <config>\n", av[0]); | 1276 | usage(); |
1178 | exit(0); | ||
1179 | } | 1277 | } |
1180 | name = av[2]; | 1278 | name = av[2]; |
1181 | } else | 1279 | } else |
1182 | name = av[1]; | 1280 | name = av[1]; |
1281 | if (!name) | ||
1282 | usage(); | ||
1283 | |||
1183 | conf_parse(name); | 1284 | conf_parse(name); |
1184 | fixup_rootmenu(&rootmenu); | 1285 | fixup_rootmenu(&rootmenu); |
1185 | conf_read(NULL); | 1286 | conf_read(NULL); |
1186 | //zconfdump(stdout); | 1287 | //zconfdump(stdout); |
1187 | 1288 | ||
1188 | v = new ConfigMainWindow(); | 1289 | v = new ConfigMainWindow(); |
1189 | 1290 | ||
1190 | //zconfdump(stdout); | 1291 | //zconfdump(stdout); |
1191 | v->show(); | 1292 | v->show(); |
1192 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); | 1293 | configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); |
1193 | configApp->exec(); | 1294 | configApp->exec(); |
1194 | 1295 | ||
1195 | #if QT_VERSION >= 300 | 1296 | #if QT_VERSION >= 300 |
1196 | configSettings->writeEntry("/kconfig/qconf/window x", v->pos().x()); | 1297 | configSettings->writeEntry("/kconfig/qconf/window x", v->pos().x()); |
1197 | configSettings->writeEntry("/kconfig/qconf/window y", v->pos().y()); | 1298 | configSettings->writeEntry("/kconfig/qconf/window y", v->pos().y()); |
1198 | configSettings->writeEntry("/kconfig/qconf/window width", v->size().width()); | 1299 | configSettings->writeEntry("/kconfig/qconf/window width", v->size().width()); |
1199 | configSettings->writeEntry("/kconfig/qconf/window height", v->size().height()); | 1300 | configSettings->writeEntry("/kconfig/qconf/window height", v->size().height()); |
1200 | delete configSettings; | 1301 | delete configSettings; |
1201 | #endif | 1302 | #endif |
1202 | return 0; | 1303 | return 0; |
1203 | } | 1304 | } |