mirror of
https://github.com/YACReader/yacreader
synced 2025-07-21 14:34:42 -04:00
Added tag 6.5 for changeset 19399e8c6157
This commit is contained in:
73
YACReaderLibrary/db/tablemodel.h
Normal file
73
YACReaderLibrary/db/tablemodel.h
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef TABLEMODEL_H
|
||||
#define TABLEMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QModelIndex>
|
||||
#include <QVariant>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
class ComicDB;
|
||||
|
||||
class TableItem;
|
||||
|
||||
//! [0]
|
||||
class TableModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TableModel(QObject *parent = 0);
|
||||
TableModel( QSqlQuery &sqlquery, QObject *parent = 0);
|
||||
~TableModel();
|
||||
|
||||
|
||||
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;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
void setupModelData(unsigned long long int parentFolder,const QString & databasePath);
|
||||
|
||||
//M<>todos de conveniencia
|
||||
QStringList getPaths(const QString & _source);
|
||||
QString getComicPath(QModelIndex mi);
|
||||
ComicDB getComic(const QModelIndex & mi); //--> para la edici<63>n
|
||||
ComicDB getComic(int row);
|
||||
QVector<bool> getReadList();
|
||||
QVector<bool> setAllComicsRead(bool read);
|
||||
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la informaci<63>n com<6F>n a los comics seleccionados
|
||||
QModelIndex getIndexFromId(quint64 id);
|
||||
//setcomicInfo(QModelIndex & mi); --> inserta en la base datos
|
||||
//setComicInfoForAllComics(); --> inserta la informaci<63>n com<6F>n a todos los c<>mics de una sola vez.
|
||||
//setComicInfoForSelectedComis(QList<QModelIndex> list); -->inserta la informaci<63>n com<6F>n para los comics seleccionados
|
||||
QVector<bool> setComicsRead(QList<QModelIndex> list,bool read);
|
||||
qint64 asignNumbers(QList<QModelIndex> list,int startingNumber);
|
||||
void remove(ComicDB * comic, int row);
|
||||
void removeInTransaction(int row);
|
||||
|
||||
public slots:
|
||||
void remove(int row);
|
||||
void startTransaction();
|
||||
void finishTransaction();
|
||||
|
||||
private:
|
||||
void setupModelData( QSqlQuery &sqlquery);
|
||||
ComicDB _getComic(const QModelIndex & mi);
|
||||
QList<TableItem *> _data;
|
||||
|
||||
QString _databasePath;
|
||||
|
||||
QSqlDatabase dbTransaction;
|
||||
|
||||
signals:
|
||||
void beforeReset();
|
||||
void reset();
|
||||
};
|
||||
//! [0]
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user