Resolved issue #732. Tape app. Improve Database dialog.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-01-23 13:08:20 +02:00
parent 2aaffd0e0d
commit 0cc551b786
4 changed files with 87 additions and 13 deletions

View File

@ -39,6 +39,7 @@
- New internal variable RotationElArc.
- [#794] Better control over scale value.
- [#392] Improve feature: Show progress bar while opening pattern file.
- [#732] Tape app. Improve Database dialog.
# Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -68,6 +68,7 @@ DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &DialogMDataBase::UpdateChecks);
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this, &DialogMDataBase::TreeMenu);
connect(ui->lineEditSearch, &QLineEdit::textChanged, this, &DialogMDataBase::FilterMeasurements);
ReadSettings();
}
@ -105,6 +106,7 @@ DialogMDataBase::DialogMDataBase(QWidget *parent)
connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &DialogMDataBase::ShowDescription);
connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this, &DialogMDataBase::TreeMenu);
connect(ui->treeWidget, &QTreeWidget::itemActivated, this, &DialogMDataBase::ShowDescription);
connect(ui->lineEditSearch, &QLineEdit::textChanged, this, &DialogMDataBase::FilterMeasurements);
ReadSettings();
}
@ -307,19 +309,7 @@ void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
//---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::ShowDescription(QTreeWidgetItem *item, int column)
{
if (column != 0 && column != -1)
{
ui->textEdit->clear();
return;
}
if (item == nullptr)
{
ui->textEdit->clear();
return;
}
if (item->childCount() != 0)
if ((column != 0 && column != -1) || item == nullptr || item->childCount() != 0)
{
ui->textEdit->clear();
return;
@ -399,6 +389,31 @@ void DialogMDataBase::Recheck()
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::FilterMeasurements(const QString &search)
{
FilterGroup(groupA, search);
FilterGroup(groupB, search);
FilterGroup(groupC, search);
FilterGroup(groupD, search);
FilterGroup(groupE, search);
FilterGroup(groupF, search);
FilterGroup(groupG, search);
FilterGroup(groupH, search);
FilterGroup(groupI, search);
FilterGroup(groupJ, search);
FilterGroup(groupK, search);
FilterGroup(groupL, search);
FilterGroup(groupM, search);
FilterGroup(groupN, search);
FilterGroup(groupO, search);
FilterGroup(groupP, search);
FilterGroup(groupQ, search);
const QList<QTreeWidgetItem *> list = ui->treeWidget->selectedItems();
list.isEmpty() ? ShowDescription(nullptr, -1) : ShowDescription(list.first(), 0);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::InitDataBase(const QStringList &list)
{
@ -432,6 +447,29 @@ void DialogMDataBase::InitGroup(QTreeWidgetItem **group, const QString &groupNam
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::FilterGroup(QTreeWidgetItem *group, const QString &search)
{
SCASSERT(group != nullptr)
bool match = false;
for (int i=0; i < group->childCount(); ++i)
{
QTreeWidgetItem *childItem = group->child(i);
const bool hidden = (not childItem->isSelected()
&& not childItem->text(0).contains(search, Qt::CaseInsensitive))
|| (childItem->isSelected() && not ui->textEdit->toPlainText().contains(search, Qt::CaseInsensitive)
&& not childItem->text(0).contains(search, Qt::CaseInsensitive));
childItem->setHidden(hidden);
if (not hidden)
{
match = true;
}
}
group->setHidden(not group->text(0).contains(search, Qt::CaseInsensitive) && not match);
}
//---------------------------------------------------------------------------------------------------------------------
QTreeWidgetItem *DialogMDataBase::AddGroup(const QString &text)
{

View File

@ -62,6 +62,7 @@ private slots:
void ShowDescription(QTreeWidgetItem *item, int column);
void TreeMenu(const QPoint &pos);
void Recheck();
void FilterMeasurements(const QString &search);
private:
Q_DISABLE_COPY(DialogMDataBase)
@ -90,6 +91,7 @@ private:
void InitDataBase(const QStringList &list = QStringList());
void InitGroup(QTreeWidgetItem **group, const QString &groupName, const QStringList &mList,
const QStringList &list = QStringList());
void FilterGroup(QTreeWidgetItem *group, const QString &search);
Q_REQUIRED_RESULT QTreeWidgetItem *AddGroup(const QString &text);

View File

@ -24,8 +24,35 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelSearch">
<property name="text">
<string>Search:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditSearch">
<property name="placeholderText">
<string>Search</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -64,9 +91,15 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>Select measurement</string>
</property>
</widget>
</widget>
</item>