[qet] qet/qet: [5698] Element panel : elements can be searched by their name but also with by all their informations.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 5698
Author:   blacksun
Date:     2019-01-04 23:06:34 +0100 (Fri, 04 Jan 2019)
Log Message:
-----------
Element panel : elements can be searched by their name but also with by all their informations.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/sources/ElementsCollection/elementcollectionitem.cpp
    trunk/sources/ElementsCollection/elementscollectionwidget.cpp
    trunk/sources/ElementsCollection/elementslocation.cpp
    trunk/sources/ElementsCollection/elementslocation.h
    trunk/sources/ElementsCollection/fileelementcollectionitem.cpp
    trunk/sources/ElementsCollection/xmlprojectelementcollectionitem.cpp

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2019-01-04 15:14:46 UTC (rev 5697)
+++ trunk/ChangeLog	2019-01-04 22:06:34 UTC (rev 5698)
@@ -1,7 +1,7 @@
 ====== ChangeLog from 0.6 to 0.7 ======
 
 
-* Element editor : 
+* Element editor :
 * Element informations (manufacturer, reference etc...) can be created directly from the element editor. For that go to the widget "Element Property"
 * It is no longer required to have a text field, for save the edited element.
 * Improve the behavior with the arrow keys (depending to the current selection  (nothing / one / several).
@@ -12,7 +12,7 @@
 * Rectangle can have rounded corner.
 
 
-* Diagram editor : 
+* Diagram editor :
 * Conductors can now be drawn with two colors.
 * Improve High-DPI support on Windows and Linux plateform.
 * The code for the resize handles has been almost completely redesigned.
@@ -40,11 +40,12 @@
 * 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 : 
+* Title block editor :
 Added new title block variables %projectpath, %projectfilename, %projecttitle, previous-folio-num and next-folio-num
 "%saveddate, %savedtime, %savedfilename and %savedfilepath" they variables should be updated after file save or save as dialog is confirmed,
 before file is saved.
@@ -52,7 +53,7 @@
 
 
 * Improve for new qet_tb_generator plug-in : added the full path of the current project as
-an argument when calling the plug-in from QET if a project is open. 
+an argument when calling the plug-in from QET if a project is open.
 If not a file dialog is showed to select the QET project.
 
 
@@ -71,7 +72,7 @@
 * DXF export : add some colors for basic shapes inside dxf.
 
 
-* Bug fix : 
+* Bug fix :
 * Fix compilation warning (clang and gcc).
 
 * Fix element text item alignment work well when text rotation != 0.
@@ -110,7 +111,7 @@
 * In the panel left split the view into a several docks.
 * High-DPI support (Qt 5.6.0)
 * new python plugin to generate terminal block.
-* Windows packages are now created on a Debian operating system using cross-compilation and targeted to make executable binary files for these operating systems. 
+* Windows packages are now created on a Debian operating system using cross-compilation and targeted to make executable binary files for these operating systems.
 This technical evolution allows a significant time saving during the creation of the packages. And we can provide also in the same time Windows XP and Vista packages by cross-compil with Qt 5.7.1 environment
 * The Mac OS X executable binary files are created on a virtual environment, moved compiler to latest LLVM clan version, improved dmg packages with added Info.plist.
 * An annoying memory leak has been found and solved. Afters hours of use, some users noticed that the RAM consumption growed steadily, up to 10GB or more. This problem is now solved.
@@ -166,29 +167,29 @@
 
 
 ====== ChangeLog from 0.3 rc to 0.3 ======
-First, the collection of symbols has made a big step forward, with about 1560 new elements. 
-There are now symbols for pneumatics, hydraulics, process, solar, cold, etc. Considerable effort has been done to organize the collection in a better way. 
+First, the collection of symbols has made a big step forward, with about 1560 new elements.
+There are now symbols for pneumatics, hydraulics, process, solar, cold, etc. Considerable effort has been done to organize the collection in a better way.
 We hope that the new organisation is clearer for all. We would like to thank all the contributors who send us symbols.
 
 =====-Element Editor: =====
-Considerable work has be done to replace the manual defining zone of the symbol, aka hotspot.And fix bugs, It is now automatic. You do not have to care about it anymore. 
-Primary colors have been added for the drawing shapes. 
+Considerable work has be done to replace the manual defining zone of the symbol, aka hotspot.And fix bugs, It is now automatic. You do not have to care about it anymore.
+Primary colors have been added for the drawing shapes.
 A contextual menu (right click) has been added. So, you can now work more quickly with symbols. It is also more user-friendly.
 
 ====== ChangeLog from v0.3 rc ======
 
 =====-Element Editor: =====
-* Replacing checkboxes with lists of colors. 
+* Replacing checkboxes with lists of colors.
 * Removed the manual hotspot, it is now automatic and you do not have to worry.
 Officially Collection: a large classification work on the structure was realized. It should be clear to everyone.
 The collection is enriched with 1711 items in 286 categories (ie 1997 files)
 
 =====-Schema Editor:=====
-* Added import image, image rotation, image resizing and saving the file in the project. 
-(Double click on the image called a widget and cursor that reduce or enlarge the selected image.) 
+* Added import image, image rotation, image resizing and saving the file in the project.
+(Double click on the image called a widget and cursor that reduce or enlarge the selected image.)
 NB: Following the "edit image" entry will also be added in the right click menu.
 * F5 keyboard shortcut can recharge symbol collections.
-Some bugs have been resolved, and the translation status continues to grow. 
+Some bugs have been resolved, and the translation status continues to grow.
 
 
 ======ChangeLog from v0.3 beta ======
@@ -365,4 +366,4 @@
   * Affinage du constructeur de la classe QETApp
   * Moins d'avertissements à la compilation (testé avec gcc 4.3)
   * Moins d'inclusions non pertinentes
-  * Nettoyage du trunk : déplacement des sources dans un sous-répertoire
+  * Nettoyage du trunk : déplacement des sources dans un sous-répertoire
\ No newline at end of file

Modified: trunk/sources/ElementsCollection/elementcollectionitem.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementcollectionitem.cpp	2019-01-04 15:14:46 UTC (rev 5697)
+++ trunk/sources/ElementsCollection/elementcollectionitem.cpp	2019-01-04 22:06:34 UTC (rev 5698)
@@ -34,6 +34,7 @@
 	setText(QString());
 	setToolTip(QString());
 	setIcon(QIcon());
+	setData(QString());
 }
 
 /**

Modified: trunk/sources/ElementsCollection/elementscollectionwidget.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionwidget.cpp	2019-01-04 15:14:46 UTC (rev 5697)
+++ trunk/sources/ElementsCollection/elementscollectionwidget.cpp	2019-01-04 22:06:34 UTC (rev 5698)
@@ -624,7 +624,7 @@
 	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)

Modified: trunk/sources/ElementsCollection/elementslocation.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementslocation.cpp	2019-01-04 15:14:46 UTC (rev 5697)
+++ trunk/sources/ElementsCollection/elementslocation.cpp	2019-01-04 22:06:34 UTC (rev 5698)
@@ -682,6 +682,23 @@
 }
 
 /**
+ * @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
 */

