34 #include <QVBoxLayout> 36 #include <QDesktopServices> 55 qRegisterMetaType<QVector<int>>();
77 for (
int i=0; i <
m_model->rowCount() ; i++)
88 QList <QETProject *> prj; prj.append(project);
125 if (!location.
exist())
134 qde->statusBar()->clearMessage();
136 QWidget::leaveEvent(event);
173 m_tree_view->setDragDropMode(QAbstractItemView::DragDrop);
174 m_tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
178 m_tree_view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
212 connect(
m_tree_view, &QTreeView::doubleClicked, [
this](
const QModelIndex &index) {
216 connect(
m_tree_view, &QTreeView::entered, [
this] (
const QModelIndex &index) {
220 qde->statusBar()->showMessage(eci->
localName());
237 bool add_open_dir =
false;
298 QDesktopServices::openUrl(static_cast<FileElementCollectionItem*>(eci)->dirPath());
300 QDesktopServices::openUrl(QUrl(
"file:///" + static_cast<FileElementCollectionItem*>(eci)->dirPath()));
305 QDesktopServices::openUrl(static_cast<XmlProjectElementCollectionItem*>(eci)->project()->currentDir());
307 QDesktopServices::openUrl(QUrl(
"file:///" + static_cast<XmlProjectElementCollectionItem*>(eci)->project()->currentDir()));
320 if ( !(eci && eci->
isElement()) )
return;
325 app->openElementLocations(QList<ElementsLocation>() << location);
342 if (! (loc.isElement() && loc.exist() && loc.isFileSystem() && loc.collectionPath().startsWith(
"custom://")) )
return;
345 tr(
"Supprimer l'élément ?",
"message box title"),
346 tr(
"Êtes-vous sûr de vouloir supprimer cet élément ?\n",
"message box content"),
347 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
349 QFile file(loc.fileSystemPath());
357 tr(
"Suppression de l'élément",
"message box title"),
358 tr(
"La suppression de l'élément a échoué.",
"message box content"));
374 if (! (loc.isDirectory() && loc.exist() && loc.isFileSystem() && loc.collectionPath().startsWith(
"custom://")) )
return;
377 tr(
"Supprimer le dossier?",
"message box title"),
378 tr(
"Êtes-vous sûr de vouloir supprimer le dossier ?\n" 379 "Tout les éléments et les dossier contenus dans ce dossier seront supprimés.",
380 "message box content"),
381 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
383 QDir dir (loc.fileSystemPath());
384 if (dir.removeRecursively())
391 tr(
"Suppression du dossier",
"message box title"),
392 tr(
"La suppression du dossier a échoué.",
"message box content"));
413 if (ece.exec() == QDialog::Accepted)
432 if (new_dir_editor.exec() == QDialog::Accepted)
473 eci->setBackground(QBrush());
483 eci->setBackground(QBrush(QColor(255, 204, 0, 255)));
501 eci->setBackground(QBrush());
515 if (eci && eci->
isDir()) {
516 QString txt1 =
tr(
"Le dossier %1 contient").arg(eci->
localName());
517 QString txt2 =
tr(
"%n élément(s), répartie(s)",
"", eci->
elementsChild().size());
519 QString txt4 =
tr(
"Chemin de la collection : %1").arg(eci->
collectionPath());
522 txt5 =
tr(
"Chemin dans le système de fichiers : %1").arg(static_cast<FileElementCollectionItem*>(eci)->fileSystemPath());
525 tr(
"Propriété du dossier %1").arg(eci->
localName()),
526 txt1 +
" " + txt2 +
" " + txt3 +
"\n\n" + txt4 +
"\n" + txt5);
538 QList <QETProject *> project_list;
573 if (!location.
exist())
578 if (index.isValid()) {
579 QStandardItem *item =
m_model->itemFromIndex(index);
601 QModelIndex current_index =
m_tree_view->currentIndex();
613 if (current_index.isValid())
623 QStringList text_list = text.split(
"+", QString::SkipEmptyParts);
624 QModelIndexList match_index;
625 foreach (QString txt, text_list) {
627 Qt::UserRole+1, QVariant(txt), -1, Qt::MatchContains | Qt::MatchRecursive);
630 foreach(QModelIndex index, match_index)
641 for (
int i=0 ; i <
m_model->rowCount() ; i++)
654 m_tree_view->setRowHidden(index.row(), index.parent(), hide);
657 for (
int i=0 ; i<
m_model->rowCount(index) ; i++)
672 if (index.isValid()) {
687 if (!index.isValid())
The ElementCollectionItem class This class represent a item (a directory or an element) in a element ...
virtual void clearData()
ElementCollectionItem::clearData Reset the data.
void saveToLocation(ElementsLocation loc)
int type() const override
void preselectedLocation(const ElementsLocation &location)
NewElementWizard::preselectedLocation Select item in the tree view represented by location...
void highlightUnusedElement()
ElementsCollectionModel::highlightUnusedElement Highlight every unused element of managed project...
The ElementsTreeView class This class just reimplement startDrag from QTreeView, for set a custom pix...
QList< ElementCollectionItem * > directoriesChild() const
ElementCollectionItem::directoriesChild.
QString collectionPath() const override
FileElementCollectionItem::collectionPath.
The ElementsCategoryEditor class This class provides a dialog to edit an existing category or create ...
void loadingProgressValue(int)
QList< QETProject * > project() const
ElementsCollectionModel::project.
QList< ElementCollectionItem * > elementsChild() const
ElementCollectionItem::elementsChild.
void setUpData(ElementCollectionItem *eci)
The XmlProjectElementCollectionItem class This class specialise ElementCollectionItem for manage an x...
void removeProject(QETProject *project)
ElementsCollectionModel::removeProject Remove project from this model.
void loadCollections(bool common_collection, bool custom_collection, QList< QETProject *> projects)
ElementsCollectionModel::loadCollections Load the several collections in this model. Prefer use this method instead of addCommonCollection, addCustomCollection and addProject, because it use multithreading to speed up the loading. This method emit loadingMaxValue(int) for know the maximum progress value This method emit loadingProgressValue(int) for know the current progress value.
bool isCommonCollection() const
FileElementCollectionItem::isCommonCollection.
void addLocation(const ElementsLocation &location)
ElementsCollectionModel::addLocation Add the element or directory to this model. If the location is a...
bool exist() const
ElementsLocation::exist.
void loadingMaxValue(int)
virtual bool isElement() const =0
The FileElementCollectionItem class This class specialise ElementCollectionItem for manage a collecti...
virtual QString collectionPath() const =0
virtual bool isDir() const =0
static QETDiagramEditor * diagramEditorAncestorOf(const QWidget *child)
QETApp::diagramEditorAncestorOf.
QMessageBox::StandardButton question(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
QMessageBox::StandardButton information(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
bool isCollectionRoot() const override
FileElementCollectionItem::isCollectionRoot.
bool isCollectionRoot() const override
XmlProjectElementCollectionItem::isCollectionRoot.
bool isDir() const override
FileElementCollectionItem::isDir.
static QETApp * instance()
virtual QString localName()=0
QMessageBox::StandardButton warning(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
QModelIndex indexFromLocation(const ElementsLocation &location)
ElementsCollectionModel::indexFromLocation Return the index who represent . Index can be non valid...