diff --git a/sources/elementspanel.cpp b/sources/elementspanel.cpp index 1b5112b02..18673d9e1 100644 --- a/sources/elementspanel.cpp +++ b/sources/elementspanel.cpp @@ -26,7 +26,6 @@ #include "fileelementdefinition.h" #include "qeticons.h" #include "templatescollection.h" -#include "treecoloranimation.h" #include "element.h" /* @@ -347,34 +346,6 @@ void ElementsPanel::panelContentChange() { } } -/** - Inform this panel the project \a project has integrated the element at \a location -*/ -QList ElementsPanel::elementIntegrated(QETProject *project, const ElementsLocation &location) { - // the base implementation simply refreshes the adequate category and returns the list of added locations - QList added_locations = GenericPanel::elementIntegrated(project, location); - if (!added_locations.count() || !mustHighlightIntegratedElements()) { - return(added_locations); - } - - // the additional job of this method consists in displaying the integrated elements... - if (QTreeWidgetItem *integrated_element_qtwi = itemForElementsLocation(location)) { - ensureHierarchyIsVisible(QList() << integrated_element_qtwi); - scrollToItem(integrated_element_qtwi, QAbstractItemView::PositionAtCenter); - } - - // and make them "flash" (not too obviously though) so the user notices they have been integrated. - QList items; - foreach (ElementsLocation loc, added_locations) { - if (QTreeWidgetItem *added_item = itemForElementsLocation(loc)) { - items << added_item; - } - } - highlightItems(items, this, SLOT(scrollToSelectedItem())); - - return(added_locations); -} - /** Methode permettant d'ajouter un projet au panel d'elements. @param qtwi_parent QTreeWidgetItem parent sous lequel sera insere le projet @@ -548,15 +519,6 @@ int ElementsPanel::elementsCollectionItemsCount() { return(items_count); } -/** - @return true if freshly integrated elements should be highlighted, false otherwise. -*/ -bool ElementsPanel::mustHighlightIntegratedElements() const -{ - QSettings settings; - return(settings.value("diagrameditor/highlight-integrated-elements", true).toBool()); -} - /** * @brief ElementsPanel::reload * Reload the elements tree @@ -896,30 +858,3 @@ void ElementsPanel::scrollToSelectedItem() { scrollToItem(selected_items.first(), QAbstractItemView::PositionAtCenter); } } - -/** - Scroll to and highlight \a items. Once the animation is finished, the slot - \a method is called on the object \a receiver. -*/ -void ElementsPanel::highlightItems(const QList &items, const QObject *receiver, const char *method) { - TreeColorAnimation *animation1 = new TreeColorAnimation(items); - animation1 -> setStartValue(QColor(Qt::white)); - animation1 -> setEndValue(QColor(Qt::yellow)); - animation1 -> setDuration(400); - animation1 -> setEasingCurve(QEasingCurve::InQuad); - - TreeColorAnimation *animation2 = new TreeColorAnimation(items); - animation2 -> setStartValue(QColor(Qt::yellow)); - animation2 -> setEndValue(QColor(Qt::white)); - animation2 -> setDuration(500); - animation2 -> setEasingCurve(QEasingCurve::OutInQuint); - - QSequentialAnimationGroup *animation = new QSequentialAnimationGroup(this); - animation -> addAnimation(animation1); - animation -> addAnimation(new QPauseAnimation(700)); - animation -> addAnimation(animation2); - if (receiver) { - connect(animation, SIGNAL(finished()), receiver, method); - } - animation -> start(QAbstractAnimation::DeleteWhenStopped); -} diff --git a/sources/elementspanel.h b/sources/elementspanel.h index d9d030575..1758cdea8 100644 --- a/sources/elementspanel.h +++ b/sources/elementspanel.h @@ -63,7 +63,6 @@ class ElementsPanel : public GenericPanel { void reloadCollections(); int elementsCollectionItemsCount(); - bool mustHighlightIntegratedElements() const; signals: void requestForProject(QETProject *); @@ -87,7 +86,6 @@ class ElementsPanel : public GenericPanel { void applyCurrentFilter(const QList &); void ensureHierarchyIsVisible(const QList &); void scrollToSelectedItem(); - void highlightItems(const QList &, const QObject * = 0, const char * = 0); protected: void dragEnterEvent(QDragEnterEvent *); @@ -101,7 +99,6 @@ class ElementsPanel : public GenericPanel { protected slots: void panelContentChange(); - virtual QList elementIntegrated(QETProject *, const ElementsLocation &); private: virtual QTreeWidgetItem *addProject (QETProject *); diff --git a/sources/genericpanel.cpp b/sources/genericpanel.cpp index 2422efb23..5e59d5386 100644 --- a/sources/genericpanel.cpp +++ b/sources/genericpanel.cpp @@ -265,10 +265,6 @@ QTreeWidgetItem *GenericPanel::fillProjectItem(QTreeWidgetItem *project_qtwi, QE project, SIGNAL(projectDiagramsOrderChanged(QETProject *, int, int)), this, SLOT (projectDiagramsOrderChanged(QETProject *, int, int)) ); - connect( - project, SIGNAL(elementIntegrated(QETProject *, const ElementsLocation &)), - this, SLOT(elementIntegrated(QETProject *, const ElementsLocation &)) - ); } else { // remove diagrams unknown to the project (presumably removed) removeObsoleteItems(project -> diagrams(), project_qtwi, QET::Diagram, false); @@ -786,44 +782,6 @@ QTreeWidgetItem *GenericPanel::fillElementsCategoryItem(QTreeWidgetItem *categor return(fillItem(category_qtwi, options, freshly_created)); } -/** - Refresh elements category at \a location. - @return the refreshed tree item -*/ -QTreeWidgetItem *GenericPanel::refreshElementsCategory(const ElementsLocation &location) { - QTreeWidgetItem *item = itemForElementsLocation(location); - if (!item) return(0); - if (item -> type() != QET::ElementsCategory && item -> type() != QET::ElementsCollection) return(0); - QTreeWidgetItem *result = fillElementsCategoryItem( - item, - QETApp::collectionItem(location) -> toCategory(), - PanelOptions(QFlag(item -> data(0, GenericPanel::PanelFlags).toInt())), - false - ); - return(result); -} - -/** - Refresh element at \a location. - @return the refreshed tree item -*/ -QTreeWidgetItem *GenericPanel::refreshElement(const ElementsLocation &location) { - QTreeWidgetItem *item = itemForElementsLocation(location); - if (!item) return(0); - if (item -> type() != QET::Element) return(0); - - QTreeWidgetItem *parent = item -> parent(); - if (!parent) return(0); - - QTreeWidgetItem *result = updateElementItem( - item, - QETApp::collectionItem(location) -> toElement(), - PanelOptions(QFlag(parent -> data(0, GenericPanel::PanelFlags).toInt())), - false - ); - return(result); -} - /** */ @@ -1006,40 +964,6 @@ void GenericPanel::projectDiagramsOrderChanged(QETProject *project, int from, in emit(panelContentChanged()); } -/** - Inform this panel the project \a project has integrated the element at \a location -*/ -QList GenericPanel::elementIntegrated(QETProject *project, const ElementsLocation &location) { - Q_UNUSED(project) - QList added_locations; - - int i = 0; - ElementsLocation loc = location; - // starting from the provided location, goes up into the tree until a displayed location is reached - while (i < 100 && !(itemForElementsLocation(loc))) { - added_locations << loc; - loc = loc.parent(); - ++ i; - } - if (added_locations.count()) { - refreshElementsCategory(loc); - } else { - if (refreshElement(location)) { - added_locations << location; - } - } - - // Since we have refreshed the panel before the element is actually used by - // the diagram, it will appear as unused; we force it as used. - // FIXME a better solution would be to get warned when an element gets used - // or unused. - if (QTreeWidgetItem *integrated_element_qtwi = itemForElementsLocation(location)) { - integrated_element_qtwi -> setToolTip(0, location.toString()); - integrated_element_qtwi -> setBackground(0, QBrush()); - } - return(added_locations); -} - /** Inform this panel the diagram \a diagram has changed its title to \a title. */ diff --git a/sources/genericpanel.h b/sources/genericpanel.h index 8534a4337..b1bd25776 100644 --- a/sources/genericpanel.h +++ b/sources/genericpanel.h @@ -144,8 +144,6 @@ class GenericPanel : public QTreeWidget { virtual QTreeWidgetItem *getItemForElementsCategory(ElementsCategory *, bool * = 0); virtual QTreeWidgetItem *updateElementsCategoryItem(QTreeWidgetItem *, ElementsCategory *, PanelOptions = AddAllChild, bool = false); virtual QTreeWidgetItem *fillElementsCategoryItem (QTreeWidgetItem *, ElementsCategory *, PanelOptions = AddAllChild, bool = false); - virtual QTreeWidgetItem *refreshElementsCategory(const ElementsLocation &); - virtual QTreeWidgetItem *refreshElement(const ElementsLocation &); // elements methods public: @@ -167,7 +165,6 @@ class GenericPanel : public QTreeWidget { virtual void diagramAdded(QETProject *, Diagram *); virtual void diagramRemoved(QETProject *, Diagram *); virtual void projectDiagramsOrderChanged(QETProject *, int, int); - virtual QList elementIntegrated(QETProject *, const ElementsLocation &); virtual void diagramTitleChanged(Diagram *, const QString &); virtual void templatesCollectionChanged(TitleBlockTemplatesCollection*, const QString &); virtual void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &); diff --git a/sources/qetproject.h b/sources/qetproject.h index 225532070..9cea5a520 100644 --- a/sources/qetproject.h +++ b/sources/qetproject.h @@ -164,7 +164,6 @@ class QETProject : public QObject void diagramRemoved(QETProject *, Diagram *); void projectModified(QETProject *, bool); void projectDiagramsOrderChanged(QETProject *, int, int); - void elementIntegrated(QETProject *, const ElementsLocation &); void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &); void readOnlyChanged(QETProject *, bool); void reportPropertiesChanged(QString); diff --git a/sources/treecoloranimation.cpp b/sources/treecoloranimation.cpp deleted file mode 100644 index 703bbe96e..000000000 --- a/sources/treecoloranimation.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright 2006-2016 The QElectroTech Team - This file is part of QElectroTech. - - QElectroTech is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - QElectroTech is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QElectroTech. If not, see . -*/ -#include "treecoloranimation.h" - -/** - Constructor - @param items List of items whose background color will be animated. - @param parent Parent QObject -*/ -TreeColorAnimation::TreeColorAnimation(const QList &items, QObject *parent) : - QVariantAnimation(parent), - items_(items) -{ -} - -/** - Destructor -*/ -TreeColorAnimation::~TreeColorAnimation() { -} - -/** - @return the list of items whose background color will be animated. -*/ -QList TreeColorAnimation::items() const { - return(items_); -} - -/** - Apply the provided color to animated items. - @param color Color to be applied on animated items. -*/ -void TreeColorAnimation::updateCurrentValue(const QVariant &color) { - foreach (QTreeWidgetItem *item, items_) { - item -> setBackgroundColor(0, color.value()); - } -} diff --git a/sources/treecoloranimation.h b/sources/treecoloranimation.h deleted file mode 100644 index 8b04949fa..000000000 --- a/sources/treecoloranimation.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright 2006-2016 The QElectroTech Team - This file is part of QElectroTech. - - QElectroTech is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - QElectroTech is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QElectroTech. If not, see . -*/ -#ifndef TREE_COLOR_ANIMATION_H -#define TREE_COLOR_ANIMATION_H -#include - -/** - This class allows animating a background color change for a - set of QTreeWidgetItem. -*/ -class TreeColorAnimation : public QVariantAnimation { - // Constructors, destructor - public: - TreeColorAnimation(const QList &items, QObject * = 0); - virtual ~TreeColorAnimation(); - - // methods - public: - QList items() const; - - protected: - void updateCurrentValue(const QVariant &); - - // attributes - private: - QList items_; ///< Items this object will animate -}; -#endif