Modified: trunk/sources/ElementsCollection/elementslocation.h
===================================================================
--- trunk/sources/ElementsCollection/elementslocation.h	2019-01-04 15:14:46 UTC (rev 5697)
+++ trunk/sources/ElementsCollection/elementslocation.h	2019-01-04 22:06:34 UTC (rev 5698)
@@ -19,6 +19,7 @@
 #define ELEMENTS_LOCATION_H
 
 #include "nameslist.h"
+#include "diagramcontext.h"
 #include <QString>
 #include <QIcon>
 
@@ -77,6 +78,7 @@
 		QIcon icon() const;
 		QString name() const;
 		QString fileName() const;
+		DiagramContext elementInformations() const;
 	
 	private:
 		QString m_collection_path;

Modified: trunk/sources/ElementsCollection/fileelementcollectionitem.cpp
===================================================================
--- trunk/sources/ElementsCollection/fileelementcollectionitem.cpp	2019-01-04 15:14:46 UTC (rev 5697)
+++ trunk/sources/ElementsCollection/fileelementcollectionitem.cpp	2019-01-04 22:06:34 UTC (rev 5698)
@@ -240,7 +240,20 @@
 	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());
 }

Modified: trunk/sources/ElementsCollection/xmlprojectelementcollectionitem.cpp
===================================================================
--- trunk/sources/ElementsCollection/xmlprojectelementcollectionitem.cpp	2019-01-04 15:14:46 UTC (rev 5697)
+++ trunk/sources/ElementsCollection/xmlprojectelementcollectionitem.cpp	2019-01-04 22:06:34 UTC (rev 5698)
@@ -189,10 +189,24 @@
 		//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());
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/