The "clean project" dialog is now able to clean unused title block template.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1478 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-01-24 07:11:19 +00:00
parent 7f9d792368
commit cae43d0fc1
5 changed files with 34 additions and 5 deletions

View File

@@ -643,11 +643,12 @@ bool ProjectView::saveAll() {
}
/**
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 @@ int ProjectView::cleanProject() {
}
// construit un petit dialogue pour parametrer le nettoyage
QCheckBox *clean_tbt = new QCheckBox(tr("Supprimer les mod\350les de cartouche inutilis<69>s 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 @@ int ProjectView::cleanProject() {
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 ProjectView::cleanProject() {
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);

View File

@@ -740,6 +740,13 @@ bool QETProject::usesTitleBlockTemplate(const TitleBlockTemplateLocation &locati
return(false);
}
/**
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

View File

@@ -109,6 +109,7 @@ class QETProject : public QObject {
QString integrateTitleBlockTemplate(const TitleBlockTemplateLocation &, MoveTitleBlockTemplatesHandler *handler);
bool usesElement(const ElementsLocation &);
bool usesTitleBlockTemplate(const TitleBlockTemplateLocation &);
void cleanUnusedTitleBlocKTemplates();
void cleanUnusedElements(MoveElementsHandler *);
void cleanEmptyCategories(MoveElementsHandler *);
bool projectWasModified();

View File

@@ -287,6 +287,19 @@ void TitleBlockTemplatesProjectCollection::fromXml(const QDomElement &xml_elemen
}
}
/**
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

View File

@@ -96,6 +96,7 @@ class TitleBlockTemplatesProjectCollection : public TitleBlockTemplatesCollectio
virtual TitleBlockTemplateLocation location(const QString & = QString());
virtual bool isReadOnly(const QString & = QString()) const;
virtual void fromXml(const QDomElement &);
virtual void deleteUnusedTitleBlocKTemplates();
// attributes
private: