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

📄 qconf.cc

📁 busybox最新版的源码:学习和应用的好东东,多的不说了,大家看后再说吧
💻 CC
📖 第 1 页 / 共 3 页
字号:
/* * 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>#include <stdlib.h>#include "lkc.h"#include "qconf.h"#include "qconf.moc"#include "images.c"#ifdef _# undef _# define _ qgettext#endifstatic QApplication *configApp;static inline QString qgettext(const char* str){  return QString::fromLocal8Bit(gettext(str));}static inline QString qgettext(const QString& str){  return QString::fromLocal8Bit(gettext(str.latin1()));}ConfigSettings::ConfigSettings()	: showAll(false), showName(false), showRange(false), showData(false){}#if QT_VERSION >= 300/** * Reads the list column settings from the application settings. */void ConfigSettings::readListSettings(){	showAll = readBoolEntry("/kconfig/qconf/showAll", false);	showName = readBoolEntry("/kconfig/qconf/showName", false);	showRange = readBoolEntry("/kconfig/qconf/showRange", false);	showData = readBoolEntry("/kconfig/qconf/showData", false);}/** * Reads a list of integer values from the application settings. */QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok){	QValueList<int> result;	QStringList entryList = readListEntry(key, ok);	if (ok) {		QStringList::Iterator it;		for (it = entryList.begin(); it != entryList.end(); ++it)			result.push_back((*it).toInt());	}	return result;}/** * Writes a list of integer values to the application settings. */bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value){	QStringList stringList;	QValueList<int>::ConstIterator it;	for (it = value.begin(); it != value.end(); ++it)		stringList.push_back(QString::number(*it));	return writeEntry(key, stringList);}#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/* * 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 = QString::fromLocal8Bit(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);		}		goto set_prompt;	case P_COMMENT:		setPixmap(promptColIdx, 0);		goto set_prompt;	default:		;	}	if (!sym)		goto set_prompt;	setText(nameColIdx, QString::fromLocal8Bit(sym->name));	type = sym_get_type(sym);	switch (type) {	case S_BOOLEAN:	case S_TRISTATE:		char ch;		if (!sym_is_changable(sym) && !list->showAll) {			setPixmap(promptColIdx, 0);			setText(noColIdx, QString::null);			setText(modColIdx, QString::null);			setText(yesColIdx, QString::null);			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		int i = list->mapIdx(dataColIdx);		if (i >= 0)			setRenameEnabled(i, TRUE);#endif		setText(dataColIdx, data);		if (type == S_STRING)			prompt = QString("%1: %2").arg(prompt).arg(data);		else			prompt = QString("(%2) %1").arg(prompt).arg(data);		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);}/* * construct a menu entry */void ConfigItem::init(void){	if (menu) {		ConfigList* list = listView();		nextItem = (ConfigItem*)menu->data;		menu->data = this;		if (list->mode != fullMode)			setOpen(TRUE);		sym_calc_value(menu->sym);	}	updateMenu();}/* * destruct a menu entry */ConfigItem::~ConfigItem(void){	if (menu) {		ConfigItem** ip = (ConfigItem**)&menu->data;		for (; *ip; ip = &(*ip)->nextItem) {			if (*ip == this) {				*ip = nextItem;				break;			}		}	}}void ConfigLineEdit::show(ConfigItem* i){	item = i;	if (sym_get_string_value(item->menu->sym))		setText(QString::fromLocal8Bit(sym_get_string_value(item->menu->sym)));	else		setText(QString::null);	Parent::show();	setFocus();}void ConfigLineEdit::keyPressEvent(QKeyEvent* e){	switch (e->key()) {	case Key_Escape:		break;	case Key_Return:	case Key_Enter:		sym_set_string_value(item->menu->sym, text().latin1());		parent()->updateList(item);		break;	default:		Parent::keyPressEvent(e);		return;	}	e->accept();	parent()->list->setFocus();	hide();}ConfigList::ConfigList(ConfigView* p, ConfigMainWindow* cv, ConfigSettings* configSettings)	: Parent(p), cview(cv),	  updateAll(false),	  symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),	  choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),	  menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),	  showAll(false), showName(false), showRange(false), showData(false),	  rootEntry(0){	int i;	setSorting(-1);	setRootIsDecorated(TRUE);	disabledColorGroup = palette().active();	disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text());	inactivedColorGroup = palette().active();	inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight());	connect(this, SIGNAL(selectionChanged(void)),		SLOT(updateSelection(void)));	if (configSettings) {		showAll = configSettings->showAll;		showName = configSettings->showName;		showRange = configSettings->showRange;		showData = configSettings->showData;	}	for (i = 0; i < colNr; i++)		colMap[i] = colRevMap[i] = -1;	addColumn(promptColIdx, "Option");	reinit();}void ConfigList::reinit(void){	removeColumn(dataColIdx);	removeColumn(yesColIdx);	removeColumn(modColIdx);	removeColumn(noColIdx);	removeColumn(nameColIdx);	if (showName)		addColumn(nameColIdx, "Name");	if (showRange) {		addColumn(noColIdx, "N");		addColumn(modColIdx, "M");		addColumn(yesColIdx, "Y");	}	if (showData)		addColumn(dataColIdx, "Value");	updateListAll();}void ConfigList::updateSelection(void){	struct menu *menu;	enum prop_type type;	ConfigItem* item = (ConfigItem*)selectedItem();	if (!item)		return;	cview->setHelp(item);	menu = item->menu;	if (!menu)		return;	type = menu->prompt ? menu->prompt->type : P_UNKNOWN;	if (mode == menuMode && type == P_MENU)		emit menuSelected(menu);}void ConfigList::updateList(ConfigItem* item){	ConfigItem* last = 0;	if (!rootEntry)		goto update;	if (rootEntry != &rootmenu && (mode == singleMode ||	    (mode == symbolMode && rootEntry->parent != &rootmenu))) {		item = firstChild();		if (!item)			item = new ConfigItem(this, 0, true);		last = item;	}

⌨️ 快捷键说明

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