Remove unused methods

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4518 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun 2016-05-24 20:59:45 +00:00
parent e5f85c542c
commit a218cf5249
9 changed files with 27 additions and 237 deletions

View File

@ -558,55 +558,6 @@ void ElementsCategory::move(MoveElementsDescription *mvt_desc) {
}
}
/**
Cette methode supprime recursivement les elements inutilises dans le projet.
Si cette categorie n'est pas rattachee a un projet, elle ne fait rien
@param handler Gestionnaire d'erreurs a utiliser pour effectuer le
nettoyage. Si handler vaut 0, les erreurs, problemes et questions sont
purement et simplement ignores.
*/
void ElementsCategory::deleteUnusedElements(MoveElementsHandler *handler) {
// si cette categorie n'est pas rattachee a un projet, elle ne fait rien
QETProject *parent_project = project();
if (!parent_project) return;
// supprime les elements inutilises dans les sous-categories
foreach(ElementsCategory *sub_category, categories()) {
sub_category -> deleteUnusedElements(handler);
}
// supprime les elements inutilises dans cette categorie
foreach(ElementDefinition *element, elements()) {
if (!parent_project -> usesElement(element -> location())) {
bool element_deletion = element -> remove();
if (!element_deletion && handler) {
handler -> errorWithAnElement(element, tr("Impossible de supprimer l'élément"));
}
}
}
}
/**
Cette methode supprime toutes les sous-categories de cette categories qui
ne contiennent pas d'elements ou de categories contenant des elements.
@param handler Gestionnaire d'erreurs a utiliser pour effectuer le
nettoyage. Si handler vaut 0, les erreurs, problemes et questions sont
purement et simplement ignores.
*/
void ElementsCategory::deleteEmptyCategories(MoveElementsHandler *handler) {
// supprime les sous-categories qui ne comportent pas d'elements
foreach(ElementsCategory *sub_category, categories()) {
sub_category -> deleteEmptyCategories(handler);
sub_category -> reload();
if (!sub_category -> isEmpty()) {
bool category_deletion = sub_category -> remove();
if (!category_deletion && handler) {
handler -> errorWithACategory(sub_category, tr("Impossible de supprimer la catégorie"));
}
}
}
}
/**
@return true si cette collection est vide (pas de sous-categorie, pas
d'element), false sinon.

View File

@ -63,8 +63,6 @@ class ElementsCategory : public ElementsCollectionItem {
virtual ElementDefinition *toElement();
virtual ElementsCollectionItem *copy(ElementsCategory *, MoveElementsHandler *, bool = true);
virtual ElementsCollectionItem *move(ElementsCategory *, MoveElementsHandler *);
virtual void deleteUnusedElements(MoveElementsHandler *handler);
virtual void deleteEmptyCategories(MoveElementsHandler *handler);
virtual bool isEmpty();
virtual int count();

View File

@ -370,13 +370,6 @@ QTreeWidgetItem *ElementsPanel::addProject(QETProject *project) {
}
}
if (ElementsCollection *elmt_collection = project -> embeddedCollection()) {
if (QTreeWidgetItem *elmt_collection_qtwi = itemForElementsCollection(elmt_collection)) {
if (first_add) elmt_collection_qtwi -> setExpanded(true);
}
}
qtwi_project -> setStatusTip(0, tr("Double-cliquez pour réduire ou développer ce projet", "Status tip"));
return(qtwi_project);
@ -492,13 +485,6 @@ bool ElementsPanel::matchesFilter(const QTreeWidgetItem *item, QString filter) c
void ElementsPanel::reloadCollections() {
QETApp::commonElementsCollection() -> reload();
QETApp::customElementsCollection() -> reload();
// reloads collection of every project displayed in this panel
foreach(QETProject *project, projects_to_display_) {
if (ElementsCollection *project_collection = project -> embeddedCollection()) {
project_collection -> reload();
}
}
}
/**
@ -511,11 +497,7 @@ int ElementsPanel::elementsCollectionItemsCount() {
int items_count = 0;
items_count += QETApp::commonElementsCollection() -> count();
items_count += QETApp::customElementsCollection() -> count();
foreach(QETProject *project, projects_to_display_.values()) {
if (ElementsCollection *project_collection = project -> embeddedCollection()) {
items_count += project_collection -> count();
}
}
return(items_count);
}

View File

@ -290,23 +290,7 @@ QTreeWidgetItem *GenericPanel::fillProjectItem(QTreeWidgetItem *project_qtwi, QE
options
);
}
if (options & AddChildElementsCollections) {
QTreeWidgetItem *collection_qtwi = addElementsCollection(
project -> embeddedCollection(),
project_qtwi,
options
);
QString collection_whatsthis = tr("Ceci est une collection embarquée dans un fichier projet. Elle permet de stocker et gérer les éléments utilisés dans les schémas du projet parent.", "\"What's this\" tip");
collection_qtwi -> setWhatsThis(0, collection_whatsthis);
// special instructions for the integration category
if (QTreeWidgetItem *integration_qtwi = itemForElementsCategory(project -> integrationCategory())) {
QString integration_whats_this = tr("Cette catégorie d'éléments est utilisée pour intégrer automatiquement dans le projet tout élément utilisé sur un des schémas de ce projet.", "\"What's this\" tip");
integration_qtwi -> setWhatsThis(0, integration_whats_this);
}
}
return(fillItem(project_qtwi, options, freshly_created));
}
@ -593,14 +577,6 @@ QTreeWidgetItem *GenericPanel::addElementsCollection(ElementsCollection *collect
/**
*/
QTreeWidgetItem *GenericPanel::itemForElementsCollection(ElementsCollection *collection) {
if (!collection) return(0);
return(elements_.value(collection -> rootCategory() -> location(), 0));
}
/**
*/
QTreeWidgetItem *GenericPanel::getItemForElementsCollection(ElementsCollection *collection, bool *created) {
if (!collection) return(0);

View File

@ -130,7 +130,6 @@ class GenericPanel : public QTreeWidget {
public:
virtual QTreeWidgetItem *itemForElementsLocation(const ElementsLocation &);
virtual QTreeWidgetItem *addElementsCollection(ElementsCollection *, QTreeWidgetItem *, PanelOptions = AddAllChild);
virtual QTreeWidgetItem *itemForElementsCollection(ElementsCollection *);
protected:
virtual QTreeWidgetItem *getItemForElementsCollection(ElementsCollection *, bool * = 0);
virtual QTreeWidgetItem *updateElementsCollectionItem(QTreeWidgetItem *, ElementsCollection *, PanelOptions = AddAllChild, bool = false);

View File

@ -808,18 +808,6 @@ int ProjectView::cleanProject() {
if (clean_tbt -> isChecked()) {
project_->embeddedTitleBlockTemplatesCollection()->deleteUnusedTitleBlocKTemplates();
}
if (clean_elements -> isChecked()) {
InteractiveMoveElementsHandler *handler = new InteractiveMoveElementsHandler(this);
project_ -> cleanUnusedElements(handler);
delete handler;
++ clean_count;
}
if (clean_categories -> isChecked()) {
InteractiveMoveElementsHandler *handler = new InteractiveMoveElementsHandler(this);
project_ -> cleanEmptyCategories(handler);
delete handler;
++ clean_count;
}
}
return(clean_count);
}

View File

@ -325,11 +325,6 @@ QList<ElementsCollection *> QETApp::availableCollections() {
// collection perso
coll_list << customElementsCollection();
// collections embarquees
foreach(QETProject *opened_project, registered_projects_.values()) {
coll_list << opened_project -> embeddedCollection();
}
return(coll_list);
}
@ -1723,17 +1718,15 @@ void QETApp::printLicense() {
chemin correspond aussi bien a une collection qu'a sa categorie racine
@return l'item correspondant a l'adresse virtuelle path, ou 0 si celui-ci n'a pas ete trouve
*/
ElementsCollectionItem *QETApp::collectionItem(const ElementsLocation &location, bool prefer_collections) {
if (QETProject *target_project = location.project()) {
return(target_project -> embeddedCollection() -> item(location.path(), prefer_collections));
} else {
QString path(location.path());
if (path.startsWith("common://")) {
return(common_collection -> item(path, prefer_collections));
} else if (path.startsWith("custom://")) {
return(custom_collection -> item(path, prefer_collections));
}
ElementsCollectionItem *QETApp::collectionItem(const ElementsLocation &location, bool prefer_collections)
{
QString path(location.path());
if (path.startsWith("common://")) {
return(common_collection -> item(path, prefer_collections));
} else if (path.startsWith("custom://")) {
return(custom_collection -> item(path, prefer_collections));
}
return(0);
}
@ -1741,17 +1734,15 @@ ElementsCollectionItem *QETApp::collectionItem(const ElementsLocation &location,
@param location adresse virtuelle de la categorie a creer
@return la categorie creee, ou 0 en cas d'echec
*/
ElementsCategory *QETApp::createCategory(const ElementsLocation &location) {
if (QETProject *target_project = location.project()) {
return(target_project -> embeddedCollection() -> createCategory(location.path()));
} else {
QString path(location.path());
if (path.startsWith("common://")) {
return(common_collection -> createCategory(path));
} else if (path.startsWith("custom://")) {
return(custom_collection -> createCategory(path));
}
ElementsCategory *QETApp::createCategory(const ElementsLocation &location)
{
QString path(location.path());
if (path.startsWith("common://")) {
return(common_collection -> createCategory(path));
} else if (path.startsWith("custom://")) {
return(custom_collection -> createCategory(path));
}
return(0);
}
@ -1759,17 +1750,15 @@ ElementsCategory *QETApp::createCategory(const ElementsLocation &location) {
@param location adresse virtuelle de l'element a creer
@return l'element cree, ou 0 en cas d'echec
*/
ElementDefinition *QETApp::createElement(const ElementsLocation &location) {
if (QETProject *target_project = location.project()) {
return(target_project -> embeddedCollection() -> createElement(location.path()));
} else {
QString path(location.path());
if (path.startsWith("common://")) {
return(common_collection -> createElement(path));
} else if (path.startsWith("custom://")) {
return(custom_collection -> createElement(path));
}
ElementDefinition *QETApp::createElement(const ElementsLocation &location)
{
QString path(location.path());
if (path.startsWith("common://")) {
return(common_collection -> createElement(path));
} else if (path.startsWith("custom://")) {
return(custom_collection -> createElement(path));
}
return(0);
}

View File

@ -182,13 +182,6 @@ int QETProject::folioIndex(const Diagram *diagram) const {
return(diagrams_.indexOf(const_cast<Diagram *>(diagram)));
}
/**
@return la collection embarquee de ce projet
*/
ElementsCollection *QETProject::embeddedCollection() const {
return(collection_);
}
/**
* @brief QETProject::embeddedCollection
* @return The embedded collection
@ -695,8 +688,7 @@ bool QETProject::isEmpty() const {
// si le projet a un titre, on considere qu'il n'est pas vide
if (!project_title_.isEmpty()) return(false);
// si la collection du projet n'est pas vide, alors le projet n'est pas vide
if (!collection_ -> isEmpty()) return(false);
//@TODO check if the embedded element collection is empty
// compte le nombre de schemas non vides
int pertinent_diagrams = 0;
@ -707,18 +699,6 @@ bool QETProject::isEmpty() const {
return(pertinent_diagrams > 0);
}
/**
@return la categorie dediee aux elements integres automatiquement dans le
projet ou 0 si celle-ci n'a pu etre creee.
@see ensureIntegrationCategoryExists()
*/
ElementsCategory *QETProject::integrationCategory() const {
ElementsCategory *root_cat = rootCategory();
if (!root_cat) return(0);
return(root_cat -> category(integration_category_name));
}
/**
* @brief QETProject::importElement
* Import the element represented by @location to the embbeded collection of this project
@ -876,29 +856,6 @@ bool QETProject::usesTitleBlockTemplate(const TitleBlockTemplateLocation &locati
return(false);
}
/**
Supprime tous les elements inutilises dans le projet
@param handler Gestionnaire d'erreur
*/
void QETProject::cleanUnusedElements(MoveElementsHandler *handler) {
ElementsCategory *root_cat = rootCategory();
if (!root_cat) return;
root_cat -> deleteUnusedElements(handler);
}
/**
Supprime tous les categories vides (= ne contenant aucun element ou que des
categories vides) dans le projet
@param handler Gestionnaire d'erreur
*/
void QETProject::cleanEmptyCategories(MoveElementsHandler *handler) {
ElementsCategory *root_cat = rootCategory();
if (!root_cat) return;
root_cat -> deleteEmptyCategories(handler);
}
/**
Gere la reecriture du projet
*/
@ -1034,17 +991,6 @@ void QETProject::setupTitleBlockTemplatesCollection() {
);
}
/**
@return un pointeur vers la categorie racine de la collection embarquee, ou
0 si celle-ci n'est pas accessible.
*/
ElementsCategory *QETProject::rootCategory() const {
if (!collection_) return(0);
ElementsCategory *root_cat = collection_ -> rootCategory();
return(root_cat);
}
/**
* @brief QETProject::readProjectXml
* Read and make the project from an xml description
@ -1433,38 +1379,6 @@ bool QETProject::projectOptionsWereModified() {
return(modified_);
}
/**
Cette methode sert a reperer un projet vide, c-a-d un projet identique a ce
que l'on obtient en faisant Fichier > Nouveau.
@return true si la collection d'elements embarquee a ete modifiee.
Concretement, cette methode retourne true si la collection embarquee
contient 0 element et 1 categorie vide qui s'avere etre la categorie dediee
aux elements integres automatiquement dans le projet.
*/
bool QETProject::embeddedCollectionWasModified() {
ElementsCategory *root_cat = rootCategory();
if (!root_cat) return(false);
// la categorie racine doit comporter 0 element et 1 categorie
if (root_cat -> categories().count() != 1) return(true);
if (root_cat -> elements().count() != 0) return(true);
// la categorie d'integration doit exister
ElementsCategory *integ_cat = integrationCategory();
if (!integ_cat) return(true);
// la categorie d'integration doit avoir les noms par defaut
if (integ_cat -> categoryNames() != namesListForIntegrationCategory()) {
return(true);
}
// the integration category must be empty
if (integ_cat -> categories().count()) return(true);
if (integ_cat -> elements().count()) return(true);
return(false);
}
/**
@return the project-wide properties made available to child diagrams.
*/
@ -1493,7 +1407,6 @@ bool QETProject::projectWasModified() {
if ( projectOptionsWereModified() ||
!undo_stack_ -> isClean() ||
embeddedCollectionWasModified() ||
titleblocks_.templates().count() )
return(true);

View File

@ -83,7 +83,6 @@ class QETProject : public QObject
int getFolioSheetsQuantity() const; /// get the folio sheets quantity for this project
void setFolioSheetsQuantity(int); /// set the folio sheets quantity for this project
int folioIndex(const Diagram *) const;
ElementsCollection *embeddedCollection() const;
XmlElementCollection *embeddedElementCollection()const;
TitleBlockTemplatesProjectCollection *embeddedTitleBlockTemplatesCollection();
QString filePath();
@ -134,16 +133,12 @@ class QETProject : public QObject
bool isReadOnly() const;
void setReadOnly(bool);
bool isEmpty() const;
ElementsCategory *integrationCategory() const;
ElementsLocation importElement(ElementsLocation &location);
QString integrateTitleBlockTemplate(const TitleBlockTemplateLocation &, MoveTitleBlockTemplatesHandler *handler);
bool usesElement(const ElementsLocation &);
bool usesTitleBlockTemplate(const TitleBlockTemplateLocation &);
void cleanUnusedElements(MoveElementsHandler *);
void cleanEmptyCategories(MoveElementsHandler *);
bool projectWasModified();
bool projectOptionsWereModified();
bool embeddedCollectionWasModified();
DiagramContext projectProperties();
void setProjectProperties(const DiagramContext &);
QUndoStack* undoStack() {return undo_stack_;}
@ -179,7 +174,6 @@ class QETProject : public QObject
private:
void setupTitleBlockTemplatesCollection();
ElementsCategory *rootCategory() const;
void readProjectXml(QDomDocument &xml_project);
void readDiagramsXml(QDomDocument &xml_project);