diff mbox

[3/4] xconfig: allow editing of remarks for config symbols

Message ID 57715d006f612817fa5bc38146560ecd84605a05.1256767265.git.aragorn@Anduril.ringwar.org (mailing list archive)
State New, archived
Headers show

Commit Message

Bernhard Kaindl Nov. 7, 2009, 6:45 a.m. UTC
None
diff mbox

Patch

diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 00c5150..58c74a0 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -278,6 +278,54 @@  ConfigItem::~ConfigItem(void)
 	}
 }
 
+ConfigRemarkEdit::ConfigRemarkEdit(ConfigView* parent) : Parent(parent)
+{
+	connect(this, SIGNAL(lostFocus()), SLOT(hide()));
+	Parent::hide();
+}
+
+void ConfigRemarkEdit::show(ConfigItem* i)
+{
+	item = i;
+	if (item->menu->sym->remark)
+		setText(QString::fromLocal8Bit(item->menu->sym->remark));
+	else
+		setText(QString::null);
+	Parent::show();
+	setFocus();
+}
+
+void ConfigRemarkEdit::saveremark()
+{
+	if (item && item->menu && item->menu->sym) {
+		if (item->menu->sym->remark)
+			free(item->menu->sym->remark);
+		item->menu->sym->remark = strdup(text().latin1());
+		sym_set_changed(item->menu->sym);
+		sym_add_change_count(1);
+		sym_clear_all_valid();
+	}
+}
+
+void ConfigRemarkEdit::hide() {
+	saveremark();
+	Parent::hide();
+}
+
+void ConfigRemarkEdit::keyPressEvent(QKeyEvent* e)
+{
+	switch (e->key()) {
+	case Qt::Key_Escape:
+	case Qt::Key_Return:
+	case Qt::Key_Enter:
+		e->accept();
+		parent()->list->setFocus();
+		hide();
+		return;
+	}
+	Parent::keyPressEvent(e);
+}
+
 ConfigLineEdit::ConfigLineEdit(ConfigView* parent)
 	: Parent(parent)
 {
@@ -668,6 +716,10 @@  void ConfigList::keyPressEvent(QKeyEvent* ev)
 			emit menuSelected(menu);
 			break;
 		}
+	case Qt::Key_Less:
+		if (item && item->menu && item->menu->sym && !sym_is_choice(item->menu->sym))
+			parent()->remarkEdit->show(item);
+		break;
 	case Qt::Key_Space:
 		changeValue(item);
 		break;
@@ -843,6 +895,7 @@  ConfigView::ConfigView(QWidget* parent, const char *name)
 	list = new ConfigList(this, name);
 	lineEdit = new ConfigLineEdit(this);
 	lineEdit->hide();
+	remarkEdit = new ConfigRemarkEdit(this);
 
 	this->nextView = viewList;
 	viewList = this;
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index b3b5657..f8ee581 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -29,6 +29,7 @@  class ConfigView;
 class ConfigList;
 class ConfigItem;
 class ConfigLineEdit;
+class ConfigRemarkEdit;
 class ConfigMainWindow;
 
 
@@ -197,6 +198,23 @@  public:
 	bool goParent;
 };
 
+class ConfigRemarkEdit : public QLineEdit {
+	Q_OBJECT
+	typedef class QLineEdit Parent;
+public:
+	ConfigRemarkEdit(ConfigView* parent);
+	ConfigView* parent(void) const
+	{
+		return (ConfigView*)Parent::parent();
+	}
+	void keyPressEvent(QKeyEvent *e);
+	void show(ConfigItem *i);
+	void hide();
+private:
+	ConfigItem *item;
+	void saveremark();
+};
+
 class ConfigLineEdit : public QLineEdit {
 	Q_OBJECT
 	typedef class QLineEdit Parent;
@@ -239,6 +257,7 @@  signals:
 public:
 	ConfigList* list;
 	ConfigLineEdit* lineEdit;
+	ConfigRemarkEdit* remarkEdit;
 
 	static ConfigView* viewList;
 	ConfigView* nextView;