mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Implementing drag and drop
This commit is contained in:
parent
e6fdc7e7fd
commit
a6e7cf9a8c
19 changed files with 887 additions and 113 deletions
|
@ -27,7 +27,7 @@ CSVDoc::FileDialog::FileDialog(QWidget *parent) :
|
||||||
|
|
||||||
resize(400, 400);
|
resize(400, 400);
|
||||||
|
|
||||||
connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList)));
|
// connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList)));
|
||||||
connect(projectNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
|
connect(projectNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
|
||||||
|
|
||||||
connect(projectCreateButton, SIGNAL(clicked()), this, SIGNAL(createNewFile()));
|
connect(projectCreateButton, SIGNAL(clicked()), this, SIGNAL(createNewFile()));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
project (Components)
|
project (Components)
|
||||||
|
set (CMAKE_BUILD_TYPE DEBUG)
|
||||||
# source files
|
# source files
|
||||||
|
|
||||||
add_component_dir (settings
|
add_component_dir (settings
|
||||||
|
@ -74,6 +74,7 @@ if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
||||||
add_component_qt_dir (esxselector
|
add_component_qt_dir (esxselector
|
||||||
model/masterproxymodel model/modelitem model/datafilesmodel
|
model/masterproxymodel model/modelitem model/datafilesmodel
|
||||||
model/pluginsproxymodel model/esmfile model/naturalsort
|
model/pluginsproxymodel model/esmfile model/naturalsort
|
||||||
|
model/contentmodel
|
||||||
view/profilescombobox view/comboboxlineedit
|
view/profilescombobox view/comboboxlineedit
|
||||||
view/lineedit view/contentselector
|
view/lineedit view/contentselector
|
||||||
)
|
)
|
||||||
|
|
428
components/esxselector/model/contentmodel.cpp
Normal file
428
components/esxselector/model/contentmodel.cpp
Normal file
|
@ -0,0 +1,428 @@
|
||||||
|
#include "contentmodel.hpp"
|
||||||
|
#include "esmfile.hpp"
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QTextCodec>
|
||||||
|
#include <components/esm/esmreader.hpp>
|
||||||
|
|
||||||
|
EsxModel::ContentModel::ContentModel(QObject *parent) :
|
||||||
|
QAbstractTableModel(parent), mEncoding("win1252")
|
||||||
|
{}
|
||||||
|
|
||||||
|
void EsxModel::ContentModel::setEncoding(const QString &encoding)
|
||||||
|
{
|
||||||
|
mEncoding = encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
int EsxModel::ContentModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if (parent.isValid())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
QModelIndex EsxModel::ContentModel::parent(const QModelIndex &child) const
|
||||||
|
{
|
||||||
|
if(!child.isValid())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return child.parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex EsxModel::ContentModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
int EsxModel::ContentModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if(parent.isValid())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return mFiles.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant EsxModel::ContentModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if (index.row() >= mFiles.size())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
EsmFile *file = item(index.row());
|
||||||
|
|
||||||
|
if (!file)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
const int column = index.column();
|
||||||
|
|
||||||
|
switch (role)
|
||||||
|
{
|
||||||
|
case Qt::EditRole:
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
{
|
||||||
|
switch (column)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return file->fileName();
|
||||||
|
case 1:
|
||||||
|
return file->author();
|
||||||
|
case 2:
|
||||||
|
return QString("%1 kB").arg(int((file->size() + 1023) / 1024));
|
||||||
|
case 3:
|
||||||
|
return file->modified().toString(Qt::ISODate);
|
||||||
|
case 4:
|
||||||
|
return file->accessed().toString(Qt::TextDate);
|
||||||
|
case 5:
|
||||||
|
return file->version();
|
||||||
|
case 6:
|
||||||
|
return file->path();
|
||||||
|
case 7:
|
||||||
|
return file->masters().join(", ");
|
||||||
|
case 8:
|
||||||
|
return file->description();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::TextAlignmentRole:
|
||||||
|
{
|
||||||
|
switch (column)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
return Qt::AlignLeft + Qt::AlignVCenter;
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
return Qt::AlignRight + Qt::AlignVCenter;
|
||||||
|
default:
|
||||||
|
return Qt::AlignLeft + Qt::AlignVCenter;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::ToolTipRole:
|
||||||
|
{
|
||||||
|
if (column != 0)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if (file->version() == 0.0f)
|
||||||
|
return QVariant(); // Data not set
|
||||||
|
|
||||||
|
return QString("<b>Author:</b> %1<br/> \
|
||||||
|
<b>Version:</b> %2<br/> \
|
||||||
|
<br/><b>Description:</b><br/>%3<br/> \
|
||||||
|
<br/><b>Dependencies: </b>%4<br/>")
|
||||||
|
.arg(file->author())
|
||||||
|
.arg(QString::number(file->version()))
|
||||||
|
.arg(file->description())
|
||||||
|
.arg(file->masters().join(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
case Qt::UserRole:
|
||||||
|
{
|
||||||
|
if (file->masters().size() == 0)
|
||||||
|
return "game";
|
||||||
|
else
|
||||||
|
return "addon";
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags EsxModel::ContentModel::flags(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
|
EsmFile *file = item(index.row());
|
||||||
|
|
||||||
|
if (!file)
|
||||||
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
|
Qt::ItemFlags dragDropFlags = Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||||
|
Qt::ItemFlags checkFlags = Qt::ItemIsUserCheckable;
|
||||||
|
Qt::ItemFlags defaultFlags = Qt::ItemIsDropEnabled | Qt::ItemIsSelectable;
|
||||||
|
|
||||||
|
if (canBeChecked(file))
|
||||||
|
return Qt::ItemIsEnabled | dragDropFlags | checkFlags | defaultFlags;
|
||||||
|
else
|
||||||
|
return defaultFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EsxModel::ContentModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
|
{
|
||||||
|
if (index.isValid() && role == Qt::EditRole)
|
||||||
|
{
|
||||||
|
QString fname = value.value<QString>();
|
||||||
|
mFiles.replace(index.row(), findItem(fname));
|
||||||
|
emit dataChanged(index, index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EsxModel::ContentModel::insertRows(int position, int rows, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
beginInsertRows(parent, position, position+rows-1);
|
||||||
|
|
||||||
|
for (int row = 0; row < rows; ++row)
|
||||||
|
mFiles.insert(position, new EsmFile);
|
||||||
|
|
||||||
|
endInsertRows();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EsxModel::ContentModel::removeRows(int position, int rows, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
beginRemoveRows(parent, position, position+rows-1);
|
||||||
|
|
||||||
|
for (int row = 0; row < rows; ++row)
|
||||||
|
mFiles.removeAt(position);
|
||||||
|
|
||||||
|
endRemoveRows();
|
||||||
|
emit dataChanged(index(0,0,parent), index(rowCount()-1, 0, parent));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::DropActions EsxModel::ContentModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return Qt::CopyAction | Qt::MoveAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList EsxModel::ContentModel::mimeTypes() const
|
||||||
|
{
|
||||||
|
QStringList types;
|
||||||
|
types << "application/omwcontent";
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMimeData *EsxModel::ContentModel::mimeData(const QModelIndexList &indexes) const
|
||||||
|
{
|
||||||
|
QMimeData *mimeData = new QMimeData();
|
||||||
|
QByteArray encodedData;
|
||||||
|
|
||||||
|
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||||
|
|
||||||
|
foreach (const QModelIndex &index, indexes)
|
||||||
|
{
|
||||||
|
if (index.isValid())
|
||||||
|
{
|
||||||
|
QString text = data(index, Qt::DisplayRole).toString();
|
||||||
|
stream << text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mimeData->setData("application/omwcontent", encodedData);
|
||||||
|
return mimeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EsxModel::ContentModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
if (action == Qt::IgnoreAction)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!data->hasFormat("application/omwcontent"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (column > 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int beginRow;
|
||||||
|
|
||||||
|
if (row != -1)
|
||||||
|
beginRow = row;
|
||||||
|
else if (parent.isValid())
|
||||||
|
beginRow = parent.row();
|
||||||
|
else
|
||||||
|
beginRow = rowCount();
|
||||||
|
|
||||||
|
QByteArray encodedData = data->data("application/omwcontent");
|
||||||
|
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||||
|
QStringList newItems;
|
||||||
|
int rows = 0;
|
||||||
|
|
||||||
|
while (!stream.atEnd())
|
||||||
|
{
|
||||||
|
QString text;
|
||||||
|
stream >> text;
|
||||||
|
newItems << text;
|
||||||
|
++rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
insertRows(beginRow, rows, QModelIndex());
|
||||||
|
|
||||||
|
foreach (const QString &text, newItems)
|
||||||
|
{
|
||||||
|
QModelIndex idx = index(beginRow, 0, QModelIndex());
|
||||||
|
setData(idx, text);
|
||||||
|
beginRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::ContentModel::addFile(EsmFile *file)
|
||||||
|
{
|
||||||
|
emit beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count());
|
||||||
|
mFiles.append(file);
|
||||||
|
emit endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::ContentModel::addFiles(const QString &path)
|
||||||
|
{
|
||||||
|
QDir dir(path);
|
||||||
|
QStringList filters;
|
||||||
|
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";
|
||||||
|
dir.setNameFilters(filters);
|
||||||
|
|
||||||
|
// Create a decoder for non-latin characters in esx metadata
|
||||||
|
QTextCodec *codec;
|
||||||
|
|
||||||
|
if (mEncoding == QLatin1String("win1252")) {
|
||||||
|
codec = QTextCodec::codecForName("windows-1252");
|
||||||
|
} else if (mEncoding == QLatin1String("win1251")) {
|
||||||
|
codec = QTextCodec::codecForName("windows-1251");
|
||||||
|
} else if (mEncoding == QLatin1String("win1250")) {
|
||||||
|
codec = QTextCodec::codecForName("windows-1250");
|
||||||
|
} else {
|
||||||
|
return; // This should never happen;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextDecoder *decoder = codec->makeDecoder();
|
||||||
|
|
||||||
|
foreach (const QString &path, dir.entryList()) {
|
||||||
|
QFileInfo info(dir.absoluteFilePath(path));
|
||||||
|
EsmFile *file = new EsmFile(path);
|
||||||
|
|
||||||
|
try {
|
||||||
|
ESM::ESMReader fileReader;
|
||||||
|
ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(mEncoding.toStdString()));
|
||||||
|
fileReader.setEncoder(&encoder);
|
||||||
|
fileReader.open(dir.absoluteFilePath(path).toStdString());
|
||||||
|
|
||||||
|
std::vector<ESM::Header::MasterData> mlist = fileReader.getMasters();
|
||||||
|
|
||||||
|
QStringList masters;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < mlist.size(); ++i) {
|
||||||
|
QString master = QString::fromStdString(mlist[i].name);
|
||||||
|
masters.append(master);
|
||||||
|
}
|
||||||
|
|
||||||
|
file->setAuthor(decoder->toUnicode(fileReader.getAuthor().c_str()));
|
||||||
|
file->setSize(info.size());
|
||||||
|
file->setDates(info.lastModified(), info.lastRead());
|
||||||
|
file->setVersion(fileReader.getFVer());
|
||||||
|
file->setPath(info.absoluteFilePath());
|
||||||
|
file->setMasters(masters);
|
||||||
|
file->setDescription(decoder->toUnicode(fileReader.getDesc().c_str()));
|
||||||
|
|
||||||
|
|
||||||
|
// Put the file in the table
|
||||||
|
if (findItem(path) == 0)
|
||||||
|
addFile(file);
|
||||||
|
|
||||||
|
} catch(std::runtime_error &e) {
|
||||||
|
// An error occurred while reading the .esp
|
||||||
|
qWarning() << "Error reading addon file: " << e.what();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
delete decoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
EsxModel::EsmFile* EsxModel::ContentModel::findItem(const QString &name)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mFiles.size(); ++i)
|
||||||
|
{
|
||||||
|
if (name == item(i)->fileName())
|
||||||
|
return item(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not found
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
EsxModel::EsmFile* EsxModel::ContentModel::item(int row) const
|
||||||
|
{
|
||||||
|
if (row >= 0 && row < mFiles.count())
|
||||||
|
return mFiles.at(row);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex EsxModel::ContentModel::indexFromItem(EsmFile *item) const
|
||||||
|
{
|
||||||
|
if (item)
|
||||||
|
//return createIndex(mFiles.indexOf(item), 0);
|
||||||
|
return index(mFiles.indexOf(item),0);
|
||||||
|
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::CheckState EsxModel::ContentModel::checkState(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
return mCheckStates[item(index.row())->fileName()];
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::ContentModel::setCheckState(const QModelIndex &index, Qt::CheckState state)
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString name = item(index.row())->fileName();
|
||||||
|
mCheckStates[name] = state;
|
||||||
|
|
||||||
|
// Force a redraw of the view since unchecking one item can affect another
|
||||||
|
QModelIndex firstIndex = indexFromItem(mFiles.first());
|
||||||
|
QModelIndex lastIndex = indexFromItem(mFiles.last());
|
||||||
|
|
||||||
|
emit dataChanged(firstIndex, lastIndex);
|
||||||
|
//emit checkedItemsChanged(checkedItems());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EsxModel::ContentModel::canBeChecked(const EsmFile *file) const
|
||||||
|
{
|
||||||
|
//element can be checked if all its dependencies are
|
||||||
|
foreach (const QString &master, file->masters())
|
||||||
|
{
|
||||||
|
if (!mCheckStates.contains(master) || mCheckStates[master] != Qt::Checked)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
EsxModel::ContentFileList EsxModel::ContentModel::checkedItems() const
|
||||||
|
{
|
||||||
|
ContentFileList list;
|
||||||
|
|
||||||
|
for (int i = 0; i < mFiles.size(); ++i)
|
||||||
|
{
|
||||||
|
EsmFile *file = item(i);
|
||||||
|
|
||||||
|
// Only add the items that are in the checked list and available
|
||||||
|
if (mCheckStates[file->fileName()] == Qt::Checked && canBeChecked(file))
|
||||||
|
list << file;
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::ContentModel::uncheckAll()
|
||||||
|
{
|
||||||
|
emit layoutAboutToBeChanged();
|
||||||
|
mCheckStates.clear();
|
||||||
|
emit layoutChanged();
|
||||||
|
}
|
64
components/esxselector/model/contentmodel.hpp
Normal file
64
components/esxselector/model/contentmodel.hpp
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#ifndef CONTENTMODEL_HPP
|
||||||
|
#define CONTENTMODEL_HPP
|
||||||
|
|
||||||
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
|
namespace EsxModel
|
||||||
|
{
|
||||||
|
class EsmFile;
|
||||||
|
|
||||||
|
typedef QList<EsmFile *> ContentFileList;
|
||||||
|
|
||||||
|
class ContentModel : public QAbstractTableModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ContentModel(QObject *parent = 0);
|
||||||
|
|
||||||
|
void setEncoding(const QString &encoding);
|
||||||
|
|
||||||
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||||
|
|
||||||
|
bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
|
||||||
|
bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
void addFiles(const QString &path);
|
||||||
|
|
||||||
|
QModelIndex indexFromItem(EsmFile *item) const;
|
||||||
|
EsxModel::EsmFile *findItem(const QString &name);
|
||||||
|
|
||||||
|
Qt::CheckState checkState(const QModelIndex &index);
|
||||||
|
void setCheckState(const QModelIndex &index, Qt::CheckState state);
|
||||||
|
ContentFileList checkedItems() const;
|
||||||
|
void uncheckAll();
|
||||||
|
/*
|
||||||
|
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||||
|
QModelIndex parent(const QModelIndex &child) const;
|
||||||
|
*/
|
||||||
|
private:
|
||||||
|
|
||||||
|
void addFile(EsmFile *file);
|
||||||
|
EsmFile* item(int row) const;
|
||||||
|
bool canBeChecked(const EsmFile *file) const;
|
||||||
|
|
||||||
|
ContentFileList mFiles;
|
||||||
|
QHash<QString, Qt::CheckState> mCheckStates;
|
||||||
|
QString mEncoding;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // CONTENTMODEL_HPP
|
|
@ -48,13 +48,12 @@ void EsxModel::DataFilesModel::setCheckState(const QModelIndex &index, Qt::Check
|
||||||
|
|
||||||
Qt::CheckState EsxModel::DataFilesModel::checkState(const QModelIndex &index)
|
Qt::CheckState EsxModel::DataFilesModel::checkState(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
EsmFile *file = item(index.row());
|
return mCheckStates[item(index.row())->fileName()];
|
||||||
return mCheckStates[file->fileName()];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int EsxModel::DataFilesModel::columnCount(const QModelIndex &parent) const
|
int EsxModel::DataFilesModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return parent.isValid() ? 0 : 9;
|
return parent.isValid() ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EsxModel::DataFilesModel::rowCount(const QModelIndex &parent) const
|
int EsxModel::DataFilesModel::rowCount(const QModelIndex &parent) const
|
||||||
|
@ -82,7 +81,7 @@ QVariant EsxModel::DataFilesModel::data(const QModelIndex &index, int role) cons
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
EsmFile *file = item(index.row());
|
const EsmFile *file = item(index.row());
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -90,6 +89,7 @@ QVariant EsxModel::DataFilesModel::data(const QModelIndex &index, int role) cons
|
||||||
const int column = index.column();
|
const int column = index.column();
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
case Qt::EditRole:
|
||||||
case Qt::DisplayRole: {
|
case Qt::DisplayRole: {
|
||||||
|
|
||||||
switch (column) {
|
switch (column) {
|
||||||
|
@ -172,25 +172,26 @@ Qt::ItemFlags EsxModel::DataFilesModel::flags(const QModelIndex &index) const
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
EsmFile *file = item(index.row());
|
const EsmFile *file = item(index.row());
|
||||||
|
|
||||||
|
Qt::ItemFlags dragDropFlags = Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
|
||||||
|
Qt::ItemFlags checkFlags = Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
if (canBeChecked(file)) {
|
if (canBeChecked(file))
|
||||||
if (index.column() == 0) {
|
{
|
||||||
return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
if (index.column() == 0)
|
||||||
} else {
|
return dragDropFlags | checkFlags | Qt::ItemIsEnabled;
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
else
|
||||||
}
|
return Qt::ItemIsDropEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
} else {
|
|
||||||
if (index.column() == 0) {
|
|
||||||
return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
|
|
||||||
} else {
|
|
||||||
return Qt::ItemIsSelectable;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (index.column() == 0)
|
||||||
|
return dragDropFlags | checkFlags;
|
||||||
|
|
||||||
|
return Qt::ItemIsDropEnabled | Qt::ItemIsSelectable;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant EsxModel::DataFilesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant EsxModel::DataFilesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
|
@ -210,22 +211,27 @@ QVariant EsxModel::DataFilesModel::headerData(int section, Qt::Orientation orien
|
||||||
case 7: return tr("Masters");
|
case 7: return tr("Masters");
|
||||||
case 8: return tr("Description");
|
case 8: return tr("Description");
|
||||||
}
|
}
|
||||||
} /* else {
|
|
||||||
// Show row numbers
|
|
||||||
return ++section;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EsxModel::DataFilesModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool EsxModel::DataFilesModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (role == Qt::EditRole)
|
||||||
|
{
|
||||||
|
qDebug() << "replacing: " << mFiles.at(index.row())->fileName();
|
||||||
|
// mFiles.replace(index.row(), value.value<const EsxModel::EsmFile *>());
|
||||||
|
qDebug() << "with: " << mFiles.at(index.row())->fileName();
|
||||||
|
emit dataChanged(index, index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
bool lessThanEsmFile(const EsxModel::EsmFile *e1, const EsxModel::EsmFile *e2)
|
bool lessThanEsmFile(const EsxModel::EsmFile *e1, const EsxModel::EsmFile *e2)
|
||||||
{
|
{
|
||||||
//Masters first then alphabetically
|
//Masters first then alphabetically
|
||||||
|
@ -236,16 +242,15 @@ bool lessThanEsmFile(const EsxModel::EsmFile *e1, const EsxModel::EsmFile *e2)
|
||||||
|
|
||||||
return e1->fileName().toLower() < e2->fileName().toLower();
|
return e1->fileName().toLower() < e2->fileName().toLower();
|
||||||
}
|
}
|
||||||
|
//!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
bool lessThanDate(const EsxModel::EsmFile *e1, const EsxModel::EsmFile *e2)
|
bool lessThanDate(const EsxModel::EsmFile *e1, const EsxModel::EsmFile *e2)
|
||||||
{
|
{
|
||||||
if (e1->modified().toString(Qt::ISODate) < e2->modified().toString(Qt::ISODate)) {
|
if (e1->modified().toString(Qt::ISODate) < e2->modified().toString(Qt::ISODate))
|
||||||
return true;
|
return true;
|
||||||
} else {
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
void EsxModel::DataFilesModel::sort(int column, Qt::SortOrder order)
|
void EsxModel::DataFilesModel::sort(int column, Qt::SortOrder order)
|
||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
|
@ -259,7 +264,7 @@ void EsxModel::DataFilesModel::sort(int column, Qt::SortOrder order)
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxModel::DataFilesModel::addFile(EsmFile *file)
|
void EsxModel::DataFilesModel::addFile(const EsmFile *file)
|
||||||
{
|
{
|
||||||
emit beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count());
|
emit beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count());
|
||||||
mFiles.append(file);
|
mFiles.append(file);
|
||||||
|
@ -331,22 +336,23 @@ void EsxModel::DataFilesModel::addFiles(const QString &path)
|
||||||
delete decoder;
|
delete decoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex EsxModel::DataFilesModel::indexFromItem(EsmFile *item) const
|
QModelIndex EsxModel::DataFilesModel::indexFromItem(const EsmFile *item) const
|
||||||
{
|
{
|
||||||
if (item)
|
if (item)
|
||||||
return createIndex(mFiles.indexOf(item), 0);
|
//return createIndex(mFiles.indexOf(item), 0);
|
||||||
|
return index(mFiles.indexOf(item),0);
|
||||||
|
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
EsxModel::EsmFile* EsxModel::DataFilesModel::findItem(const QString &name)
|
const EsxModel::EsmFile* EsxModel::DataFilesModel::findItem(const QString &name)
|
||||||
{
|
{
|
||||||
QList<EsmFile *>::ConstIterator it;
|
EsmFileList::ConstIterator it;
|
||||||
QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd();
|
EsmFileList::ConstIterator itEnd = mFiles.constEnd();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (it = mFiles.constBegin(); it != itEnd; ++it) {
|
for (it = mFiles.constBegin(); it != itEnd; ++it) {
|
||||||
EsmFile *file = item(i);
|
const EsmFile *file = item(i);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
if (name == file->fileName())
|
if (name == file->fileName())
|
||||||
|
@ -357,12 +363,12 @@ EsxModel::EsmFile* EsxModel::DataFilesModel::findItem(const QString &name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EsxModel::EsmFile* EsxModel::DataFilesModel::item(int row) const
|
const EsxModel::EsmFile* EsxModel::DataFilesModel::item(int row) const
|
||||||
{
|
{
|
||||||
if (row >= 0 && row < mFiles.count())
|
if (row >= 0 && row < mFiles.count())
|
||||||
return mFiles.at(row);
|
return mFiles.at(row);
|
||||||
else
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EsxModel::EsmFileList EsxModel::DataFilesModel::checkedItems()
|
EsxModel::EsmFileList EsxModel::DataFilesModel::checkedItems()
|
||||||
|
@ -372,14 +378,11 @@ EsxModel::EsmFileList EsxModel::DataFilesModel::checkedItems()
|
||||||
EsmFileList::ConstIterator it;
|
EsmFileList::ConstIterator it;
|
||||||
EsmFileList::ConstIterator itEnd = mFiles.constEnd();
|
EsmFileList::ConstIterator itEnd = mFiles.constEnd();
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for (it = mFiles.constBegin(); it != itEnd; ++it)
|
for (it = mFiles.constBegin(); it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
EsmFile *file = *it;
|
|
||||||
|
|
||||||
// Only add the items that are in the checked list and available
|
// Only add the items that are in the checked list and available
|
||||||
if (mCheckStates[file->fileName()] == Qt::Checked && canBeChecked(file))
|
if (mCheckStates[(*it)->fileName()] == Qt::Checked && canBeChecked(*it))
|
||||||
list << file;
|
list << (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -389,12 +392,12 @@ QStringList EsxModel::DataFilesModel::checkedItemsPaths()
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
|
||||||
QList<EsmFile *>::ConstIterator it;
|
EsmFileList::ConstIterator it;
|
||||||
QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd();
|
EsmFileList::ConstIterator itEnd = mFiles.constEnd();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (it = mFiles.constBegin(); it != itEnd; ++it) {
|
for (it = mFiles.constBegin(); it != itEnd; ++it) {
|
||||||
EsmFile *file = item(i);
|
const EsmFile *file = item(i);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
if (mCheckStates[file->fileName()] == Qt::Checked && canBeChecked(file))
|
if (mCheckStates[file->fileName()] == Qt::Checked && canBeChecked(file))
|
||||||
|
@ -403,7 +406,6 @@ QStringList EsxModel::DataFilesModel::checkedItemsPaths()
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxModel::DataFilesModel::uncheckAll()
|
void EsxModel::DataFilesModel::uncheckAll()
|
||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
|
@ -411,18 +413,17 @@ void EsxModel::DataFilesModel::uncheckAll()
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
EsxModel::EsmFileList EsxModel::DataFilesModel::uncheckedItems()
|
EsxModel::EsmFileList EsxModel::DataFilesModel::uncheckedItems()
|
||||||
{
|
{
|
||||||
EsmFileList list;
|
EsmFileList list;
|
||||||
EsmFileList checked = checkedItems();
|
EsmFileList checked = checkedItems();
|
||||||
|
|
||||||
EsmFileList::ConstIterator it;
|
EsmFileList::ConstIterator it;
|
||||||
EsmFileList::ConstIterator itEnd = mFiles.constEnd();
|
|
||||||
|
|
||||||
int i = 0;
|
for (it = mFiles.constBegin(); it != mFiles.constEnd(); ++it)
|
||||||
for (it = mFiles.constBegin(); it != itEnd; ++it) {
|
{
|
||||||
EsmFile *file = item(i);
|
const EsmFile *file = *it;
|
||||||
++i;
|
|
||||||
|
|
||||||
// Add the items that are not in the checked list
|
// Add the items that are not in the checked list
|
||||||
if (!checked.contains(file))
|
if (!checked.contains(file))
|
||||||
|
@ -431,8 +432,8 @@ EsxModel::EsmFileList EsxModel::DataFilesModel::uncheckedItems()
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
bool EsxModel::DataFilesModel::canBeChecked(EsmFile *file) const
|
bool EsxModel::DataFilesModel::canBeChecked(const EsmFile *file) const
|
||||||
{
|
{
|
||||||
//element can be checked if all its dependencies are
|
//element can be checked if all its dependencies are
|
||||||
foreach (const QString &master, file->masters())
|
foreach (const QString &master, file->masters())
|
||||||
|
@ -442,3 +443,110 @@ bool EsxModel::DataFilesModel::canBeChecked(EsmFile *file) const
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::DropActions EsxModel::DataFilesModel::supportedDropActions() const
|
||||||
|
{
|
||||||
|
return Qt::CopyAction | Qt::MoveAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList EsxModel::DataFilesModel::mimeTypes() const
|
||||||
|
{
|
||||||
|
QStringList types;
|
||||||
|
types << "application/omwcontent";
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMimeData *EsxModel::DataFilesModel::mimeData(const QModelIndexList &indexes) const
|
||||||
|
{
|
||||||
|
// if (indexes.at(0).isValid())
|
||||||
|
// return new EsmFile(*item(indexes.at(0).row()));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EsxModel::DataFilesModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
if (action == Qt::IgnoreAction)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (action != Qt::MoveAction)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!data->hasFormat("application/omwcontent"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int dropRow = row;
|
||||||
|
|
||||||
|
if (dropRow == -1)
|
||||||
|
{
|
||||||
|
if (parent.isValid())
|
||||||
|
dropRow = parent.row();
|
||||||
|
else
|
||||||
|
dropRow = rowCount(QModelIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent.isValid())
|
||||||
|
qDebug() << "parent: " << parent.data().toString();
|
||||||
|
qDebug() << "dragged file: " << (qobject_cast<const EsmFile *>(data))->fileName();
|
||||||
|
// qDebug() << "inserting file: " << droppedfile->fileName() << " ahead of " << file->fileName();
|
||||||
|
insertRows (dropRow, 1, QModelIndex());
|
||||||
|
|
||||||
|
|
||||||
|
const EsmFile *draggedFile = qobject_cast<const EsmFile *>(data);
|
||||||
|
|
||||||
|
int dragRow = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < mFiles.size(); ++i)
|
||||||
|
if (draggedFile->fileName() == mFiles.at(i)->fileName())
|
||||||
|
{
|
||||||
|
dragRow = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < mFiles.count(); ++i)
|
||||||
|
{
|
||||||
|
qDebug() << "index: " << i << "file: " << item(i)->fileName();
|
||||||
|
qDebug() << mFiles.at(i)->fileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "drop row: " << dropRow << "; drag row: " << dragRow;
|
||||||
|
// const EsmFile *file = qobject_cast<const EsmFile *>(data);
|
||||||
|
// int index = mFiles.indexOf(file);
|
||||||
|
//qDebug() << "file name: " << file->fileName() << "; index: " << index;
|
||||||
|
mFiles.swap(dropRow, dragRow);
|
||||||
|
//setData(index(startRow, 0), varFile);
|
||||||
|
emit dataChanged(index(0,0), index(rowCount(),0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EsxModel::DataFilesModel::insertRows(int row, int count, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
qDebug() << "inserting row: " << row << " count: " << count;
|
||||||
|
beginInsertRows(QModelIndex(),row, row+count-1);
|
||||||
|
|
||||||
|
EsmFile *file = new EsmFile();
|
||||||
|
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
mFiles.insert(row + i, file);
|
||||||
|
|
||||||
|
endInsertRows();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EsxModel::DataFilesModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
qDebug() << "removing row: " << row << " count: " << count;
|
||||||
|
beginRemoveRows(QModelIndex(), row, row+count-1);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
mFiles.removeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
endRemoveRows();
|
||||||
|
qDebug() <<"remove success";
|
||||||
|
|
||||||
|
emit dataChanged(parent, index(rowCount()-1, 0, parent));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace EsxModel
|
||||||
{
|
{
|
||||||
class EsmFile;
|
class EsmFile;
|
||||||
|
|
||||||
typedef QList<EsmFile *> EsmFileList;
|
typedef QList<const EsmFile *> EsmFileList;
|
||||||
|
|
||||||
class DataFilesModel : public QAbstractTableModel
|
class DataFilesModel : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,8 @@ namespace EsxModel
|
||||||
virtual ~DataFilesModel();
|
virtual ~DataFilesModel();
|
||||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
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());
|
bool moveRow(int oldrow, int row, const QModelIndex &parent = QModelIndex());
|
||||||
|
|
||||||
|
@ -33,7 +35,10 @@ namespace EsxModel
|
||||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||||
|
|
||||||
inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
|
inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
|
||||||
{ return QAbstractTableModel::index(row, column, parent); }
|
{
|
||||||
|
QModelIndex idx = QAbstractTableModel::index(row, 0, parent);
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
|
||||||
void setEncoding(const QString &encoding);
|
void setEncoding(const QString &encoding);
|
||||||
|
|
||||||
|
@ -41,6 +46,11 @@ namespace EsxModel
|
||||||
|
|
||||||
void uncheckAll();
|
void uncheckAll();
|
||||||
|
|
||||||
|
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 checkedItems();
|
||||||
EsmFileList uncheckedItems();
|
EsmFileList uncheckedItems();
|
||||||
QStringList checkedItemsPaths();
|
QStringList checkedItemsPaths();
|
||||||
|
@ -48,16 +58,17 @@ namespace EsxModel
|
||||||
Qt::CheckState checkState(const QModelIndex &index);
|
Qt::CheckState checkState(const QModelIndex &index);
|
||||||
void setCheckState(const QModelIndex &index, Qt::CheckState state);
|
void setCheckState(const QModelIndex &index, Qt::CheckState state);
|
||||||
|
|
||||||
QModelIndex indexFromItem(EsmFile *item) const;
|
QModelIndex indexFromItem(const EsmFile *item) const;
|
||||||
EsmFile* findItem(const QString &name);
|
const EsmFile* findItem(const QString &name);
|
||||||
EsmFile* item(int row) const;
|
const EsmFile* item(int row) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void checkedItemsChanged(const EsmFileList &items);
|
void checkedItemsChanged(const EsmFileList &items);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool canBeChecked(EsmFile *file) const;
|
|
||||||
void addFile(EsmFile *file);
|
bool canBeChecked(const EsmFile *file) const;
|
||||||
|
void addFile(const EsmFile *file);
|
||||||
|
|
||||||
EsmFileList mFiles;
|
EsmFileList mFiles;
|
||||||
QHash<QString, Qt::CheckState> mCheckStates;
|
QHash<QString, Qt::CheckState> mCheckStates;
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
#include "esmfile.hpp"
|
#include "esmfile.hpp"
|
||||||
|
|
||||||
EsxModel::EsmFile::EsmFile(QString fileName, ModelItem *parent)
|
EsxModel::EsmFile::EsmFile(QString fileName, ModelItem *parent)
|
||||||
: ModelItem(parent)
|
: ModelItem(parent), mFileName(fileName), mSize(0), mVersion(0.0f)
|
||||||
{
|
{}
|
||||||
mFileName = fileName;
|
/*
|
||||||
mSize = 0;
|
EsxModel::EsmFile::EsmFile(const EsmFile &file)
|
||||||
mVersion = 0.0f;
|
: ModelItem(file.parent()), mFileName(file.mFileName), mSize(file.mSize),
|
||||||
}
|
mVersion(file.mVersion), mAuthor(file.mAuthor), mModified(file.mModified),
|
||||||
|
mAccessed(file.mAccessed), mPath(file.mPath), mMasters(file.mMasters),
|
||||||
|
mDescription(file.mDescription)
|
||||||
|
{}
|
||||||
|
|
||||||
|
*/
|
||||||
void EsxModel::EsmFile::setFileName(const QString &fileName)
|
void EsxModel::EsmFile::setFileName(const QString &fileName)
|
||||||
{
|
{
|
||||||
mFileName = fileName;
|
mFileName = fileName;
|
||||||
|
|
|
@ -14,7 +14,9 @@ namespace EsxModel
|
||||||
Q_PROPERTY(QString filename READ fileName)
|
Q_PROPERTY(QString filename READ fileName)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EsmFile(QString fileName = QString(), ModelItem *parent = 0);
|
EsmFile(QString fileName = QString(), ModelItem *parent = 0);
|
||||||
|
// EsmFile(const EsmFile &);
|
||||||
|
|
||||||
~EsmFile()
|
~EsmFile()
|
||||||
{}
|
{}
|
||||||
|
@ -38,6 +40,7 @@ namespace EsxModel
|
||||||
inline QStringList masters() const { return mMasters; }
|
inline QStringList masters() const { return mMasters; }
|
||||||
inline QString description() const { return mDescription; }
|
inline QString description() const { return mDescription; }
|
||||||
|
|
||||||
|
//inline ModelItem *parent() const { return ModelItem::parent(); this->}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mFileName;
|
QString mFileName;
|
||||||
|
@ -53,4 +56,6 @@ namespace EsxModel
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE (EsxModel::EsmFile *)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "masterproxymodel.hpp"
|
#include "masterproxymodel.hpp"
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
EsxModel::MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableModel* model) :
|
EsxModel::MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableModel* model) :
|
||||||
QSortFilterProxyModel(parent)
|
QSortFilterProxyModel(parent)
|
||||||
|
@ -7,10 +9,36 @@ EsxModel::MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableMode
|
||||||
setFilterRole (Qt::UserRole);
|
setFilterRole (Qt::UserRole);
|
||||||
|
|
||||||
if (model)
|
if (model)
|
||||||
setSourceModel (model);
|
setSourceModel (model);
|
||||||
|
//connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(slotSourceModelChanged(QModelIndex, QModelIndex)));
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
QVariant EsxModel::MasterProxyModel::data(const QModelIndex &index, int role) const
|
QVariant EsxModel::MasterProxyModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
return QSortFilterProxyModel::data (index, role);
|
if (index.isValid())
|
||||||
|
return QSortFilterProxyModel::data (index, role);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
void EsxModel::MasterProxyModel::slotSourceModelChanged(QModelIndex topLeft, QModelIndex botRight)
|
||||||
|
{
|
||||||
|
qDebug() << "source data changed.. updating master proxy";
|
||||||
|
emit dataChanged(index(0,0), index(rowCount()-1,0));
|
||||||
|
|
||||||
|
int curRow = -1;
|
||||||
|
/*
|
||||||
|
for (int i = 0; i < rowCount() - 1; ++i)
|
||||||
|
{
|
||||||
|
if (index(i,0).data(Qt::CheckState) == Qt::Checked)
|
||||||
|
{
|
||||||
|
curRow = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
*/
|
||||||
|
if (curRow != -1);
|
||||||
|
// index(curRow, 0).setDataQt::CheckState)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#define MASTERPROXYMODEL_HPP
|
#define MASTERPROXYMODEL_HPP
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QMimeData>
|
||||||
|
|
||||||
class QAbstractTableModel;
|
class QAbstractTableModel;
|
||||||
|
|
||||||
|
@ -12,12 +14,12 @@ namespace EsxModel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MasterProxyModel(QObject *parent = 0, QAbstractTableModel *model = 0);
|
explicit MasterProxyModel(QObject *parent = 0, QAbstractTableModel *model = 0);
|
||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
// virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void slotSourceModelChanged(QModelIndex topLeft, QModelIndex botRight);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // MASTERPROXYMODEL_HPP
|
#endif // MASTERPROXYMODEL_HPP
|
||||||
|
|
|
@ -2,9 +2,14 @@
|
||||||
|
|
||||||
EsxModel::ModelItem::ModelItem(ModelItem *parent)
|
EsxModel::ModelItem::ModelItem(ModelItem *parent)
|
||||||
: mParentItem(parent)
|
: mParentItem(parent)
|
||||||
, QObject(parent)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
EsxModel::ModelItem::ModelItem(const ModelItem *parent)
|
||||||
|
// : mParentItem(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
EsxModel::ModelItem::~ModelItem()
|
EsxModel::ModelItem::~ModelItem()
|
||||||
{
|
{
|
||||||
|
@ -12,11 +17,18 @@ EsxModel::ModelItem::~ModelItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EsxModel::ModelItem *EsxModel::ModelItem::parent()
|
EsxModel::ModelItem *EsxModel::ModelItem::parent() const
|
||||||
{
|
{
|
||||||
return mParentItem;
|
return mParentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EsxModel::ModelItem::hasFormat(const QString &mimetype) const
|
||||||
|
{
|
||||||
|
if (mimetype == "application/omwcontent")
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return QMimeData::hasFormat(mimetype);
|
||||||
|
}
|
||||||
int EsxModel::ModelItem::row() const
|
int EsxModel::ModelItem::row() const
|
||||||
{
|
{
|
||||||
if (mParentItem)
|
if (mParentItem)
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
#ifndef MODELITEM_HPP
|
#ifndef MODELITEM_HPP
|
||||||
#define MODELITEM_HPP
|
#define MODELITEM_HPP
|
||||||
|
|
||||||
#include <QObject>
|
#include <QMimeData>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
namespace EsxModel
|
namespace EsxModel
|
||||||
{
|
{
|
||||||
class ModelItem : public QObject
|
class ModelItem : public QMimeData
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModelItem(ModelItem *parent = 0);
|
ModelItem(ModelItem *parent = 0);
|
||||||
|
//ModelItem(const ModelItem *parent = 0);
|
||||||
|
|
||||||
~ModelItem();
|
~ModelItem();
|
||||||
|
|
||||||
ModelItem *parent();
|
ModelItem *parent() const;
|
||||||
int row() const;
|
int row() const;
|
||||||
|
|
||||||
int childCount() const;
|
int childCount() const;
|
||||||
|
@ -24,6 +26,8 @@ namespace EsxModel
|
||||||
void appendChild(ModelItem *child);
|
void appendChild(ModelItem *child);
|
||||||
void removeChild(int row);
|
void removeChild(int row);
|
||||||
|
|
||||||
|
bool hasFormat(const QString &mimetype) const;
|
||||||
|
|
||||||
//virtual bool acceptChild(ModelItem *child);
|
//virtual bool acceptChild(ModelItem *child);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include "pluginsproxymodel.hpp"
|
#include "pluginsproxymodel.hpp"
|
||||||
#include "datafilesmodel.hpp"
|
#include "contentmodel.hpp"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
EsxModel::PluginsProxyModel::PluginsProxyModel(QObject *parent, DataFilesModel *model) :
|
EsxModel::PluginsProxyModel::PluginsProxyModel(QObject *parent, ContentModel *model) :
|
||||||
QSortFilterProxyModel(parent)
|
QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
setFilterRegExp (QString("addon"));
|
setFilterRegExp (QString("addon"));
|
||||||
|
@ -22,12 +23,18 @@ QVariant EsxModel::PluginsProxyModel::data(const QModelIndex &index, int role) c
|
||||||
{
|
{
|
||||||
case Qt::CheckStateRole:
|
case Qt::CheckStateRole:
|
||||||
{
|
{
|
||||||
if (index.column() != 0)
|
if (index.column() != 0)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
return static_cast<DataFilesModel *>(sourceModel())->checkState(mapToSource(index));
|
return static_cast<ContentModel *>(sourceModel())->checkState(mapToSource(index));
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
return QSortFilterProxyModel::data(index, role);
|
||||||
return QSortFilterProxyModel::data (index, role);
|
}
|
||||||
|
|
||||||
|
bool EsxModel::PluginsProxyModel::removeRows(int position, int rows, const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
bool success = QSortFilterProxyModel::removeRows(position, rows, parent);
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ class QAbstractTableModel;
|
||||||
|
|
||||||
namespace EsxModel
|
namespace EsxModel
|
||||||
{
|
{
|
||||||
class DataFilesModel;
|
class ContentModel;
|
||||||
|
|
||||||
class PluginsProxyModel : public QSortFilterProxyModel
|
class PluginsProxyModel : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
|
@ -16,10 +16,12 @@ namespace EsxModel
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit PluginsProxyModel(QObject *parent = 0, DataFilesModel *model = 0);
|
explicit PluginsProxyModel(QObject *parent = 0, ContentModel *model = 0);
|
||||||
~PluginsProxyModel();
|
~PluginsProxyModel();
|
||||||
|
|
||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
|
bool removeRows(int row, int count, const QModelIndex &parent);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
components/esxselector/model/sourcemodel.cpp
Normal file
6
components/esxselector/model/sourcemodel.cpp
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#include "sourcemodel.h"
|
||||||
|
|
||||||
|
SourceModel::SourceModel(QObject *parent) :
|
||||||
|
QAbstractTableClass(parent)
|
||||||
|
{
|
||||||
|
}
|
18
components/esxselector/model/sourcemodel.h
Normal file
18
components/esxselector/model/sourcemodel.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef SOURCEMODEL_H
|
||||||
|
#define SOURCEMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractTableClass>
|
||||||
|
|
||||||
|
class SourceModel : public QAbstractTableClass
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SourceModel(QObject *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SOURCEMODEL_H
|
|
@ -3,6 +3,8 @@
|
||||||
#include "../model/datafilesmodel.hpp"
|
#include "../model/datafilesmodel.hpp"
|
||||||
#include "../model/masterproxymodel.hpp"
|
#include "../model/masterproxymodel.hpp"
|
||||||
#include "../model/pluginsproxymodel.hpp"
|
#include "../model/pluginsproxymodel.hpp"
|
||||||
|
#include "../model/contentmodel.hpp"
|
||||||
|
#include "../model/esmfile.hpp"
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
@ -14,7 +16,33 @@ EsxView::ContentSelector::ContentSelector(QWidget *parent) :
|
||||||
QDialog(parent)
|
QDialog(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
buildModelsAndViews();
|
// buildModelsAndViews();
|
||||||
|
buildDragDropModelView();
|
||||||
|
}
|
||||||
|
void EsxView::ContentSelector::buildDragDropModelView()
|
||||||
|
{
|
||||||
|
mContentModel = new EsxModel::ContentModel();
|
||||||
|
|
||||||
|
//mContentModel->addFiles("/home/joel/Projects/OpenMW/Data_Files");
|
||||||
|
mMasterProxyModel = new EsxModel::MasterProxyModel(this, mContentModel);
|
||||||
|
mPluginsProxyModel = new EsxModel::PluginsProxyModel(this, mContentModel);
|
||||||
|
|
||||||
|
tableView->setModel (mPluginsProxyModel);
|
||||||
|
|
||||||
|
masterView->setPlaceholderText(QString("Select a game file..."));
|
||||||
|
masterView->setModel(mMasterProxyModel);
|
||||||
|
pluginView->setModel(mPluginsProxyModel);
|
||||||
|
|
||||||
|
profilesComboBox->setPlaceholderText(QString("Select a profile..."));
|
||||||
|
|
||||||
|
updateViews();
|
||||||
|
connect(pluginView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotPluginTableItemClicked(const QModelIndex &)));
|
||||||
|
connect(masterView, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentMasterIndexChanged(int)));
|
||||||
|
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentProfileIndexChanged(int)));
|
||||||
|
|
||||||
|
|
||||||
|
connect(mContentModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
||||||
|
connect(tableView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotPluginTableItemClicked(const QModelIndex &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxView::ContentSelector::buildModelsAndViews()
|
void EsxView::ContentSelector::buildModelsAndViews()
|
||||||
|
@ -22,15 +50,15 @@ void EsxView::ContentSelector::buildModelsAndViews()
|
||||||
// Models
|
// Models
|
||||||
mDataFilesModel = new EsxModel::DataFilesModel (this);
|
mDataFilesModel = new EsxModel::DataFilesModel (this);
|
||||||
|
|
||||||
mMasterProxyModel = new EsxModel::MasterProxyModel (this, mDataFilesModel);
|
// mMasterProxyModel = new EsxModel::MasterProxyModel (this, mDataFilesModel);
|
||||||
mPluginsProxyModel = new EsxModel::PluginsProxyModel (this, mDataFilesModel);
|
// mPluginsProxyModel = new EsxModel::PluginsProxyModel (this, mDataFilesModel);
|
||||||
|
|
||||||
masterView->setPlaceholderText(QString("Select a game file..."));
|
masterView->setPlaceholderText(QString("Select a game file..."));
|
||||||
masterView->setModel(mMasterProxyModel);
|
masterView->setModel(mMasterProxyModel);
|
||||||
pluginView->setModel(mPluginsProxyModel);
|
pluginView->setModel(mPluginsProxyModel);
|
||||||
profilesComboBox->setPlaceholderText(QString("Select a profile..."));
|
profilesComboBox->setPlaceholderText(QString("Select a profile..."));
|
||||||
|
|
||||||
|
updateViews();
|
||||||
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
||||||
connect(pluginView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotPluginTableItemClicked(const QModelIndex &)));
|
connect(pluginView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotPluginTableItemClicked(const QModelIndex &)));
|
||||||
connect(masterView, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentMasterIndexChanged(int)));
|
connect(masterView, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentMasterIndexChanged(int)));
|
||||||
|
@ -39,15 +67,15 @@ void EsxView::ContentSelector::buildModelsAndViews()
|
||||||
|
|
||||||
void EsxView::ContentSelector::addFiles(const QString &path)
|
void EsxView::ContentSelector::addFiles(const QString &path)
|
||||||
{
|
{
|
||||||
mDataFilesModel->addFiles(path);
|
mContentModel->addFiles(path);
|
||||||
mDataFilesModel->sort(3); // Sort by date accessed
|
mContentModel->sort(3); // Sort by date accessed
|
||||||
masterView->setCurrentIndex(-1);
|
masterView->setCurrentIndex(-1);
|
||||||
mDataFilesModel->uncheckAll();
|
mContentModel->uncheckAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxView::ContentSelector::setEncoding(const QString &encoding)
|
void EsxView::ContentSelector::setEncoding(const QString &encoding)
|
||||||
{
|
{
|
||||||
mDataFilesModel->setEncoding(encoding);
|
mContentModel->setEncoding(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxView::ContentSelector::setCheckState(QModelIndex index, QSortFilterProxyModel *model)
|
void EsxView::ContentSelector::setCheckState(QModelIndex index, QSortFilterProxyModel *model)
|
||||||
|
@ -62,15 +90,20 @@ void EsxView::ContentSelector::setCheckState(QModelIndex index, QSortFilterProxy
|
||||||
|
|
||||||
if (sourceIndex.isValid())
|
if (sourceIndex.isValid())
|
||||||
{
|
{
|
||||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
(mContentModel->checkState(sourceIndex) == Qt::Checked)
|
||||||
? mDataFilesModel->setCheckState(sourceIndex, Qt::Unchecked)
|
? mContentModel->setCheckState(sourceIndex, Qt::Unchecked)
|
||||||
: mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
: mContentModel->setCheckState(sourceIndex, Qt::Checked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList EsxView::ContentSelector::checkedItemsPaths()
|
QStringList EsxView::ContentSelector::checkedItemsPaths()
|
||||||
{
|
{
|
||||||
return mDataFilesModel->checkedItemsPaths();
|
QStringList itemPaths;
|
||||||
|
|
||||||
|
foreach( const EsxModel::EsmFile *file, mContentModel->checkedItems())
|
||||||
|
itemPaths << file->path();
|
||||||
|
|
||||||
|
return itemPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxView::ContentSelector::updateViews()
|
void EsxView::ContentSelector::updateViews()
|
||||||
|
@ -106,5 +139,6 @@ void EsxView::ContentSelector::slotCurrentMasterIndexChanged(int index)
|
||||||
|
|
||||||
void EsxView::ContentSelector::slotPluginTableItemClicked(const QModelIndex &index)
|
void EsxView::ContentSelector::slotPluginTableItemClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
|
qDebug() << "setting checkstate in plugin...";
|
||||||
setCheckState(index, mPluginsProxyModel);
|
setCheckState(index, mPluginsProxyModel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
namespace EsxModel
|
namespace EsxModel
|
||||||
{
|
{
|
||||||
|
class ContentModel;
|
||||||
class DataFilesModel;
|
class DataFilesModel;
|
||||||
class PluginsProxyModel;
|
class PluginsProxyModel;
|
||||||
class MasterProxyModel;
|
class MasterProxyModel;
|
||||||
|
@ -23,6 +24,7 @@ namespace EsxView
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
EsxModel::DataFilesModel *mDataFilesModel;
|
EsxModel::DataFilesModel *mDataFilesModel;
|
||||||
|
EsxModel::ContentModel *mContentModel;
|
||||||
EsxModel::MasterProxyModel *mMasterProxyModel;
|
EsxModel::MasterProxyModel *mMasterProxyModel;
|
||||||
EsxModel::PluginsProxyModel *mPluginsProxyModel;
|
EsxModel::PluginsProxyModel *mPluginsProxyModel;
|
||||||
|
|
||||||
|
@ -37,6 +39,7 @@ namespace EsxView
|
||||||
void setCheckState(QModelIndex index, QSortFilterProxyModel *model);
|
void setCheckState(QModelIndex index, QSortFilterProxyModel *model);
|
||||||
QStringList checkedItemsPaths();
|
QStringList checkedItemsPaths();
|
||||||
void on_checkAction_triggered();
|
void on_checkAction_triggered();
|
||||||
|
void buildDragDropModelView();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void profileChanged(int index);
|
void profileChanged(int index);
|
||||||
|
|
|
@ -7,28 +7,19 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>518</width>
|
<width>518</width>
|
||||||
<height>304</height>
|
<height>310</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::DefaultContextMenu</enum>
|
<enum>Qt::DefaultContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="contentGroupBox">
|
<widget class="QGroupBox" name="contentGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Content</string>
|
<string>Content</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="leftMargin">
|
|
||||||
<number>3</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="filterLayout">
|
<layout class="QHBoxLayout" name="filterLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -41,7 +32,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="pluginView">
|
<widget class="QTableView" name="pluginView">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -56,6 +47,18 @@
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
<set>QAbstractItemView::NoEditTriggers</set>
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropOverwriteMode">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::DragDrop</enum>
|
||||||
|
</property>
|
||||||
|
<property name="defaultDropAction">
|
||||||
|
<enum>Qt::MoveAction</enum>
|
||||||
|
</property>
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -82,6 +85,40 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="tableView">
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropOverwriteMode">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::DragDrop</enum>
|
||||||
|
</property>
|
||||||
|
<property name="defaultDropAction">
|
||||||
|
<enum>Qt::MoveAction</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
|
<property name="showGrid">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="horizontalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
Loading…
Reference in a new issue