mirror of
https://github.com/YACReader/yacreader
synced 2025-07-22 15:04:40 -04:00
fixed StyledDelegates and added proxymodel to lists model
This commit is contained in:
@ -166,6 +166,9 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant(YACReader::noHighlightedIcon(":/images/folder.png"));
|
||||
#endif
|
||||
|
||||
if(role == FolderModel::CompletedRole)
|
||||
return item->data(FolderModel::Completed);
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
|
@ -125,6 +125,11 @@ public:
|
||||
Completed = 3
|
||||
};//id INTEGER PRIMARY KEY, parentId INTEGER NOT NULL, name TEXT NOT NULL, path TEXT NOT NULL
|
||||
|
||||
enum Roles {
|
||||
FinishedRole = Qt::UserRole + 1,
|
||||
CompletedRole
|
||||
};
|
||||
|
||||
public slots:
|
||||
void deleteFolder(const QModelIndex & mi);
|
||||
|
||||
|
@ -58,6 +58,21 @@ QVariant ReadingListModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
ListItem * item = static_cast<ListItem*>(index.internalPointer());
|
||||
|
||||
if (role == ReadingListModel::TypeListsRole)
|
||||
{
|
||||
if(typeid(*item) == typeid(SpecialListItem))
|
||||
return QVariant(ReadingListModel::SpecialList);
|
||||
|
||||
if(typeid(*item) == typeid(LabelItem))
|
||||
return QVariant(ReadingListModel::Label);
|
||||
|
||||
if(typeid(*item) == typeid(ReadingListItem))
|
||||
return QVariant(ReadingListModel::ReadingList);
|
||||
|
||||
if(typeid(*item) == typeid(ReadingListSeparatorItem))
|
||||
return QVariant(ReadingListModel::Separator);
|
||||
}
|
||||
|
||||
if(typeid(*item) == typeid(ReadingListSeparatorItem))
|
||||
return QVariant();
|
||||
|
||||
@ -446,3 +461,10 @@ int ReadingListModel::addLabelIntoList(LabelItem *item)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ReadingListModelProxy::ReadingListModelProxy(QObject *parent)
|
||||
:QSortFilterProxyModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define READING_LIST_MODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QModelIndex>
|
||||
#include <QVariant>
|
||||
#include <QSqlQuery>
|
||||
@ -14,6 +15,13 @@ class SpecialListItem;
|
||||
class ReadingListItem;
|
||||
class ReadingListSeparatorItem;
|
||||
|
||||
class ReadingListModelProxy : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ReadingListModelProxy(QObject *parent = 0);
|
||||
};
|
||||
|
||||
class ReadingListModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -42,6 +50,17 @@ public:
|
||||
void rename(const QModelIndex & mi, const QString & name);
|
||||
void deleteItem(const QModelIndex & mi);
|
||||
|
||||
enum Roles {
|
||||
TypeListsRole = Qt::UserRole + 1,
|
||||
};
|
||||
|
||||
enum TypeList {
|
||||
SpecialList,
|
||||
Label,
|
||||
ReadingList,
|
||||
Separator
|
||||
};
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user