diff --git a/src/danboorupostdelegate.cpp b/src/danboorupostdelegate.cpp index 5362fbf..0a7466c 100644 --- a/src/danboorupostdelegate.cpp +++ b/src/danboorupostdelegate.cpp @@ -20,15 +20,20 @@ * */ -#include "danboorupostdelegate.h" +// Own +#include "danboorupostdelegate.h" #include "libdanbooru/danboorupost.h" +// Qt + #include #include #include #include +// KDE + #include namespace Danbooru { @@ -135,7 +140,8 @@ namespace Danbooru { } - QSize DanbooruPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const + QSize DanbooruPostDelegate::sizeHint(const QStyleOptionViewItem& option, + const QModelIndex& index) const { Q_UNUSED(option) Q_UNUSED(index) diff --git a/src/danboorupostdelegate.h b/src/danboorupostdelegate.h index a30d1a6..06cb982 100644 --- a/src/danboorupostdelegate.h +++ b/src/danboorupostdelegate.h @@ -23,6 +23,12 @@ #ifndef DANBOORUPOSTDELEGATE_H #define DANBOORUPOSTDELEGATE_H +/** + * @brief This file includes custom delegates to represent DanbooruItems. + * @file danboorupostdelegate.h + * + **/ + #include class QListView; @@ -31,6 +37,10 @@ class KPushButton; namespace Danbooru { + /** + * @brief Specific delegate for Danbooru items. + * + */ class DanbooruPostDelegate : public QStyledItemDelegate { @@ -47,10 +57,6 @@ namespace Danbooru { QModelIndex hoveredIndex() const; - QList createItemWidgets() const; - void updateItemWidgets( const QList widgets, - const QStyleOptionViewItem& option, - const QPersistentModelIndex & index) const; private: diff --git a/src/danboorutablemodel.cpp b/src/danboorutablemodel.cpp index 46a234f..26a0234 100644 --- a/src/danboorutablemodel.cpp +++ b/src/danboorutablemodel.cpp @@ -20,9 +20,13 @@ * */ +// Own + #include "danboorutablemodel.h" #include "libdanbooru/danboorupost.h" +// Qt + #include #include @@ -47,7 +51,7 @@ namespace Danbooru { void DanbooruTableModel::addPost(Danbooru::DanbooruPost* post) { - beginInsertRows(QModelIndex(), m_posts.length(), m_posts.length()+1); + beginInsertRows(QModelIndex(), m_posts.length(), m_posts.length() + 1); m_posts.append(post); endInsertRows(); } @@ -70,8 +74,12 @@ namespace Danbooru { if (role == Qt::DisplayRole) { - DanbooruPost* post = m_posts.at(index.row()); - return post->fileUrl().fileName(); + Danbooru::DanbooruPost* post = m_posts.at(index.row()); + + QVariant variant; + variant.setValue(post); + + return variant; } if (role == Qt::DecorationRole) { diff --git a/src/danboorutablemodel.h b/src/danboorutablemodel.h index f42023a..0eeeeaa 100644 --- a/src/danboorutablemodel.h +++ b/src/danboorutablemodel.h @@ -23,12 +23,29 @@ #ifndef DANBOORUTABLEMODEL_H #define DANBOORUTABLEMODEL_H +/** + * @brief This file contains a specific model to represent Danbooru Items + * @file danboorutablemodel.h + * + **/ + #include #include namespace Danbooru { + class DanbooruPost; + /** + * @brief A model to represent DanbooruItems + * + * Since items from a Danbooru service are sent by the service itself, + * there is no need for sorting or table-like structures: everything is + * represented as a flat list. + * + * Items are added through the addPost() slot. + * + */ class DanbooruTableModel : public QAbstractListModel { @@ -41,13 +58,18 @@ namespace Danbooru { int rowCount(const QModelIndex& parent=QModelIndex()) const; QVariant data(const QModelIndex& index, int role) const; - // bool insertRows(int row, int count=rowCount(), - // const QModelIndex& parent=QModelIndex()); - private: QList m_posts; public Q_SLOTS: + /** + * @brief Add a new post to the model + * + * Connect to this slot when you want to add items to the model. + * + * @param post A pointer to a DanbooruPost. + * + */ void addPost(Danbooru::DanbooruPost* post); };