-rw-r--r-- | scripts/kconfig/qconf.cc | 16 | ||||
-rw-r--r-- | scripts/kconfig/qconf.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 52419ad..0459caf 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1,153 +1,153 @@ /* * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> * Released under the terms of the GNU GPL v2.0. */ #include <qapplication.h> #include <qmainwindow.h> #include <qtoolbar.h> #include <qvbox.h> #include <qsplitter.h> #include <qlistview.h> #include <qtextview.h> #include <qlineedit.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qaction.h> #include <qheader.h> #include <qfiledialog.h> #include <qregexp.h> -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 #include <qsettings.h> #endif #include <stdlib.h> #include "lkc.h" #include "qconf.h" #include "qconf.moc" #include "images.c" static QApplication *configApp; -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 static QSettings *configSettings; #endif /* * update all the children of a menu entry * removes/adds the entries from the parent widget as necessary * * parent: either the menu list widget or a menu entry widget * menu: entry to be updated */ template <class P> void ConfigList::updateMenuList(P* parent, struct menu* menu) { struct menu* child; ConfigItem* item; ConfigItem* last; bool visible; enum prop_type type; if (!menu) { while ((item = parent->firstChild())) delete item; return; } last = parent->firstChild(); if (last && !last->goParent) last = 0; for (child = menu->list; child; child = child->next) { item = last ? last->nextSibling() : parent->firstChild(); type = child->prompt ? child->prompt->type : P_UNKNOWN; switch (mode) { case menuMode: if (!(child->flags & MENU_ROOT)) goto hide; break; case symbolMode: if (child->flags & MENU_ROOT) goto hide; break; default: break; } visible = menu_is_visible(child); if (showAll || visible) { if (!item || item->menu != child) item = new ConfigItem(parent, last, child, visible); else item->testUpdateMenu(visible); if (mode == fullMode || mode == menuMode || type != P_MENU) updateMenuList(item, child); else updateMenuList(item, 0); last = item; continue; } hide: if (item && item->menu == child) { last = parent->firstChild(); if (last == item) last = 0; else while (last->nextSibling() != item) last = last->nextSibling(); delete item; } } } -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 /* * set the new data * TODO check the value */ void ConfigItem::okRename(int col) { Parent::okRename(col); sym_set_string_value(menu->sym, text(dataColIdx).latin1()); } #endif /* * update the displayed of a menu entry */ void ConfigItem::updateMenu(void) { ConfigList* list; struct symbol* sym; struct property *prop; QString prompt; int type; tristate expr; list = listView(); if (goParent) { setPixmap(promptColIdx, list->menuBackPix); prompt = ".."; goto set_prompt; } sym = menu->sym; prop = menu->prompt; prompt = menu_get_prompt(menu); if (prop) switch (prop->type) { case P_MENU: if (list->mode == singleMode || list->mode == symbolMode) { /* a menuconfig entry is displayed differently * depending whether it's at the view root or a child. */ if (sym && list->rootEntry == menu) break; setPixmap(promptColIdx, list->menuPix); } else { if (sym) break; setPixmap(promptColIdx, 0); } @@ -170,97 +170,97 @@ void ConfigItem::updateMenu(void) char ch; if (!sym_is_changable(sym) && !list->showAll) { setPixmap(promptColIdx, 0); setText(noColIdx, 0); setText(modColIdx, 0); setText(yesColIdx, 0); break; } expr = sym_get_tristate_value(sym); switch (expr) { case yes: if (sym_is_choice_value(sym) && type == S_BOOLEAN) setPixmap(promptColIdx, list->choiceYesPix); else setPixmap(promptColIdx, list->symbolYesPix); setText(yesColIdx, "Y"); ch = 'Y'; break; case mod: setPixmap(promptColIdx, list->symbolModPix); setText(modColIdx, "M"); ch = 'M'; break; default: if (sym_is_choice_value(sym) && type == S_BOOLEAN) setPixmap(promptColIdx, list->choiceNoPix); else setPixmap(promptColIdx, list->symbolNoPix); setText(noColIdx, "N"); ch = 'N'; break; } if (expr != no) setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); if (expr != mod) setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); if (expr != yes) setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); setText(dataColIdx, QChar(ch)); break; case S_INT: case S_HEX: case S_STRING: const char* data; data = sym_get_string_value(sym); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 int i = list->mapIdx(dataColIdx); if (i >= 0) setRenameEnabled(i, TRUE); #endif setText(dataColIdx, data); if (type == S_STRING) prompt.sprintf("%s: %s", prompt.latin1(), data); else prompt.sprintf("(%s) %s", data, prompt.latin1()); break; } if (!sym_has_value(sym) && visible) prompt += " (NEW)"; set_prompt: setText(promptColIdx, prompt); } void ConfigItem::testUpdateMenu(bool v) { ConfigItem* i; visible = v; if (!menu) return; sym_calc_value(menu->sym); if (menu->flags & MENU_CHANGED) { /* the menu entry changed, so update all list items */ menu->flags &= ~MENU_CHANGED; for (i = (ConfigItem*)menu->data; i; i = i->nextItem) i->updateMenu(); } else if (listView()->updateAll) updateMenu(); } void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) { ConfigList* list = listView(); if (visible) { if (isSelected() && !list->hasFocus() && list->mode == menuMode) Parent::paintCell(p, list->inactivedColorGroup, column, width, align); else Parent::paintCell(p, cg, column, width, align); } else Parent::paintCell(p, list->disabledColorGroup, column, width, align); } @@ -445,97 +445,97 @@ void ConfigList::setValue(ConfigItem* item, tristate val) switch (type) { case S_BOOLEAN: case S_TRISTATE: oldval = sym_get_tristate_value(sym); if (!sym_set_tristate_value(sym, val)) return; if (oldval == no && item->menu->list) item->setOpen(TRUE); parent()->updateList(item); break; } } void ConfigList::changeValue(ConfigItem* item) { struct symbol* sym; struct menu* menu; int type, oldexpr, newexpr; menu = item->menu; if (!menu) return; sym = menu->sym; if (!sym) { if (item->menu->list) item->setOpen(!item->isOpen()); return; } type = sym_get_type(sym); switch (type) { case S_BOOLEAN: case S_TRISTATE: oldexpr = sym_get_tristate_value(sym); newexpr = sym_toggle_tristate_value(sym); if (item->menu->list) { if (oldexpr == newexpr) item->setOpen(!item->isOpen()); else if (oldexpr == no) item->setOpen(TRUE); } if (oldexpr != newexpr) parent()->updateList(item); break; case S_INT: case S_HEX: case S_STRING: -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (colMap[dataColIdx] >= 0) item->startRename(colMap[dataColIdx]); else #endif parent()->lineEdit->show(item); break; } } void ConfigList::setRootMenu(struct menu *menu) { enum prop_type type; if (rootEntry == menu) return; type = menu && menu->prompt ? menu->prompt->type : P_UNKNOWN; if (type != P_MENU) return; updateMenuList(this, 0); rootEntry = menu; updateListAll(); setSelected(currentItem(), hasFocus()); } void ConfigList::setParentMenu(void) { ConfigItem* item; struct menu *oldroot; oldroot = rootEntry; if (rootEntry == &rootmenu) return; setRootMenu(menu_get_parent_menu(rootEntry->parent)); QListViewItemIterator it(this); for (; (item = (ConfigItem*)it.current()); it++) { if (item->menu == oldroot) { setCurrentItem(item); ensureItemVisible(item); break; } } } void ConfigList::keyPressEvent(QKeyEvent* ev) { QListViewItem* i = currentItem(); ConfigItem* item; @@ -706,97 +706,97 @@ ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview) lineEdit = new ConfigLineEdit(this); lineEdit->hide(); this->nextView = viewList; viewList = this; } ConfigView::~ConfigView(void) { ConfigView** vp; for (vp = &viewList; *vp; vp = &(*vp)->nextView) { if (*vp == this) { *vp = nextView; break; } } } void ConfigView::updateList(ConfigItem* item) { ConfigView* v; for (v = viewList; v; v = v->nextView) v->list->updateList(item); } void ConfigView::updateListAll(void) { ConfigView* v; for (v = viewList; v; v = v->nextView) v->list->updateListAll(); } /* * Construct the complete config widget */ ConfigMainWindow::ConfigMainWindow(void) { QMenuBar* menu; QSplitter* split1; QSplitter* split2; bool ok; int x, y, width, height; QWidget *d = configApp->desktop(); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 width = configSettings->readNumEntry("/kconfig/qconf/window width", d->width() - 64); height = configSettings->readNumEntry("/kconfig/qconf/window height", d->height() - 64); resize(width, height); x = configSettings->readNumEntry("/kconfig/qconf/window x", 0, &ok); if (ok) y = configSettings->readNumEntry("/kconfig/qconf/window y", 0, &ok); if (ok) move(x, y); #else width = d->width() - 64; height = d->height() - 64; resize(width, height); #endif showDebug = false; split1 = new QSplitter(this); split1->setOrientation(QSplitter::Horizontal); setCentralWidget(split1); menuView = new ConfigView(split1, this); menuList = menuView->list; split2 = new QSplitter(split1); split2->setOrientation(QSplitter::Vertical); // create config tree configView = new ConfigView(split2, this); configList = configView->list; helpText = new QTextView(split2); helpText->setTextFormat(Qt::RichText); setTabOrder(configList, helpText); configList->setFocus(); menu = menuBar(); toolBar = new QToolBar("Tools", this); backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this); connect(backAction, SIGNAL(activated()), SLOT(goBack())); backAction->setEnabled(FALSE); QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this); connect(quitAction, SIGNAL(activated()), SLOT(close())); QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this); connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); QAction *saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this); connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); @@ -1221,84 +1221,84 @@ void ConfigMainWindow::showIntro(void) "which you can then match by examining other options.\n\n"; QMessageBox::information(this, "qconf", str); } void ConfigMainWindow::showAbout(void) { static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n" "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; QMessageBox::information(this, "qconf", str); } void fixup_rootmenu(struct menu *menu) { struct menu *child; static int menu_cnt = 0; menu->flags |= MENU_ROOT; for (child = menu->list; child; child = child->next) { if (child->prompt && child->prompt->type == P_MENU) { menu_cnt++; fixup_rootmenu(child); menu_cnt--; } else if (!menu_cnt) fixup_rootmenu(child); } } static const char *progname; static void usage(void) { printf("%s <config>\n", progname); exit(0); } int main(int ac, char** av) { ConfigMainWindow* v; const char *name; #ifndef LKC_DIRECT_LINK kconfig_load(); #endif progname = av[0]; configApp = new QApplication(ac, av); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 configSettings = new QSettings; #endif if (ac > 1 && av[1][0] == '-') { switch (av[1][1]) { case 'h': case '?': usage(); } name = av[2]; } else name = av[1]; if (!name) usage(); conf_parse(name); fixup_rootmenu(&rootmenu); conf_read(NULL); //zconfdump(stdout); v = new ConfigMainWindow(); //zconfdump(stdout); v->show(); configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); configApp->exec(); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 configSettings->writeEntry("/kconfig/qconf/window x", v->pos().x()); configSettings->writeEntry("/kconfig/qconf/window y", v->pos().y()); configSettings->writeEntry("/kconfig/qconf/window width", v->size().width()); configSettings->writeEntry("/kconfig/qconf/window height", v->size().height()); delete configSettings; #endif return 0; } diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index c548884..dee5254 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -96,97 +96,97 @@ public: if (col >= 0) { Parent::removeColumn(col); colRevMap[col] = colMap[idx] = -1; } } void setAllOpen(bool open); void setParentMenu(void); template <class P> void ConfigList::updateMenuList(P*, struct menu*); bool updateAll; QPixmap symbolYesPix, symbolModPix, symbolNoPix; QPixmap choiceYesPix, choiceNoPix; QPixmap menuPix, menuInvPix, menuBackPix, voidPix; bool showAll, showName, showRange, showData; enum listMode mode; struct menu *rootEntry; QColorGroup disabledColorGroup; QColorGroup inactivedColorGroup; private: int colMap[colNr]; int colRevMap[colNr]; }; class ConfigItem : public QListViewItem { typedef class QListViewItem Parent; public: ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v) : Parent(parent, after), menu(m), visible(v), goParent(false) { init(); } ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) : Parent(parent, after), menu(m), visible(v), goParent(false) { init(); } ConfigItem(QListView *parent, ConfigItem *after, bool v) : Parent(parent, after), menu(0), visible(v), goParent(true) { init(); } ~ConfigItem(void); void init(void); -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 void okRename(int col); #endif void updateMenu(void); void testUpdateMenu(bool v); ConfigList* listView() const { return (ConfigList*)Parent::listView(); } ConfigItem* firstChild() const { return (ConfigItem *)Parent::firstChild(); } ConfigItem* nextSibling() const { return (ConfigItem *)Parent::nextSibling(); } void setText(colIdx idx, const QString& text) { Parent::setText(listView()->mapIdx(idx), text); } QString text(colIdx idx) const { return Parent::text(listView()->mapIdx(idx)); } void setPixmap(colIdx idx, const QPixmap& pm) { Parent::setPixmap(listView()->mapIdx(idx), pm); } const QPixmap* pixmap(colIdx idx) const { return Parent::pixmap(listView()->mapIdx(idx)); } void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); ConfigItem* nextItem; struct menu *menu; bool visible; bool goParent; }; class ConfigLineEdit : public QLineEdit { Q_OBJECT typedef class QLineEdit Parent; public: ConfigLineEdit(ConfigView* parent) : Parent(parent) { } ConfigView* parent(void) const |