• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

digikam

albummodel.h

Go to the documentation of this file.
00001 /* ============================================================
00002  *
00003  * This file is a part of digiKam project
00004  * http://www.digikam.org
00005  *
00006  * Date        : 2008-03-22
00007  * Description : Qt Model for Albums
00008  *
00009  * Copyright (C) 2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
00010  *
00011  * This program is free software; you can redistribute it
00012  * and/or modify it under the terms of the GNU General
00013  * Public License as published by the Free Software Foundation;
00014  * either version 2, or (at your option)
00015  * any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * ============================================================ */
00023 
00024 #ifndef ALBUMMODEL_H
00025 #define ALBUMMODEL_H
00026 
00027 // Qt includes.
00028 
00029 #include <QAbstractItemModel>
00030 
00031 // Local includes.
00032 
00033 #include "album.h"
00034 
00035 namespace Digikam
00036 {
00037 
00038 class AlbumManager;
00039 class AlbumModelPriv;
00040 
00041 class AbstractAlbumModel : public QAbstractItemModel
00042 {
00043     Q_OBJECT
00044 
00045 public:
00046 
00053     enum RootAlbumBehavior
00054     {
00057         IncludeRootAlbum,
00060         IgnoreRootAlbum
00061     };
00062 
00063     enum AlbumDataRole
00064     {
00066         AlbumTypeRole = Qt::UserRole,
00068         AlbumPointerRole = Qt::UserRole + 1
00069     };
00070 
00076     AbstractAlbumModel(Album::Type albumType, Album *rootAlbum, RootAlbumBehavior rootBehavior = IncludeRootAlbum,
00077                        QObject *parent = 0);
00078     ~AbstractAlbumModel();
00079 
00080     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00081     virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00082     virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
00083     virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
00084     virtual Qt::ItemFlags flags(const QModelIndex &index) const;
00085     virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
00086     virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
00087     virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
00088     virtual QModelIndex parent(const QModelIndex &index) const;
00089 
00090     virtual Qt::DropActions supportedDropActions() const;
00091     virtual QStringList mimeTypes() const;
00092     virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
00093     virtual QMimeData * mimeData(const QModelIndexList &indexes) const;
00094 
00095 protected:
00096 
00097     // these can be reimplemented in a subclass
00098     virtual QVariant decorationRole(Album *a) const;
00099     virtual QString columnHeader() const;
00100     virtual Qt::ItemFlags itemFlags(Album *album) const;
00101     virtual bool filterAlbum(Album *album) const;
00102 
00103     QModelIndex indexForAlbum(Album *album) const;
00104     Album *albumForIndex(const QModelIndex &index) const;
00105     Album *rootAlbum() const;
00106 
00107 protected slots:
00108 
00109     void slotAlbumAboutToBeAdded(Album *album, Album *parent, Album *prev);
00110     void slotAlbumAdded(Album *);
00111     void slotAlbumAboutToBeDeleted(Album *album);
00112     void slotAlbumHasBeenDeleted(void *);
00113     void slotAlbumsCleared();
00114     void slotAlbumIconChanged(Album* album);
00115     void slotAlbumRenamed(Album *album);
00116 
00117 private:
00118 
00119     AlbumModelPriv *d;
00120 };
00121 
00122 // ------------------------------------------------------------------
00123 
00124 class AbstractSpecificAlbumModel : public AbstractAlbumModel
00125 {
00126     Q_OBJECT
00127 
00128 public:
00129 
00131     AbstractSpecificAlbumModel(Album::Type albumType, Album *rootAlbum,
00132                                RootAlbumBehavior rootBehavior = IncludeRootAlbum,
00133                                QObject *parent = 0);
00134 
00135 protected:
00136 
00137     virtual QVariant decorationRole(Album *a) const = 0;
00138     virtual QString  columnHeader() const;
00139 
00140 protected slots:
00141 
00142     void slotGotThumbnailFromIcon(Album *album, const QPixmap& thumbnail);
00143     void slotThumbnailLost(Album *album);
00144     void slotReloadThumbnails();
00145 
00146 protected:
00147 
00148     void emitDataChangedForChildren(Album *album);
00149 
00150     QString m_columnHeader;
00151 };
00152 
00153 // ------------------------------------------------------------------
00154 
00155 class AbstractCheckableAlbumModel : public AbstractSpecificAlbumModel
00156 {
00157     Q_OBJECT
00158 
00159 public:
00160 
00163 
00164     AbstractCheckableAlbumModel(Album::Type albumType, Album *rootAlbum,
00165                                 RootAlbumBehavior rootBehavior = IncludeRootAlbum,
00166                                 QObject *parent = 0);
00167 
00169     void setCheckable(bool isCheckable);
00170     bool isCheckable() const;
00173     void setTristate(bool isTristate);
00174     bool isTristate() const;
00175 
00177     bool isChecked(Album *album) const;
00179     Qt::CheckState checkState(Album *album) const;
00180 
00182     void setChecked(Album *album, bool isChecked);
00184     void setCheckState(Album *album, Qt::CheckState state);
00185 
00187     QList<Album *> checkedAlbums() const;
00188 
00190     void resetCheckedAlbums();
00191 
00192 signals:
00193 
00196     void checkStateChanged(Album *album, int checkState);
00197 
00198 protected:
00199 
00200     virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00201     virtual Qt::ItemFlags flags(const QModelIndex &index) const;
00202     virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
00203 
00204 private:
00205 
00206     Qt::ItemFlags m_extraFlags;
00207     QHash<Album *, Qt::CheckState> m_checkedAlbums;
00208 };
00209 
00210 // ------------------------------------------------------------------
00211 
00212 class AlbumModel : public AbstractCheckableAlbumModel
00213 {
00214 public:
00215 
00217     AlbumModel(RootAlbumBehavior rootBehavior = IncludeRootAlbum, QObject *parent = 0);
00218 
00219 protected:
00220 
00221     virtual QVariant decorationRole(Album *a) const;
00222 };
00223 
00224 // ------------------------------------------------------------------
00225 
00226 class TagModel : public AbstractCheckableAlbumModel
00227 {
00228 public:
00229 
00231     TagModel(RootAlbumBehavior rootBehavior = IncludeRootAlbum, QObject *parent = 0);
00232 
00233 protected:
00234 
00235     virtual QVariant decorationRole(Album *a) const;
00236 };
00237 
00238 } // namespace Digikam
00239 
00240 #endif // ALBUMMODEL_H

digikam

Skip menu "digikam"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • digikam
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal