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
This commit is contained in:
xavier
2012-02-06 22:13:39 +00:00
parent 7ca84724ae
commit 7661b2f47e
4 changed files with 49 additions and 0 deletions

View File

@@ -36,6 +36,38 @@ ElementsCollection::ElementsCollection(ElementsCollectionItem *parent) :
ElementsCollection::~ElementsCollection() { 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 @return toujours true
*/ */

View File

@@ -18,6 +18,7 @@
#ifndef ELEMENTS_COLLECTION_H #ifndef ELEMENTS_COLLECTION_H
#define ELEMENTS_COLLECTION_H #define ELEMENTS_COLLECTION_H
#include <QtCore> #include <QtCore>
#include <QIcon>
#include "elementscollectionitem.h" #include "elementscollectionitem.h"
class QETProject; class QETProject;
class ElementsCategory; class ElementsCategory;
@@ -41,6 +42,10 @@ class ElementsCollection : public ElementsCollectionItem {
// Implementations de methodes virtuelles pures des classes parentes // Implementations de methodes virtuelles pures des classes parentes
public: 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 isCollection() const;
virtual bool isRootCategory() const; virtual bool isRootCategory() const;
virtual bool isCategory() const; virtual bool isCategory() const;
@@ -87,8 +92,15 @@ class ElementsCollection : public ElementsCollectionItem {
virtual ElementsCollectionCache *cache() const; virtual ElementsCollectionCache *cache() const;
virtual void setCache(ElementsCollectionCache *); virtual void setCache(ElementsCollectionCache *);
signals:
void elementsCollectionChanged(ElementsCollection *);
// attributs // attributs
protected: 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 /// Protocole utilise pour acceder a cette collection
QString protocol_; QString protocol_;
/// Projet auquel appartient cette collection /// Projet auquel appartient cette collection

View File

@@ -256,6 +256,8 @@ void QETApp::newElementEditor() {
ElementsCollection *QETApp::commonElementsCollection() { ElementsCollection *QETApp::commonElementsCollection() {
if (!common_collection) { if (!common_collection) {
common_collection = new FileElementsCollection(QETApp::commonElementsDir()); 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 -> setProtocol("common");
common_collection -> setCache(collections_cache_); common_collection -> setCache(collections_cache_);
} }
@@ -268,6 +270,8 @@ ElementsCollection *QETApp::commonElementsCollection() {
ElementsCollection *QETApp::customElementsCollection() { ElementsCollection *QETApp::customElementsCollection() {
if (!custom_collection) { if (!custom_collection) {
custom_collection = new FileElementsCollection(QETApp::customElementsDir()); 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 -> setProtocol("custom");
custom_collection -> setCache(collections_cache_); custom_collection -> setCache(collections_cache_);
} }

View File

@@ -981,6 +981,7 @@ void QETProject::readElementsCollectionXml() {
// sinon lit cette collection // sinon lit cette collection
collection_ = new XmlElementsCollection(collection_root); collection_ = new XmlElementsCollection(collection_root);
} }
collection_ -> setTitle(tr("Collection embarqu\351e"));
collection_ -> setProtocol("embed"); collection_ -> setProtocol("embed");
collection_ -> setProject(this); collection_ -> setProject(this);
connect(collection_, SIGNAL(written()), this, SLOT(componentWritten())); connect(collection_, SIGNAL(written()), this, SLOT(componentWritten()));