Songbook-Client  0.7
This application is a manager of customguitar songbooks
 All Classes Files Functions Variables Enumerations Enumerator Pages
Public Types | Public Slots | Signals | Public Member Functions | Properties
CLibrary Class Reference

CLibrary is the base model that corresponds to the list of songs. More...

#include <library.hh>

List of all members.

Public Types

enum  Roles {
  TitleRole = Qt::UserRole + 1, ArtistRole = Qt::UserRole + 2, AlbumRole = Qt::UserRole + 3, CoverRole = Qt::UserRole + 4,
  LilypondRole = Qt::UserRole + 5, LanguageRole = Qt::UserRole + 6, PathRole = Qt::UserRole + 7, CoverSmallRole = Qt::UserRole + 8,
  CoverFullRole = Qt::UserRole + 9, RelativePathRole = Qt::UserRole + 10, MaxRole = RelativePathRole
}

Public Slots

void readSettings ()
void update ()

Signals

void wasModified ()
void directoryChanged (const QDir &directory)

Public Member Functions

 CLibrary (CMainWindow *parent)
 Constructor.
 ~CLibrary ()
 Destructor.
void writeSettings ()
bool checkSongbookPath (const QString &path)
QString findSongbookPath ()
QDir directory () const
void setDirectory (const QString &directory)
void setDirectory (const QDir &directory)
QStringList templates () const
QAbstractListModel * completionModel () const
QAbstractListModel * artistCompletionModel () const
QAbstractListModel * albumCompletionModel () const
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
virtual int rowCount (const QModelIndex &index=QModelIndex()) const
virtual int columnCount (const QModelIndex &index=QModelIndex()) const
QString pathToSong (const QString &artist, const QString &title) const
QString pathToSong (Song &song) const
void addSong (const Song &song, bool reset=false)
void addSong (const QString &path)
void addSongs (const QStringList &paths)
bool containsSong (const QString &path)
void removeSong (const QString &path)
int getSongIndex (const QString &path) const
Song getSong (const QString &path) const
void loadSong (const QString &path, Song *song)
void createArtistDirectory (Song &song)
void saveSong (Song &song)
void saveCover (Song &song, const QImage &cover)
void deleteSong (const QString &path)

Properties

QDir directory

Detailed Description

CLibrary is the base model that corresponds to the list of songs.

A CLibrary is a list of Song objects (structure representing .sg files) that are fetched from a local directory.

This model is used to build an intermediate model (CSongSortFilterProxyModel) that allows filtering options, and is then presented in the library tab (CTabWidget) of the main window (CMainWindow) through its associated view (CLibraryView).


Member Enumeration Documentation

Each Song in the CLibrary has a set of data elements associated with it, each with its own role. The roles are used by the view to indicate to the model which type of data it needs.

Enumerator:
TitleRole 

the title of the song item.

ArtistRole 

the artist of the song item.

AlbumRole 

the album of the song item.

CoverRole 

the cover of the song item.

LilypondRole 

whether or not the song item contains lilypond music sheets.

LanguageRole 

the language of the song item.

PathRole 

the absolute path to the .sg file corresponding to the song item.

CoverSmallRole 

the thumbnail cover (22x22) of the song item.

CoverFullRole 

the full cover (128x128) of the song item.

RelativePathRole 

the relative path to the .sg file corresponding to the song item (from the base directory of the songbook).


Member Function Documentation

void CLibrary::addSong ( const Song song,
bool  reset = false 
)

Adds a the song song to the library. If reset is true, the whole library is parsed again.

See also:
addSongs
void CLibrary::addSong ( const QString &  path)

A Song object is built from the file path and is added to the library.

See also:
addSongs
void CLibrary::addSongs ( const QStringList &  paths)

Song objects are built from the files in paths and are added to the library.

See also:
addSong
QAbstractListModel * CLibrary::albumCompletionModel ( ) const

Returns the album completion model associated with the library. The completion model is based on the list of words from the album column.

See also:
completionModel, artistCompletionModel
QAbstractListModel * CLibrary::artistCompletionModel ( ) const

Returns the artist completion model associated with the library. The completion model is based on the list of words from the artist column.

See also:
completionModel, albumCompletionModel
int CLibrary::columnCount ( const QModelIndex &  index = QModelIndex()) const
virtual

Reimplements QAbstractTableModel::columnCount. Returns 6 as the number of columns for a song item (title, artist, path, album, lilypond, language).

See also:
rowCount
QAbstractListModel * CLibrary::completionModel ( ) const

Returns the completion model associated with the library. The completion model isi based on the list of words from title, artist and album columns.

See also:
artistCompletionModel, albumCompletionModel
bool CLibrary::containsSong ( const QString &  path)

Returns true if the song path is already in the library.

See also:
addSong, removeSong
void CLibrary::createArtistDirectory ( Song song)

Creates the artist subdirectory for the song song (if required).

QVariant CLibrary::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const

Reimplements QAbstractTableModel::data. Returns the data at position index for the given role.

See also:
headerData
void CLibrary::deleteSong ( const QString &  path)

Removes the file path from the library.

QDir CLibrary::directory ( ) const

Returns the directory of the library.

See also:
setDirectory
Song CLibrary::getSong ( const QString &  path) const

Returns the Song object whose path is path from the library.

See also:
getSongIndex
int CLibrary::getSongIndex ( const QString &  path) const

Returns the index of the song path from the library.

See also:
getSong
QVariant CLibrary::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const

Reimplements QAbstractTableModel::headerData.

See also:
data
void CLibrary::loadSong ( const QString &  path,
Song song 
)

Loads a Song object in the library from the file path.

QString CLibrary::pathToSong ( const QString &  artist,
const QString &  title 
) const

Returns the absolute path of an .sg file from artist and title names. Following the songbook convention, the song "Hello world!" from artist "Unknown" would be located in /path/to/songbook/songs/unknown/hello_world.sg".

QString CLibrary::pathToSong ( Song song) const

This is a convenience method that returns the absolute path of an .sg file from a Song object.

void CLibrary::removeSong ( const QString &  path)

Removes the song path from the library.

See also:
addSong, addSongs
int CLibrary::rowCount ( const QModelIndex &  index = QModelIndex()) const
virtual

Reimplements QAbstractTableModel::rowCount. Returns the number of Song items in the library.

See also:
columnCount
void CLibrary::saveCover ( Song song,
const QImage &  cover 
)

Saves the cover cover in the library directory (update the cover path if required).

See also:
saveSong
void CLibrary::saveSong ( Song song)

Saves the song song in the library (update the song path if required).

See also:
saveCover
void CLibrary::setDirectory ( const QString &  directory)

Sets directory as the directory for the library.

See also:
directory
void CLibrary::setDirectory ( const QDir &  directory)

Sets directory as the directory for the library.

See also:
directory
QStringList CLibrary::templates ( ) const

Returns the list of available templates (*.tmpl files).


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