mirror of
https://github.com/YACReader/yacreader
synced 2025-07-26 08:55:05 -04:00
added SortVolumeComics widget (and models)
This commit is contained in:
82
YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp
Normal file
82
YACReaderLibrary/comic_vine/model/local_comic_list_model.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
#include "local_comic_list_model.h"
|
||||
|
||||
LocalComicListModel::LocalComicListModel(QObject *parent) :
|
||||
QAbstractItemModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void LocalComicListModel::load(QList<ComicDB> &comics)
|
||||
{
|
||||
_data = comics;
|
||||
}
|
||||
|
||||
|
||||
QModelIndex LocalComicListModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
return QModelIndex(); //no parent
|
||||
}
|
||||
|
||||
int LocalComicListModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return _data.count();
|
||||
}
|
||||
|
||||
int LocalComicListModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
if(_data.isEmpty())
|
||||
return 0;
|
||||
else
|
||||
return 1;//_data.at(0)->count();
|
||||
}
|
||||
|
||||
QVariant LocalComicListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
if(role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
int row = index.row();
|
||||
int column = index.column();
|
||||
return _data[row].getFileName();
|
||||
}
|
||||
|
||||
Qt::ItemFlags LocalComicListModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return 0;
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
QVariant LocalComicListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
|
||||
{
|
||||
return QVariant(QString(tr("file name")));
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QModelIndex LocalComicListModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(row, column);
|
||||
}
|
||||
|
34
YACReaderLibrary/comic_vine/model/local_comic_list_model.h
Normal file
34
YACReaderLibrary/comic_vine/model/local_comic_list_model.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef LOCAL_COMIC_LIST_MODEL_H
|
||||
#define LOCAL_COMIC_LIST_MODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
#include "comic_db.h"
|
||||
|
||||
class LocalComicListModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LocalComicListModel(QObject *parent = 0);
|
||||
|
||||
void load(QList<ComicDB> & comics);
|
||||
|
||||
//QAbstractItemModel methods
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent) const;
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QList<ComicDB> _data;
|
||||
};
|
||||
|
||||
#endif // LOCAL_COMIC_LIST_MODEL_H
|
11
YACReaderLibrary/comic_vine/model/volume_comics_model.cpp
Normal file
11
YACReaderLibrary/comic_vine/model/volume_comics_model.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "volume_comics_model.h"
|
||||
|
||||
VolumeComicsModel::VolumeComicsModel(QObject * parent) :
|
||||
JSONModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void VolumeComicsModel::load(const QString & json)
|
||||
{
|
||||
|
||||
}
|
18
YACReaderLibrary/comic_vine/model/volume_comics_model.h
Normal file
18
YACReaderLibrary/comic_vine/model/volume_comics_model.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef VOLUME_COMICS_MODEL_H
|
||||
#define VOLUME_COMICS_MODEL_H
|
||||
|
||||
#include "json_model.h"
|
||||
|
||||
class VolumeComicsModel : public JSONModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VolumeComicsModel(QObject *parent = 0);
|
||||
void load(const QString & json);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // VOLUME_COMICS_MODEL_H
|
@ -139,3 +139,8 @@ QModelIndex VolumesModel::index(int row, int column, const QModelIndex &parent)
|
||||
return createIndex(row, column, _data[row]);
|
||||
}
|
||||
|
||||
QString VolumesModel::getVolumeId(const QModelIndex &index) const
|
||||
{
|
||||
return _data.at(index.row())->at(ID);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ public:
|
||||
int role = Qt::DisplayRole) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
QString getVolumeId(const QModelIndex & index) const;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
Reference in New Issue
Block a user