From 7661b2f47e55391c724fad4e01f6faf6730ffa3c Mon Sep 17 00:00:00 2001 From: xavier Date: Mon, 6 Feb 2012 22:13:39 +0000 Subject: [PATCH] Elements collection now have a title and an icon. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1491 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/elementscollection.cpp | 32 ++++++++++++++++++++++++++++++++ sources/elementscollection.h | 12 ++++++++++++ sources/qetapp.cpp | 4 ++++ sources/qetproject.cpp | 1 + 4 files changed, 49 insertions(+) diff --git a/sources/elementscollection.cpp b/sources/elementscollection.cpp index aaf3d0326..f1ba58925 100644 --- a/sources/elementscollection.cpp +++ b/sources/elementscollection.cpp @@ -36,6 +36,38 @@ ElementsCollection::ElementsCollection(ElementsCollectionItem *parent) : ElementsCollection::~ElementsCollection() { } +/** + @return the title for this collection +*/ +QString ElementsCollection::title() const { + return(title_); +} + +/** + @param title New title for this collection +*/ +void ElementsCollection::setTitle(const QString &title) { + if (title_ == title) return; + title_ = title; + emit(elementsCollectionChanged(this)); +} + +/** + @return the icon for this collection +*/ +QIcon ElementsCollection::icon() const { + return(icon_); +} + +/** + @param icon the icon for this collection +*/ +void ElementsCollection::setIcon(const QIcon &icon) { + if (icon_.cacheKey() == icon.cacheKey()) return; + icon_ = icon; + emit(elementsCollectionChanged(this)); +} + /** @return toujours true */ diff --git a/sources/elementscollection.h b/sources/elementscollection.h index 08b16fa57..6e49de240 100644 --- a/sources/elementscollection.h +++ b/sources/elementscollection.h @@ -18,6 +18,7 @@ #ifndef ELEMENTS_COLLECTION_H #define ELEMENTS_COLLECTION_H #include +#include #include "elementscollectionitem.h" class QETProject; class ElementsCategory; @@ -41,6 +42,10 @@ class ElementsCollection : public ElementsCollectionItem { // Implementations de methodes virtuelles pures des classes parentes public: + virtual QString title() const; + virtual void setTitle(const QString &); + virtual QIcon icon() const; + virtual void setIcon(const QIcon &); virtual bool isCollection() const; virtual bool isRootCategory() const; virtual bool isCategory() const; @@ -87,8 +92,15 @@ class ElementsCollection : public ElementsCollectionItem { virtual ElementsCollectionCache *cache() const; virtual void setCache(ElementsCollectionCache *); + signals: + void elementsCollectionChanged(ElementsCollection *); + // attributs protected: + /// Title to be used when referring to this collection + QString title_; + /// Icon to be displayed when representing this collection + QIcon icon_; /// Protocole utilise pour acceder a cette collection QString protocol_; /// Projet auquel appartient cette collection diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index f16cffc1a..317fcf417 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -256,6 +256,8 @@ void QETApp::newElementEditor() { ElementsCollection *QETApp::commonElementsCollection() { if (!common_collection) { common_collection = new FileElementsCollection(QETApp::commonElementsDir()); + common_collection -> setTitle(tr("Collection QET")); + common_collection -> setIcon(QIcon(":/ico/16x16/qet.png")); common_collection -> setProtocol("common"); common_collection -> setCache(collections_cache_); } @@ -268,6 +270,8 @@ ElementsCollection *QETApp::commonElementsCollection() { ElementsCollection *QETApp::customElementsCollection() { if (!custom_collection) { custom_collection = new FileElementsCollection(QETApp::customElementsDir()); + custom_collection -> setTitle(tr("Collection utilisateur")); + custom_collection -> setIcon(QIcon(":/ico/16x16/go-home.png")); custom_collection -> setProtocol("custom"); custom_collection -> setCache(collections_cache_); } diff --git a/sources/qetproject.cpp b/sources/qetproject.cpp index 817914d39..1e65d699c 100644 --- a/sources/qetproject.cpp +++ b/sources/qetproject.cpp @@ -981,6 +981,7 @@ void QETProject::readElementsCollectionXml() { // sinon lit cette collection collection_ = new XmlElementsCollection(collection_root); } + collection_ -> setTitle(tr("Collection embarqu\351e")); collection_ -> setProtocol("embed"); collection_ -> setProject(this); connect(collection_, SIGNAL(written()), this, SLOT(componentWritten()));