BibleTime
|
#include <btbookmarksmodel.h>
Public Types | |
enum | BookmarksRoles { TypeRole = Qt::UserRole + 1 } |
Public Slots | |
bool | load (QString fileName=QString(), const QModelIndex &rootItem=QModelIndex()) |
Import bookmarks from file. More... | |
bool | save (QString fileName=QString(), const QModelIndex &rootItem=QModelIndex()) |
Save bookmarks or specified branch to file. More... | |
Public Member Functions | |
QModelIndex | addBookmark (int const row, QModelIndex const &parent, CSwordModuleInfo const &module, QString const &key, QString const &description=QString(), QString const &title=QString()) |
add new item with given parameters More... | |
QModelIndex | addFolder (int row, const QModelIndex &parent, const QString &name=QString()) |
add new folder. More... | |
BtBookmarksModel (QObject *parent=nullptr) | |
BtBookmarksModel (QString const &fileName=QString(), QObject *parent=nullptr) | |
Constructor/destructor for new bookmarks model, data is loaded on first constructor call and unloaded on last destructor call. More... | |
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
void | copyItems (int row, const QModelIndex &parent, const QModelIndexList &toCopy) |
Copies item to target position. More... | |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
QString | description (const QModelIndex &index) const |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
bool | hasChildren (const QModelIndex &parent=QModelIndex()) const override |
bool | hasDescendant (const QModelIndex &baseIndex, const QModelIndex &testIndex) const |
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 |
bool | insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) override |
bool | isBookmark (const QModelIndex &index) const |
bool | isFolder (const QModelIndex &index) const |
QString | key (const QModelIndex &index) const |
CSwordModuleInfo * | module (const QModelIndex &index) const |
QModelIndex | parent (const QModelIndex &index) const override |
bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) override |
QHash< int, QByteArray > | roleNames () const override |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
void | setDescription (const QModelIndex &index, const QString &description) |
set descritpion for index. More... | |
void | sortItems (QModelIndex const &parent=QModelIndex(), Qt::SortOrder const order=Qt::AscendingOrder) |
~BtBookmarksModel () override | |
Private Member Functions | |
bool | slotSave () |
Private Attributes | |
BtBookmarksModelPrivate *const | d_ptr |
Model to load and display bookmarks. It is saved periodically if it was loaded from default bookmarks file. No more one such model allowed at time.
Definition at line 25 of file btbookmarksmodel.h.
Enumerator | |
---|---|
TypeRole |
Definition at line 32 of file btbookmarksmodel.h.
BtBookmarksModel::BtBookmarksModel | ( | QObject * | parent = nullptr | ) |
Definition at line 553 of file btbookmarksmodel.cpp.
References load().
BtBookmarksModel::BtBookmarksModel | ( | QString const & | fileName = QString() , |
QObject * | parent = nullptr |
||
) |
Constructor/destructor for new bookmarks model, data is loaded on first constructor call and unloaded on last destructor call.
[in] | fileName | loads a list of items (with subitem trees) from a named file or from the default bookmarks file if empty. |
Definition at line 560 of file btbookmarksmodel.cpp.
References load().
|
override |
Definition at line 565 of file btbookmarksmodel.cpp.
QModelIndex BtBookmarksModel::addBookmark | ( | int const | row, |
QModelIndex const & | parent, | ||
CSwordModuleInfo const & | module, | ||
QString const & | key, | ||
QString const & | description = QString() , |
||
QString const & | title = QString() |
||
) |
add new item with given parameters
Definition at line 829 of file btbookmarksmodel.cpp.
References description(), key(), module(), parent(), r(), and rowCount().
Referenced by CBookmarkIndex::dropEvent().
QModelIndex BtBookmarksModel::addFolder | ( | int | row, |
const QModelIndex & | parent, | ||
const QString & | name = QString() |
||
) |
add new folder.
Definition at line 855 of file btbookmarksmodel.cpp.
References parent().
Referenced by CBookmarkIndex::CBookmarkIndex().
|
override |
Definition at line 582 of file btbookmarksmodel.cpp.
References parent().
void BtBookmarksModel::copyItems | ( | int | row, |
const QModelIndex & | parent, | ||
const QModelIndexList & | toCopy | ||
) |
Copies item to target position.
[in] | row | new item will occupy given row. |
[in] | parent | if invalid new item will be placed on top level. |
[in] | toCopy | item to copy. |
Definition at line 740 of file btbookmarksmodel.cpp.
References BT_ASSERT, index(), and parent().
Referenced by CBookmarkIndex::dropEvent().
|
override |
Definition at line 607 of file btbookmarksmodel.cpp.
References index(), isBookmark(), and TypeRole.
QString BtBookmarksModel::description | ( | const QModelIndex & | index | ) | const |
Definition at line 810 of file btbookmarksmodel.cpp.
References index().
Referenced by addBookmark(), CBookmarkIndex::CBookmarkIndex(), CBookmarkIndex::dragObject(), and setDescription().
|
override |
Definition at line 632 of file btbookmarksmodel.cpp.
References index().
|
override |
Definition at line 587 of file btbookmarksmodel.cpp.
References parent(), and rowCount().
bool BtBookmarksModel::hasDescendant | ( | const QModelIndex & | baseIndex, |
const QModelIndex & | testIndex | ||
) | const |
Definition at line 874 of file btbookmarksmodel.cpp.
Referenced by CBookmarkIndex::dropEvent().
|
override |
Definition at line 638 of file btbookmarksmodel.cpp.
|
override |
Definition at line 590 of file btbookmarksmodel.cpp.
References parent().
Referenced by CBookmarkIndex::CBookmarkIndex(), copyItems(), data(), description(), flags(), isBookmark(), isFolder(), key(), module(), parent(), setData(), and setDescription().
|
override |
Definition at line 674 of file btbookmarksmodel.cpp.
References BT_ASSERT, and parent().
Referenced by CBookmarkIndex::CBookmarkIndex().
bool BtBookmarksModel::isBookmark | ( | const QModelIndex & | index | ) | const |
Definition at line 734 of file btbookmarksmodel.cpp.
References index().
Referenced by CBookmarkIndex::CBookmarkIndex(), data(), CBookmarkIndex::dragObject(), CBookmarkIndex::dropEvent(), CBookmarkIndex::enableAction(), CBookmarkIndex::hasBookmarksRecursively(), and CBookmarkIndex::paintEvent().
bool BtBookmarksModel::isFolder | ( | const QModelIndex & | index | ) | const |
Definition at line 728 of file btbookmarksmodel.cpp.
References index().
Referenced by CBookmarkIndex::CBookmarkIndex(), CBookmarkIndex::dropEvent(), CBookmarkIndex::enableAction(), CBookmarkIndex::hasBookmarksRecursively(), and CBookmarkIndex::paintEvent().
QString BtBookmarksModel::key | ( | const QModelIndex & | index | ) | const |
Definition at line 801 of file btbookmarksmodel.cpp.
References index().
Referenced by addBookmark(), CBookmarkIndex::CBookmarkIndex(), and CBookmarkIndex::dragObject().
|
slot |
Import bookmarks from file.
[in] | fileName | file to load bookmarks. |
[in] | rootItem | bookmarks will be loaded under specified item, if empty, items will be loaded on top level. Items will be placed in append mode. |
Definition at line 705 of file btbookmarksmodel.cpp.
References BT_ASSERT, BT_CONNECT, and slotSave().
Referenced by BtBookmarksModel(), and CBookmarkIndex::CBookmarkIndex().
CSwordModuleInfo * BtBookmarksModel::module | ( | const QModelIndex & | index | ) | const |
Definition at line 792 of file btbookmarksmodel.cpp.
References index().
Referenced by addBookmark(), CBookmarkIndex::CBookmarkIndex(), and CBookmarkIndex::dragObject().
|
override |
Definition at line 599 of file btbookmarksmodel.cpp.
References index().
Referenced by addBookmark(), addFolder(), columnCount(), copyItems(), hasChildren(), index(), insertRows(), removeRows(), rowCount(), and sortItems().
|
override |
Definition at line 659 of file btbookmarksmodel.cpp.
|
override |
Definition at line 940 of file btbookmarksmodel.cpp.
References TypeRole.
|
override |
Reimplemented from QAbstractItemModel
Definition at line 574 of file btbookmarksmodel.cpp.
References parent().
Referenced by addBookmark(), CBookmarkIndex::CBookmarkIndex(), CBookmarkIndex::dropEvent(), CBookmarkIndex::hasBookmarksRecursively(), and hasChildren().
|
slot |
Save bookmarks or specified branch to file.
[in] | fileName | use file or save to the default bookmarks file if it is empty, file will be overwriten if it exists. |
[in] | rootItem | is used to save specified branch of bookmark items or save all bookmarks if it is empty. |
Definition at line 688 of file btbookmarksmodel.cpp.
References BT_ASSERT, BtBookmarksModelPrivate::defaultBookmarksFile(), and util::tool::savePlainFile().
Referenced by CBookmarkIndex::CBookmarkIndex(), slotSave(), and ~BtBookmarksModel().
|
override |
Definition at line 646 of file btbookmarksmodel.cpp.
References index().
Referenced by CBookmarkIndex::CBookmarkIndex().
void BtBookmarksModel::setDescription | ( | const QModelIndex & | index, |
const QString & | description | ||
) |
set descritpion for index.
Definition at line 819 of file btbookmarksmodel.cpp.
References description(), and index().
Referenced by CBookmarkIndex::CBookmarkIndex().
|
inlineprivate |
void BtBookmarksModel::sortItems | ( | QModelIndex const & | parent = QModelIndex() , |
Qt::SortOrder const | order = Qt::AscendingOrder |
||
) |
[in] | parent | sort items under specified index, if invalid sort all items. |
Definition at line 894 of file btbookmarksmodel.cpp.
References BtBookmarksModelSortAscending(), BtBookmarksModelSortDescending(), and parent().
Referenced by CBookmarkIndex::CBookmarkIndex().
|
private |
Definition at line 162 of file btbookmarksmodel.h.
Referenced by ~BtBookmarksModel().