Finished implementing drag / drop

refactored datafilesmodel (now contentmodel)
refactored esmfil
actorid
graffy76 11 years ago
parent 0eb06ada39
commit 244e581952

@ -1,17 +1,37 @@
#include "contentmodel.hpp" #include "contentmodel.hpp"
#include "esmfile.hpp" #include "esmfile.hpp"
#include <QDebug>
#include <QDir> #include <QDir>
#include <QTextCodec> #include <QTextCodec>
#include <components/esm/esmreader.hpp> #include <components/esm/esmreader.hpp>
#include <QDebug>
EsxModel::ContentModel::ContentModel(QObject *parent) : EsxModel::ContentModel::ContentModel(QObject *parent) :
QAbstractTableModel(parent), mEncoding("win1252") QAbstractTableModel(parent),
{} mMimeType ("application/omwcontent"),
mMimeTypes (QStringList() << mMimeType),
mColumnCount (1),
mDragDropFlags (Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled),
mDefaultFlags (Qt::ItemIsDropEnabled | Qt::ItemIsSelectable),
mDropActions (Qt::CopyAction | Qt::MoveAction)
{
setEncoding ("win1252");
uncheckAll();
}
void EsxModel::ContentModel::setEncoding(const QString &encoding) void EsxModel::ContentModel::setEncoding(const QString &encoding)
{ {
mEncoding = encoding; if (encoding == QLatin1String("win1252"))
mCodec = QTextCodec::codecForName("windows-1252");
else if (encoding == QLatin1String("win1251"))
mCodec = QTextCodec::codecForName("windows-1251");
else if (encoding == QLatin1String("win1250"))
mCodec = QTextCodec::codecForName("windows-1250");
else
return; // This should never happen;
} }
int EsxModel::ContentModel::columnCount(const QModelIndex &parent) const int EsxModel::ContentModel::columnCount(const QModelIndex &parent) const
@ -19,7 +39,7 @@ int EsxModel::ContentModel::columnCount(const QModelIndex &parent) const
if (parent.isValid()) if (parent.isValid())
return 0; return 0;
return 1; return mColumnCount;
} }
int EsxModel::ContentModel::rowCount(const QModelIndex &parent) const int EsxModel::ContentModel::rowCount(const QModelIndex &parent) const
@ -30,22 +50,28 @@ int EsxModel::ContentModel::rowCount(const QModelIndex &parent) const
return mFiles.size(); return mFiles.size();
} }
EsxModel::EsmFile* EsxModel::ContentModel::item(int row) const const EsxModel::EsmFile* EsxModel::ContentModel::item(int row) const
{ {
if (row >= 0 && row < mFiles.count()) if (row >= 0 && row < mFiles.size())
return mFiles.at(row); return mFiles.at(row);
return 0; return 0;
} }
EsxModel::EsmFile* EsxModel::ContentModel::findItem(const QString &name) EsxModel::EsmFile *EsxModel::ContentModel::item(int row)
{ {
for (int i = 0; i < mFiles.size(); ++i) if (row >= 0 && row < mFiles.count())
return mFiles.at(row);
return 0;
}
const EsxModel::EsmFile *EsxModel::ContentModel::findItem(const QString &name) const
{
foreach (const EsmFile *file, mFiles)
{ {
if (name == item(i)->fileName()) if (name == file->fileName())
return item(i); return file;
} }
return 0; return 0;
} }
@ -62,19 +88,15 @@ Qt::ItemFlags EsxModel::ContentModel::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());
if (!file) if (!file)
return Qt::NoItemFlags; 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)) if (canBeChecked(file))
return Qt::ItemIsEnabled | dragDropFlags | checkFlags | defaultFlags; return Qt::ItemIsEnabled | mDragDropFlags | mDefaultFlags;
else
return defaultFlags; return mDefaultFlags;
} }
QVariant EsxModel::ContentModel::data(const QModelIndex &index, int role) const QVariant EsxModel::ContentModel::data(const QModelIndex &index, int role) const
@ -85,7 +107,7 @@ QVariant EsxModel::ContentModel::data(const QModelIndex &index, int role) const
if (index.row() >= mFiles.size()) if (index.row() >= mFiles.size())
return QVariant(); return QVariant();
EsmFile *file = item(index.row()); const EsmFile *file = item(index.row());
if (!file) if (!file)
return QVariant(); return QVariant();
@ -97,25 +119,11 @@ QVariant EsxModel::ContentModel::data(const QModelIndex &index, int role) const
case Qt::EditRole: case Qt::EditRole:
case Qt::DisplayRole: case Qt::DisplayRole:
{ {
switch (column) if (column >=0 && column <=EsmFile::FileProperty_Master)
{ return file->fileProperty(static_cast<const EsmFile::FileProperty>(column));
case 0:
return file->fileName();
case 1:
return file->author();
case 2:
return file->modified().toString(Qt::ISODate);
case 3:
return file->version();
case 4:
return file->path();
case 5:
return file->masters().join(", ");
case 6:
return file->description();
}
return QVariant(); return QVariant();
break;
} }
case Qt::TextAlignmentRole: case Qt::TextAlignmentRole:
@ -132,6 +140,7 @@ QVariant EsxModel::ContentModel::data(const QModelIndex &index, int role) const
return Qt::AlignLeft + Qt::AlignVCenter; return Qt::AlignLeft + Qt::AlignVCenter;
} }
return QVariant(); return QVariant();
break;
} }
case Qt::ToolTipRole: case Qt::ToolTipRole:
@ -139,23 +148,16 @@ QVariant EsxModel::ContentModel::data(const QModelIndex &index, int role) const
if (column != 0) if (column != 0)
return QVariant(); return QVariant();
if (file->version() == 0.0f) return file->toolTip();
return QVariant(); // Data not set break;
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::CheckStateRole: case Qt::CheckStateRole:
{
if (!file->isMaster()) if (!file->isMaster())
return isChecked(file->fileName()); return isChecked(file->fileName());
break; break;
}
case Qt::UserRole: case Qt::UserRole:
{ {
@ -179,6 +181,7 @@ bool EsxModel::ContentModel::setData(const QModelIndex &index, const QVariant &v
EsmFile *file = item(index.row()); EsmFile *file = item(index.row());
QString fileName = file->fileName(); QString fileName = file->fileName();
bool success = false;
switch(role) switch(role)
{ {
@ -186,20 +189,15 @@ bool EsxModel::ContentModel::setData(const QModelIndex &index, const QVariant &v
{ {
QStringList list = value.toStringList(); QStringList list = value.toStringList();
//iterate the string list, assigning values to proeprties for (int i = 0; i < EsmFile::FileProperty_Master; i++)
//index-enum correspondence 1:1 file->setFileProperty(static_cast<EsmFile::FileProperty>(i), list.at(i));
for (int i = 0; i < EsxModel::Property_Master; i++)
file->setProperty(static_cast<EsmFileProperty>(i), list.at(i));
//iterate the remainder of the string list, assifning everything for (int i = EsmFile::FileProperty_Master; i < list.size(); i++)
// as file->setFileProperty (EsmFile::FileProperty_Master, list.at(i));
for (int i = EsxModel::Property_Master; i < list.size(); i++)
file->setProperty (EsxModel::Property_Master, list.at(i));
//emit data changed for the item itself
emit dataChanged(index, index); emit dataChanged(index, index);
return true; success = true;
} }
break; break;
@ -209,34 +207,37 @@ bool EsxModel::ContentModel::setData(const QModelIndex &index, const QVariant &v
emit dataChanged(index, index); emit dataChanged(index, index);
for(int i = 0; i < mFiles.size(); i++) foreach (EsmFile *file, mFiles)
{ {
if (file->masters().contains(fileName))
if (mFiles.at(i)->masters().contains(fileName))
{ {
QModelIndex idx = QAbstractTableModel::index(i, 0); QModelIndex idx = indexFromItem(file);
emit dataChanged(idx, idx); emit dataChanged(idx, idx);
} }
} }
success = true;
return true;
} }
break; break;
case Qt::CheckStateRole: case Qt::CheckStateRole:
{ {
bool checked = ((value.toInt() == Qt::Checked) && !isChecked(fileName)); int checkValue = value.toInt();
setCheckState(fileName, checked); if ((checkValue==Qt::Checked) && !isChecked(fileName))
setCheckState(fileName, true);
else if ((checkValue == Qt::Checked) && isChecked (fileName))
setCheckState(fileName, false);
else if (checkValue == Qt::Unchecked)
setCheckState(fileName, false);
emit dataChanged(index, index); emit dataChanged(index, index);
return true; success = true;
} }
break; break;
} }
return false; return success;
} }
bool EsxModel::ContentModel::insertRows(int position, int rows, const QModelIndex &parent) bool EsxModel::ContentModel::insertRows(int position, int rows, const QModelIndex &parent)
@ -271,16 +272,12 @@ bool EsxModel::ContentModel::removeRows(int position, int rows, const QModelInde
Qt::DropActions EsxModel::ContentModel::supportedDropActions() const Qt::DropActions EsxModel::ContentModel::supportedDropActions() const
{ {
return Qt::CopyAction | Qt::MoveAction; return mDropActions;
} }
QStringList EsxModel::ContentModel::mimeTypes() const QStringList EsxModel::ContentModel::mimeTypes() const
{ {
QStringList types; return mMimeTypes;
types << "application/omwcontent";
return types;
} }
QMimeData *EsxModel::ContentModel::mimeData(const QModelIndexList &indexes) const QMimeData *EsxModel::ContentModel::mimeData(const QModelIndexList &indexes) const
@ -292,14 +289,11 @@ QMimeData *EsxModel::ContentModel::mimeData(const QModelIndexList &indexes) cons
if (!index.isValid()) if (!index.isValid())
continue; continue;
QByteArray fileData = item(index.row())->encodedData(); encodedData.append(item(index.row())->encodedData());
foreach (const char c, fileData)
encodedData.append(c);
} }
QMimeData *mimeData = new QMimeData(); QMimeData *mimeData = new QMimeData();
mimeData->setData("application/omwcontent", encodedData); mimeData->setData(mMimeType, encodedData);
return mimeData; return mimeData;
} }
@ -309,13 +303,13 @@ bool EsxModel::ContentModel::dropMimeData(const QMimeData *data, Qt::DropAction
if (action == Qt::IgnoreAction) if (action == Qt::IgnoreAction)
return true; return true;
if (!data->hasFormat("application/omwcontent")) if (column > 0)
return false; return false;
if (column > 0) if (!data->hasFormat(mMimeType))
return false; return false;
int beginRow; int beginRow = rowCount();
if (row != -1) if (row != -1)
beginRow = row; beginRow = row;
@ -323,23 +317,28 @@ bool EsxModel::ContentModel::dropMimeData(const QMimeData *data, Qt::DropAction
else if (parent.isValid()) else if (parent.isValid())
beginRow = parent.row(); beginRow = parent.row();
else QByteArray encodedData = data->data(mMimeType);
beginRow = rowCount();
QByteArray encodedData = data->data("application/omwcontent");
QDataStream stream(&encodedData, QIODevice::ReadOnly); QDataStream stream(&encodedData, QIODevice::ReadOnly);
while (!stream.atEnd()) while (!stream.atEnd())
{ {
QString value;
QStringList values; QStringList values;
QStringList masters;
for (int i = 0; i < EsmFile::sPropertyCount; ++i) for (int i = 0; i < EsmFile::FileProperty_Master; ++i)
stream >> values; {
stream >> value;
values << value;
}
stream >> masters;
insertRows(beginRow, 1); insertRows(beginRow, 1);
QModelIndex idx = index(beginRow++, 0, QModelIndex()); QModelIndex idx = index(beginRow++, 0, QModelIndex());
setData(idx, values, Qt::EditRole); setData(idx, QStringList() << values << masters, Qt::EditRole);
} }
return true; return true;
@ -349,37 +348,8 @@ bool EsxModel::ContentModel::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())
{
{// if the master is not found in checkstates
// or it is not specifically checked, return false
if (!mCheckStates.contains(master))
return false;
if (!isChecked(master)) if (!isChecked(master))
return false; return false;
}
bool found = false;
//iterate each file, if it is not a master and
//does not have a master that is currently checked,
//return false.
foreach(const EsmFile *file, mFiles)
{
QString filename = file->fileName();
found = (filename == master);
if (found)
{
if (!isChecked(filename))
return false;
}
}
if (!found)
return false;
}
return true; return true;
} }
@ -387,9 +357,8 @@ bool EsxModel::ContentModel::canBeChecked(const EsmFile *file) const
void EsxModel::ContentModel::addFile(EsmFile *file) void EsxModel::ContentModel::addFile(EsmFile *file)
{ {
beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count()); beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count());
{
mFiles.append(file); mFiles.append(file);
} endInsertRows(); endInsertRows();
} }
void EsxModel::ContentModel::addFiles(const QString &path) void EsxModel::ContentModel::addFiles(const QString &path)
@ -400,45 +369,26 @@ void EsxModel::ContentModel::addFiles(const QString &path)
dir.setNameFilters(filters); dir.setNameFilters(filters);
// Create a decoder for non-latin characters in esx metadata // Create a decoder for non-latin characters in esx metadata
QTextCodec *codec; QTextDecoder *decoder = mCodec->makeDecoder();
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()) { foreach (const QString &path, dir.entryList())
{
QFileInfo info(dir.absoluteFilePath(path)); QFileInfo info(dir.absoluteFilePath(path));
EsmFile *file = new EsmFile(path); EsmFile *file = new EsmFile(path);
try { try {
ESM::ESMReader fileReader; ESM::ESMReader fileReader;
ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(mEncoding.toStdString())); ToUTF8::Utf8Encoder encoder(ToUTF8::calculateEncoding(QString(mCodec->name()).toStdString()));
fileReader.setEncoder(&encoder); fileReader.setEncoder(&encoder);
fileReader.open(dir.absoluteFilePath(path).toStdString()); fileReader.open(dir.absoluteFilePath(path).toStdString());
std::vector<ESM::Header::MasterData> mlist = fileReader.getMasters(); foreach (const ESM::Header::MasterData &item, fileReader.getMasters())
file->addMaster(QString::fromStdString(item.name));
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->setAuthor (decoder->toUnicode(fileReader.getAuthor().c_str()));
//file->setSize(info.size()); file->setDate (info.lastModified());
file->setDate(info.lastModified()); file->setVersion (fileReader.getFVer());
file->setVersion(0.0f); file->setPath (info.absoluteFilePath());
file->setPath(info.absoluteFilePath());
file->setMasters(masters);
file->setDescription(decoder->toUnicode(fileReader.getDesc().c_str())); file->setDescription(decoder->toUnicode(fileReader.getDesc().c_str()));
@ -459,7 +409,10 @@ void EsxModel::ContentModel::addFiles(const QString &path)
bool EsxModel::ContentModel::isChecked(const QString& name) const bool EsxModel::ContentModel::isChecked(const QString& name) const
{ {
if (mCheckStates.contains(name))
return (mCheckStates[name] == Qt::Checked); return (mCheckStates[name] == Qt::Checked);
return false;
} }
void EsxModel::ContentModel::setCheckState(const QString &name, bool isChecked) void EsxModel::ContentModel::setCheckState(const QString &name, bool isChecked)
@ -479,12 +432,9 @@ EsxModel::ContentFileList EsxModel::ContentModel::checkedItems() const
{ {
ContentFileList list; ContentFileList list;
for (int i = 0; i < mFiles.size(); ++i) foreach (EsmFile *file, mFiles)
{ {
EsmFile *file = item(i); if (isChecked(file->fileName()))
// Only add the items that are in the checked list and available
if (mCheckStates[file->fileName()] == Qt::Checked && canBeChecked(file))
list << file; list << file;
} }

@ -2,7 +2,7 @@
#define CONTENTMODEL_HPP #define CONTENTMODEL_HPP
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QStringList>
namespace EsxModel namespace EsxModel
{ {
class EsmFile; class EsmFile;
@ -35,7 +35,7 @@ namespace EsxModel
void addFiles(const QString &path); void addFiles(const QString &path);
QModelIndex indexFromItem(EsmFile *item) const; QModelIndex indexFromItem(EsmFile *item) const;
EsxModel::EsmFile *findItem(const QString &name); const EsxModel::EsmFile *findItem(const QString &name) const;
bool isChecked(const QString &name) const; bool isChecked(const QString &name) const;
void setCheckState(const QString &name, bool isChecked); void setCheckState(const QString &name, bool isChecked);
@ -45,16 +45,21 @@ namespace EsxModel
private: private:
void addFile(EsmFile *file); void addFile(EsmFile *file);
EsmFile* item(int row) const; const EsmFile *item(int row) const;
EsmFile *item(int row);
bool canBeChecked(const EsmFile *file) const; bool canBeChecked(const EsmFile *file) const;
ContentFileList mFiles; ContentFileList mFiles;
QHash<QString, Qt::CheckState> mCheckStates; QHash<QString, Qt::CheckState> mCheckStates;
QString mEncoding; QTextCodec *mCodec;
signals:
public slots: public:
QString mMimeType;
QStringList mMimeTypes;
int mColumnCount;
Qt::ItemFlags mDragDropFlags;
Qt::ItemFlags mDefaultFlags;
Qt::DropActions mDropActions;
}; };
} }

@ -4,19 +4,15 @@
#include <QDataStream> #include <QDataStream>
int EsxModel::EsmFile::sPropertyCount = 7; int EsxModel::EsmFile::sPropertyCount = 7;
QString EsxModel::EsmFile::sToolTip = QString("<b>Author:</b> %1<br/> \
<b>Version:</b> %2<br/> \
<br/><b>Description:</b><br/>%3<br/> \
<br/><b>Dependencies: </b>%4<br/>");
EsxModel::EsmFile::EsmFile(QString fileName, ModelItem *parent) EsxModel::EsmFile::EsmFile(QString fileName, ModelItem *parent)
: ModelItem(parent), mFileName(fileName), mVersion(0.0f) : ModelItem(parent), mFileName(fileName), mVersion(0.0f)
{} {}
/*
EsxModel::EsmFile::EsmFile(const EsmFile &file)
: 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;
@ -64,35 +60,72 @@ QByteArray EsxModel::EsmFile::encodedData() const
return encodedData; return encodedData;
} }
void EsxModel::EsmFile::setProperty (const EsmFileProperty prop, const QString &value) QVariant EsxModel::EsmFile::fileProperty(const FileProperty prop) const
{
switch (prop)
{
case FileProperty_FileName:
return mFileName;
break;
case FileProperty_Author:
return mAuthor;
break;
case FileProperty_Version:
return mVersion;
break;
case FileProperty_DateModified:
return mModified.toString(Qt::ISODate);
break;
case FileProperty_Path:
return mPath;
break;
case FileProperty_Description:
return mDescription;
break;
case FileProperty_Master:
return mMasters;
break;
default:
break;
}
return QVariant();
}
void EsxModel::EsmFile::setFileProperty (const FileProperty prop, const QString &value)
{ {
switch (prop) switch (prop)
{ {
case Property_FileName: case FileProperty_FileName:
mFileName = value; mFileName = value;
break; break;
case Property_Author: case FileProperty_Author:
mAuthor = value; mAuthor = value;
break; break;
case Property_Version: case FileProperty_Version:
mVersion = value.toFloat(); mVersion = value.toFloat();
break; break;
case Property_DateModified: case FileProperty_DateModified:
mModified = QDateTime::fromString(value); mModified = QDateTime::fromString(value);
break; break;
case Property_Path: case FileProperty_Path:
mPath = value; mPath = value;
break; break;
case Property_Description: case FileProperty_Description:
mDescription = value; mDescription = value;
break; break;
case Property_Master: case FileProperty_Master:
mMasters << value; mMasters << value;
break; break;

@ -10,17 +10,6 @@ class QMimeData;
namespace EsxModel namespace EsxModel
{ {
enum EsmFileProperty
{
Property_FileName = 0,
Property_Author = 1,
Property_Version = 2,
Property_DateModified = 3,
Property_Path = 4,
Property_Description = 5,
Property_Master = 6
};
class EsmFile : public ModelItem class EsmFile : public ModelItem
{ {
Q_OBJECT Q_OBJECT
@ -28,13 +17,24 @@ namespace EsxModel
public: public:
enum FileProperty
{
FileProperty_FileName = 0,
FileProperty_Author = 1,
FileProperty_Version = 2,
FileProperty_DateModified = 3,
FileProperty_Path = 4,
FileProperty_Description = 5,
FileProperty_Master = 6
};
EsmFile(QString fileName = QString(), ModelItem *parent = 0); EsmFile(QString fileName = QString(), ModelItem *parent = 0);
// EsmFile(const EsmFile &); // EsmFile(const EsmFile &);
~EsmFile() ~EsmFile()
{} {}
void setProperty (const EsmFileProperty prop, const QString &value); void setFileProperty (const FileProperty prop, const QString &value);
void setFileName(const QString &fileName); void setFileName(const QString &fileName);
void setAuthor(const QString &author); void setAuthor(const QString &author);
@ -45,19 +45,28 @@ namespace EsxModel
void setMasters(const QStringList &masters); void setMasters(const QStringList &masters);
void setDescription(const QString &description); void setDescription(const QString &description);
inline void addMaster (const QString &name) {mMasters.append(name); }
QVariant fileProperty (const FileProperty prop) const;
inline QString fileName() const { return mFileName; } inline QString fileName() const { return mFileName; }
inline QString author() const { return mAuthor; } inline QString author() const { return mAuthor; }
inline QDateTime modified() const { return mModified; } inline QDateTime modified() const { return mModified; }
inline float version() const { return mVersion; } inline float version() const { return mVersion; }
inline QString path() const { return mPath; } inline QString path() const { return mPath; }
inline QStringList masters() const { return mMasters; } inline const QStringList &masters() const { return mMasters; }
inline QString description() const { return mDescription; } inline QString description() const { return mDescription; }
inline QString toolTip() const { return sToolTip.arg(mAuthor)
.arg(mVersion)
.arg(mDescription)
.arg(mMasters.join(", "));
}
inline bool isMaster() const { return (mMasters.size() == 0); } inline bool isMaster() const { return (mMasters.size() == 0); }
QByteArray encodedData() const; QByteArray encodedData() const;
public: public:
static int sPropertyCount; static int sPropertyCount;
static QString sToolTip;
private: private:
@ -68,6 +77,7 @@ namespace EsxModel
QString mPath; QString mPath;
QStringList mMasters; QStringList mMasters;
QString mDescription; QString mDescription;
QString mToolTip;
}; };
} }

@ -54,11 +54,9 @@ void EsxView::ContentSelector::buildPluginsView()
mPluginsProxyModel->setDynamicSortFilter (true); mPluginsProxyModel->setDynamicSortFilter (true);
mPluginsProxyModel->setSourceModel (mContentModel); mPluginsProxyModel->setSourceModel (mContentModel);
tableView->setModel (mPluginsProxyModel);
pluginView->setModel(mPluginsProxyModel); pluginView->setModel(mPluginsProxyModel);
connect(pluginView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotPluginTableItemClicked(const QModelIndex &))); connect(pluginView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotPluginTableItemClicked(const QModelIndex &)));
connect(tableView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotPluginTableItemClicked(const QModelIndex &)));
} }
void EsxView::ContentSelector::buildProfilesView() void EsxView::ContentSelector::buildProfilesView()
@ -120,10 +118,12 @@ void EsxView::ContentSelector::slotCurrentMasterIndexChanged(int index)
proxy->setDynamicSortFilter(false); proxy->setDynamicSortFilter(false);
if (oldIndex > -1) if (oldIndex > -1)
qDebug() << "clearing old master check state";
model->setData(model->index(oldIndex, 0), false, Qt::UserRole + 1); model->setData(model->index(oldIndex, 0), false, Qt::UserRole + 1);
oldIndex = index; oldIndex = index;
qDebug() << "setting new master check state";
model->setData(model->index(index, 0), true, Qt::UserRole + 1); model->setData(model->index(index, 0), true, Qt::UserRole + 1);
if (proxy) if (proxy)
@ -132,8 +132,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...";
QAbstractItemModel *const model = pluginView->model(); QAbstractItemModel *const model = pluginView->model();
QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model); QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>518</width> <width>518</width>
<height>310</height> <height>313</height>
</rect> </rect>
</property> </property>
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
@ -44,6 +44,9 @@
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum> <enum>Qt::DefaultContextMenu</enum>
</property> </property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="editTriggers"> <property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set> <set>QAbstractItemView::NoEditTriggers</set>
</property> </property>
@ -85,40 +88,6 @@
</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…
Cancel
Save