⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qconf.cc

📁 busybox最新版的源码:学习和应用的好东东,多的不说了,大家看后再说吧
💻 CC
📖 第 1 页 / 共 3 页
字号:
	if ((mode == singleMode || (mode == symbolMode && !(rootEntry->flags & MENU_ROOT))) &&	    rootEntry->sym && rootEntry->prompt) {		item = last ? last->nextSibling() : firstChild();		if (!item)			item = new ConfigItem(this, last, rootEntry, true);		else			item->testUpdateMenu(true);		updateMenuList(item, rootEntry);		triggerUpdate();		return;	}update:	updateMenuList(this, rootEntry);	triggerUpdate();}void ConfigList::setAllOpen(bool open){	QListViewItemIterator it(this);	for (; it.current(); it++)		it.current()->setOpen(open);}void ConfigList::setValue(ConfigItem* item, tristate val){	struct symbol* sym;	int type;	tristate oldval;	sym = item->menu ? item->menu->sym : 0;	if (!sym)		return;	type = sym_get_type(sym);	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 (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;	struct menu *menu;	enum prop_type type;	if (ev->key() == Key_Escape && mode != fullMode) {		emit parentSelected();		ev->accept();		return;	}	if (!i) {		Parent::keyPressEvent(ev);		return;	}	item = (ConfigItem*)i;	switch (ev->key()) {	case Key_Return:	case Key_Enter:		if (item->goParent) {			emit parentSelected();			break;		}		menu = item->menu;		if (!menu)			break;		type = menu->prompt ? menu->prompt->type : P_UNKNOWN;		if (type == P_MENU && rootEntry != menu &&		    mode != fullMode && mode != menuMode) {			emit menuSelected(menu);			break;		}	case Key_Space:		changeValue(item);		break;	case Key_N:		setValue(item, no);		break;	case Key_M:		setValue(item, mod);		break;	case Key_Y:		setValue(item, yes);		break;	default:		Parent::keyPressEvent(ev);		return;	}	ev->accept();}void ConfigList::contentsMousePressEvent(QMouseEvent* e){	//QPoint p(contentsToViewport(e->pos()));	//printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y());	Parent::contentsMousePressEvent(e);}void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e){	QPoint p(contentsToViewport(e->pos()));	ConfigItem* item = (ConfigItem*)itemAt(p);	struct menu *menu;	enum prop_type ptype;	const QPixmap* pm;	int idx, x;	if (!item)		goto skip;	menu = item->menu;	x = header()->offset() + p.x();	idx = colRevMap[header()->sectionAt(x)];	switch (idx) {	case promptColIdx:		pm = item->pixmap(promptColIdx);		if (pm) {			int off = header()->sectionPos(0) + itemMargin() +				treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0));			if (x >= off && x < off + pm->width()) {				if (item->goParent) {					emit parentSelected();					break;				} else if (!menu)					break;				ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;				if (ptype == P_MENU && rootEntry != menu &&				    mode != fullMode && mode != menuMode)					emit menuSelected(menu);				else					changeValue(item);			}		}		break;	case noColIdx:		setValue(item, no);		break;	case modColIdx:		setValue(item, mod);		break;	case yesColIdx:		setValue(item, yes);		break;	case dataColIdx:		changeValue(item);		break;	}skip:	//printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y());	Parent::contentsMouseReleaseEvent(e);}void ConfigList::contentsMouseMoveEvent(QMouseEvent* e){	//QPoint p(contentsToViewport(e->pos()));	//printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y());	Parent::contentsMouseMoveEvent(e);}void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e){	QPoint p(contentsToViewport(e->pos()));	ConfigItem* item = (ConfigItem*)itemAt(p);	struct menu *menu;	enum prop_type ptype;	if (!item)		goto skip;	if (item->goParent) {		emit parentSelected();		goto skip;	}	menu = item->menu;	if (!menu)		goto skip;	ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;	if (ptype == P_MENU && (mode == singleMode || mode == symbolMode))		emit menuSelected(menu);	else if (menu->sym)		changeValue(item);skip:	//printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y());	Parent::contentsMouseDoubleClickEvent(e);}void ConfigList::focusInEvent(QFocusEvent *e){	Parent::focusInEvent(e);	QListViewItem* item = currentItem();	if (!item)		return;	setSelected(item, TRUE);	emit gotFocus();}ConfigView* ConfigView::viewList;ConfigView::ConfigView(QWidget* parent, ConfigMainWindow* cview,		       ConfigSettings *configSettings)	: Parent(parent){	list = new ConfigList(this, cview, configSettings);	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;	bool ok;	int x, y, width, height;	QWidget *d = configApp->desktop();	ConfigSettings* configSettings = new ConfigSettings();#if QT_VERSION >= 300	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);	showDebug = configSettings->readBoolEntry("/kconfig/qconf/showDebug", false);	// read list settings into configSettings, will be used later for ConfigList setup	configSettings->readListSettings();#else	width = d->width() - 64;	height = d->height() - 64;	resize(width, height);	showDebug = false;#endif	split1 = new QSplitter(this);	split1->setOrientation(QSplitter::Horizontal);	setCentralWidget(split1);	menuView = new ConfigView(split1, this, configSettings);	menuList = menuView->list;	split2 = new QSplitter(split1);	split2->setOrientation(QSplitter::Vertical);	// create config tree	configView = new ConfigView(split2, this, configSettings);	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()));	QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this);	  connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));	QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this);	  connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));	QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this);	  connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));	QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);	  connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));	QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);	  showNameAction->setToggleAction(TRUE);	  showNameAction->setOn(configList->showName);	  connect(showNameAction, SIGNAL(toggled(bool)), SLOT(setShowName(bool)));	QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this);	  showRangeAction->setToggleAction(TRUE);	  showRangeAction->setOn(configList->showRange);	  connect(showRangeAction, SIGNAL(toggled(bool)), SLOT(setShowRange(bool)));	QAction *showDataAction = new QAction(NULL, "Show Data", 0, this);	  showDataAction->setToggleAction(TRUE);	  showDataAction->setOn(configList->showData);	  connect(showDataAction, SIGNAL(toggled(bool)), SLOT(setShowData(bool)));	QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this);	  showAllAction->setToggleAction(TRUE);	  showAllAction->setOn(configList->showAll);	  connect(showAllAction, SIGNAL(toggled(bool)), SLOT(setShowAll(bool)));	QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);	  showDebugAction->setToggleAction(TRUE);	  showDebugAction->setOn(showDebug);	  connect(showDebugAction, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));	QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);	  connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));	QAction *showAboutAction = new QAction(NULL, "About", 0, this);	  connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));	// init tool bar	backAction->addTo(toolBar);	toolBar->addSeparator();	loadAction->addTo(toolBar);	saveAction->addTo(toolBar);	toolBar->addSeparator();	singleViewAction->addTo(toolBar);	splitViewAction->addTo(toolBar);	fullViewAction->addTo(toolBar);	// create config menu	QPopupMenu* config = new QPopupMenu(this);	menu->insertItem("&File", config);	loadAction->addTo(config);	saveAction->addTo(config);	saveAsAction->addTo(config);	config->insertSeparator();	quitAction->addTo(config);	// create options menu	QPopupMenu* optionMenu = new QPopupMenu(this);	menu->insertItem("&Option", optionMenu);	showNameAction->addTo(optionMenu);	showRangeAction->addTo(optionMenu);	showDataAction->addTo(optionMenu);	optionMenu->insertSeparator();	showAllAction->addTo(optionMenu);	showDebugAction->addTo(optionMenu);	// create help menu	QPopupMenu* helpMenu = new QPopupMenu(this);	menu->insertSeparator();	menu->insertItem("&Help", helpMenu);	showIntroAction->addTo(helpMenu);	showAboutAction->addTo(helpMenu);	connect(configList, SIGNAL(menuSelected(struct menu *)),		SLOT(changeMenu(struct menu *)));	connect(configList, SIGNAL(parentSelected()),		SLOT(goBack()));	connect(menuList, SIGNAL(menuSelected(struct menu *)),		SLOT(changeMenu(struct menu *)));	connect(configList, SIGNAL(gotFocus(void)),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -