mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Elements collection widget: add entry 'directory propertie' in the context menu
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4743 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -192,6 +192,36 @@ QList<ElementCollectionItem *> ElementCollectionItem::directoriesDirectChild() c
|
|||||||
return dir_child;
|
return dir_child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
* @brief ElementCollectionItem::items
|
||||||
* @return every childs of this item (direct and indirect childs)
|
* @return every childs of this item (direct and indirect childs)
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ class ElementCollectionItem : public QStandardItem
|
|||||||
|
|
||||||
QList<ElementCollectionItem *> elementsDirectChild() const;
|
QList<ElementCollectionItem *> elementsDirectChild() const;
|
||||||
QList<ElementCollectionItem *> directoriesDirectChild() const;
|
QList<ElementCollectionItem *> directoriesDirectChild() const;
|
||||||
|
QList<ElementCollectionItem *> elementsChild() const;
|
||||||
|
QList<ElementCollectionItem *> directoriesChild() const;
|
||||||
QList<ElementCollectionItem *> items() const;
|
QList<ElementCollectionItem *> items() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ void ElementsCollectionWidget::setUpAction()
|
|||||||
m_new_element = new QAction(QET::Icons::ElementNew, tr("Nouvel élément"), this);
|
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_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_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 @@ void ElementsCollectionWidget::setUpConnection()
|
|||||||
connect(m_new_element, &QAction::triggered, this, &ElementsCollectionWidget::newElement);
|
connect(m_new_element, &QAction::triggered, this, &ElementsCollectionWidget::newElement);
|
||||||
connect(m_show_this_dir, &QAction::triggered, this, &ElementsCollectionWidget::showThisDir);
|
connect(m_show_this_dir, &QAction::triggered, this, &ElementsCollectionWidget::showThisDir);
|
||||||
connect(m_show_all_dir, &QAction::triggered, this, &ElementsCollectionWidget::resetShowThisDir);
|
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) {
|
connect(m_tree_view, &QTreeView::doubleClicked, [this](const QModelIndex &index) {
|
||||||
this->m_index_at_context_menu = index ;
|
this->m_index_at_context_menu = index ;
|
||||||
@@ -242,6 +244,8 @@ void ElementsCollectionWidget::customContextMenu(const QPoint &point)
|
|||||||
//there is a current filtered dir, add entry to reset it
|
//there is a current filtered dir, add entry to reset it
|
||||||
if (m_showed_index.isValid())
|
if (m_showed_index.isValid())
|
||||||
m_context_menu->addAction(m_show_all_dir);
|
m_context_menu->addAction(m_show_all_dir);
|
||||||
|
|
||||||
|
m_context_menu->addAction(m_dir_propertie);
|
||||||
}
|
}
|
||||||
if (add_open_dir)
|
if (add_open_dir)
|
||||||
m_context_menu->addAction(m_open_dir);
|
m_context_menu->addAction(m_open_dir);
|
||||||
@@ -472,6 +476,28 @@ void ElementsCollectionWidget::resetShowThisDir()
|
|||||||
search();
|
search();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
* @brief ElementsCollectionWidget::reload, the displayed collections.
|
||||||
*/
|
*/
|
||||||
@@ -629,5 +655,8 @@ void ElementsCollectionWidget::showAndExpandItem(const QModelIndex &index, bool
|
|||||||
* @return The internal pointer of index casted to ElementCollectionItem;
|
* @return The internal pointer of index casted to ElementCollectionItem;
|
||||||
*/
|
*/
|
||||||
ElementCollectionItem *ElementsCollectionWidget::elementCollectionItemForIndex(const QModelIndex &index) {
|
ElementCollectionItem *ElementsCollectionWidget::elementCollectionItemForIndex(const QModelIndex &index) {
|
||||||
|
if (!index.isValid())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
return static_cast<ElementCollectionItem*>(m_model->itemFromIndex(index));
|
return static_cast<ElementCollectionItem*>(m_model->itemFromIndex(index));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ class ElementsCollectionWidget : public QWidget
|
|||||||
void newElement();
|
void newElement();
|
||||||
void showThisDir();
|
void showThisDir();
|
||||||
void resetShowThisDir();
|
void resetShowThisDir();
|
||||||
|
void dirProperties();
|
||||||
void search();
|
void search();
|
||||||
void hideCollection(bool hide = true);
|
void hideCollection(bool hide = true);
|
||||||
void hideItem(bool hide, const QModelIndex &index = QModelIndex(), bool recursive = true);
|
void hideItem(bool hide, const QModelIndex &index = QModelIndex(), bool recursive = true);
|
||||||
@@ -102,7 +103,8 @@ class ElementsCollectionWidget : public QWidget
|
|||||||
*m_new_directory,
|
*m_new_directory,
|
||||||
*m_new_element,
|
*m_new_element,
|
||||||
*m_show_this_dir,
|
*m_show_this_dir,
|
||||||
*m_show_all_dir;
|
*m_show_all_dir,
|
||||||
|
*m_dir_propertie;
|
||||||
|
|
||||||
bool m_first_show = true;
|
bool m_first_show = true;
|
||||||
QList<QETProject *> m_waiting_project;
|
QList<QETProject *> m_waiting_project;
|
||||||
|
|||||||
Reference in New Issue
Block a user