EComboBox and StringListEdit improvments

This commit is contained in:
2021-07-06 17:36:40 +03:00
parent 3f7306cea6
commit e3a87fbb9b
9 changed files with 178 additions and 146 deletions

BIN
icons/list-edit-apply.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -231,11 +231,11 @@ void Delegate::changedFlag() {
int row = 0; int row = 0;
qulonglong val = 0; qulonglong val = 0;
QList<QModelIndex> chldr; QList<QModelIndex> chldr;
mi = p.child(row, 1); mi = model->index(row, 1, p);
while (mi.isValid()) { while (mi.isValid()) {
chldr << mi; chldr << mi;
model->setData(mi, !mi.data(Qt::UserRole + 4).toBool(), Qt::UserRole + 4); model->setData(mi, !mi.data(Qt::UserRole + 4).toBool(), Qt::UserRole + 4);
mi = p.child(++row, 1); mi =model->index(++row, 1, p);
} }
bool cc = cmi.data(Qt::UserRole + 3).toBool(); bool cc = cmi.data(Qt::UserRole + 3).toBool();
qulonglong cv = cmi.data(Qt::UserRole).toULongLong(); qulonglong cv = cmi.data(Qt::UserRole).toULongLong();
@@ -358,8 +358,8 @@ void PropertyEditor::rebuild() {
tli->setFont(0, font_b); tli->setFont(0, font_b);
setItemBackColor(tli, Qt::darkGray); setItemBackColor(tli, Qt::darkGray);
setItemForeColor(tli, Qt::white); setItemForeColor(tli, Qt::white);
tli->setFirstColumnSpanned(true);
addTopLevelItem(tli); addTopLevelItem(tli);
setFirstItemColumnSpanned(tli, true);
tli->setExpanded(true); tli->setExpanded(true);
for (int i = ps; i < pe; ++i) { for (int i = ps; i < pe; ++i) {
props << o->property(i); props << o->property(i);

View File

@@ -1,12 +1,11 @@
#include <QStandardItemModel>
#include <QApplication> #include <QApplication>
#include <QDebug>
#include <QHeaderView> #include <QHeaderView>
#include <QStandardItemModel>
#include "ecombobox.h" #include "ecombobox.h"
#include "qad_types.h" #include "qad_types.h"
class EModel: public QStandardItemModel { class QAD_WIDGETS_EXPORT EModel: public QStandardItemModel {
public: public:
EModel(QObject * parent = 0): QStandardItemModel(parent) { EModel(QObject * parent = 0): QStandardItemModel(parent) {
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
@@ -21,10 +20,12 @@ protected:
} }
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
Qt::DropActions supportedDragActions() const {return Qt::MoveAction;} Qt::DropActions supportedDragActions() const {return Qt::MoveAction;}
Qt::DropActions supportedDropActions() const {return Qt::MoveAction;}
#endif #endif
}; };
EComboBox::EComboBox(QWidget * parent): QComboBox(parent) { EComboBox::EComboBox(QWidget * parent): QComboBox(parent) {
setView(&iv); setView(&iv);
setModel(new EModel()); setModel(new EModel());
@@ -52,6 +53,7 @@ EComboBox::EComboBox(QWidget * parent): QComboBox(parent) {
header.layout()->addWidget(&filter); header.layout()->addWidget(&filter);
header.setParent(iv.header()); header.setParent(iv.header());
connect(&filter, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(&filter, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(model(), &EModel::layoutChanged, this, &EComboBox::rowsChanged);
} }

View File

@@ -52,7 +52,7 @@ private slots:
void filterChanged(const QString & text, bool first = false); void filterChanged(const QString & text, bool first = false);
signals: signals:
void rowsChanged();
}; };
#endif // ECOMBOBOX_H #endif // ECOMBOBOX_H

View File

@@ -5,7 +5,7 @@
<name>CLineEdit</name> <name>CLineEdit</name>
<message> <message>
<location filename="../clineedit.cpp" line="9"/> <location filename="../clineedit.cpp" line="9"/>
<location filename="../clineedit.cpp" line="45"/> <location filename="../clineedit.cpp" line="44"/>
<source>Clear</source> <source>Clear</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -233,8 +233,8 @@
<context> <context>
<name>EComboBox</name> <name>EComboBox</name>
<message> <message>
<location filename="../ecombobox.cpp" line="44"/> <location filename="../ecombobox.cpp" line="45"/>
<location filename="../ecombobox.cpp" line="80"/> <location filename="../ecombobox.cpp" line="82"/>
<source>Filter</source> <source>Filter</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -242,8 +242,8 @@
<context> <context>
<name>EvalSpinBox</name> <name>EvalSpinBox</name>
<message> <message>
<location filename="../evalspinbox.cpp" line="28"/> <location filename="../evalspinbox.cpp" line="34"/>
<location filename="../evalspinbox.cpp" line="93"/> <location filename="../evalspinbox.cpp" line="100"/>
<source>Clear</source> <source>Clear</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -251,32 +251,32 @@
<context> <context>
<name>MatrixEdit</name> <name>MatrixEdit</name>
<message> <message>
<location filename="../matrixedit.ui" line="33"/> <location filename="../matrixedit.ui" line="39"/>
<source>Cols:</source> <source>Cols:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="47"/> <location filename="../matrixedit.ui" line="53"/>
<source>Rows:</source> <source>Rows:</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="76"/> <location filename="../matrixedit.ui" line="82"/>
<source>Null</source> <source>Null</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="79"/> <location filename="../matrixedit.ui" line="85"/>
<source>0</source> <source>0</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="86"/> <location filename="../matrixedit.ui" line="92"/>
<source>Identity</source> <source>Identity</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="89"/> <location filename="../matrixedit.ui" line="95"/>
<source>I</source> <source>I</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -284,23 +284,24 @@
<context> <context>
<name>PathEdit</name> <name>PathEdit</name>
<message> <message>
<location filename="../qvariantedit.cpp" line="105"/> <location filename="../qvariantedit.cpp" line="112"/>
<source>All files(*)</source> <source>All files(*)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="112"/> <location filename="../qvariantedit.cpp" line="117"/>
<location filename="../qvariantedit.cpp" line="125"/> <location filename="../qvariantedit.cpp" line="129"/>
<source>Choose</source> <source>Choose</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="139"/> <location filename="../qvariantedit.cpp" line="152"/>
<source>Select directory</source> <source>Select directory</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="140"/> <location filename="../qvariantedit.cpp" line="155"/>
<location filename="../qvariantedit.cpp" line="157"/>
<source>Select file</source> <source>Select file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -378,8 +379,8 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qcodeedit.cpp" line="53"/> <location filename="../qcodeedit.cpp" line="84"/>
<location filename="../qcodeedit.cpp" line="570"/> <location filename="../qcodeedit.cpp" line="580"/>
<source>Press F1 for details</source> <source>Press F1 for details</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -525,57 +526,57 @@
<context> <context>
<name>QPIConfigWidget</name> <name>QPIConfigWidget</name>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="339"/> <location filename="../qpiconfigwidget.cpp" line="345"/>
<source>Name</source> <source>Name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="339"/> <location filename="../qpiconfigwidget.cpp" line="345"/>
<source>Value</source> <source>Value</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="339"/> <location filename="../qpiconfigwidget.cpp" line="345"/>
<source>Type</source> <source>Type</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="339"/> <location filename="../qpiconfigwidget.cpp" line="345"/>
<source>Comment</source> <source>Comment</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="354"/> <location filename="../qpiconfigwidget.cpp" line="360"/>
<source>Add item ...</source> <source>Add item ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="355"/> <location filename="../qpiconfigwidget.cpp" line="361"/>
<source>Add node ...</source> <source>Add node ...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="356"/> <location filename="../qpiconfigwidget.cpp" line="362"/>
<source>Convert to item</source> <source>Convert to item</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="357"/> <location filename="../qpiconfigwidget.cpp" line="363"/>
<source>Convert to node</source> <source>Convert to node</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="358"/> <location filename="../qpiconfigwidget.cpp" line="364"/>
<source>Remove</source> <source>Remove</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="359"/> <location filename="../qpiconfigwidget.cpp" line="365"/>
<source>Expand all</source> <source>Expand all</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="360"/> <location filename="../qpiconfigwidget.cpp" line="366"/>
<source>Collapse all</source> <source>Collapse all</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -625,7 +626,7 @@
<context> <context>
<name>QVariantEdit</name> <name>QVariantEdit</name>
<message> <message>
<location filename="../qvariantedit.cpp" line="186"/> <location filename="../qvariantedit.cpp" line="203"/>
<source>Invalid value</source> <source>Invalid value</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -655,23 +656,38 @@
</context> </context>
<context> <context>
<name>StringListEdit</name> <name>StringListEdit</name>
<message>
<location filename="../qvariantedit.cpp" line="66"/>
<source>Apply</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../qvariantedit.cpp" line="67"/> <location filename="../qvariantedit.cpp" line="67"/>
<location filename="../qvariantedit.cpp" line="86"/> <location filename="../qvariantedit.cpp" line="92"/>
<source>Add</source> <source>Add</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="68"/> <location filename="../qvariantedit.cpp" line="68"/>
<location filename="../qvariantedit.cpp" line="87"/> <location filename="../qvariantedit.cpp" line="93"/>
<source>Remove</source> <source>Remove</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="69"/> <location filename="../qvariantedit.cpp" line="69"/>
<location filename="../qvariantedit.cpp" line="88"/> <location filename="../qvariantedit.cpp" line="94"/>
<source>Clear</source> <source>Clear</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../qvariantedit.cpp" line="84"/>
<source>Clear All</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qvariantedit.cpp" line="84"/>
<source>Clear All?</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
</TS> </TS>

View File

@@ -5,7 +5,7 @@
<name>CLineEdit</name> <name>CLineEdit</name>
<message> <message>
<location filename="../clineedit.cpp" line="9"/> <location filename="../clineedit.cpp" line="9"/>
<location filename="../clineedit.cpp" line="45"/> <location filename="../clineedit.cpp" line="44"/>
<source>Clear</source> <source>Clear</source>
<translation>Сбросить</translation> <translation>Сбросить</translation>
</message> </message>
@@ -233,8 +233,8 @@
<context> <context>
<name>EComboBox</name> <name>EComboBox</name>
<message> <message>
<location filename="../ecombobox.cpp" line="44"/> <location filename="../ecombobox.cpp" line="45"/>
<location filename="../ecombobox.cpp" line="80"/> <location filename="../ecombobox.cpp" line="82"/>
<source>Filter</source> <source>Filter</source>
<translation>Фильтр</translation> <translation>Фильтр</translation>
</message> </message>
@@ -242,8 +242,8 @@
<context> <context>
<name>EvalSpinBox</name> <name>EvalSpinBox</name>
<message> <message>
<location filename="../evalspinbox.cpp" line="28"/> <location filename="../evalspinbox.cpp" line="34"/>
<location filename="../evalspinbox.cpp" line="93"/> <location filename="../evalspinbox.cpp" line="100"/>
<source>Clear</source> <source>Clear</source>
<translation>Очистить</translation> <translation>Очистить</translation>
</message> </message>
@@ -251,32 +251,32 @@
<context> <context>
<name>MatrixEdit</name> <name>MatrixEdit</name>
<message> <message>
<location filename="../matrixedit.ui" line="33"/> <location filename="../matrixedit.ui" line="39"/>
<source>Cols:</source> <source>Cols:</source>
<translation>Колонки:</translation> <translation>Колонки:</translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="47"/> <location filename="../matrixedit.ui" line="53"/>
<source>Rows:</source> <source>Rows:</source>
<translation>Строки:</translation> <translation>Строки:</translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="76"/> <location filename="../matrixedit.ui" line="82"/>
<source>Null</source> <source>Null</source>
<translation>Обнулить</translation> <translation>Обнулить</translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="79"/> <location filename="../matrixedit.ui" line="85"/>
<source>0</source> <source>0</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="86"/> <location filename="../matrixedit.ui" line="92"/>
<source>Identity</source> <source>Identity</source>
<translation>Единичная</translation> <translation>Единичная</translation>
</message> </message>
<message> <message>
<location filename="../matrixedit.ui" line="89"/> <location filename="../matrixedit.ui" line="95"/>
<source>I</source> <source>I</source>
<translation></translation> <translation></translation>
</message> </message>
@@ -284,23 +284,24 @@
<context> <context>
<name>PathEdit</name> <name>PathEdit</name>
<message> <message>
<location filename="../qvariantedit.cpp" line="105"/> <location filename="../qvariantedit.cpp" line="112"/>
<source>All files(*)</source> <source>All files(*)</source>
<translation>Все файлы(*)</translation> <translation>Все файлы(*)</translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="112"/> <location filename="../qvariantedit.cpp" line="117"/>
<location filename="../qvariantedit.cpp" line="125"/> <location filename="../qvariantedit.cpp" line="129"/>
<source>Choose</source> <source>Choose</source>
<translation>Выберите</translation> <translation>Выберите</translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="139"/> <location filename="../qvariantedit.cpp" line="152"/>
<source>Select directory</source> <source>Select directory</source>
<translation>Выберите директорию</translation> <translation>Выберите директорию</translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="140"/> <location filename="../qvariantedit.cpp" line="155"/>
<location filename="../qvariantedit.cpp" line="157"/>
<source>Select file</source> <source>Select file</source>
<translation>Выберите файл</translation> <translation>Выберите файл</translation>
</message> </message>
@@ -308,8 +309,8 @@
<context> <context>
<name>QCodeEdit</name> <name>QCodeEdit</name>
<message> <message>
<location filename="../qcodeedit.cpp" line="53"/> <location filename="../qcodeedit.cpp" line="84"/>
<location filename="../qcodeedit.cpp" line="570"/> <location filename="../qcodeedit.cpp" line="580"/>
<source>Press F1 for details</source> <source>Press F1 for details</source>
<translation>Нажмите F1 для справочной информации</translation> <translation>Нажмите F1 для справочной информации</translation>
</message> </message>
@@ -525,57 +526,57 @@
<context> <context>
<name>QPIConfigWidget</name> <name>QPIConfigWidget</name>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="339"/> <location filename="../qpiconfigwidget.cpp" line="345"/>
<source>Name</source> <source>Name</source>
<translation>Имя</translation> <translation>Имя</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="339"/> <location filename="../qpiconfigwidget.cpp" line="345"/>
<source>Value</source> <source>Value</source>
<translation>Значение</translation> <translation>Значение</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="339"/> <location filename="../qpiconfigwidget.cpp" line="345"/>
<source>Type</source> <source>Type</source>
<translation>Тип</translation> <translation>Тип</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="339"/> <location filename="../qpiconfigwidget.cpp" line="345"/>
<source>Comment</source> <source>Comment</source>
<translation>Описание</translation> <translation>Описание</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="354"/> <location filename="../qpiconfigwidget.cpp" line="360"/>
<source>Add item ...</source> <source>Add item ...</source>
<translation>Добавить поле ...</translation> <translation>Добавить поле ...</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="355"/> <location filename="../qpiconfigwidget.cpp" line="361"/>
<source>Add node ...</source> <source>Add node ...</source>
<translation>Добавить секцию ...</translation> <translation>Добавить секцию ...</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="356"/> <location filename="../qpiconfigwidget.cpp" line="362"/>
<source>Convert to item</source> <source>Convert to item</source>
<translation>Преобразовать в значение</translation> <translation>Преобразовать в значение</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="357"/> <location filename="../qpiconfigwidget.cpp" line="363"/>
<source>Convert to node</source> <source>Convert to node</source>
<translation>Преобразовать в секцию</translation> <translation>Преобразовать в секцию</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="358"/> <location filename="../qpiconfigwidget.cpp" line="364"/>
<source>Remove</source> <source>Remove</source>
<translation>Удалить</translation> <translation>Удалить</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="359"/> <location filename="../qpiconfigwidget.cpp" line="365"/>
<source>Expand all</source> <source>Expand all</source>
<translation>Свернуть все</translation> <translation>Свернуть все</translation>
</message> </message>
<message> <message>
<location filename="../qpiconfigwidget.cpp" line="360"/> <location filename="../qpiconfigwidget.cpp" line="366"/>
<source>Collapse all</source> <source>Collapse all</source>
<translation>Развернуть все</translation> <translation>Развернуть все</translation>
</message> </message>
@@ -625,7 +626,7 @@
<context> <context>
<name>QVariantEdit</name> <name>QVariantEdit</name>
<message> <message>
<location filename="../qvariantedit.cpp" line="186"/> <location filename="../qvariantedit.cpp" line="203"/>
<source>Invalid value</source> <source>Invalid value</source>
<translation>Неверное значение</translation> <translation>Неверное значение</translation>
</message> </message>
@@ -655,23 +656,38 @@
</context> </context>
<context> <context>
<name>StringListEdit</name> <name>StringListEdit</name>
<message>
<location filename="../qvariantedit.cpp" line="66"/>
<source>Apply</source>
<translation>Применить</translation>
</message>
<message> <message>
<location filename="../qvariantedit.cpp" line="67"/> <location filename="../qvariantedit.cpp" line="67"/>
<location filename="../qvariantedit.cpp" line="86"/> <location filename="../qvariantedit.cpp" line="92"/>
<source>Add</source> <source>Add</source>
<translation>Добавить</translation> <translation>Добавить</translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="68"/> <location filename="../qvariantedit.cpp" line="68"/>
<location filename="../qvariantedit.cpp" line="87"/> <location filename="../qvariantedit.cpp" line="93"/>
<source>Remove</source> <source>Remove</source>
<translation>Удалить</translation> <translation>Удалить</translation>
</message> </message>
<message> <message>
<location filename="../qvariantedit.cpp" line="69"/> <location filename="../qvariantedit.cpp" line="69"/>
<location filename="../qvariantedit.cpp" line="88"/> <location filename="../qvariantedit.cpp" line="94"/>
<source>Clear</source> <source>Clear</source>
<translation>Очистить</translation> <translation>Очистить</translation>
</message> </message>
<message>
<location filename="../qvariantedit.cpp" line="84"/>
<source>Clear All</source>
<translation>Очистить всё</translation>
</message>
<message>
<location filename="../qvariantedit.cpp" line="84"/>
<source>Clear All?</source>
<translation>Очистить всё?</translation>
</message>
</context> </context>
</TS> </TS>

View File

@@ -1,42 +1,43 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>../../icons/edit-clear-locationbar-rtl.png</file> <file>../../icons/edit-clear-locationbar-rtl.png</file>
<file>../../icons/edit-copy.png</file> <file>../../icons/edit-copy.png</file>
<file>../../icons/edit-paste.png</file> <file>../../icons/edit-paste.png</file>
<file>../../icons/edit-find.png</file> <file>../../icons/edit-find.png</file>
<file>../../icons/edit-delete.png</file> <file>../../icons/edit-delete.png</file>
<file>../../icons/edit-clear.png</file> <file>../../icons/edit-clear.png</file>
<file>../../icons/dialog-ok-apply.png</file> <file>../../icons/dialog-ok-apply.png</file>
<file>../../icons/dialog-warning.png</file> <file>../../icons/dialog-warning.png</file>
<file>../../icons/tools-wizard.png</file> <file>../../icons/tools-wizard.png</file>
<file>../../icons/go-next.png</file> <file>../../icons/go-next.png</file>
<file>../../icons/go-previous.png</file> <file>../../icons/go-previous.png</file>
<file>../../icons/item.png</file> <file>../../icons/item.png</file>
<file>../../icons/item-add.png</file> <file>../../icons/item-add.png</file>
<file>../../icons/node.png</file> <file>../../icons/node.png</file>
<file>../../icons/node-add.png</file> <file>../../icons/node-add.png</file>
<file>../../icons/list-add.png</file> <file>../../icons/list-add.png</file>
<file>../../icons/document-new.png</file> <file>../../icons/list-edit-apply.png</file>
<file>../../icons/document-edit.png</file> <file>../../icons/document-new.png</file>
<file>../../icons/document-close.png</file> <file>../../icons/document-edit.png</file>
<file>../../icons/document-save.png</file> <file>../../icons/document-close.png</file>
<file>../../icons/document-save-as.png</file> <file>../../icons/document-save.png</file>
<file>../../icons/document-save-all.png</file> <file>../../icons/document-save-as.png</file>
<file>../../icons/document-revert.png</file> <file>../../icons/document-save-all.png</file>
<file>../../icons/document-open.png</file> <file>../../icons/document-revert.png</file>
<file>../../icons/document-open-recent.png</file> <file>../../icons/document-open.png</file>
<file>../../icons/alpha.png</file> <file>../../icons/document-open-recent.png</file>
<file>../../icons/chardialog.png</file> <file>../../icons/alpha.png</file>
<file>../../icons/clineedit.png</file> <file>../../icons/chardialog.png</file>
<file>../../icons/colorbutton.png</file> <file>../../icons/clineedit.png</file>
<file>../../icons/ecombobox.png</file> <file>../../icons/colorbutton.png</file>
<file>../../icons/evalspinbox.png</file> <file>../../icons/ecombobox.png</file>
<file>../../icons/qcodeedit.png</file> <file>../../icons/evalspinbox.png</file>
<file>../../icons/qpiconsole.png</file> <file>../../icons/qcodeedit.png</file>
<file>../../icons/qvariantedit.png</file> <file>../../icons/qpiconsole.png</file>
<file>../../icons/spinslider.png</file> <file>../../icons/qvariantedit.png</file>
<file>../../icons/code-word.png</file> <file>../../icons/spinslider.png</file>
<file>../../icons/f1.png</file> <file>../../icons/code-word.png</file>
<file>../../icons/scroll_spin.png</file> <file>../../icons/f1.png</file>
</qresource> <file>../../icons/scroll_spin.png</file>
</qresource>
</RCC> </RCC>

View File

@@ -1,14 +1,7 @@
#include "qvariantedit.h" #include "qvariantedit.h"
#include <QDateTimeEdit> #include <QDateTimeEdit>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox>
StringListEdit::~StringListEdit() {
delete combo;
delete butt_add;
delete butt_del;
delete butt_clear;
}
QStringList StringListEdit::value() const { QStringList StringListEdit::value() const {
@@ -19,10 +12,15 @@ QStringList StringListEdit::value() const {
void StringListEdit::setValue(const QStringList & v) { void StringListEdit::setValue(const QStringList & v) {
int pi = combo->currentIndex();
combo->clear(); combo->clear();
if (!v.isEmpty()) { if (!v.isEmpty()) {
combo->addItems(v); combo->addItems(v);
combo->setCurrentIndex(0); if (pi < combo->count() && pi >= 0) {
combo->setCurrentIndex(pi);
} else {
combo->setCurrentIndex(0);
}
} }
} }
@@ -47,36 +45,44 @@ void StringListEdit::clear() {
} }
StringListEdit::StringListEdit(QWidget * parent): QWidget(parent), lay(QBoxLayout::LeftToRight, this) { StringListEdit::StringListEdit(QWidget * parent): QWidget(parent) {
lay = new QBoxLayout(QBoxLayout::LeftToRight);
combo = new EComboBox(this); combo = new EComboBox(this);
combo->setEditable(true); combo->setEditable(true);
combo->setLineEdit(new CLineEdit); combo->setLineEdit(new CLineEdit);
combo->setInsertPolicy(QComboBox::NoInsert); combo->setInsertPolicy(QComboBox::NoInsert);
butt_apply = new QPushButton(this);
butt_add = new QPushButton(this); butt_add = new QPushButton(this);
butt_del = new QPushButton(this); butt_del = new QPushButton(this);
butt_clear = new QPushButton(this); butt_clear = new QPushButton(this);
/*butt_add->setIconSize(QSize(16, 16)); butt_apply->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
butt_del->setIconSize(QSize(16, 16));
butt_clear->setIconSize(QSize(16, 16));*/
butt_add->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); butt_add->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
butt_del->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); butt_del->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
butt_clear->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); butt_clear->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
butt_apply->setIcon(QIcon(":/icons/list-edit-apply.png"));
butt_add->setIcon(QIcon(":/icons/list-add.png")); butt_add->setIcon(QIcon(":/icons/list-add.png"));
butt_del->setIcon(QIcon(":/icons/edit-delete.png")); butt_del->setIcon(QIcon(":/icons/list-remove.png"));
butt_clear->setIcon(QIcon(":/icons/edit-clear.png")); butt_clear->setIcon(QIcon(":/icons/edit-clear.png"));
butt_apply->setToolTip(tr("Apply"));
butt_add->setToolTip(tr("Add")); butt_add->setToolTip(tr("Add"));
butt_del->setToolTip(tr("Remove")); butt_del->setToolTip(tr("Remove"));
butt_clear->setToolTip(tr("Clear")); butt_clear->setToolTip(tr("Clear"));
lay.setContentsMargins(0, 0, 0, 0); lay->setContentsMargins(0, 0, 0, 0);
lay.setSpacing(2); lay->setSpacing(2);
lay.addWidget(combo); lay->addWidget(combo);
lay.addWidget(butt_add); lay->addWidget(butt_apply);
lay.addWidget(butt_del); lay->addWidget(butt_add);
lay.addWidget(butt_clear); lay->addWidget(butt_del);
lay->addWidget(butt_clear);
setLayout(lay);
connect(combo->lineEdit(), SIGNAL(returnPressed()), this, SLOT(editItem())); connect(combo->lineEdit(), SIGNAL(returnPressed()), this, SLOT(editItem()));
connect(combo, SIGNAL(rowsChanged()), this, SIGNAL(valueChanged()));
connect(butt_apply, SIGNAL(clicked(bool)), this, SLOT(editItem()));
connect(butt_add, SIGNAL(clicked(bool)), this, SLOT(addItem())); connect(butt_add, SIGNAL(clicked(bool)), this, SLOT(addItem()));
connect(butt_del, SIGNAL(clicked(bool)), this, SLOT(delItem())); connect(butt_del, SIGNAL(clicked(bool)), this, SLOT(delItem()));
connect(butt_clear, SIGNAL(clicked(bool)), this, SLOT(clear())); connect(butt_clear, &QPushButton::clicked, [this](){
if (QMessageBox::question(this, tr("Clear All"), tr("Clear All?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) clear();
});
} }
@@ -95,6 +101,7 @@ void StringListEdit::editItem() {
int ci = combo->currentIndex(); int ci = combo->currentIndex();
if (ci < 0) return; if (ci < 0) return;
combo->setItemText(ci, combo->currentText()); combo->setItemText(ci, combo->currentText());
emit valueChanged();
} }
@@ -104,14 +111,11 @@ PathEdit::PathEdit(QWidget * parent): QWidget(parent), lay(QBoxLayout::LeftToRig
is_dir = is_abs = is_save = false; is_dir = is_abs = is_save = false;
filter = tr("All files(*)"); filter = tr("All files(*)");
line = new CLineEdit(this); line = new CLineEdit(this);
//line->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
butt_select = new QPushButton(this); butt_select = new QPushButton(this);
//butt_select->setIconSize(QSize(16, 16));
butt_select->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); butt_select->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
butt_select->setIcon(QIcon(":/icons/document-open.png")); butt_select->setIcon(QIcon(":/icons/document-open.png"));
butt_select->setToolTip(tr("Choose") + " ..."); butt_select->setToolTip(tr("Choose") + " ...");
lay.setContentsMargins(0, 0, 0, 0); lay.setContentsMargins(0, 0, 0, 0);
//lay.setSpacing(2);
lay.addWidget(line); lay.addWidget(line);
lay.addWidget(butt_select); lay.addWidget(butt_select);
connect(line, SIGNAL(textChanged(QString)), this, SIGNAL(valueChanged())); connect(line, SIGNAL(textChanged(QString)), this, SIGNAL(valueChanged()));
@@ -188,7 +192,6 @@ QVariantEdit::~QVariantEdit() {
void QVariantEdit::resizeEvent(QResizeEvent * e) { void QVariantEdit::resizeEvent(QResizeEvent * e) {
//_resize();
QWidget::resizeEvent(e); QWidget::resizeEvent(e);
} }
@@ -275,8 +278,6 @@ void QVariantEdit::_recreate(const QVariant & new_value) {
case QMetaType::Double: case QMetaType::Double:
#endif #endif
_espin = new EvalSpinBox(this); _espin = new EvalSpinBox(this);
//_spin->setDecimals(5);
//_spin->setRange(-1E+199, 1E+199);
_cur_edit = _espin; _cur_edit = _espin;
connect(_espin, SIGNAL(valueChanged(double)), this, SLOT(_changed())); connect(_espin, SIGNAL(valueChanged(double)), this, SLOT(_changed()));
break; break;
@@ -409,10 +410,8 @@ void QVariantEdit::_recreate(const QVariant & new_value) {
} }
} }
} }
//qDebug() << _cur_edit;
if (_cur_edit) { if (_cur_edit) {
_resize(); _resize();
//_cur_edit->show();
} }
_value = new_value; _value = new_value;
} }
@@ -610,7 +609,6 @@ void QVariantEdit::_newPath() {
_value = _value.toString(); _value = _value.toString();
connect(_path, SIGNAL(valueChanged()), this, SLOT(_changed())); connect(_path, SIGNAL(valueChanged()), this, SLOT(_changed()));
_resize(); _resize();
//_cur_edit->show();
} }

View File

@@ -39,16 +39,15 @@ class QAD_WIDGETS_EXPORT StringListEdit: public QWidget
Q_OBJECT Q_OBJECT
public: public:
StringListEdit(QWidget * parent = 0); StringListEdit(QWidget * parent = 0);
~StringListEdit();
QStringList value() const; QStringList value() const;
private: private:
virtual void changeEvent(QEvent * e); virtual void changeEvent(QEvent * e);
QBoxLayout lay; QBoxLayout * lay;
EComboBox * combo; EComboBox * combo;
QPushButton * butt_add, * butt_del, * butt_clear; QPushButton * butt_apply, * butt_add, * butt_del, * butt_clear;
public slots: public slots:
void setValue(const QStringList & v); void setValue(const QStringList & v);