mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-24 03:10:52 +01:00
Modification du filtre : recherche sur plusieur mot (sepration caractere +)
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3378 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -507,6 +507,20 @@ bool ElementsPanel::matchesCurrentFilter(const QTreeWidgetItem *item) const {
|
|||||||
return(item_matches);
|
return(item_matches);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return true if \a item matches the filter, false otherwise
|
||||||
|
*/
|
||||||
|
bool ElementsPanel::matchesFilter(const QTreeWidgetItem *item, QString filter) const {
|
||||||
|
if (!item) return(false);
|
||||||
|
|
||||||
|
// no filter => we consider the item matches
|
||||||
|
if (filter.isEmpty()) return(true);
|
||||||
|
|
||||||
|
bool item_matches = item -> text(0).contains(filter, Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
return(item_matches);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reloads the following collections:
|
Reloads the following collections:
|
||||||
* common collection
|
* common collection
|
||||||
@@ -818,14 +832,38 @@ bool ElementsPanel::scrollToElement(const ElementsLocation &location) {
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Build filter list for multiple filter
|
||||||
|
*/
|
||||||
|
void ElementsPanel::buildFilterList() {
|
||||||
|
if (filter_.isEmpty()) return;
|
||||||
|
filter_list_ = filter_.split( '+' );
|
||||||
|
/*
|
||||||
|
qDebug() << "*******************";
|
||||||
|
foreach( QString filter , filter_list_ ) {
|
||||||
|
filter = filter.trimmed();
|
||||||
|
qDebug() << filter;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Apply the current filter to a given item.
|
Apply the current filter to a given item.
|
||||||
*/
|
*/
|
||||||
void ElementsPanel::applyCurrentFilter(const QList<QTreeWidgetItem *> &items) {
|
void ElementsPanel::applyCurrentFilter(const QList<QTreeWidgetItem *> &items) {
|
||||||
if (filter_.isEmpty()) return;
|
if (filter_.isEmpty()) return;
|
||||||
|
buildFilterList();
|
||||||
QList<QTreeWidgetItem *> matching_items;
|
QList<QTreeWidgetItem *> matching_items;
|
||||||
|
|
||||||
foreach (QTreeWidgetItem *item, items) {
|
foreach (QTreeWidgetItem *item, items) {
|
||||||
bool item_matches = matchesCurrentFilter(item);
|
bool item_matches = true;
|
||||||
|
|
||||||
|
foreach( QString filter , filter_list_ ) {
|
||||||
|
filter = filter.trimmed();
|
||||||
|
if ( !filter.isEmpty() ) {
|
||||||
|
item_matches &= matchesFilter(item, filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (item_matches) matching_items << item;
|
if (item_matches) matching_items << item;
|
||||||
item -> setHidden(!item_matches);
|
item -> setHidden(!item_matches);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ class ElementsPanel : public GenericPanel {
|
|||||||
void projectWasOpened(QETProject *);
|
void projectWasOpened(QETProject *);
|
||||||
void projectWasClosed(QETProject *);
|
void projectWasClosed(QETProject *);
|
||||||
bool scrollToElement(const ElementsLocation &);
|
bool scrollToElement(const ElementsLocation &);
|
||||||
|
void buildFilterList();
|
||||||
void applyCurrentFilter(const QList<QTreeWidgetItem *> &);
|
void applyCurrentFilter(const QList<QTreeWidgetItem *> &);
|
||||||
void ensureHierarchyIsVisible(const QList<QTreeWidgetItem *> &);
|
void ensureHierarchyIsVisible(const QList<QTreeWidgetItem *> &);
|
||||||
void scrollToSelectedItem();
|
void scrollToSelectedItem();
|
||||||
@@ -96,6 +97,7 @@ class ElementsPanel : public GenericPanel {
|
|||||||
void startElementDrag(const ElementsLocation &);
|
void startElementDrag(const ElementsLocation &);
|
||||||
void startTitleBlockTemplateDrag(const TitleBlockTemplateLocation &);
|
void startTitleBlockTemplateDrag(const TitleBlockTemplateLocation &);
|
||||||
bool matchesCurrentFilter(const QTreeWidgetItem *) const;
|
bool matchesCurrentFilter(const QTreeWidgetItem *) const;
|
||||||
|
bool matchesFilter(const QTreeWidgetItem *, QString) const;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void firstActivation();
|
void firstActivation();
|
||||||
@@ -121,6 +123,7 @@ class ElementsPanel : public GenericPanel {
|
|||||||
int loading_progress_; ///< used to track the loading progress of elements collections
|
int loading_progress_; ///< used to track the loading progress of elements collections
|
||||||
bool first_reload_; ///< used to distinguish the first time this panel is reloaded
|
bool first_reload_; ///< used to distinguish the first time this panel is reloaded
|
||||||
QString filter_; ///< Currently applied filter
|
QString filter_; ///< Currently applied filter
|
||||||
|
QStringList filter_list_; ///< Currently applied list of filter
|
||||||
QTreeWidgetItem *it_prev_, *it_;
|
QTreeWidgetItem *it_prev_, *it_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user