/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #ifndef PICFILESMODEL_H #define PICFILESMODEL_H #include "smtreemodel.h" #include "mappingtreemodel.h" class QSqlQuery; class PicFilesModel : public SmTreeModel { Q_OBJECT public: enum Roles { FileNameRole = Qt::UserRole + 1, SizeRole = Qt::UserRole + 2, MimeTypeRole = Qt::UserRole + 3, FullPathRole = Qt::UserRole + 4, IdRole = Qt::UserRole + 5, AddedRole = Qt::UserRole + 6, Md5SumRole = Qt::UserRole + 7, PicSizeRole = Qt::UserRole + 8 }; enum Fields { FileName = 0, Size = 1, MimeType = 2, FullPath = 3, Id = 4, Added = 5, Md5Sum = 6, PicSize = 7 }; enum { NumFields = 8 }; explicit PicFilesModel(const QStringList &headers, QObject *parent = 0); void setMapping(int pMapId); //some data Qt::ItemFlags flags(const QModelIndex &) const { return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } QVariant data(const QModelIndex &index, int role) const; QList dataList(const QModelIndex &idx); QList > allFiles() const; void removeFiles(const QList > &files); bool changeMappings(const QList &fileIds, const QList &parentIds); QList mappingDataFromFile(int fileId); SmTreeItem *mappingTreeFromFile(int fileId); SmTreeItem *findRecursive(SmTreeItem *start, const QVariant &name, const QVariant id) const; QList mappingDataFromFiles(const QList fileIds); void selectFromAll(); void selectFromRecent(int days); void selectFromSelection(QList ids); void allPicIds(); void recentPicIds(); QList > getNextBatch(); QList > allPics() const { return mAllPics; } public slots: void populate(); private: QList mappingPIdsFromFiles(QList fileIds); QSqlDatabase mDb; MappingTreeModel *mMappingTreeModel; QString mPopulateQS; QString mMappingsQS; QList mMappingIds; QList > mAllPics; QList > mRecentPics; QList > *mCurrentPics; int mCurrentBatch; }; #endif // PICFILESMODEL_H