@@ -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;
@@ -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;