[qet] qet/qet: [4743] Elements collection widget: add entry 'directory propertie ' in the context menu |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 4743
Author: blacksun
Date: 2016-10-15 15:39:02 +0200 (Sat, 15 Oct 2016)
Log Message:
-----------
Elements collection widget: add entry 'directory propertie' in the context menu
Modified Paths:
--------------
trunk/sources/ElementsCollection/elementcollectionitem.cpp
trunk/sources/ElementsCollection/elementcollectionitem.h
trunk/sources/ElementsCollection/elementscollectionwidget.cpp
trunk/sources/ElementsCollection/elementscollectionwidget.h
Modified: trunk/sources/ElementsCollection/elementcollectionitem.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementcollectionitem.cpp 2016-10-14 14:59:18 UTC (rev 4742)
+++ trunk/sources/ElementsCollection/elementcollectionitem.cpp 2016-10-15 13:39:02 UTC (rev 4743)
@@ -193,6 +193,36 @@
}
/**
+ * @brief ElementCollectionItem::elementsChild
+ * @return Every elements child (direct and indirect) of this item
+ */
+QList<ElementCollectionItem *> ElementCollectionItem::elementsChild() const
+{
+ QList <ElementCollectionItem *> list = elementsDirectChild();
+
+ foreach (ElementCollectionItem *eci, directoriesChild())
+ list.append(eci->elementsDirectChild());
+
+ return list;
+}
+
+/**
+ * @brief ElementCollectionItem::directoriesChild
+ * @return Every directories child (direct and indirect) of this item
+ */
+QList<ElementCollectionItem *> ElementCollectionItem::directoriesChild() const
+{
+ QList<ElementCollectionItem *> list = directoriesDirectChild();
+ QList<ElementCollectionItem *> child_list;
+ foreach (ElementCollectionItem *eci, list) {
+ child_list.append(eci->directoriesChild());
+ }
+
+ list.append(child_list);
+ return list;
+}
+
+/**
* @brief ElementCollectionItem::items
* @return every childs of this item (direct and indirect childs)
*/
Modified: trunk/sources/ElementsCollection/elementcollectionitem.h
===================================================================
--- trunk/sources/ElementsCollection/elementcollectionitem.h 2016-10-14 14:59:18 UTC (rev 4742)
+++ trunk/sources/ElementsCollection/elementcollectionitem.h 2016-10-15 13:39:02 UTC (rev 4743)
@@ -53,6 +53,8 @@
QList<ElementCollectionItem *> elementsDirectChild() const;
QList<ElementCollectionItem *> directoriesDirectChild() const;
+ QList<ElementCollectionItem *> elementsChild() const;
+ QList<ElementCollectionItem *> directoriesChild() const;
QList<ElementCollectionItem *> items() const;
};
Modified: trunk/sources/ElementsCollection/elementscollectionwidget.cpp
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionwidget.cpp 2016-10-14 14:59:18 UTC (rev 4742)
+++ trunk/sources/ElementsCollection/elementscollectionwidget.cpp 2016-10-15 13:39:02 UTC (rev 4743)
@@ -127,6 +127,7 @@
m_new_element = new QAction(QET::Icons::ElementNew, tr("Nouvel élément"), this);
m_show_this_dir = new QAction(QET::Icons::ZoomDraw, tr("Afficher uniquement ce dossier"), this);
m_show_all_dir = new QAction(QET::Icons::ZoomOriginal, tr("Afficher tous les dossiers"), this);
+ m_dir_propertie = new QAction(QET::Icons::Folder, tr("Propriété du dossier"), this);
}
/**
@@ -184,6 +185,7 @@
connect(m_new_element, &QAction::triggered, this, &ElementsCollectionWidget::newElement);
connect(m_show_this_dir, &QAction::triggered, this, &ElementsCollectionWidget::showThisDir);
connect(m_show_all_dir, &QAction::triggered, this, &ElementsCollectionWidget::resetShowThisDir);
+ connect(m_dir_propertie, &QAction::triggered, this, &ElementsCollectionWidget::dirProperties);
connect(m_tree_view, &QTreeView::doubleClicked, [this](const QModelIndex &index) {
this->m_index_at_context_menu = index ;
@@ -242,6 +244,8 @@
//there is a current filtered dir, add entry to reset it
if (m_showed_index.isValid())
m_context_menu->addAction(m_show_all_dir);
+
+ m_context_menu->addAction(m_dir_propertie);
}
if (add_open_dir)
m_context_menu->addAction(m_open_dir);
@@ -473,6 +477,28 @@
}
/**
+ * @brief ElementsCollectionWidget::dirProperties
+ * Open an informative dialog about the curent index
+ */
+void ElementsCollectionWidget::dirProperties()
+{
+ ElementCollectionItem *eci = elementCollectionItemForIndex(m_index_at_context_menu);
+ if (eci && eci->isDir()) {
+ QString txt1 = tr("Le dossier %1 contient").arg(eci->localName());
+ QString txt2 = tr("%n élément(s), répartie(s)", "", eci->elementsChild().size());
+ QString txt3 = tr("dans %n dossier(s).", "" , eci->directoriesChild().size());
+ QString txt4 = tr("Chemin de la collection : %1").arg(eci->collectionPath());
+ QString txt5;
+ if (eci->type() == FileElementCollectionItem::Type) {
+ txt5 = tr("Chemin dans le système de fichiers : %1").arg(static_cast<FileElementCollectionItem*>(eci)->fileSystemPath());
+ }
+ QMessageBox::information(this,
+ tr("Propriété du dossier %1").arg(eci->localName()),
+ txt1 + " " + txt2 + " " + txt3 + "\n\n" + txt4 + "\n" + txt5);
+ }
+}
+
+/**
* @brief ElementsCollectionWidget::reload, the displayed collections.
*/
void ElementsCollectionWidget::reload()
@@ -629,5 +655,8 @@
* @return The internal pointer of index casted to ElementCollectionItem;
*/
ElementCollectionItem *ElementsCollectionWidget::elementCollectionItemForIndex(const QModelIndex &index) {
+ if (!index.isValid())
+ return nullptr;
+
return static_cast<ElementCollectionItem*>(m_model->itemFromIndex(index));
}
Modified: trunk/sources/ElementsCollection/elementscollectionwidget.h
===================================================================
--- trunk/sources/ElementsCollection/elementscollectionwidget.h 2016-10-14 14:59:18 UTC (rev 4742)
+++ trunk/sources/ElementsCollection/elementscollectionwidget.h 2016-10-15 13:39:02 UTC (rev 4743)
@@ -69,6 +69,7 @@
void newElement();
void showThisDir();
void resetShowThisDir();
+ void dirProperties();
void search();
void hideCollection(bool hide = true);
void hideItem(bool hide, const QModelIndex &index = QModelIndex(), bool recursive = true);
@@ -102,7 +103,8 @@
*m_new_directory,
*m_new_element,
*m_show_this_dir,
- *m_show_all_dir;
+ *m_show_all_dir,
+ *m_dir_propertie;
bool m_first_show = true;
QList<QETProject *> m_waiting_project;