digiKam
Digikam::SetupCollectionModel Class Reference
+ Inheritance diagram for Digikam::SetupCollectionModel:

Classes

class  Item
 

Public Types

enum  Category { CategoryLocal = 0 , CategoryRemovable = 1 , CategoryRemote = 2 , NumberOfCategories }
 
enum  Columns {
  ColumnStatus = 0 , ColumnName = 1 , ColumnPath = 2 , ColumnUpdateButton = 3 ,
  ColumnDeleteButton = 4 , NumberOfColumns
}
 
enum  SetupCollectionDataRole {
  IsCategoryRole = Qt::UserRole , CategoryButtonDisplayRole = Qt::UserRole + 1 , CategoryButtonMapId = Qt::UserRole + 2 , IsUpdateRole = Qt::UserRole + 3 ,
  UpdateDecorationRole = Qt::UserRole + 4 , UpdateMapId = Qt::UserRole + 5 , IsDeleteRole = Qt::UserRole + 6 , DeleteDecorationRole = Qt::UserRole + 7 ,
  DeleteMapId = Qt::UserRole + 8
}
 

Public Slots

void slotCategoryButtonPressed (int mappedId)
 
void slotDeletePressed (int mappedId)
 
void slotUpdatePressed (int mappedId)
 

Signals

void collectionsLoaded ()
 Emitted when all collections were loaded and the model reset in loadCollections. More...
 

Public Member Functions

void apply ()
 Apply the changed settings to CollectionManager. More...
 
QList< QModelIndex > categoryIndexes () const
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 QAbstractItemModel implementation. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QModelIndex indexForCategory (Category category) const
 
void loadCollections ()
 Read collections from CollectionManager. More...
 
QModelIndex parent (const QModelIndex &index) const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 
void setParentWidgetForDialogs (QWidget *const widget)
 Set a widget used as parent for dialogs and message boxes. More...
 
 SetupCollectionModel (QObject *const parent=nullptr)
 
 ~SetupCollectionModel () override
 

Protected Slots

void addCollection (int category)
 
void deleteCollection (int internalId)
 
void updateCollection (int internalId)
 

Protected Member Functions

bool askForNewCollectionCategory (int *const category)
 
bool askForNewCollectionPath (int category, QString *const newPath, QString *const newLabel)
 
int buttonMapId (const QModelIndex &index) const
 
int categoryButtonMapId (const QModelIndex &index) const
 
QModelIndex indexForId (int id, int column) const
 

Static Protected Member Functions

static Category typeToCategory (CollectionLocation::Type type)
 

Protected Attributes

QList< Itemm_collections
 
QWidget * m_dialogParentWidget
 

Member Enumeration Documentation

◆ Category

Enumerator
CategoryLocal 
CategoryRemovable 
CategoryRemote 
NumberOfCategories 

◆ Columns

Enumerator
ColumnStatus 
ColumnName 
ColumnPath 
ColumnUpdateButton 
ColumnDeleteButton 
NumberOfColumns 

◆ SetupCollectionDataRole

SetupCollectionModel is a model specialized for use in SetupCollectionTreeView. It provides a reads the current collections from CollectionManager, displays them in three categories, and supports adding and removing collections

Enumerator
IsCategoryRole 

Returns true if the model index is the index of a category.

CategoryButtonDisplayRole 

The text for the category button.

CategoryButtonMapId 
IsUpdateRole 

Returns true if the model index is the index of a button.

UpdateDecorationRole 

The pixmap of the button.

UpdateMapId 
IsDeleteRole 

Returns true if the model index is the index of a button.

DeleteDecorationRole 

The pixmap of the button.

DeleteMapId 

Constructor & Destructor Documentation

◆ SetupCollectionModel()

Digikam::SetupCollectionModel::SetupCollectionModel ( QObject *const  parent = nullptr)
explicit

Internal data structure:

The category entries get a model index with INTERNALID and are identified by their row(). The item entries get the index in m_collections as INTERNALID. No item is ever removed from m_collections, deleted entries are only marked as such.

Items have a location, a parentId, and a name and label field. parentId always contains the category, needed to implement parent(). The location is the location if it exists, or is null if the item was added. Name and label are null if unchanged, then the values from location are used. They are valid if edited (label) or the location was added (both valid, location null).

◆ ~SetupCollectionModel()

Digikam::SetupCollectionModel::~SetupCollectionModel ( )
override

Member Function Documentation

◆ addCollection

void Digikam::SetupCollectionModel::addCollection ( int  category)
protectedslot

◆ apply()

◆ askForNewCollectionCategory()

bool Digikam::SetupCollectionModel::askForNewCollectionCategory ( int *const  category)
protected

◆ askForNewCollectionPath()

◆ buttonMapId()

int Digikam::SetupCollectionModel::buttonMapId ( const QModelIndex &  index) const
protected

References index(), and INTERNALID.

Referenced by data().

◆ categoryButtonMapId()

int Digikam::SetupCollectionModel::categoryButtonMapId ( const QModelIndex &  index) const
protected

References index(), and INTERNALID.

Referenced by data().

◆ categoryIndexes()

QList< QModelIndex > Digikam::SetupCollectionModel::categoryIndexes ( ) const

◆ collectionsLoaded

void Digikam::SetupCollectionModel::collectionsLoaded ( )
signal

Emitted when all collections were loaded and the model reset in loadCollections.

Referenced by loadCollections().

◆ columnCount()

int Digikam::SetupCollectionModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

◆ data()

◆ deleteCollection

void Digikam::SetupCollectionModel::deleteCollection ( int  internalId)
protectedslot

◆ flags()

Qt::ItemFlags Digikam::SetupCollectionModel::flags ( const QModelIndex &  index) const
override

References ColumnName, index(), and INTERNALID.

◆ headerData()

QVariant Digikam::SetupCollectionModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
override

◆ index()

◆ indexForCategory()

QModelIndex Digikam::SetupCollectionModel::indexForCategory ( Category  category) const

◆ indexForId()

QModelIndex Digikam::SetupCollectionModel::indexForId ( int  id,
int  column 
) const
protected

◆ loadCollections()

void Digikam::SetupCollectionModel::loadCollections ( )

◆ parent()

QModelIndex Digikam::SetupCollectionModel::parent ( const QModelIndex &  index) const
override

◆ rowCount()

int Digikam::SetupCollectionModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

◆ setData()

bool Digikam::SetupCollectionModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
override

◆ setParentWidgetForDialogs()

void Digikam::SetupCollectionModel::setParentWidgetForDialogs ( QWidget *const  widget)

Set a widget used as parent for dialogs and message boxes.

References m_dialogParentWidget.

Referenced by Digikam::SetupCollectionTreeView::setModel().

◆ slotCategoryButtonPressed

void Digikam::SetupCollectionModel::slotCategoryButtonPressed ( int  mappedId)
slot

Forward category button clicked signals to this slot. mappedId is retrieved with the CategoryButtonMapId role for the model index of the button

References addCollection().

◆ slotDeletePressed

void Digikam::SetupCollectionModel::slotDeletePressed ( int  mappedId)
slot

References deleteCollection().

◆ slotUpdatePressed

void Digikam::SetupCollectionModel::slotUpdatePressed ( int  mappedId)
slot

Forward button clicked signals to this slot. mappedId is retrieved with the ButtonMapId role for the model index of the button

References updateCollection().

◆ typeToCategory()

◆ updateCollection

Member Data Documentation

◆ m_collections

◆ m_dialogParentWidget

QWidget* Digikam::SetupCollectionModel::m_dialogParentWidget
protected

The documentation for this class was generated from the following files: