mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Wrap code for better readability
This commit is contained in:
@@ -402,9 +402,11 @@ ElementsLocation ElementCollectionHandler::createDir(ElementsLocation &parent, c
|
|||||||
@param location : location to copy
|
@param location : location to copy
|
||||||
@return true if import with success
|
@return true if import with success
|
||||||
*/
|
*/
|
||||||
bool ElementCollectionHandler::importFromProject(QETProject *project, ElementsLocation &location)
|
bool ElementCollectionHandler::importFromProject(QETProject *project,
|
||||||
|
ElementsLocation &location)
|
||||||
{
|
{
|
||||||
if (!(location.isElement() && location.exist() && location.isProject())) return false;
|
if (!(location.isElement() && location.exist() && location.isProject()))
|
||||||
|
return false;
|
||||||
|
|
||||||
ElementsLocation destination(location.collectionPath(false), project);
|
ElementsLocation destination(location.collectionPath(false), project);
|
||||||
if (destination.exist()) return true;
|
if (destination.exist()) return true;
|
||||||
@@ -421,14 +423,18 @@ bool ElementCollectionHandler::importFromProject(QETProject *project, ElementsLo
|
|||||||
while (!destination.exist()) {
|
while (!destination.exist()) {
|
||||||
names.append(source.fileName());
|
names.append(source.fileName());
|
||||||
source = source.parent();
|
source = source.parent();
|
||||||
destination = ElementsLocation(source.collectionPath(), project);
|
destination = ElementsLocation(source.collectionPath(),
|
||||||
|
project);
|
||||||
}
|
}
|
||||||
|
|
||||||
XmlElementCollection *collection = project->embeddedElementCollection();
|
XmlElementCollection *collection = project->embeddedElementCollection();
|
||||||
|
|
||||||
while (!names.isEmpty()) {
|
while (!names.isEmpty()) {
|
||||||
source.addToPath(names.takeLast());
|
source.addToPath(names.takeLast());
|
||||||
destination = collection->copy(source, destination, QString(), false);
|
destination = collection->copy(source,
|
||||||
|
destination,
|
||||||
|
QString(),
|
||||||
|
false);
|
||||||
|
|
||||||
if (!destination.exist())
|
if (!destination.exist())
|
||||||
return false;
|
return false;
|
||||||
@@ -445,7 +451,8 @@ bool ElementCollectionHandler::importFromProject(QETProject *project, ElementsLo
|
|||||||
@param name_list : NamesList to use
|
@param name_list : NamesList to use
|
||||||
@return return true if success
|
@return return true if success
|
||||||
*/
|
*/
|
||||||
bool ElementCollectionHandler::setNames(ElementsLocation &location, const NamesList &name_list)
|
bool ElementCollectionHandler::setNames(ElementsLocation &location,
|
||||||
|
const NamesList &name_list)
|
||||||
{
|
{
|
||||||
if ( !(location.exist() && location.isWritable()) ) {
|
if ( !(location.exist() && location.isWritable()) ) {
|
||||||
return false;
|
return false;
|
||||||
@@ -454,11 +461,13 @@ bool ElementCollectionHandler::setNames(ElementsLocation &location, const NamesL
|
|||||||
if (location.isFileSystem()) {
|
if (location.isFileSystem()) {
|
||||||
if (location.isDirectory()) {
|
if (location.isDirectory()) {
|
||||||
QDomDocument document;
|
QDomDocument document;
|
||||||
QDomElement root = document.createElement("qet-directory");
|
QDomElement root = document.createElement(
|
||||||
|
"qet-directory");
|
||||||
document.appendChild(root);
|
document.appendChild(root);
|
||||||
root.appendChild(name_list.toXml(document));
|
root.appendChild(name_list.toXml(document));
|
||||||
|
|
||||||
QString filepath = location.fileSystemPath() + "/qet_directory";
|
QString filepath = location.fileSystemPath()
|
||||||
|
+ "/qet_directory";
|
||||||
if (!QET::writeXmlFile(document, filepath)) {
|
if (!QET::writeXmlFile(document, filepath)) {
|
||||||
qDebug() << "ElementCollectionHandler::setNames : write qet-directory file failed";
|
qDebug() << "ElementCollectionHandler::setNames : write qet-directory file failed";
|
||||||
return false;
|
return false;
|
||||||
@@ -469,14 +478,18 @@ bool ElementCollectionHandler::setNames(ElementsLocation &location, const NamesL
|
|||||||
|
|
||||||
if (location.isElement()) {
|
if (location.isElement()) {
|
||||||
QDomDocument document;
|
QDomDocument document;
|
||||||
document.appendChild(document.importNode(location.xml(), true));
|
document.appendChild(document.importNode(location.xml(),
|
||||||
|
true));
|
||||||
if (document.isNull()) {
|
if (document.isNull()) {
|
||||||
qDebug() << "ElementCollectionHandler::setNames : failed to load xml document from file";
|
qDebug() << "ElementCollectionHandler::setNames : failed to load xml document from file";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement document_element = document.documentElement();
|
QDomElement document_element = document.documentElement();
|
||||||
document_element.replaceChild(name_list.toXml(document), document_element.firstChildElement("names"));
|
document_element.replaceChild(
|
||||||
|
name_list.toXml(document),
|
||||||
|
document_element
|
||||||
|
.firstChildElement("names"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -484,7 +497,8 @@ bool ElementCollectionHandler::setNames(ElementsLocation &location, const NamesL
|
|||||||
if (location.isProject()) {
|
if (location.isProject()) {
|
||||||
QDomElement element = location.xml();
|
QDomElement element = location.xml();
|
||||||
QDomDocument document = element.ownerDocument();
|
QDomDocument document = element.ownerDocument();
|
||||||
element.replaceChild(name_list.toXml(document), element.firstChildElement("names"));
|
element.replaceChild(name_list.toXml(document),
|
||||||
|
element.firstChildElement("names"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ void ElementCollectionItem::clearData()
|
|||||||
@return : The last item that exist in this hierarchy,
|
@return : The last item that exist in this hierarchy,
|
||||||
or nullptr can't find (an error was occurred, or path already exist)
|
or nullptr can't find (an error was occurred, or path already exist)
|
||||||
*/
|
*/
|
||||||
ElementCollectionItem *ElementCollectionItem::lastItemForPath(const QString &path, QString &no_found_path)
|
ElementCollectionItem *ElementCollectionItem::lastItemForPath(
|
||||||
|
const QString &path,
|
||||||
|
QString &no_found_path)
|
||||||
{
|
{
|
||||||
QStringList str_list = path.split("/");
|
QStringList str_list = path.split("/");
|
||||||
if (str_list.isEmpty()) return nullptr;
|
if (str_list.isEmpty()) return nullptr;
|
||||||
@@ -76,7 +78,8 @@ ElementCollectionItem *ElementCollectionItem::lastItemForPath(const QString &pat
|
|||||||
@param name
|
@param name
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
ElementCollectionItem *ElementCollectionItem::childWithCollectionName(const QString& name) const
|
ElementCollectionItem *ElementCollectionItem::childWithCollectionName(
|
||||||
|
const QString& name) const
|
||||||
{
|
{
|
||||||
rowCount();
|
rowCount();
|
||||||
foreach (QStandardItem *qsi, directChilds()) {
|
foreach (QStandardItem *qsi, directChilds()) {
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ QVariant ElementsCollectionModel::data(const QModelIndex &index, int role) const
|
|||||||
@param indexes
|
@param indexes
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QMimeData *ElementsCollectionModel::mimeData(const QModelIndexList &indexes) const
|
QMimeData *ElementsCollectionModel::mimeData(
|
||||||
|
const QModelIndexList &indexes) const
|
||||||
{
|
{
|
||||||
QModelIndex index = indexes.first();
|
QModelIndex index = indexes.first();
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
@@ -315,7 +316,9 @@ void ElementsCollectionModel::addCommonCollection(bool set_data)
|
|||||||
void ElementsCollectionModel::addCustomCollection(bool set_data)
|
void ElementsCollectionModel::addCustomCollection(bool set_data)
|
||||||
{
|
{
|
||||||
FileElementCollectionItem *feci = new FileElementCollectionItem();
|
FileElementCollectionItem *feci = new FileElementCollectionItem();
|
||||||
if (feci->setRootPath(QETApp::customElementsDirN(), set_data, m_hide_element)) {
|
if (feci->setRootPath(QETApp::customElementsDirN(),
|
||||||
|
set_data,
|
||||||
|
m_hide_element)) {
|
||||||
invisibleRootItem()->appendRow(feci);
|
invisibleRootItem()->appendRow(feci);
|
||||||
if (set_data)
|
if (set_data)
|
||||||
feci->setUpData();
|
feci->setUpData();
|
||||||
@@ -502,7 +505,8 @@ QList <ElementCollectionItem *> ElementsCollectionModel::items() const
|
|||||||
@param project
|
@param project
|
||||||
@return return all items for project. the list can be empty
|
@return return all items for project. the list can be empty
|
||||||
*/
|
*/
|
||||||
QList<ElementCollectionItem *> ElementsCollectionModel::projectItems(QETProject *project) const
|
QList<ElementCollectionItem *> ElementsCollectionModel::projectItems(
|
||||||
|
QETProject *project) const
|
||||||
{
|
{
|
||||||
QList <ElementCollectionItem *> list;
|
QList <ElementCollectionItem *> list;
|
||||||
|
|
||||||
@@ -596,7 +600,9 @@ void ElementsCollectionModel::elementIntegratedToCollection(const QString& path)
|
|||||||
XmlProjectElementCollectionItem *xpeci = m_project_hash.value(project);
|
XmlProjectElementCollectionItem *xpeci = m_project_hash.value(project);
|
||||||
|
|
||||||
QString collection_name;
|
QString collection_name;
|
||||||
ElementCollectionItem *eci = xpeci->lastItemForPath(path, collection_name);
|
ElementCollectionItem *eci = xpeci->lastItemForPath(
|
||||||
|
path,
|
||||||
|
collection_name);
|
||||||
if (!eci)
|
if (!eci)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -626,7 +632,8 @@ void ElementsCollectionModel::itemRemovedFromCollection(const QString& path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (project) {
|
if (project) {
|
||||||
QModelIndex index = indexFromLocation(ElementsLocation(path, project));
|
QModelIndex index = indexFromLocation(
|
||||||
|
ElementsLocation(path, project));
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
removeRow(index.row(), index.parent());
|
removeRow(index.row(), index.parent());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,16 +80,20 @@ void ElementsTreeView::startElementDrag(const ElementsLocation &location)
|
|||||||
|
|
||||||
if (location.isDirectory())
|
if (location.isDirectory())
|
||||||
{
|
{
|
||||||
mime_data->setData("application/x-qet-category-uri", location_str.toLatin1());
|
mime_data->setData("application/x-qet-category-uri",
|
||||||
|
location_str.toLatin1());
|
||||||
drag->setPixmap(QET::Icons::Folder.pixmap(22, 22));
|
drag->setPixmap(QET::Icons::Folder.pixmap(22, 22));
|
||||||
}
|
}
|
||||||
else if (location.isElement())
|
else if (location.isElement())
|
||||||
{
|
{
|
||||||
mime_data->setData("application/x-qet-element-uri", location_str.toLatin1());
|
mime_data->setData("application/x-qet-element-uri",
|
||||||
|
location_str.toLatin1());
|
||||||
|
|
||||||
//Build the element for set the pixmap of the QDrag
|
//Build the element for set the pixmap of the QDrag
|
||||||
int elmt_creation_state;
|
int elmt_creation_state;
|
||||||
Element *temp_elmt = ElementFactory::Instance()->createElement(location, nullptr, &elmt_creation_state);
|
Element *temp_elmt = ElementFactory::Instance()->createElement(
|
||||||
|
location, nullptr,
|
||||||
|
&elmt_creation_state);
|
||||||
if (elmt_creation_state)
|
if (elmt_creation_state)
|
||||||
{
|
{
|
||||||
delete temp_elmt;
|
delete temp_elmt;
|
||||||
@@ -100,10 +104,17 @@ void ElementsTreeView::startElementDrag(const ElementsLocation &location)
|
|||||||
QPoint elmt_hotspot(temp_elmt->hotspot());
|
QPoint elmt_hotspot(temp_elmt->hotspot());
|
||||||
|
|
||||||
//Adjust the size of the pixmap if he is too big
|
//Adjust the size of the pixmap if he is too big
|
||||||
QPoint elmt_pixmap_size(elmt_pixmap.width(), elmt_pixmap.height());
|
QPoint elmt_pixmap_size(elmt_pixmap.width(),
|
||||||
if (elmt_pixmap.width() > MAX_DND_PIXMAP_WIDTH || elmt_pixmap.height() > MAX_DND_PIXMAP_HEIGHT)
|
elmt_pixmap.height());
|
||||||
|
if (elmt_pixmap.width()
|
||||||
|
> MAX_DND_PIXMAP_WIDTH
|
||||||
|
|| elmt_pixmap.height()
|
||||||
|
> MAX_DND_PIXMAP_HEIGHT)
|
||||||
{
|
{
|
||||||
elmt_pixmap = elmt_pixmap.scaled(MAX_DND_PIXMAP_WIDTH, MAX_DND_PIXMAP_HEIGHT, Qt::KeepAspectRatio);
|
elmt_pixmap = elmt_pixmap.scaled(
|
||||||
|
MAX_DND_PIXMAP_WIDTH,
|
||||||
|
MAX_DND_PIXMAP_HEIGHT,
|
||||||
|
Qt::KeepAspectRatio);
|
||||||
elmt_hotspot = QPoint(
|
elmt_hotspot = QPoint(
|
||||||
elmt_hotspot.x() * elmt_pixmap.width() / elmt_pixmap_size.x(),
|
elmt_hotspot.x() * elmt_pixmap.width() / elmt_pixmap_size.x(),
|
||||||
elmt_hotspot.y() * elmt_pixmap.height() / elmt_pixmap_size.y()
|
elmt_hotspot.y() * elmt_pixmap.height() / elmt_pixmap_size.y()
|
||||||
|
|||||||
@@ -46,9 +46,18 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
|
|||||||
|
|
||||||
NamesList names;
|
NamesList names;
|
||||||
|
|
||||||
const QChar russian_data[24] = { 0x0418, 0x043C, 0x043F, 0x043E, 0x0440, 0x0442, 0x0438, 0x0440, 0x043E, 0x0432, 0x0430, 0x043D, 0x043D, 0x044B, 0x0435, 0x0020, 0x044D, 0x043B, 0x0435, 0x043C, 0x0435, 0x043D, 0x0442, 0x044B };
|
const QChar russian_data[24] = { 0x0418, 0x043C, 0x043F, 0x043E, 0x0440,
|
||||||
const QChar greek_data[18] = { 0x0395, 0x03b9, 0x03c3, 0x03b7, 0x03b3, 0x03bc, 0x03ad, 0x03bd, 0x03b1, 0x0020, 0x03c3, 0x03c4, 0x03bf, 0x03b9, 0x03c7, 0x03b5, 0x03af, 0x03b1 };
|
0x0442, 0x0438, 0x0440, 0x043E, 0x0432,
|
||||||
const QChar turkish_data[12] ={ 0x0130, 0x0074, 0x0068, 0x0061, 0x006C, 0x0020, 0x00F6, 0x011F, 0x0065, 0x006C, 0x0065, 0x0072 };
|
0x0430, 0x043D, 0x043D, 0x044B, 0x0435,
|
||||||
|
0x0020, 0x044D, 0x043B, 0x0435, 0x043C,
|
||||||
|
0x0435, 0x043D, 0x0442, 0x044B };
|
||||||
|
const QChar greek_data[18] = { 0x0395, 0x03b9, 0x03c3, 0x03b7, 0x03b3,
|
||||||
|
0x03bc, 0x03ad, 0x03bd, 0x03b1, 0x0020,
|
||||||
|
0x03c3, 0x03c4, 0x03bf, 0x03b9, 0x03c7,
|
||||||
|
0x03b5, 0x03af, 0x03b1 };
|
||||||
|
const QChar turkish_data[12] ={ 0x0130, 0x0074, 0x0068, 0x0061, 0x006C,
|
||||||
|
0x0020, 0x00F6, 0x011F, 0x0065, 0x006C,
|
||||||
|
0x0065, 0x0072 };
|
||||||
names.addName("fr", "Éléments importés");
|
names.addName("fr", "Éléments importés");
|
||||||
names.addName("en", "Imported elements");
|
names.addName("en", "Imported elements");
|
||||||
names.addName("de", "Importierte elemente");
|
names.addName("de", "Importierte elemente");
|
||||||
@@ -80,12 +89,14 @@ XmlElementCollection::XmlElementCollection(QETProject *project) :
|
|||||||
-the collection in a dom_element (the dom element in cloned)
|
-the collection in a dom_element (the dom element in cloned)
|
||||||
@param project : the project of this collection
|
@param project : the project of this collection
|
||||||
*/
|
*/
|
||||||
XmlElementCollection::XmlElementCollection(const QDomElement &dom_element, QETProject *project) :
|
XmlElementCollection::XmlElementCollection(const QDomElement &dom_element,
|
||||||
|
QETProject *project) :
|
||||||
QObject(project),
|
QObject(project),
|
||||||
m_project(project)
|
m_project(project)
|
||||||
{
|
{
|
||||||
if (dom_element.tagName() == "collection")
|
if (dom_element.tagName() == "collection")
|
||||||
m_dom_document.appendChild(m_dom_document.importNode(dom_element, true));
|
m_dom_document.appendChild(m_dom_document.importNode(
|
||||||
|
dom_element, true));
|
||||||
else
|
else
|
||||||
qDebug() << "XmlElementCollection : tagName of dom_element is not collection";
|
qDebug() << "XmlElementCollection : tagName of dom_element is not collection";
|
||||||
}
|
}
|
||||||
@@ -114,9 +125,11 @@ QDomElement XmlElementCollection::importCategory() const {
|
|||||||
@param parent_element
|
@param parent_element
|
||||||
@return All childs element in the parent_element tree
|
@return All childs element in the parent_element tree
|
||||||
*/
|
*/
|
||||||
QDomNodeList XmlElementCollection::childs(const QDomElement &parent_element) const
|
QDomNodeList XmlElementCollection::childs(
|
||||||
|
const QDomElement &parent_element) const
|
||||||
{
|
{
|
||||||
if (parent_element.ownerDocument() != m_dom_document) return QDomNodeList();
|
if (parent_element.ownerDocument() != m_dom_document)
|
||||||
|
return QDomNodeList();
|
||||||
return parent_element.childNodes();
|
return parent_element.childNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,9 +145,11 @@ QDomNodeList XmlElementCollection::childs(const QDomElement &parent_element) con
|
|||||||
@param child_name : name of child to search.
|
@param child_name : name of child to search.
|
||||||
@return The child QDomElement or a null QDomElement if not found
|
@return The child QDomElement or a null QDomElement if not found
|
||||||
*/
|
*/
|
||||||
QDomElement XmlElementCollection::child(const QDomElement &parent_element, const QString &child_name) const
|
QDomElement XmlElementCollection::child(const QDomElement &parent_element,
|
||||||
|
const QString &child_name) const
|
||||||
{
|
{
|
||||||
if (parent_element.ownerDocument() != m_dom_document) return QDomElement();
|
if (parent_element.ownerDocument() != m_dom_document)
|
||||||
|
return QDomElement();
|
||||||
|
|
||||||
//Get all childs element of parent_element
|
//Get all childs element of parent_element
|
||||||
QDomNodeList child_list = parent_element.childNodes();
|
QDomNodeList child_list = parent_element.childNodes();
|
||||||
@@ -143,7 +158,8 @@ QDomElement XmlElementCollection::child(const QDomElement &parent_element, const
|
|||||||
for (int i=0 ; i<child_list.length() ; i++)
|
for (int i=0 ; i<child_list.length() ; i++)
|
||||||
{
|
{
|
||||||
QDomElement child_element = child_list.item(i).toElement();
|
QDomElement child_element = child_list.item(i).toElement();
|
||||||
if (child_element.tagName() == tag_name) found_dom_element << child_element;
|
if (child_element.tagName() == tag_name)
|
||||||
|
found_dom_element << child_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_dom_element.isEmpty()) return QDomElement();
|
if (found_dom_element.isEmpty()) return QDomElement();
|
||||||
@@ -184,7 +200,8 @@ QDomElement XmlElementCollection::child(const QString &path) const
|
|||||||
@param parent_element
|
@param parent_element
|
||||||
@return A list of directory stored in parent_element
|
@return A list of directory stored in parent_element
|
||||||
*/
|
*/
|
||||||
QList<QDomElement> XmlElementCollection::directories(const QDomElement &parent_element) const
|
QList<QDomElement> XmlElementCollection::directories(
|
||||||
|
const QDomElement &parent_element) const
|
||||||
{
|
{
|
||||||
QList <QDomElement> directory_list;
|
QList <QDomElement> directory_list;
|
||||||
QDomNodeList node_list = childs(parent_element);
|
QDomNodeList node_list = childs(parent_element);
|
||||||
@@ -193,7 +210,8 @@ QList<QDomElement> XmlElementCollection::directories(const QDomElement &parent_e
|
|||||||
for (int i=0 ; i < node_list.count() ; i++)
|
for (int i=0 ; i < node_list.count() ; i++)
|
||||||
{
|
{
|
||||||
QDomNode node = node_list.at(i);
|
QDomNode node = node_list.at(i);
|
||||||
if (node.isElement() && node.toElement().tagName() == "category")
|
if (node.isElement()
|
||||||
|
&& node.toElement().tagName() == "category")
|
||||||
directory_list << node.toElement();
|
directory_list << node.toElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +223,8 @@ QList<QDomElement> XmlElementCollection::directories(const QDomElement &parent_e
|
|||||||
@param parent_element
|
@param parent_element
|
||||||
@return a list of names for every child directories of parent_element
|
@return a list of names for every child directories of parent_element
|
||||||
*/
|
*/
|
||||||
QStringList XmlElementCollection::directoriesNames(const QDomElement &parent_element) const
|
QStringList XmlElementCollection::directoriesNames(
|
||||||
|
const QDomElement &parent_element) const
|
||||||
{
|
{
|
||||||
QList <QDomElement> childs = directories(parent_element);
|
QList <QDomElement> childs = directories(parent_element);
|
||||||
QStringList names;
|
QStringList names;
|
||||||
@@ -225,7 +244,8 @@ QStringList XmlElementCollection::directoriesNames(const QDomElement &parent_ele
|
|||||||
@param parent_element
|
@param parent_element
|
||||||
@return A list of element stored in parent_element
|
@return A list of element stored in parent_element
|
||||||
*/
|
*/
|
||||||
QList<QDomElement> XmlElementCollection::elements(const QDomElement &parent_element) const
|
QList<QDomElement> XmlElementCollection::elements(
|
||||||
|
const QDomElement &parent_element) const
|
||||||
{
|
{
|
||||||
QList <QDomElement> element_list;
|
QList <QDomElement> element_list;
|
||||||
QDomNodeList node_list = childs(parent_element);
|
QDomNodeList node_list = childs(parent_element);
|
||||||
@@ -246,7 +266,8 @@ QList<QDomElement> XmlElementCollection::elements(const QDomElement &parent_elem
|
|||||||
@param parent_element
|
@param parent_element
|
||||||
@return A list of names fr every childs element of parent_element
|
@return A list of names fr every childs element of parent_element
|
||||||
*/
|
*/
|
||||||
QStringList XmlElementCollection::elementsNames(const QDomElement &parent_element) const
|
QStringList XmlElementCollection::elementsNames(
|
||||||
|
const QDomElement &parent_element) const
|
||||||
{
|
{
|
||||||
QList <QDomElement> childs = elements(parent_element);
|
QList <QDomElement> childs = elements(parent_element);
|
||||||
QStringList names;
|
QStringList names;
|
||||||
@@ -337,7 +358,8 @@ QString XmlElementCollection::addElement(ElementsLocation &location)
|
|||||||
|
|
||||||
if (location.isFileSystem()) {
|
if (location.isFileSystem()) {
|
||||||
//Get the root dir of the filesystem collection
|
//Get the root dir of the filesystem collection
|
||||||
QDir dir(location.fileSystemPath().remove(location.collectionPath(false)));
|
QDir dir(location.fileSystemPath().remove(
|
||||||
|
location.collectionPath(false)));
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
@@ -446,11 +468,15 @@ QString XmlElementCollection::addElement(ElementsLocation &location)
|
|||||||
The tag name of xml_definition must be "definition".
|
The tag name of xml_definition must be "definition".
|
||||||
@return True if the element is added with success.
|
@return True if the element is added with success.
|
||||||
*/
|
*/
|
||||||
bool XmlElementCollection::addElementDefinition(const QString &dir_path, const QString &elmt_name, const QDomElement &xml_definition)
|
bool XmlElementCollection::addElementDefinition(
|
||||||
|
const QString &dir_path,
|
||||||
|
const QString &elmt_name,
|
||||||
|
const QDomElement &xml_definition)
|
||||||
{
|
{
|
||||||
QDomElement dom_dir = directory(dir_path);
|
QDomElement dom_dir = directory(dir_path);
|
||||||
if (dom_dir.isNull()) {
|
if (dom_dir.isNull()) {
|
||||||
qDebug() << "XmlElementCollection::addElementDefinition : No directory at path : " << dir_path;
|
qDebug() << "XmlElementCollection::addElementDefinition : No directory at path : "
|
||||||
|
<< dir_path;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,9 +536,16 @@ bool XmlElementCollection::removeElement(const QString& path)
|
|||||||
@return the ElementLocation that represent the copy,
|
@return the ElementLocation that represent the copy,
|
||||||
if copy failed return a null ElementLocation
|
if copy failed return a null ElementLocation
|
||||||
*/
|
*/
|
||||||
ElementsLocation XmlElementCollection::copy(ElementsLocation &source, ElementsLocation &destination, const QString& rename, bool deep_copy)
|
ElementsLocation XmlElementCollection::copy(
|
||||||
|
ElementsLocation &source,
|
||||||
|
ElementsLocation &destination,
|
||||||
|
const QString& rename,
|
||||||
|
bool deep_copy)
|
||||||
{
|
{
|
||||||
if (!(source.exist() && destination.isDirectory() && destination.isProject() && destination.projectCollection() == this))
|
if (!(source.exist()
|
||||||
|
&& destination.isDirectory()
|
||||||
|
&& destination.isProject()
|
||||||
|
&& destination.projectCollection() == this))
|
||||||
return ElementsLocation();
|
return ElementsLocation();
|
||||||
|
|
||||||
if (source.isElement())
|
if (source.isElement())
|
||||||
@@ -537,14 +570,17 @@ bool XmlElementCollection::exist(const QString &path) const
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief XmlElementCollection::createDir
|
@brief XmlElementCollection::createDir
|
||||||
Create a child directorie at path @path with the name @name.
|
Create a child directorie at path path with the name name.
|
||||||
Emit directorieAdded if success.
|
Emit directorieAdded if success.
|
||||||
@param path : path of parent diectorie
|
@param path : path of parent diectorie
|
||||||
@param name : name of the directori to create.
|
@param name : name of the directori to create.
|
||||||
@param name_list : translation of the directorie name.
|
@param name_list : translation of the directorie name.
|
||||||
@return true if creation success, if directorie already exist return true.
|
@return true if creation success,
|
||||||
|
if directorie already exist return true.
|
||||||
*/
|
*/
|
||||||
bool XmlElementCollection::createDir(const QString& path, const QString& name, const NamesList &name_list)
|
bool XmlElementCollection::createDir(const QString& path,
|
||||||
|
const QString& name,
|
||||||
|
const NamesList &name_list)
|
||||||
{
|
{
|
||||||
QString new_dir_path = path + "/" + name;
|
QString new_dir_path = path + "/" + name;
|
||||||
|
|
||||||
@@ -597,7 +633,9 @@ bool XmlElementCollection::removeDir(const QString& path)
|
|||||||
if false, only return the direct childs location of dom_element.
|
if false, only return the direct childs location of dom_element.
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QList<ElementsLocation> XmlElementCollection::elementsLocation(QDomElement dom_element, bool childs) const
|
QList<ElementsLocation> XmlElementCollection::elementsLocation(
|
||||||
|
QDomElement dom_element,
|
||||||
|
bool childs) const
|
||||||
{
|
{
|
||||||
QList <ElementsLocation> location_list;
|
QList <ElementsLocation> location_list;
|
||||||
|
|
||||||
@@ -640,12 +678,14 @@ QList<ElementsLocation> XmlElementCollection::elementsLocation(QDomElement dom_e
|
|||||||
The tag name of dom_element must be "element"
|
The tag name of dom_element must be "element"
|
||||||
@return the element location, location can be null if fail.
|
@return the element location, location can be null if fail.
|
||||||
*/
|
*/
|
||||||
ElementsLocation XmlElementCollection::domToLocation(QDomElement dom_element) const
|
ElementsLocation XmlElementCollection::domToLocation(
|
||||||
|
QDomElement dom_element) const
|
||||||
{
|
{
|
||||||
if (dom_element.ownerDocument() == m_dom_document) {
|
if (dom_element.ownerDocument() == m_dom_document) {
|
||||||
QString path = dom_element.attribute("name");
|
QString path = dom_element.attribute("name");
|
||||||
|
|
||||||
while (!dom_element.parentNode().isNull() && dom_element.parentNode().isElement()) {
|
while (!dom_element.parentNode().isNull()
|
||||||
|
&& dom_element.parentNode().isElement()) {
|
||||||
dom_element = dom_element.parentNode().toElement();
|
dom_element = dom_element.parentNode().toElement();
|
||||||
|
|
||||||
if (dom_element.tagName() == "category")
|
if (dom_element.tagName() == "category")
|
||||||
@@ -678,8 +718,10 @@ void XmlElementCollection::cleanUnusedDirectory()
|
|||||||
|
|
||||||
for(int i=0 ; i<lst.size() ; i++) {
|
for(int i=0 ; i<lst.size() ; i++) {
|
||||||
QDomElement dir = lst.item(i).toElement();
|
QDomElement dir = lst.item(i).toElement();
|
||||||
//elmt haven't got child node "element" or "category", so he is emty, we can remove it
|
//elmt haven't got child node "element" or "category",
|
||||||
if (dir.elementsByTagName("element").isEmpty() && dir.elementsByTagName("category").isEmpty()) {
|
//so he is emty, we can remove it
|
||||||
|
if (dir.elementsByTagName("element").isEmpty()
|
||||||
|
&& dir.elementsByTagName("category").isEmpty()) {
|
||||||
if (removeDir(domToLocation(dir).collectionPath(false)))
|
if (removeDir(domToLocation(dir).collectionPath(false)))
|
||||||
i=-1;
|
i=-1;
|
||||||
}
|
}
|
||||||
@@ -698,7 +740,11 @@ void XmlElementCollection::cleanUnusedDirectory()
|
|||||||
@return the ElementLocation that represent the copy,
|
@return the ElementLocation that represent the copy,
|
||||||
if copy failed return a null ElementLocation
|
if copy failed return a null ElementLocation
|
||||||
*/
|
*/
|
||||||
ElementsLocation XmlElementCollection::copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename, bool deep_copy)
|
ElementsLocation XmlElementCollection::copyDirectory(
|
||||||
|
ElementsLocation &source,
|
||||||
|
ElementsLocation &destination,
|
||||||
|
const QString& rename,
|
||||||
|
bool deep_copy)
|
||||||
{
|
{
|
||||||
QString new_dir_name = rename.isEmpty() ? source.fileName() : rename;
|
QString new_dir_name = rename.isEmpty() ? source.fileName() : rename;
|
||||||
|
|
||||||
@@ -707,10 +753,12 @@ ElementsLocation XmlElementCollection::copyDirectory(ElementsLocation &source, E
|
|||||||
if (parent_dir_dom.isNull()) return ElementsLocation();
|
if (parent_dir_dom.isNull()) return ElementsLocation();
|
||||||
|
|
||||||
//Remove the previous directory with the same path
|
//Remove the previous directory with the same path
|
||||||
QDomElement element = child(destination.collectionPath(false) + "/" + new_dir_name);
|
QDomElement element = child(destination.collectionPath(false)
|
||||||
|
+ "/" + new_dir_name);
|
||||||
if (!element.isNull()) {
|
if (!element.isNull()) {
|
||||||
element.parentNode().removeChild(element);
|
element.parentNode().removeChild(element);
|
||||||
emit directoryRemoved(destination.collectionPath(false) + "/" + new_dir_name);
|
emit directoryRemoved(destination.collectionPath(false)
|
||||||
|
+ "/" + new_dir_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementsLocation created_location;
|
ElementsLocation created_location;
|
||||||
@@ -723,27 +771,35 @@ ElementsLocation XmlElementCollection::copyDirectory(ElementsLocation &source, E
|
|||||||
|
|
||||||
|
|
||||||
QDir dir(source.fileSystemPath());
|
QDir dir(source.fileSystemPath());
|
||||||
QDomElement elmt_dom = QETXML::fileSystemDirToXmlCollectionDir(m_dom_document, dir, new_dir_name);
|
QDomElement elmt_dom = QETXML::fileSystemDirToXmlCollectionDir(
|
||||||
|
m_dom_document, dir, new_dir_name);
|
||||||
if (elmt_dom.isNull()) return ElementsLocation();
|
if (elmt_dom.isNull()) return ElementsLocation();
|
||||||
|
|
||||||
parent_dir_dom.appendChild(elmt_dom);
|
parent_dir_dom.appendChild(elmt_dom);
|
||||||
|
|
||||||
created_location.setPath(destination.projectCollectionPath() + "/" + new_dir_name);
|
created_location.setPath(destination.projectCollectionPath()
|
||||||
|
+ "/" + new_dir_name);
|
||||||
|
|
||||||
if (deep_copy)
|
if (deep_copy)
|
||||||
{
|
{
|
||||||
//Append all directories of source to the new created directory
|
//Append all directories of source to the new created directory
|
||||||
foreach(QString str, source_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
|
foreach(QString str, source_dir.entryList(
|
||||||
|
QDir::Dirs | QDir::NoDotAndDotDot,
|
||||||
|
QDir::Name))
|
||||||
{
|
{
|
||||||
ElementsLocation sub_source(source.fileSystemPath() + "/" + str);
|
ElementsLocation sub_source(source.fileSystemPath()
|
||||||
|
+ "/" + str);
|
||||||
copyDirectory(sub_source, created_location);
|
copyDirectory(sub_source, created_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Append all elements of source to the new created directory
|
//Append all elements of source to the new created directory
|
||||||
source_dir.setNameFilters(QStringList() << "*.elmt");
|
source_dir.setNameFilters(QStringList() << "*.elmt");
|
||||||
foreach(QString str, source_dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
|
foreach(QString str, source_dir.entryList(
|
||||||
|
QDir::Files | QDir::NoDotAndDotDot,
|
||||||
|
QDir::Name))
|
||||||
{
|
{
|
||||||
ElementsLocation sub_source(source.fileSystemPath() + "/" + str);
|
ElementsLocation sub_source(source.fileSystemPath()
|
||||||
|
+ "/" + str);
|
||||||
copyElement(sub_source, created_location);
|
copyElement(sub_source, created_location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -786,7 +842,10 @@ ElementsLocation XmlElementCollection::copyDirectory(ElementsLocation &source, E
|
|||||||
@param rename : rename the copy with rename else use the name of source
|
@param rename : rename the copy with rename else use the name of source
|
||||||
@return The ElementsLocation of the copy
|
@return The ElementsLocation of the copy
|
||||||
*/
|
*/
|
||||||
ElementsLocation XmlElementCollection::copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename)
|
ElementsLocation XmlElementCollection::copyElement(
|
||||||
|
ElementsLocation &source,
|
||||||
|
ElementsLocation &destination,
|
||||||
|
const QString& rename)
|
||||||
{
|
{
|
||||||
QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename;
|
QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename;
|
||||||
|
|
||||||
@@ -796,7 +855,8 @@ ElementsLocation XmlElementCollection::copyElement(ElementsLocation &source, Ele
|
|||||||
if (source.isFileSystem())
|
if (source.isFileSystem())
|
||||||
{
|
{
|
||||||
QFile file(source.fileSystemPath());
|
QFile file(source.fileSystemPath());
|
||||||
elmt_dom = QETXML::fileSystemElementToXmlCollectionElement(m_dom_document, file, new_elmt_name);
|
elmt_dom = QETXML::fileSystemElementToXmlCollectionElement(
|
||||||
|
m_dom_document, file, new_elmt_name);
|
||||||
if (elmt_dom.isNull()) return ElementsLocation();
|
if (elmt_dom.isNull()) return ElementsLocation();
|
||||||
}
|
}
|
||||||
//Copy with a xml collection source
|
//Copy with a xml collection source
|
||||||
@@ -810,7 +870,8 @@ ElementsLocation XmlElementCollection::copyElement(ElementsLocation &source, Ele
|
|||||||
|
|
||||||
|
|
||||||
//Remove the previous element with the same path
|
//Remove the previous element with the same path
|
||||||
QDomElement element = child(destination.collectionPath(false) + "/" + new_elmt_name);
|
QDomElement element = child(destination.collectionPath(false)
|
||||||
|
+ "/" + new_elmt_name);
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
if (!element.isNull()) {
|
if (!element.isNull()) {
|
||||||
element.parentNode().removeChild(element);
|
element.parentNode().removeChild(element);
|
||||||
@@ -822,7 +883,8 @@ ElementsLocation XmlElementCollection::copyElement(ElementsLocation &source, Ele
|
|||||||
if (dir_dom.isNull()) return ElementsLocation();
|
if (dir_dom.isNull()) return ElementsLocation();
|
||||||
dir_dom.appendChild(elmt_dom);
|
dir_dom.appendChild(elmt_dom);
|
||||||
|
|
||||||
ElementsLocation copy_loc(destination.projectCollectionPath() + "/" + new_elmt_name);
|
ElementsLocation copy_loc(destination.projectCollectionPath()
|
||||||
|
+ "/" + new_elmt_name);
|
||||||
|
|
||||||
if (removed) {
|
if (removed) {
|
||||||
emit elementChanged(copy_loc.collectionPath(false));
|
emit elementChanged(copy_loc.collectionPath(false));
|
||||||
|
|||||||
@@ -133,7 +133,8 @@ bool XmlProjectElementCollectionItem::isCollectionRoot() const
|
|||||||
(the child must exist in the xml element collection)
|
(the child must exist in the xml element collection)
|
||||||
@param collection_name : name of the child item to add.
|
@param collection_name : name of the child item to add.
|
||||||
*/
|
*/
|
||||||
void XmlProjectElementCollectionItem::addChildAtPath(const QString &collection_name)
|
void XmlProjectElementCollectionItem::addChildAtPath(
|
||||||
|
const QString &collection_name)
|
||||||
{
|
{
|
||||||
if (collection_name.isEmpty())
|
if (collection_name.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -66,7 +66,9 @@ void NameListWidget::setNames(const NamesList &name_list)
|
|||||||
values << lang << value;
|
values << lang << value;
|
||||||
QTreeWidgetItem *qtwi = new QTreeWidgetItem(values);
|
QTreeWidgetItem *qtwi = new QTreeWidgetItem(values);
|
||||||
if (!m_read_only) {
|
if (!m_read_only) {
|
||||||
qtwi->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
qtwi->setFlags(Qt::ItemIsEditable
|
||||||
|
| Qt::ItemIsEnabled
|
||||||
|
| Qt::ItemIsSelectable);
|
||||||
}
|
}
|
||||||
ui->m_tree->addTopLevelItem(qtwi);
|
ui->m_tree->addTopLevelItem(qtwi);
|
||||||
ui->m_tree->sortItems(0, Qt::AscendingOrder);
|
ui->m_tree->sortItems(0, Qt::AscendingOrder);
|
||||||
|
|||||||
@@ -55,11 +55,18 @@ class PropertiesEditorDialog : public QDialog
|
|||||||
//Build the dialog
|
//Build the dialog
|
||||||
QVBoxLayout *vlayout = new QVBoxLayout(this);
|
QVBoxLayout *vlayout = new QVBoxLayout(this);
|
||||||
vlayout->addWidget(editor);
|
vlayout->addWidget(editor);
|
||||||
QDialogButtonBox *button_box = new QDialogButtonBox (QDialogButtonBox::Apply | QDialogButtonBox::Cancel | QDialogButtonBox::Reset, this);
|
QDialogButtonBox *button_box = new QDialogButtonBox (
|
||||||
|
QDialogButtonBox::Apply
|
||||||
|
| QDialogButtonBox::Cancel
|
||||||
|
| QDialogButtonBox::Reset,
|
||||||
|
this);
|
||||||
vlayout->addWidget(button_box);
|
vlayout->addWidget(button_box);
|
||||||
|
|
||||||
//Setup connection between button box and the editor
|
//Setup connection between button box and the editor
|
||||||
connect(button_box, &QDialogButtonBox::clicked, [editor, button_box, this](QAbstractButton *button)
|
connect(button_box,
|
||||||
|
&QDialogButtonBox::clicked,
|
||||||
|
[editor, button_box, this]
|
||||||
|
(QAbstractButton *button)
|
||||||
{
|
{
|
||||||
switch(button_box->buttonRole(button))
|
switch(button_box->buttonRole(button))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ void PropertiesEditorDockWidget::reset()
|
|||||||
@return true if was added (or already add)
|
@return true if was added (or already add)
|
||||||
or false if can't be add (editor = nullptr)
|
or false if can't be add (editor = nullptr)
|
||||||
*/
|
*/
|
||||||
bool PropertiesEditorDockWidget::addEditor(PropertiesEditorWidget *editor, int index)
|
bool PropertiesEditorDockWidget::addEditor(PropertiesEditorWidget *editor,
|
||||||
|
int index)
|
||||||
{
|
{
|
||||||
if (!editor) return false;
|
if (!editor) return false;
|
||||||
if (m_editor_list.contains(editor)) return true;
|
if (m_editor_list.contains(editor)) return true;
|
||||||
|
|||||||
@@ -26,7 +26,11 @@
|
|||||||
@param old_value
|
@param old_value
|
||||||
@param new_value
|
@param new_value
|
||||||
*/
|
*/
|
||||||
QPropertyUndoCommand::QPropertyUndoCommand(QObject *object, const char *property_name, const QVariant &old_value, const QVariant &new_value, QUndoCommand *parent) :
|
QPropertyUndoCommand::QPropertyUndoCommand(QObject *object,
|
||||||
|
const char *property_name,
|
||||||
|
const QVariant &old_value,
|
||||||
|
const QVariant &new_value,
|
||||||
|
QUndoCommand *parent) :
|
||||||
QUndoCommand(parent),
|
QUndoCommand(parent),
|
||||||
m_object(object),
|
m_object(object),
|
||||||
m_property_name(property_name),
|
m_property_name(property_name),
|
||||||
@@ -43,7 +47,10 @@ QPropertyUndoCommand::QPropertyUndoCommand(QObject *object, const char *property
|
|||||||
@param old_value
|
@param old_value
|
||||||
@param parent
|
@param parent
|
||||||
*/
|
*/
|
||||||
QPropertyUndoCommand::QPropertyUndoCommand(QObject *object, const char *property_name, const QVariant &old_value, QUndoCommand *parent) :
|
QPropertyUndoCommand::QPropertyUndoCommand(QObject *object,
|
||||||
|
const char *property_name,
|
||||||
|
const QVariant &old_value,
|
||||||
|
QUndoCommand *parent) :
|
||||||
QUndoCommand(parent),
|
QUndoCommand(parent),
|
||||||
m_object(object),
|
m_object(object),
|
||||||
m_property_name(property_name),
|
m_property_name(property_name),
|
||||||
|
|||||||
@@ -25,7 +25,10 @@
|
|||||||
@param duration : the duration of animation
|
@param duration : the duration of animation
|
||||||
@see void QVariantAnimation::setDuration(int msecs)
|
@see void QVariantAnimation::setDuration(int msecs)
|
||||||
*/
|
*/
|
||||||
QWidgetAnimation::QWidgetAnimation(QWidget *widget, Qt::Orientation orientation, QWidgetAnimation::Behavior behavior, int duration) :
|
QWidgetAnimation::QWidgetAnimation(QWidget *widget,
|
||||||
|
Qt::Orientation orientation,
|
||||||
|
QWidgetAnimation::Behavior behavior,
|
||||||
|
int duration) :
|
||||||
QPropertyAnimation(widget),
|
QPropertyAnimation(widget),
|
||||||
m_orientation(orientation),
|
m_orientation(orientation),
|
||||||
m_widget(widget),
|
m_widget(widget),
|
||||||
@@ -34,7 +37,9 @@ QWidgetAnimation::QWidgetAnimation(QWidget *widget, Qt::Orientation orientation,
|
|||||||
m_behavior(behavior)
|
m_behavior(behavior)
|
||||||
{
|
{
|
||||||
setTargetObject(widget);
|
setTargetObject(widget);
|
||||||
setPropertyName( m_orientation == Qt::Vertical ? "maximumHeight" : "maximumWidth");
|
setPropertyName( m_orientation == Qt::Vertical
|
||||||
|
? "maximumHeight"
|
||||||
|
: "maximumWidth");
|
||||||
setDuration(duration);
|
setDuration(duration);
|
||||||
setEasingCurve(QEasingCurve::OutCubic);
|
setEasingCurve(QEasingCurve::OutCubic);
|
||||||
|
|
||||||
@@ -42,8 +47,11 @@ QWidgetAnimation::QWidgetAnimation(QWidget *widget, Qt::Orientation orientation,
|
|||||||
{
|
{
|
||||||
m_state = QWidgetAnimation::Finish;
|
m_state = QWidgetAnimation::Finish;
|
||||||
|
|
||||||
if ( (this->m_orientation == Qt::Vertical && m_widget->geometry().height() == 0) ||
|
if ( (this->m_orientation == Qt::Vertical
|
||||||
(this->m_orientation == Qt::Horizontal && m_widget->geometry().width() == 0) ) {
|
&& m_widget->geometry().height() == 0) ||
|
||||||
|
(this->m_orientation == Qt::Horizontal
|
||||||
|
&& m_widget->geometry().width() == 0))
|
||||||
|
{
|
||||||
m_widget->hide();
|
m_widget->hide();
|
||||||
} else {
|
} else {
|
||||||
m_widget->setMaximumSize(m_maximum);
|
m_widget->setMaximumSize(m_maximum);
|
||||||
@@ -78,32 +86,39 @@ void QWidgetAnimation::show()
|
|||||||
int end_value = 10000;
|
int end_value = 10000;
|
||||||
if (m_behavior == QWidgetAnimation::minimumSizeHint)
|
if (m_behavior == QWidgetAnimation::minimumSizeHint)
|
||||||
{
|
{
|
||||||
end_value = m_orientation == Qt::Horizontal ? m_widget->minimumSizeHint().width() :
|
end_value = m_orientation == Qt::Horizontal
|
||||||
m_widget->minimumSizeHint().height();
|
? m_widget->minimumSizeHint().width()
|
||||||
|
: m_widget->minimumSizeHint().height();
|
||||||
}
|
}
|
||||||
else if (m_behavior == QWidgetAnimation::availableSpace && m_widget->parentWidget())
|
else if (m_behavior == QWidgetAnimation::availableSpace
|
||||||
|
&& m_widget->parentWidget())
|
||||||
{
|
{
|
||||||
m_widget->parentWidget()->layout();
|
m_widget->parentWidget()->layout();
|
||||||
int available_ = m_orientation == Qt::Horizontal ? m_widget->parentWidget()->width() :
|
int available_ = m_orientation == Qt::Horizontal
|
||||||
m_widget->parentWidget()->height();
|
? m_widget->parentWidget()->width()
|
||||||
|
: m_widget->parentWidget()->height();
|
||||||
for (auto w : m_widget_to_substract) {
|
for (auto w : m_widget_to_substract) {
|
||||||
available_ -= m_orientation == Qt::Horizontal ? w->minimumSizeHint().width() :
|
available_ -= m_orientation == Qt::Horizontal
|
||||||
w->minimumSizeHint().height();
|
? w->minimumSizeHint().width()
|
||||||
|
: w->minimumSizeHint().height();
|
||||||
}
|
}
|
||||||
|
|
||||||
int mini_ = m_orientation == Qt::Horizontal ? m_widget->minimumSizeHint().width() :
|
int mini_ = m_orientation == Qt::Horizontal
|
||||||
m_widget->minimumSizeHint().height();
|
? m_widget->minimumSizeHint().width()
|
||||||
|
: m_widget->minimumSizeHint().height();
|
||||||
|
|
||||||
end_value = available_ > mini_ ? available_ : mini_;
|
end_value = available_ > mini_ ? available_ : mini_;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_last_rect.isValid()) {
|
if (m_last_rect.isValid()) {
|
||||||
end_value = m_orientation == Qt::Horizontal ? m_last_rect.width() :
|
end_value = m_orientation == Qt::Horizontal
|
||||||
m_last_rect.height();
|
? m_last_rect.width()
|
||||||
|
: m_last_rect.height();
|
||||||
} else {
|
} else {
|
||||||
end_value = m_orientation == Qt::Horizontal ? m_maximum.width() :
|
end_value = m_orientation == Qt::Horizontal
|
||||||
m_maximum.height();
|
? m_maximum.width()
|
||||||
|
: m_maximum.height();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,8 +142,9 @@ void QWidgetAnimation::hide()
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
int start_value = m_orientation == Qt::Horizontal ? m_widget->width() :
|
int start_value = m_orientation == Qt::Horizontal
|
||||||
m_widget->height();
|
? m_widget->width()
|
||||||
|
: m_widget->height();
|
||||||
setStartValue(start_value);
|
setStartValue(start_value);
|
||||||
setEndValue(0);
|
setEndValue(0);
|
||||||
m_state = QWidgetAnimation::Hidding;
|
m_state = QWidgetAnimation::Hidding;
|
||||||
|
|||||||
@@ -53,7 +53,12 @@ class QWidgetAnimation : public QPropertyAnimation
|
|||||||
lastSize,
|
lastSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
QWidgetAnimation(QWidget *widget, Qt::Orientation orientation, QWidgetAnimation::Behavior behavior = QWidgetAnimation::minimumSizeHint, int duration = 250);
|
QWidgetAnimation(
|
||||||
|
QWidget *widget,
|
||||||
|
Qt::Orientation orientation,
|
||||||
|
QWidgetAnimation::Behavior
|
||||||
|
behavior = QWidgetAnimation::minimumSizeHint,
|
||||||
|
int duration = 250);
|
||||||
void widgetToSubtract (QVector<QWidget *> widgets);
|
void widgetToSubtract (QVector<QWidget *> widgets);
|
||||||
|
|
||||||
void show();
|
void show();
|
||||||
|
|||||||
@@ -188,7 +188,9 @@ QRectF QetGraphicsHandlerUtility::mirrorRectForPosAtIndex(const QRectF &old_rect
|
|||||||
@param index
|
@param index
|
||||||
@return
|
@return
|
||||||
*/
|
*/
|
||||||
QLineF QetGraphicsHandlerUtility::lineForPosAtIndex(const QLineF &old_line, const QPointF &pos, int index) {
|
QLineF QetGraphicsHandlerUtility::lineForPosAtIndex(const QLineF &old_line,
|
||||||
|
const QPointF &pos,
|
||||||
|
int index) {
|
||||||
QLineF line = old_line;
|
QLineF line = old_line;
|
||||||
index == 0 ? line.setP1(pos) : line.setP2(pos);
|
index == 0 ? line.setP1(pos) : line.setP2(pos);
|
||||||
return line;
|
return line;
|
||||||
@@ -201,7 +203,10 @@ QLineF QetGraphicsHandlerUtility::lineForPosAtIndex(const QLineF &old_line, cons
|
|||||||
@param pos : the pos where the new point must be added
|
@param pos : the pos where the new point must be added
|
||||||
@return the new polygon
|
@return the new polygon
|
||||||
*/
|
*/
|
||||||
QPolygonF QetGraphicsHandlerUtility::polygonForInsertPoint(const QPolygonF &old_polygon, bool closed, const QPointF &pos)
|
QPolygonF QetGraphicsHandlerUtility::polygonForInsertPoint(
|
||||||
|
const QPolygonF &old_polygon,
|
||||||
|
bool closed,
|
||||||
|
const QPointF &pos)
|
||||||
{
|
{
|
||||||
qreal max_angle = 0;
|
qreal max_angle = 0;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|||||||
@@ -397,7 +397,9 @@ ConductorProperties SearchAndReplaceWorker::invalidConductorProperties()
|
|||||||
@param change : the change properties, to be merged with original
|
@param change : the change properties, to be merged with original
|
||||||
@return a new conductor properties with the change applyed.
|
@return a new conductor properties with the change applyed.
|
||||||
*/
|
*/
|
||||||
ConductorProperties SearchAndReplaceWorker::applyChange(const ConductorProperties &original, const ConductorProperties &change)
|
ConductorProperties SearchAndReplaceWorker::applyChange(
|
||||||
|
const ConductorProperties &original,
|
||||||
|
const ConductorProperties &change)
|
||||||
{
|
{
|
||||||
ConductorProperties new_properties = original;
|
ConductorProperties new_properties = original;
|
||||||
|
|
||||||
@@ -432,7 +434,8 @@ ConductorProperties SearchAndReplaceWorker::applyChange(const ConductorPropertie
|
|||||||
@param change : the changed string:
|
@param change : the changed string:
|
||||||
@return the string to be use in the properties
|
@return the string to be use in the properties
|
||||||
*/
|
*/
|
||||||
QString SearchAndReplaceWorker::applyChange(const QString &original, const QString &change)
|
QString SearchAndReplaceWorker::applyChange(const QString &original,
|
||||||
|
const QString &change)
|
||||||
{
|
{
|
||||||
if (change.isEmpty()) {return original;}
|
if (change.isEmpty()) {return original;}
|
||||||
else if (change == eraseText()) {return QString();}
|
else if (change == eraseText()) {return QString();}
|
||||||
@@ -496,7 +499,8 @@ DiagramContext SearchAndReplaceWorker::replaceAdvanced(Element *element)
|
|||||||
@return the conductor properties with the change applied,
|
@return the conductor properties with the change applied,
|
||||||
according to the state of m_advanced_struct
|
according to the state of m_advanced_struct
|
||||||
*/
|
*/
|
||||||
ConductorProperties SearchAndReplaceWorker::replaceAdvanced(Conductor *conductor)
|
ConductorProperties SearchAndReplaceWorker::replaceAdvanced(
|
||||||
|
Conductor *conductor)
|
||||||
{
|
{
|
||||||
ConductorProperties properties = conductor->properties();
|
ConductorProperties properties = conductor->properties();
|
||||||
|
|
||||||
|
|||||||
@@ -360,7 +360,9 @@ namespace autonum
|
|||||||
@param type : type of sequential
|
@param type : type of sequential
|
||||||
(unit, unitfolio, ten, tenfolio, hundred, hundredfolio)
|
(unit, unitfolio, ten, tenfolio, hundred, hundredfolio)
|
||||||
*/
|
*/
|
||||||
void setSequentialToList(QStringList &list, NumerotationContext &context, const QString& type)
|
void setSequentialToList(QStringList &list,
|
||||||
|
NumerotationContext &context,
|
||||||
|
const QString& type)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < context.size(); i++)
|
for (int i = 0; i < context.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -384,7 +386,10 @@ namespace autonum
|
|||||||
@param hash : hash to have values inserted
|
@param hash : hash to have values inserted
|
||||||
@param autoNumName : name to use as key of hash
|
@param autoNumName : name to use as key of hash
|
||||||
*/
|
*/
|
||||||
void setFolioSequentialToHash(QStringList &list, QHash<QString, QStringList> &hash, const QString& autoNumName)
|
void setFolioSequentialToHash(QStringList &list,
|
||||||
|
QHash<QString,
|
||||||
|
QStringList> &hash,
|
||||||
|
const QString& autoNumName)
|
||||||
{
|
{
|
||||||
if (hash.isEmpty() || !hash.contains(autoNumName))
|
if (hash.isEmpty() || !hash.contains(autoNumName))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -161,7 +161,8 @@ NumStrategy::~NumStrategy() {}
|
|||||||
@brief NumStrategy::nextString
|
@brief NumStrategy::nextString
|
||||||
@return the next value of nc at position i
|
@return the next value of nc at position i
|
||||||
*/
|
*/
|
||||||
NumerotationContext NumStrategy::nextString (const NumerotationContext &nc, const int i) const {
|
NumerotationContext NumStrategy::nextString (const NumerotationContext &nc,
|
||||||
|
const int i) const {
|
||||||
QStringList strl = nc.itemAt(i);
|
QStringList strl = nc.itemAt(i);
|
||||||
NumerotationContext newnc;
|
NumerotationContext newnc;
|
||||||
newnc.addValue(strl.at(0), strl.at(1), strl.at(2).toInt());
|
newnc.addValue(strl.at(0), strl.at(1), strl.at(2).toInt());
|
||||||
@@ -170,9 +171,10 @@ NumerotationContext NumStrategy::nextString (const NumerotationContext &nc, cons
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief NumStrategy::nextNumber
|
@brief NumStrategy::nextNumber
|
||||||
@return the next value of @nc at position @i
|
@return the next value of nc at position i
|
||||||
*/
|
*/
|
||||||
NumerotationContext NumStrategy::nextNumber (const NumerotationContext &nc, const int i) const {
|
NumerotationContext NumStrategy::nextNumber (const NumerotationContext &nc,
|
||||||
|
const int i) const {
|
||||||
QStringList strl = nc.itemAt(i);
|
QStringList strl = nc.itemAt(i);
|
||||||
NumerotationContext newnc;
|
NumerotationContext newnc;
|
||||||
QString value = QString::number( (strl.at(1).toInt()) + (strl.at(2).toInt()) );
|
QString value = QString::number( (strl.at(1).toInt()) + (strl.at(2).toInt()) );
|
||||||
@@ -184,7 +186,8 @@ NumerotationContext NumStrategy::nextNumber (const NumerotationContext &nc, cons
|
|||||||
@brief NumStrategy::previousNumber
|
@brief NumStrategy::previousNumber
|
||||||
@return the previous value of nc at position i
|
@return the previous value of nc at position i
|
||||||
*/
|
*/
|
||||||
NumerotationContext NumStrategy::previousNumber(const NumerotationContext &nc, const int i) const {
|
NumerotationContext NumStrategy::previousNumber(const NumerotationContext &nc,
|
||||||
|
const int i) const {
|
||||||
QStringList strl = nc.itemAt(i);
|
QStringList strl = nc.itemAt(i);
|
||||||
NumerotationContext newnc;
|
NumerotationContext newnc;
|
||||||
QString value = QString::number( (strl.at(1).toInt()) - (strl.at(2).toInt()) );
|
QString value = QString::number( (strl.at(1).toInt()) - (strl.at(2).toInt()) );
|
||||||
|
|||||||
@@ -195,7 +195,9 @@ void AutoNumberingManagementW::on_buttonBox_clicked(QAbstractButton *button) {
|
|||||||
emit applyPressed();
|
emit applyPressed();
|
||||||
break;
|
break;
|
||||||
case QDialogButtonBox::HelpRole:
|
case QDialogButtonBox::HelpRole:
|
||||||
QMessageBox::information(this, tr("Auto Numbering Management", "title window"),
|
QMessageBox::information(
|
||||||
|
this,
|
||||||
|
tr("Auto Numbering Management", "title window"),
|
||||||
tr("In this Menu you can set whether you want the Auto Numberings to be updated or not."
|
tr("In this Menu you can set whether you want the Auto Numberings to be updated or not."
|
||||||
" For Element Auto Numbering you have 4 options of Update Policy:\n"
|
" For Element Auto Numbering you have 4 options of Update Policy:\n"
|
||||||
"-Both: both New and Existent Element labels will be updated. This is the default option.\n"
|
"-Both: both New and Existent Element labels will be updated. This is the default option.\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user