mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Report link widget : each content show the string of the conductor and search field filter with this string.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3529 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -21,6 +21,9 @@
|
|||||||
#include "qeticons.h"
|
#include "qeticons.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
|
#include "terminal.h"
|
||||||
|
#include "conductor.h"
|
||||||
|
#include "qet.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementSelectorWidget::ElementSelectorWidget
|
* @brief ElementSelectorWidget::ElementSelectorWidget
|
||||||
@@ -71,7 +74,8 @@ void ElementSelectorWidget::showElement(Element *elmt) {
|
|||||||
*/
|
*/
|
||||||
void ElementSelectorWidget::clear() {
|
void ElementSelectorWidget::clear() {
|
||||||
elements_list.clear();
|
elements_list.clear();
|
||||||
string_filter.clear();
|
in_filter.clear();
|
||||||
|
out_filter.clear();
|
||||||
if(showed_element) showed_element->setHighlighted(false);
|
if(showed_element) showed_element->setHighlighted(false);
|
||||||
foreach(QWidget *w, content_list) {
|
foreach(QWidget *w, content_list) {
|
||||||
ui->scroll_layout_->removeWidget(w);
|
ui->scroll_layout_->removeWidget(w);
|
||||||
@@ -116,8 +120,10 @@ void ElementSelectorWidget::buildInterface() {
|
|||||||
//label for the button
|
//label for the button
|
||||||
QString button_text;
|
QString button_text;
|
||||||
|
|
||||||
//if element is master and have label, add label to the string
|
/*
|
||||||
//Also to comment
|
* If element is master and have label,
|
||||||
|
* we add label and comment to the button text
|
||||||
|
*/
|
||||||
if (elmt->linkType() & Element::Master) {
|
if (elmt->linkType() & Element::Master) {
|
||||||
DiagramContext dc = elmt -> elementInformations();
|
DiagramContext dc = elmt -> elementInformations();
|
||||||
|
|
||||||
@@ -129,6 +135,42 @@ void ElementSelectorWidget::buildInterface() {
|
|||||||
|
|
||||||
if (!button_text.isEmpty())
|
if (!button_text.isEmpty())
|
||||||
button_text += "\n";
|
button_text += "\n";
|
||||||
|
|
||||||
|
//Add the string for filter this widget
|
||||||
|
QString filter;
|
||||||
|
foreach(QString str, elmt->elementInformations().keys()){
|
||||||
|
QString filter_str = elmt->elementInformations()[str].toString();
|
||||||
|
filter += filter_str;
|
||||||
|
out_filter << filter_str;
|
||||||
|
}
|
||||||
|
in_filter << filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If element is a folio report, have conductors docked to his terminal,
|
||||||
|
* and each conductor have the same text,
|
||||||
|
* we add this text to the button label and provide it through the filter
|
||||||
|
*/
|
||||||
|
if (elmt -> linkType() & Element::AllReport) {
|
||||||
|
//Report have one terminal, but we check it to prevent assert.
|
||||||
|
if (!elmt -> terminals().isEmpty()) {
|
||||||
|
//We must to have at least one conductor
|
||||||
|
if (!elmt -> terminals().first() -> conductors().isEmpty()) {
|
||||||
|
Conductor *cond = elmt->terminals().first()->conductors().first();
|
||||||
|
QSet <Conductor *> cdr_set = cond -> relatedPotentialConductors();
|
||||||
|
cdr_set << cond;
|
||||||
|
|
||||||
|
QStringList str_list;
|
||||||
|
foreach (Conductor* c, cdr_set)
|
||||||
|
str_list << c->properties().text;
|
||||||
|
|
||||||
|
if (QET::eachStrIsEqual(str_list)) {
|
||||||
|
button_text = tr("N\260 fil : ") + str_list.first() + "\n";
|
||||||
|
in_filter << str_list.first();
|
||||||
|
out_filter << str_list.first();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString title = elmt->diagram()->title();
|
QString title = elmt->diagram()->title();
|
||||||
@@ -137,15 +179,15 @@ void ElementSelectorWidget::buildInterface() {
|
|||||||
.arg(title)
|
.arg(title)
|
||||||
.arg(elmt->diagram() -> convertPosition(elmt -> scenePos()).toString());
|
.arg(elmt->diagram() -> convertPosition(elmt -> scenePos()).toString());
|
||||||
|
|
||||||
//Widget that contain the buttons
|
//Widget that contain the buttons
|
||||||
QWidget *widget = new QWidget(this);
|
QWidget *widget = new QWidget(this);
|
||||||
content_list << widget;
|
content_list << widget;
|
||||||
|
|
||||||
//Radio button for select element
|
//Radio button for select element
|
||||||
QRadioButton *rb = new QRadioButton(button_text , widget);
|
QRadioButton *rb = new QRadioButton(button_text , widget);
|
||||||
m_button_group -> addButton(rb);
|
m_button_group -> addButton(rb);
|
||||||
|
|
||||||
//Push button to highlight element
|
//Push button to highlight element
|
||||||
QPushButton *pb = new QPushButton(QET::Icons::ZoomDraw,"", widget);
|
QPushButton *pb = new QPushButton(QET::Icons::ZoomDraw,"", widget);
|
||||||
pb -> setToolTip(tr("Voir l'\351l\351ment"));
|
pb -> setToolTip(tr("Voir l'\351l\351ment"));
|
||||||
|
|
||||||
@@ -156,17 +198,10 @@ void ElementSelectorWidget::buildInterface() {
|
|||||||
hl -> addWidget(pb);
|
hl -> addWidget(pb);
|
||||||
ui -> scroll_layout_ -> insertWidget(map_id, widget);
|
ui -> scroll_layout_ -> insertWidget(map_id, widget);
|
||||||
|
|
||||||
//Add the string for filter this widget
|
//map the radio button signal
|
||||||
QString filter;
|
|
||||||
foreach(QString str, elmt->elementInformations().keys()){
|
|
||||||
filter += elmt->elementInformations()[str].toString();
|
|
||||||
}
|
|
||||||
string_filter << filter;
|
|
||||||
|
|
||||||
//map the radio button signal
|
|
||||||
connect(rb, SIGNAL(clicked()), sm_, SLOT(map()));
|
connect(rb, SIGNAL(clicked()), sm_, SLOT(map()));
|
||||||
sm_ -> setMapping(rb, map_id);
|
sm_ -> setMapping(rb, map_id);
|
||||||
//map the push button show diagram
|
//map the push button show diagram
|
||||||
connect(pb, SIGNAL(clicked()), sm_show_, SLOT(map()));
|
connect(pb, SIGNAL(clicked()), sm_show_, SLOT(map()));
|
||||||
sm_show_->setMapping(pb, map_id);
|
sm_show_->setMapping(pb, map_id);
|
||||||
|
|
||||||
@@ -184,19 +219,28 @@ void ElementSelectorWidget::showElementFromList(const int i) {
|
|||||||
showElement(elements_list.at(i));
|
showElement(elements_list.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ElementSelectorWidget::filter
|
||||||
|
* @return A stringlist with all available value
|
||||||
|
* to filter the content of this widget;
|
||||||
|
*/
|
||||||
|
QStringList ElementSelectorWidget::filter() const {
|
||||||
|
return out_filter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ElementSelectorWidget::filter
|
* @brief ElementSelectorWidget::filter
|
||||||
* Filter the content of the list.
|
* Filter the content of the list.
|
||||||
* Give an empty string remove all filter.
|
* Give an empty string remove all filter.
|
||||||
* @param str string to filter
|
* @param str string to filter
|
||||||
*/
|
*/
|
||||||
void ElementSelectorWidget::filter(const QString &str) {
|
void ElementSelectorWidget::filtered(const QString &str) {
|
||||||
if(str.isEmpty()) {
|
if(str.isEmpty()) {
|
||||||
foreach (QWidget *w, content_list) w->setHidden(false);
|
foreach (QWidget *w, content_list) w->setHidden(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i =0; i<string_filter.size(); i++) {
|
for (int i =0; i<in_filter.size(); i++) {
|
||||||
if (string_filter.at(i).contains(str, Qt::CaseInsensitive))
|
if (in_filter.at(i).contains(str, Qt::CaseInsensitive))
|
||||||
content_list.at(i)->setHidden(false);
|
content_list.at(i)->setHidden(false);
|
||||||
else
|
else
|
||||||
content_list.at(i)->setHidden(true);
|
content_list.at(i)->setHidden(true);
|
||||||
|
|||||||
@@ -46,14 +46,16 @@ class ElementSelectorWidget : public QWidget
|
|||||||
void clear();
|
void clear();
|
||||||
void setList(QList <Element *> elmt_list);
|
void setList(QList <Element *> elmt_list);
|
||||||
|
|
||||||
|
QStringList filter () const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void filter(const QString &str);
|
void filtered(const QString &str);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void buildInterface();
|
void buildInterface();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setSelectedElement(const int i) {selected_element = elements_list.at(i);}
|
void setSelectedElement (const int i) {selected_element = elements_list.at(i);}
|
||||||
void showElementFromList (const int i);
|
void showElementFromList (const int i);
|
||||||
|
|
||||||
|
|
||||||
@@ -64,7 +66,9 @@ class ElementSelectorWidget : public QWidget
|
|||||||
QSignalMapper *sm_, *sm_show_;
|
QSignalMapper *sm_, *sm_show_;
|
||||||
Element *selected_element, *showed_element;
|
Element *selected_element, *showed_element;
|
||||||
QList <QWidget *> content_list;
|
QList <QWidget *> content_list;
|
||||||
QStringList string_filter;
|
QStringList in_filter, //In filter is used inside this class to filter the content of this widget
|
||||||
|
out_filter; //Out filter is used to return (with the method filter) a list of
|
||||||
|
//available string to filter the content of this widget
|
||||||
QButtonGroup *m_button_group;
|
QButtonGroup *m_button_group;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -94,8 +94,7 @@ void LinkSingleElementWidget::buildInterface() {
|
|||||||
ui->button_linked->setDisabled(true) :
|
ui->button_linked->setDisabled(true) :
|
||||||
buildUnlinkButton();
|
buildUnlinkButton();
|
||||||
|
|
||||||
if(filter_ & Element::Master)
|
buildSearchField();
|
||||||
buildSearchField();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,12 +131,22 @@ void LinkSingleElementWidget::buildUnlinkButton() {
|
|||||||
* like label or information
|
* like label or information
|
||||||
*/
|
*/
|
||||||
void LinkSingleElementWidget::buildSearchField() {
|
void LinkSingleElementWidget::buildSearchField() {
|
||||||
search_field = new QLineEdit(this);
|
//If there isn't string to filter, we remove the search field
|
||||||
|
if (esw_->filter().isEmpty()) {
|
||||||
|
if (search_field) {
|
||||||
|
ui -> header_layout -> removeWidget(search_field);
|
||||||
|
delete search_field;
|
||||||
|
search_field = nullptr;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!search_field) search_field = new QLineEdit(this);
|
||||||
#if QT_VERSION >= 0x040700
|
#if QT_VERSION >= 0x040700
|
||||||
search_field -> setPlaceholderText(tr("Rechercher"));
|
search_field -> setPlaceholderText(tr("Rechercher"));
|
||||||
#endif
|
#endif
|
||||||
setUpCompleter();
|
setUpCompleter();
|
||||||
connect(search_field, SIGNAL(textChanged(QString)), esw_, SLOT(filter(QString)));
|
connect(search_field, SIGNAL(textChanged(QString)), esw_, SLOT(filtered(QString)));
|
||||||
ui->header_layout->addWidget(search_field);
|
ui->header_layout->addWidget(search_field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,21 +186,16 @@ QList <Element *> LinkSingleElementWidget::availableElements() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief LinkSingleElementWidget::setUpCompleter
|
* @brief LinkSingleElementWidget::setUpCompleter
|
||||||
* Setup the completer for the find_field
|
* Setup the completer of search_field
|
||||||
*/
|
*/
|
||||||
void LinkSingleElementWidget::setUpCompleter() {
|
void LinkSingleElementWidget::setUpCompleter() {
|
||||||
if (search_field) {
|
if (search_field) {
|
||||||
search_field->clear();
|
search_field -> clear();
|
||||||
delete search_field->completer();
|
delete search_field -> completer();
|
||||||
|
|
||||||
QStringList list;
|
QCompleter *comp = new QCompleter(esw_ -> filter(), search_field);
|
||||||
foreach (Element *elmt, availableElements())
|
comp -> setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
foreach(QString str, elmt->elementInformations().keys())
|
search_field -> setCompleter(comp);
|
||||||
list << elmt->elementInformations()[str].toString();
|
|
||||||
|
|
||||||
QCompleter *comp = new QCompleter(list, search_field);
|
|
||||||
comp->setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
search_field->setCompleter(comp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +205,7 @@ void LinkSingleElementWidget::setUpCompleter() {
|
|||||||
*/
|
*/
|
||||||
void LinkSingleElementWidget::setNewList() {
|
void LinkSingleElementWidget::setNewList() {
|
||||||
esw_->setList(availableElements());
|
esw_->setList(availableElements());
|
||||||
setUpCompleter();
|
buildSearchField();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user