openmw-tes3coop/components/esxselector/model/datafilesmodel.hpp

81 lines
2.6 KiB
C++
Raw Normal View History

#ifndef DATAFILESMODEL_HPP
#define DATAFILESMODEL_HPP
#include <QAbstractTableModel>
#include <QStringList>
#include <QString>
#include <QHash>
namespace EsxModel
{
class EsmFile;
2013-09-07 20:57:40 +00:00
typedef QList<const EsmFile *> EsmFileList;
class DataFilesModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit DataFilesModel(QObject *parent = 0);
virtual ~DataFilesModel();
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
2013-09-07 20:57:40 +00:00
bool removeRows(int row, int count, const QModelIndex &parent);
bool insertRows(int row, int count, const QModelIndex &parent);
bool moveRow(int oldrow, int row, const QModelIndex &parent = QModelIndex());
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
2013-09-07 20:57:40 +00:00
{
QModelIndex idx = QAbstractTableModel::index(row, 0, parent);
return idx;
}
void setEncoding(const QString &encoding);
void addFiles(const QString &path);
2012-10-30 10:26:48 +00:00
void uncheckAll();
2013-09-07 20:57:40 +00:00
Qt::DropActions supportedDropActions() const;
QStringList mimeTypes() const;
QMimeData *mimeData(const QModelIndexList &indexes) const;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
EsmFileList checkedItems();
EsmFileList uncheckedItems();
QStringList checkedItemsPaths();
Qt::CheckState checkState(const QModelIndex &index);
void setCheckState(const QModelIndex &index, Qt::CheckState state);
2013-09-07 20:57:40 +00:00
QModelIndex indexFromItem(const EsmFile *item) const;
const EsmFile* findItem(const QString &name);
const EsmFile* item(int row) const;
signals:
void checkedItemsChanged(const EsmFileList &items);
private:
2013-09-07 20:57:40 +00:00
bool canBeChecked(const EsmFile *file) const;
void addFile(const EsmFile *file);
EsmFileList mFiles;
QHash<QString, Qt::CheckState> mCheckStates;
2012-10-30 10:26:48 +00:00
QString mEncoding;
};
}
#endif // DATAFILESMODEL_HPP