mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Wrap code for better readability
This commit is contained in:
@@ -61,7 +61,8 @@ QString FileElementCollectionItem::fileSystemPath() const
|
|||||||
if (isCollectionRoot())
|
if (isCollectionRoot())
|
||||||
return m_path;
|
return m_path;
|
||||||
|
|
||||||
FileElementCollectionItem *feci = static_cast<FileElementCollectionItem *> (parent());
|
FileElementCollectionItem *feci =
|
||||||
|
static_cast<FileElementCollectionItem *> (parent());
|
||||||
if (feci)
|
if (feci)
|
||||||
return feci->fileSystemPath() + "/" + m_path;
|
return feci->fileSystemPath() + "/" + m_path;
|
||||||
else
|
else
|
||||||
@@ -129,7 +130,8 @@ QString FileElementCollectionItem::localName()
|
|||||||
pugi::xml_document docu;
|
pugi::xml_document docu;
|
||||||
if(docu.load_file(str.toStdString().c_str()))
|
if(docu.load_file(str.toStdString().c_str()))
|
||||||
{
|
{
|
||||||
if (QString(docu.document_element().name()) == "qet-directory")
|
if (QString(docu.document_element().name())
|
||||||
|
== "qet-directory")
|
||||||
{
|
{
|
||||||
NamesList nl;
|
NamesList nl;
|
||||||
nl.fromXml(docu.document_element());
|
nl.fromXml(docu.document_element());
|
||||||
@@ -192,8 +194,10 @@ QString FileElementCollectionItem::collectionPath() const
|
|||||||
else
|
else
|
||||||
return "custom://";
|
return "custom://";
|
||||||
}
|
}
|
||||||
else if (parent() && parent()->type() == FileElementCollectionItem::Type) {
|
else if (parent() && parent()->type()
|
||||||
ElementCollectionItem *eci = static_cast<ElementCollectionItem*>(parent());
|
== FileElementCollectionItem::Type) {
|
||||||
|
ElementCollectionItem *eci =
|
||||||
|
static_cast<ElementCollectionItem*>(parent());
|
||||||
if (eci->isCollectionRoot())
|
if (eci->isCollectionRoot())
|
||||||
return eci->collectionPath() + m_path;
|
return eci->collectionPath() + m_path;
|
||||||
else
|
else
|
||||||
@@ -209,7 +213,8 @@ QString FileElementCollectionItem::collectionPath() const
|
|||||||
*/
|
*/
|
||||||
bool FileElementCollectionItem::isCollectionRoot() const
|
bool FileElementCollectionItem::isCollectionRoot() const
|
||||||
{
|
{
|
||||||
if (m_path == QETApp::commonElementsDirN() || m_path == QETApp::customElementsDirN())
|
if (m_path == QETApp::commonElementsDirN()
|
||||||
|
|| m_path == QETApp::customElementsDirN())
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
@@ -259,11 +264,16 @@ void FileElementCollectionItem::setUpData()
|
|||||||
if (isDir())
|
if (isDir())
|
||||||
{
|
{
|
||||||
localName();
|
localName();
|
||||||
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled);
|
setFlags(Qt::ItemIsSelectable
|
||||||
|
| Qt::ItemIsDragEnabled
|
||||||
|
| Qt::ItemIsDropEnabled
|
||||||
|
| Qt::ItemIsEnabled);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled);
|
setFlags(Qt::ItemIsSelectable
|
||||||
|
| Qt::ItemIsDragEnabled
|
||||||
|
| Qt::ItemIsEnabled);
|
||||||
|
|
||||||
//Set the local name and all informations of the element
|
//Set the local name and all informations of the element
|
||||||
//in the data Qt::UserRole+1, these data will be use for search.
|
//in the data Qt::UserRole+1, these data will be use for search.
|
||||||
@@ -340,7 +350,8 @@ void FileElementCollectionItem::populate(bool set_data, bool hide_element)
|
|||||||
QDir dir (fileSystemPath());
|
QDir dir (fileSystemPath());
|
||||||
|
|
||||||
//Get all directory in this directory.
|
//Get all directory in this directory.
|
||||||
for(auto str : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name))
|
for(auto str : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot,
|
||||||
|
QDir::Name))
|
||||||
{
|
{
|
||||||
FileElementCollectionItem *feci = new FileElementCollectionItem();
|
FileElementCollectionItem *feci = new FileElementCollectionItem();
|
||||||
appendRow(feci);
|
appendRow(feci);
|
||||||
@@ -354,7 +365,8 @@ void FileElementCollectionItem::populate(bool set_data, bool hide_element)
|
|||||||
|
|
||||||
//Get all elmt file in this directory
|
//Get all elmt file in this directory
|
||||||
dir.setNameFilters(QStringList() << "*.elmt");
|
dir.setNameFilters(QStringList() << "*.elmt");
|
||||||
for(auto str : dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name))
|
for(auto str : dir.entryList(QDir::Files | QDir::NoDotAndDotDot,
|
||||||
|
QDir::Name))
|
||||||
{
|
{
|
||||||
FileElementCollectionItem *feci = new FileElementCollectionItem();
|
FileElementCollectionItem *feci = new FileElementCollectionItem();
|
||||||
appendRow(feci);
|
appendRow(feci);
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ class FileElementCollectionItem : public ElementCollectionItem
|
|||||||
enum { Type = UserType+2 };
|
enum { Type = UserType+2 };
|
||||||
int type() const override { return Type;}
|
int type() const override { return Type;}
|
||||||
|
|
||||||
bool setRootPath(const QString& path, bool set_data = true, bool hide_element = false);
|
bool setRootPath(const QString& path,
|
||||||
|
bool set_data = true,
|
||||||
|
bool hide_element = false);
|
||||||
QString fileSystemPath() const;
|
QString fileSystemPath() const;
|
||||||
QString dirPath() const;
|
QString dirPath() const;
|
||||||
|
|
||||||
@@ -53,7 +55,9 @@ class FileElementCollectionItem : public ElementCollectionItem
|
|||||||
void setUpIcon() override;
|
void setUpIcon() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setPathName(const QString& path_name, bool set_data = true, bool hide_element = false);
|
void setPathName(const QString& path_name,
|
||||||
|
bool set_data = true,
|
||||||
|
bool hide_element = false);
|
||||||
void populate(bool set_data = true, bool hide_element = false);
|
void populate(bool set_data = true, bool hide_element = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -41,7 +41,17 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
private:
|
private:
|
||||||
ElementsPanel *elements_panel;
|
ElementsPanel *elements_panel;
|
||||||
QAction *open_directory, *copy_path;
|
QAction *open_directory, *copy_path;
|
||||||
QAction *prj_activate, *prj_close, *prj_edit_prop, *prj_prop_diagram, *prj_add_diagram, *prj_del_diagram, *prj_move_diagram_up, *prj_move_diagram_top, *prj_move_diagram_down, *prj_move_diagram_upx10, *prj_move_diagram_downx10;
|
QAction *prj_activate,
|
||||||
|
*prj_close,
|
||||||
|
*prj_edit_prop,
|
||||||
|
*prj_prop_diagram,
|
||||||
|
*prj_add_diagram,
|
||||||
|
*prj_del_diagram,
|
||||||
|
*prj_move_diagram_up,
|
||||||
|
*prj_move_diagram_top,
|
||||||
|
*prj_move_diagram_down,
|
||||||
|
*prj_move_diagram_upx10,
|
||||||
|
*prj_move_diagram_downx10;
|
||||||
QAction *tbt_add, *tbt_edit, *tbt_remove;
|
QAction *tbt_add, *tbt_edit, *tbt_remove;
|
||||||
QMenu *context_menu;
|
QMenu *context_menu;
|
||||||
QLineEdit *filter_textfield;
|
QLineEdit *filter_textfield;
|
||||||
@@ -87,7 +97,7 @@ class ElementsPanelWidget : public QWidget {
|
|||||||
void filterEdited(const QString &);
|
void filterEdited(const QString &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent (QKeyEvent *e) override;
|
void keyPressEvent (QKeyEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString previous_filter_;
|
QString previous_filter_;
|
||||||
|
|||||||
Reference in New Issue
Block a user