add function to sort an elements list by the positions of elements.

this function is use by:
cross ref item -> shild are always sorted
element selector widget -> list of widget are sorted.


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2931 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-03-18 12:35:36 +00:00
parent 9402541022
commit e516cc6a87
3 changed files with 34 additions and 2 deletions

View File

@@ -24,6 +24,7 @@
#include <QtDebug>
#include <ui/elementpropertieswidget.h>
#include "elementprovider.h"
#include "diagramposition.h"
/**
Constructeur pour un element sans scene ni parent
@@ -54,6 +55,8 @@ void Element::editProperty() {
}
}
/**
@return true si l'element est mis en evidence
*/
@@ -499,3 +502,23 @@ void Element::initLink(QETProject *prj) {
}
tmp_uuids_link.clear();
}
/**
* @brief comparPos
* Compare position of the two elements. Compare 3 points:
* 1 folio - 2 row - 3 line
* returns a response when a comparison is found.
* @return true if elmt1 is at lower position than elmt 2, else false
*/
bool comparPos(const Element *elmt1, const Element *elmt2) {
//Compare folio first
if (elmt1->diagram()->folioIndex() != elmt2->diagram()->folioIndex())
return elmt1->diagram()->folioIndex() < elmt2->diagram()->folioIndex();
//Compare the row in second
QString a = elmt1->diagram()->convertPosition(elmt1->scenePos()).letter();
QString b = elmt2->diagram()->convertPosition(elmt2->scenePos()).letter();
if (a != b)
return a<b;
//In last compare the line
return elmt1->pos().x() <= elmt2->pos().x();
}