Wrap code for better readability

This commit is contained in:
Simon De Backer
2020-08-19 21:27:14 +02:00
parent 666f20856e
commit cdb2e7b523
24 changed files with 258 additions and 112 deletions

View File

@@ -376,7 +376,10 @@ QString XmlElementCollection::addElement(ElementsLocation &location)
if (!element_file.exists())
return QString();
created_child = QETXML::fileSystemElementToXmlCollectionElement(m_dom_document, element_file);
created_child = QETXML::
fileSystemElementToXmlCollectionElement(
m_dom_document,
element_file);
}
//str is the path of a directory, we integrate a directory.
@@ -385,7 +388,10 @@ QString XmlElementCollection::addElement(ElementsLocation &location)
if (!dir.cd(str))
return QString();
created_child = QETXML::fileSystemDirToXmlCollectionDir(m_dom_document, dir);
created_child = QETXML::
fileSystemDirToXmlCollectionDir(
m_dom_document,
dir);
}
if(created_child.isNull())

View File

@@ -36,35 +36,56 @@ class XmlElementCollection : public QObject
public:
XmlElementCollection (QETProject *project);
XmlElementCollection (const QDomElement &dom_element, QETProject *project);
XmlElementCollection (const QDomElement &dom_element,
QETProject *project);
QDomElement root() const;
QDomElement importCategory() const;
QDomNodeList childs(const QDomElement &parent_element) const;
QDomElement child(const QDomElement &parent_element, const QString &child_name) const;
QDomElement child(const QDomElement &parent_element,
const QString &child_name) const;
QDomElement child(const QString &path) const;
QList<QDomElement> directories(const QDomElement &parent_element) const;
QStringList directoriesNames(const QDomElement &parent_element) const;
QList<QDomElement> elements(const QDomElement &parent_element) const;
QStringList elementsNames(const QDomElement &parent_element) const;
QList<QDomElement> directories(
const QDomElement &parent_element) const;
QStringList directoriesNames(
const QDomElement &parent_element) const;
QList<QDomElement> elements(
const QDomElement &parent_element) const;
QStringList elementsNames(
const QDomElement &parent_element) const;
QDomElement element(const QString &path) const;
QDomElement directory(const QString &path) const;
QString addElement (ElementsLocation &location);
bool addElementDefinition (const QString &dir_path, const QString &elmt_name, const QDomElement &xml_definition);
bool addElementDefinition (const QString &dir_path,
const QString &elmt_name,
const QDomElement &xml_definition);
bool removeElement(const QString& path);
ElementsLocation copy (ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString(), bool deep_copy = true);
ElementsLocation copy (ElementsLocation &source,
ElementsLocation &destination,
const QString& rename = QString(),
bool deep_copy = true);
bool exist (const QString &path) const;
bool createDir (const QString& path, const QString& name, const NamesList &name_list);
bool createDir (const QString& path,
const QString& name,
const NamesList &name_list);
bool removeDir (const QString& path);
QList <ElementsLocation> elementsLocation (QDomElement dom_element = QDomElement(), bool childs = true) const;
QList <ElementsLocation> elementsLocation (
QDomElement dom_element = QDomElement(),
bool childs = true) const;
ElementsLocation domToLocation(QDomElement dom_element) const;
void cleanUnusedElement();
void cleanUnusedDirectory();
private:
ElementsLocation copyDirectory(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString(), bool deep_copy = true);
ElementsLocation copyElement(ElementsLocation &source, ElementsLocation &destination, const QString& rename = QString());
ElementsLocation copyDirectory(
ElementsLocation &source,
ElementsLocation &destination,
const QString& rename = QString(),
bool deep_copy = true);
ElementsLocation copyElement(ElementsLocation &source,
ElementsLocation &destination,
const QString& rename = QString());
signals:
/**

View File

@@ -170,8 +170,11 @@ QETProject *XmlProjectElementCollectionItem::project() const
Use this method for set this item the root of the collection
@param project : project to manage the collection
@param set_data : if true, call setUpData for every child of this item
@param hide_element : bool
*/
void XmlProjectElementCollectionItem::setProject(QETProject *project, bool set_data, bool hide_element)
void XmlProjectElementCollectionItem::setProject(QETProject *project,
bool set_data,
bool hide_element)
{
if (m_project)
return;
@@ -271,11 +274,16 @@ void XmlProjectElementCollectionItem::populate(bool set_data, bool hide_element)
/**
@brief XmlProjectElementCollectionItem::setXmlElement
Set the managed content of this item
@param element : the dom element (directory or element), to be managed by this item
@param element :
the dom element (directory or element), to be managed by this item
@param project : the parent project of managed collection
@param set_data : if true, call setUpData for every child of this item
@param hide_element : bool
*/
void XmlProjectElementCollectionItem::setXmlElement(const QDomElement& element, QETProject *project, bool set_data, bool hide_element)
void XmlProjectElementCollectionItem::setXmlElement(const QDomElement& element,
QETProject *project,
bool set_data,
bool hide_element)
{
m_dom_element = element;
m_project = project;

View File

@@ -46,13 +46,18 @@ class XmlProjectElementCollectionItem : public ElementCollectionItem
void addChildAtPath(const QString &collection_name) override;
QETProject * project() const;
void setProject (QETProject *project, bool set_data = true, bool hide_element = false);
void setProject (QETProject *project,
bool set_data = true,
bool hide_element = false);
void setUpData() override;
void setUpIcon() override;
private:
void populate(bool set_data = true, bool hide_element = false);
void setXmlElement(const QDomElement& element, QETProject *project, bool set_data = true, bool hide_element = false);
void setXmlElement(const QDomElement& element,
QETProject *project,
bool set_data = true,
bool hide_element = false);
private:
QETProject *m_project = nullptr;