[qet] [1478] The "clean project" dialog is now able to clean unused title block template. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 1478
Author: xavier
Date: 2012-01-24 08:11:19 +0100 (Tue, 24 Jan 2012)
Log Message:
-----------
The "clean project" dialog is now able to clean unused title block template.
Modified Paths:
--------------
branches/0.3/sources/projectview.cpp
branches/0.3/sources/qetproject.cpp
branches/0.3/sources/qetproject.h
branches/0.3/sources/titleblock/templatescollection.cpp
branches/0.3/sources/titleblock/templatescollection.h
Modified: branches/0.3/sources/projectview.cpp
===================================================================
--- branches/0.3/sources/projectview.cpp 2012-01-23 20:36:51 UTC (rev 1477)
+++ branches/0.3/sources/projectview.cpp 2012-01-24 07:11:19 UTC (rev 1478)
@@ -643,11 +643,12 @@
}
/**
- Propose a l'utilisateur de nettoyer le projet ; cela inclut la possibilite :
- * de supprimer les elements inutilises dans le projet
- * de supprimer les categories vides
- @return le nombre de traitements effectues (0 si rien n'a ete fait, 1 ou
- 2 sinon)
+ Allow the user to clean the project, which includes:
+ * deleting unused title block templates
+ * deleting unused elements
+ * deleting empty categories
+ @return an integer value above zero if elements and/or categories were
+ cleaned.
*/
int ProjectView::cleanProject() {
if (!project_) return(0);
@@ -663,10 +664,12 @@
}
// construit un petit dialogue pour parametrer le nettoyage
+ QCheckBox *clean_tbt = new QCheckBox(tr("Supprimer les mod\350les de cartouche inutilis\xE9s dans le projet"));
QCheckBox *clean_elements = new QCheckBox(tr("Supprimer les \351l\351ments inutilis\351s dans le projet"));
QCheckBox *clean_categories = new QCheckBox(tr("Supprimer les cat\351gories vides"));
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ clean_tbt -> setChecked(true);
clean_elements -> setChecked(true);
clean_categories -> setChecked(true);
@@ -677,6 +680,7 @@
clean_dialog.setWindowTitle(tr("Nettoyer le projet", "window title"));
QVBoxLayout *clean_dialog_layout = new QVBoxLayout();
+ clean_dialog_layout -> addWidget(clean_tbt);
clean_dialog_layout -> addWidget(clean_elements);
clean_dialog_layout -> addWidget(clean_categories);
clean_dialog_layout -> addWidget(buttons);
@@ -687,6 +691,9 @@
int clean_count = 0;
if (clean_dialog.exec() == QDialog::Accepted) {
+ if (clean_tbt -> isChecked()) {
+ project_ -> cleanUnusedTitleBlocKTemplates();
+ }
if (clean_elements -> isChecked()) {
InteractiveMoveElementsHandler *handler = new InteractiveMoveElementsHandler(this);
project_ -> cleanUnusedElements(handler);
Modified: branches/0.3/sources/qetproject.cpp
===================================================================
--- branches/0.3/sources/qetproject.cpp 2012-01-23 20:36:51 UTC (rev 1477)
+++ branches/0.3/sources/qetproject.cpp 2012-01-24 07:11:19 UTC (rev 1478)
@@ -741,6 +741,13 @@
}
/**
+ Delete all title block templates not used in the project
+*/
+void QETProject::cleanUnusedTitleBlocKTemplates() {
+ titleblocks_.deleteUnusedTitleBlocKTemplates();
+}
+
+/**
Supprime tous les elements inutilises dans le projet
@param handler Gestionnaire d'erreur
*/
Modified: branches/0.3/sources/qetproject.h
===================================================================
--- branches/0.3/sources/qetproject.h 2012-01-23 20:36:51 UTC (rev 1477)
+++ branches/0.3/sources/qetproject.h 2012-01-24 07:11:19 UTC (rev 1478)
@@ -109,6 +109,7 @@
QString integrateTitleBlockTemplate(const TitleBlockTemplateLocation &, MoveTitleBlockTemplatesHandler *handler);
bool usesElement(const ElementsLocation &);
bool usesTitleBlockTemplate(const TitleBlockTemplateLocation &);
+ void cleanUnusedTitleBlocKTemplates();
void cleanUnusedElements(MoveElementsHandler *);
void cleanEmptyCategories(MoveElementsHandler *);
bool projectWasModified();
Modified: branches/0.3/sources/titleblock/templatescollection.cpp
===================================================================
--- branches/0.3/sources/titleblock/templatescollection.cpp 2012-01-23 20:36:51 UTC (rev 1477)
+++ branches/0.3/sources/titleblock/templatescollection.cpp 2012-01-24 07:11:19 UTC (rev 1478)
@@ -288,6 +288,19 @@
}
/**
+ Delete all title block templates not used within the parent project
+*/
+void TitleBlockTemplatesProjectCollection::deleteUnusedTitleBlocKTemplates() {
+ if (!project_) return;
+
+ foreach (QString template_name, templates()) {
+ if (!project_ -> usesTitleBlockTemplate(location(template_name))) {
+ removeTemplate(template_name);
+ }
+ }
+}
+
+/**
Constructor
@param path Path of the directory containing the collection
@param parent Parent QObject
Modified: branches/0.3/sources/titleblock/templatescollection.h
===================================================================
--- branches/0.3/sources/titleblock/templatescollection.h 2012-01-23 20:36:51 UTC (rev 1477)
+++ branches/0.3/sources/titleblock/templatescollection.h 2012-01-24 07:11:19 UTC (rev 1478)
@@ -96,6 +96,7 @@
virtual TitleBlockTemplateLocation location(const QString & = QString());
virtual bool isReadOnly(const QString & = QString()) const;
virtual void fromXml(const QDomElement &);
+ virtual void deleteUnusedTitleBlocKTemplates();
// attributes
private: