Sayonara Player
Public Types | Public Member Functions | Protected Member Functions | List of all members
Library::ItemModel Class Referenceabstract

The ItemModel is intended to abstract the various views. It supports searching, selections and a library. More...

#include <ItemModel.h>

Inheritance diagram for Library::ItemModel:
SearchableModel< Model > SearchableModelInterface Library::AlbumModel Library::ArtistModel Library::CoverModel Library::TrackModel

Public Types

using ExtraTriggerMap = QMap< QChar, QString >
 

Public Member Functions

 ItemModel (QObject *parent, AbstractLibrary *library)
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
bool set_header_data (const QStringList &names)
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QModelIndexList search_results (const QString &substr) override
 
virtual bool is_selected (int id) const final
 
virtual const Util::Set< Id > & selections () const =0
 returns a set of the selected ids
 
virtual IndexSet selected_indexes () const
 
virtual int searchable_column () const =0
 the index of the searchable column. This is the column where the text is searched for a certain searchstring
 
virtual QString searchable_string (int row) const =0
 here, the searchable string can even be refined. Maybe we just want to search within a substring indicated by the row More...
 
virtual Id id_by_index (int row) const =0
 return the current id for a given row More...
 
virtual Cover::Location cover (const IndexSet &rows) const =0
 return the cover for multiple rows. if rows.size() > 1, an invalid, default constructed cover location is usually shown More...
 
virtual const MetaDataListmimedata_tracks () const =0
 return the tracks which belong to the selections. If an album is selected for example, all tracks of that album should be returned More...
 
Gui::CustomMimeDatacustom_mimedata () const
 
void refresh_data (int *n_rows_before=nullptr, int *n_rows_after=nullptr)
 
virtual bool has_items () const override
 
virtual ExtraTriggerMap getExtraTriggers ()
 
virtual ::Library::SearchModeMask search_mode () const final
 

Protected Member Functions

AbstractLibrarylibrary ()
 
const AbstractLibrarylibrary () const
 

Detailed Description

The ItemModel is intended to abstract the various views. It supports searching, selections and a library.

Member Function Documentation

◆ cover()

virtual Cover::Location Library::ItemModel::cover ( const IndexSet rows) const
pure virtual

return the cover for multiple rows. if rows.size() > 1, an invalid, default constructed cover location is usually shown

Parameters
rows
Returns

Implemented in Library::CoverModel, Library::TrackModel, Library::AlbumModel, and Library::ArtistModel.

◆ id_by_index()

virtual Id Library::ItemModel::id_by_index ( int  row) const
pure virtual

return the current id for a given row

Parameters
row
Returns

Implemented in Library::TrackModel, Library::ArtistModel, Library::AlbumModel, and Library::CoverModel.

◆ mimedata_tracks()

virtual const MetaDataList& Library::ItemModel::mimedata_tracks ( ) const
pure virtual

return the tracks which belong to the selections. If an album is selected for example, all tracks of that album should be returned

Returns

Implemented in Library::CoverModel, Library::AlbumModel, Library::TrackModel, and Library::ArtistModel.

◆ searchable_string()

virtual QString Library::ItemModel::searchable_string ( int  row) const
pure virtual

here, the searchable string can even be refined. Maybe we just want to search within a substring indicated by the row

Parameters
row
Returns

Implemented in Library::TrackModel, Library::AlbumModel, Library::ArtistModel, and Library::CoverModel.