Remove unused methods in generic panel and elements panel.

Remove the class tree color animation


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4517 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-05-24 20:06:04 +00:00
parent cd9fb540b9
commit e5f85c542c
7 changed files with 0 additions and 243 deletions

View File

@@ -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<ElementsLocation> ElementsPanel::elementIntegrated(QETProject *project, const ElementsLocation &location) {
// the base implementation simply refreshes the adequate category and returns the list of added locations
QList<ElementsLocation> 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<QTreeWidgetItem *>() << 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<QTreeWidgetItem *> 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<QTreeWidgetItem *> &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);
}

View File

@@ -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<QTreeWidgetItem *> &);
void ensureHierarchyIsVisible(const QList<QTreeWidgetItem *> &);
void scrollToSelectedItem();
void highlightItems(const QList<QTreeWidgetItem *> &, const QObject * = 0, const char * = 0);
protected:
void dragEnterEvent(QDragEnterEvent *);
@@ -101,7 +99,6 @@ class ElementsPanel : public GenericPanel {
protected slots:
void panelContentChange();
virtual QList<ElementsLocation> elementIntegrated(QETProject *, const ElementsLocation &);
private:
virtual QTreeWidgetItem *addProject (QETProject *);

View File

@@ -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<ElementsLocation> GenericPanel::elementIntegrated(QETProject *project, const ElementsLocation &location) {
Q_UNUSED(project)
QList<ElementsLocation> 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.
*/

View File

@@ -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<ElementsLocation> elementIntegrated(QETProject *, const ElementsLocation &);
virtual void diagramTitleChanged(Diagram *, const QString &);
virtual void templatesCollectionChanged(TitleBlockTemplatesCollection*, const QString &);
virtual void diagramUsedTemplate(TitleBlockTemplatesCollection *, const QString &);

View File

@@ -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);

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include "treecoloranimation.h"
/**
Constructor
@param items List of items whose background color will be animated.
@param parent Parent QObject
*/
TreeColorAnimation::TreeColorAnimation(const QList<QTreeWidgetItem *> &items, QObject *parent) :
QVariantAnimation(parent),
items_(items)
{
}
/**
Destructor
*/
TreeColorAnimation::~TreeColorAnimation() {
}
/**
@return the list of items whose background color will be animated.
*/
QList<QTreeWidgetItem *> 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<QColor>());
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef TREE_COLOR_ANIMATION_H
#define TREE_COLOR_ANIMATION_H
#include <QtWidgets>
/**
This class allows animating a background color change for a
set of QTreeWidgetItem.
*/
class TreeColorAnimation : public QVariantAnimation {
// Constructors, destructor
public:
TreeColorAnimation(const QList<QTreeWidgetItem *> &items, QObject * = 0);
virtual ~TreeColorAnimation();
// methods
public:
QList<QTreeWidgetItem *> items() const;
protected:
void updateCurrentValue(const QVariant &);
// attributes
private:
QList<QTreeWidgetItem *> items_; ///< Items this object will animate
};
#endif