[qet] qet/qet: [4886] Link single element widget : when link a folio report, add columns for the values : Conductor text, function, tension/protocole |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] qet/qet: [4886] Link single element widget : when link a folio report, add columns for the values : Conductor text, function, tension/protocole
- From: subversion@xxxxxxxxxxxxx
- Date: Sun, 29 Jan 2017 19:43:42 +0100
Revision: 4886
Author: blacksun
Date: 2017-01-29 19:43:42 +0100 (Sun, 29 Jan 2017)
Log Message:
-----------
Link single element widget : when link a folio report, add columns for the values : Conductor text, function, tension/protocole
Add a line edit used to filter the QTreeWidgetItem.
Modified Paths:
--------------
trunk/sources/ui/linksingleelementwidget.cpp
trunk/sources/ui/linksingleelementwidget.h
trunk/sources/ui/linksingleelementwidget.ui
Modified: trunk/sources/ui/linksingleelementwidget.cpp
===================================================================
--- trunk/sources/ui/linksingleelementwidget.cpp 2017-01-29 13:57:17 UTC (rev 4885)
+++ trunk/sources/ui/linksingleelementwidget.cpp 2017-01-29 18:43:42 UTC (rev 4886)
@@ -21,6 +21,7 @@
#include "elementprovider.h"
#include "linkelementcommand.h"
#include "diagramposition.h"
+#include "conductor.h"
#include <QTreeWidgetItem>
@@ -54,6 +55,10 @@
if(this->m_showed_element)
m_showed_element->setHighlighted(false);
});
+
+// QHeaderView *qhv = ui->m_tree_widget->header();
+// qhv->setContextMenuPolicy(Qt::CustomContextMenu);
+// connect(qhv, &QHeaderView::customContextMenuRequested, [](){qDebug() << "test";});
setElement(elmt);
}
@@ -160,7 +165,7 @@
*/
QString LinkSingleElementWidget::title() const
{
- if (m_element->linkType() == Element::AllReport)
+ if (m_element->linkType() & Element::AllReport)
return tr("Report de folio");
else
return tr("Référence croisée (esclave)");
@@ -190,29 +195,86 @@
void LinkSingleElementWidget::buildTree()
{
clearTreeWidget();
- foreach(Element *elmt, availableElements())
+ setUpHeaderLabels();
+
+ if (m_element->linkType() == Element::Slave)
{
- QStringList str_list;
- str_list << elmt->elementInformations()["label"].toString();
- str_list << elmt->elementInformations()["comment"].toString();
- if (Diagram *diag = elmt->diagram())
+ foreach(Element *elmt, availableElements())
{
- str_list << QString::number(diag->folioIndex() + 1);
- autonum::sequentialNumbers seq;
- QString F =autonum::AssignVariables::formulaToLabel(diag->border_and_titleblock.folio(), seq, diag, elmt);
- str_list << F;
- str_list << diag->convertPosition(elmt->scenePos()).toString();
- str_list << diag->title();
+ QStringList search_list;
+ QStringList str_list;
+ str_list << elmt->elementInformations()["label"].toString();
+ if (!str_list.last().isEmpty())
+ search_list << str_list.last();
+
+ str_list << elmt->elementInformations()["comment"].toString();
+ if (!str_list.last().isEmpty())
+ search_list << str_list.last();
+
+ if (Diagram *diag = elmt->diagram())
+ {
+ str_list << QString::number(diag->folioIndex() + 1);
+ autonum::sequentialNumbers seq;
+ QString F =autonum::AssignVariables::formulaToLabel(diag->border_and_titleblock.folio(), seq, diag, elmt);
+ str_list << F;
+ str_list << diag->convertPosition(elmt->scenePos()).toString();
+ str_list << diag->title();
+ }
+ else
+ {
+ qDebug() << "In method void LinkSingleElementWidget::updateUi(), provied element must have be in a diagram";
+ }
+
+ QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_tree_widget, str_list);
+ m_qtwi_elmt_hash.insert(qtwi, elmt);
+ m_qtwi_strl_hash.insert(qtwi, search_list);
}
- else
+ }
+
+ else if (m_element->linkType() & Element::AllReport)
+ {
+ foreach(Element *elmt, availableElements())
{
- qDebug() << "In method void LinkSingleElementWidget::updateUi(), provied element must have be in a diagram";
+ QStringList search_list;
+ QStringList str_list;
+
+ if (elmt->conductors().size())
+ {
+ ConductorProperties cp = elmt->conductors().first()->properties();
+ str_list << cp.text;
+ if (!str_list.last().isEmpty())
+ search_list << str_list.last();
+ str_list << cp.m_function;
+ if (!str_list.last().isEmpty())
+ search_list << str_list.last();
+ str_list << cp.m_tension_protocol;
+ if (!str_list.last().isEmpty())
+ search_list << str_list.last();
+ }
+ else
+ str_list << "" << "" << "";
+
+ if (Diagram *diag = elmt->diagram())
+ {
+ str_list << QString::number(diag->folioIndex() + 1);
+ autonum::sequentialNumbers seq;
+ QString F =autonum::AssignVariables::formulaToLabel(diag->border_and_titleblock.folio(), seq, diag, elmt);
+ str_list << F;
+ str_list << diag->convertPosition(elmt->scenePos()).toString();
+ str_list << diag->title();
+ }
+ else
+ {
+ qDebug() << "In method void LinkSingleElementWidget::updateUi(), provied element must have be in a diagram";
+ }
+
+ QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_tree_widget, str_list);
+ m_qtwi_elmt_hash.insert(qtwi, elmt);
+ m_qtwi_strl_hash.insert(qtwi, search_list);
}
- QTreeWidgetItem *qtwi = new QTreeWidgetItem(ui->m_tree_widget, str_list);
- m_qtwi_elmt_hash.insert(qtwi, elmt);
}
-
- //setUpCompleter();
+
+ setUpCompleter();
}
/**
@@ -257,26 +319,24 @@
return elmt_list;
}
-///**
-// * @brief LinkSingleElementWidget::setUpCompleter
-// * Setup the completer of search_field
-// */
-//void LinkSingleElementWidget::setUpCompleter()
-//{
-// ui->m_search_field->clear();
-// if(ui->m_search_field->completer())
-// delete ui->m_search_field->completer();
+/**
+ * @brief LinkSingleElementWidget::setUpCompleter
+ * Setup the completer of search_field
+ */
+void LinkSingleElementWidget::setUpCompleter()
+{
+ ui->m_search_field->clear();
+ if(ui->m_search_field->completer())
+ delete ui->m_search_field->completer();
-// QStringList filter;
-// foreach(QTreeWidgetItem *qtwi, m_qtwi_elmt_hash.keys())
-// {
-// filter << qtwi->data(0, Qt::DisplayRole).toString();
-// filter << qtwi->data(1, Qt::DisplayRole).toString();
-// }
-// QCompleter *c = new QCompleter(filter, ui->m_search_field);
-// c->setCaseSensitivity(Qt::CaseInsensitive);
-// ui->m_search_field->setCompleter(c);
-//}
+ QStringList search;
+ foreach(QStringList strl , m_qtwi_strl_hash.values())
+ search.append(strl);
+
+ QCompleter *c = new QCompleter(search, ui->m_search_field);
+ c->setCaseSensitivity(Qt::CaseInsensitive);
+ ui->m_search_field->setCompleter(c);
+}
/**
* @brief LinkSingleElementWidget::clearTreeWidget
@@ -297,8 +357,20 @@
delete qtwi;
m_qtwi_elmt_hash.clear();
+ m_qtwi_strl_hash.clear();
}
+void LinkSingleElementWidget::setUpHeaderLabels()
+{
+ QStringList list;
+ if (m_element->linkType() == Element::Slave)
+ list << tr("Label") << tr("Commentaire") << tr("N° de folio") << tr("Label de folio") << tr("Position") << tr("Titre de folio");
+ else if (m_element->linkType() & Element::AllReport)
+ list << tr("N° de fil") << tr("Fonction") << tr("Tension / Protocole") << tr("N° de folio") << tr("Label de folio") << tr("Position") << tr("Titre de folio");
+
+ ui->m_tree_widget->setHeaderLabels(list);
+}
+
/**
* @brief LinkSingleElementWidget::diagramWasRemovedFromProject
* * This slot is called when a diagram is removed from the parent project of edited element
@@ -364,6 +436,7 @@
ui->m_unlink_pb->hide();
ui->m_show_linked_pb->hide();
ui->m_show_this_pb->hide();
+ ui->m_search_field->show();
}
/**
@@ -376,6 +449,7 @@
ui->m_unlink_pb->show();
ui->m_show_linked_pb->show();
ui->m_show_this_pb->show();
+ ui->m_search_field->hide();
}
void LinkSingleElementWidget::on_m_unlink_pb_clicked()
@@ -450,3 +524,34 @@
{
m_show_element->trigger();
}
+
+/**
+ * @brief LinkSingleElementWidget::on_m_search_field_textEdited
+ * Search all items which match with @arg1 and shows it, other items is hidden.
+ * If @arg1 is empty, show all items.
+ * @param arg1
+ */
+void LinkSingleElementWidget::on_m_search_field_textEdited(const QString &arg1)
+{
+ //Show all items if arg1 is empty, if not hide all items
+ foreach(QTreeWidgetItem *qtwi, m_qtwi_elmt_hash.keys())
+ qtwi->setHidden(!arg1.isEmpty());
+
+ QList <QTreeWidgetItem *> qtwi_list;
+
+ foreach(QTreeWidgetItem *qtwi, m_qtwi_strl_hash.keys())
+ {
+ foreach(QString str, m_qtwi_strl_hash.value(qtwi))
+ {
+ if(str.contains(arg1, Qt::CaseInsensitive))
+ {
+ qtwi_list << qtwi;
+ continue;
+ }
+ }
+ }
+
+ //Show items which match with arg1
+ foreach(QTreeWidgetItem *qtwi, qtwi_list)
+ qtwi->setHidden(false);
+}
Modified: trunk/sources/ui/linksingleelementwidget.h
===================================================================
--- trunk/sources/ui/linksingleelementwidget.h 2017-01-29 13:57:17 UTC (rev 4885)
+++ trunk/sources/ui/linksingleelementwidget.h 2017-01-29 18:43:42 UTC (rev 4886)
@@ -60,8 +60,9 @@
private :
QList <Element *> availableElements();
-// void setUpCompleter();
+ void setUpCompleter();
void clearTreeWidget();
+ void setUpHeaderLabels();
private slots:
void diagramWasRemovedFromProject();
@@ -76,6 +77,8 @@
void on_m_show_linked_pb_clicked();
void on_m_show_this_pb_clicked();
+ void on_m_search_field_textEdited(const QString &arg1);
+
private:
Ui::LinkSingleElementWidget *ui;
@@ -83,6 +86,7 @@
Element::kind m_filter;
QHash <QTreeWidgetItem*, Element*> m_qtwi_elmt_hash;
+ QHash <QTreeWidgetItem*, QStringList> m_qtwi_strl_hash;
QTreeWidgetItem *m_qtwi_at_context_menu = nullptr,
*m_pending_qtwi = nullptr;
Modified: trunk/sources/ui/linksingleelementwidget.ui
===================================================================
--- trunk/sources/ui/linksingleelementwidget.ui 2017-01-29 13:57:17 UTC (rev 4885)
+++ trunk/sources/ui/linksingleelementwidget.ui 2017-01-29 18:43:42 UTC (rev 4886)
@@ -14,14 +14,14 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="m_label">
+ <item row="1" column="2">
+ <widget class="QPushButton" name="m_show_this_pb">
<property name="text">
- <string>Cet élément est déjà lié</string>
+ <string>Voir cet élément</string>
</property>
</widget>
</item>
- <item row="2" column="0" colspan="3">
+ <item row="3" column="0" colspan="3">
<widget class="QTreeWidget" name="m_tree_widget">
<property name="indentation">
<number>5</number>
@@ -31,40 +31,15 @@
</property>
<column>
<property name="text">
- <string>Label</string>
+ <string notr="true">1</string>
</property>
</column>
- <column>
- <property name="text">
- <string>Commentaire</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>N° de folio</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Label de folio</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Position</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Titre de folio</string>
- </property>
- </column>
</widget>
</item>
- <item row="1" column="2">
- <widget class="QPushButton" name="m_show_this_pb">
+ <item row="1" column="0">
+ <widget class="QPushButton" name="m_unlink_pb">
<property name="text">
- <string>Voir cet élément</string>
+ <string>Délier</string>
</property>
</widget>
</item>
@@ -75,13 +50,20 @@
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QPushButton" name="m_unlink_pb">
+ <item row="0" column="0">
+ <widget class="QLabel" name="m_label">
<property name="text">
- <string>Délier</string>
+ <string>Cet élément est déjà lié</string>
</property>
</widget>
</item>
+ <item row="2" column="0" colspan="3">
+ <widget class="QLineEdit" name="m_search_field">
+ <property name="placeholderText">
+ <string>Recherche</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>