Element panel : elements can be searched by their name but also with by all their informations.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5698 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2019-01-04 22:06:34 +00:00
parent d735983c16
commit 58ef54090e
7 changed files with 66 additions and 18 deletions

View File

@@ -40,8 +40,9 @@ This commit fix it, now the search function search for every terminals of a term
* QETshapeItem rectangle can have rounded corner.
* Add in config the possibility to start the numbering of the columns of titleblocks at 0.
* Add new function Search and replace widget Crtl +F
Diagram properties, Element properties, Independent text item can be changed (and mass changed) through the search and replace widget.
* Diagram properties, Element properties, Independent text item can be changed (and mass changed) through the search and replace widget.
* Added 4 tools for edit the depth (Z value) of items.
* Element panel : elements can be searched by their name but also with by all their informations.
* Title block editor :

View File

@@ -34,6 +34,7 @@ void ElementCollectionItem::clearData()
setText(QString());
setToolTip(QString());
setIcon(QIcon());
setData(QString());
}
/**

View File

@@ -624,7 +624,7 @@ void ElementsCollectionWidget::search()
QModelIndexList match_index;
foreach (QString txt, text_list) {
match_index << m_model->match(m_showed_index.isValid() ? m_model->index(0,0,m_showed_index) : m_model->index(0,0),
Qt::DisplayRole, QVariant(txt), -1, Qt::MatchContains | Qt::MatchRecursive);
Qt::UserRole+1, QVariant(txt), -1, Qt::MatchContains | Qt::MatchRecursive);
}
foreach(QModelIndex index, match_index)

View File

@@ -681,6 +681,23 @@ QString ElementsLocation::fileName() const
else return qsl.last();
}
/**
* @brief ElementsLocation::elementInformations
* @return the element information of the element represented by this location.
* If the location is a directory, the returned diagram context is empty
*/
DiagramContext ElementsLocation::elementInformations() const
{
DiagramContext context;
if (isDirectory()) {
return context;
}
QDomElement dom = this->xml().firstChildElement("elementInformations");
context.fromXml(dom, "elementInformation");
return context;
}
/**
@param location A standard element location
@return a hash identifying this location

View File

@@ -19,6 +19,7 @@
#define ELEMENTS_LOCATION_H
#include "nameslist.h"
#include "diagramcontext.h"
#include <QString>
#include <QIcon>
@@ -77,6 +78,7 @@ class ElementsLocation
QIcon icon() const;
QString name() const;
QString fileName() const;
DiagramContext elementInformations() const;
private:
QString m_collection_path;

View File

@@ -240,8 +240,21 @@ void FileElementCollectionItem::setUpData()
if (isDir())
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled);
else
{
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
//Set the local name and all informations of the element
//in the data Qt::UserRole+1, these data will be use for search.
ElementsLocation location(collectionPath());
DiagramContext context = location.elementInformations();
QStringList search_list;
for (QString key : context.keys()) {
search_list.append(context.value(key).toString());
}
search_list.append(localName());
setData(search_list.join(" "));
}
setToolTip(collectionPath());
}

View File

@@ -189,11 +189,25 @@ void XmlProjectElementCollectionItem::setUpData()
//Setup the displayed name
localName();
if (isDir())
if (isDir()) {
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled);
}
else
{
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
//Set the local name and all informations of the element
//in the data Qt::UserRole+1, these data will be use for search.
ElementsLocation location(embeddedPath(), m_project);
DiagramContext context = location.elementInformations();
QStringList search_list;
for (QString key : context.keys()) {
search_list.append(context.value(key).toString());
}
search_list.append(localName());
setData(search_list.join(" "));
}
setToolTip(collectionPath());
}