mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 12:39:59 +00:00
Moved esx selector classes out of global namespace
This commit is contained in:
parent
a14e0b32d8
commit
f6217f9c6a
@ -7,15 +7,15 @@
|
|||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
#include <components/fileorderlist/model/datafilesmodel.hpp>
|
#include <components/esxselector/model/datafilesmodel.hpp>
|
||||||
#include <components/fileorderlist/model/pluginsproxymodel.hpp>
|
#include <components/esxselector/model/pluginsproxymodel.hpp>
|
||||||
#include <components/fileorderlist/model/esm/esmfile.hpp>
|
#include <components/esxselector/model/esmfile.hpp>
|
||||||
|
|
||||||
#include <components/fileorderlist/utils/lineedit.hpp>
|
#include <components/esxselector/view/lineedit.hpp>
|
||||||
#include <components/fileorderlist/utils/naturalsort.hpp>
|
#include <components/esxselector/model/naturalsort.hpp>
|
||||||
#include <components/fileorderlist/utils/profilescombobox.hpp>
|
#include <components/esxselector/view/profilescombobox.hpp>
|
||||||
|
|
||||||
#include "components/fileorderlist/masterproxymodel.hpp"
|
#include "components/esxselector/model/masterproxymodel.hpp"
|
||||||
#include "settings/gamesettings.hpp"
|
#include "settings/gamesettings.hpp"
|
||||||
#include "settings/launchersettings.hpp"
|
#include "settings/launchersettings.hpp"
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include "ui_datafilespage.h"
|
#include "ui_datafilespage.h"
|
||||||
#include "components/fileorderlist/contentselector.hpp"
|
#include "components/esxselector/view/contentselector.hpp"
|
||||||
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
@ -20,7 +20,7 @@ class PluginsProxyModel;
|
|||||||
|
|
||||||
namespace Files { struct ConfigurationManager; }
|
namespace Files { struct ConfigurationManager; }
|
||||||
|
|
||||||
class DataFilesPage : public EsxSelector::ContentSelector
|
class DataFilesPage : public EsxView::ContentSelector
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include <components/files/ogreplugin.hpp>
|
#include <components/files/ogreplugin.hpp>
|
||||||
|
|
||||||
#include <components/fileorderlist/utils/naturalsort.hpp>
|
#include <components/esxselector/model/naturalsort.hpp>
|
||||||
|
|
||||||
#include "settings/graphicssettings.hpp"
|
#include "settings/graphicssettings.hpp"
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <QValidator>
|
#include <QValidator>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#include <components/fileorderlist/utils/lineedit.hpp>
|
#include <components/esxselector/view/lineedit.hpp>
|
||||||
|
|
||||||
TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWidget *parent) :
|
TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWidget *parent) :
|
||||||
QDialog(parent)
|
QDialog(parent)
|
||||||
@ -19,7 +19,7 @@ TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWid
|
|||||||
|
|
||||||
// Line edit
|
// Line edit
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
QValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
||||||
mLineEdit = new LineEdit(this);
|
mLineEdit = new EsxView::LineEdit(this);
|
||||||
mLineEdit->setValidator(validator);
|
mLineEdit->setValidator(validator);
|
||||||
mLineEdit->setCompleter(0);
|
mLineEdit->setCompleter(0);
|
||||||
|
|
||||||
|
@ -5,17 +5,21 @@
|
|||||||
//#include "lineedit.hpp"
|
//#include "lineedit.hpp"
|
||||||
|
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class LineEdit;
|
|
||||||
|
namespace EsxView {
|
||||||
|
class LineEdit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TextInputDialog : public QDialog
|
class TextInputDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0);
|
explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0);
|
||||||
inline LineEdit *lineEdit() { return mLineEdit; }
|
inline EsxView::LineEdit *lineEdit() { return mLineEdit; }
|
||||||
void setOkButtonEnabled(bool enabled);
|
void setOkButtonEnabled(bool enabled);
|
||||||
|
|
||||||
LineEdit *mLineEdit;
|
EsxView::LineEdit *mLineEdit;
|
||||||
|
|
||||||
int exec();
|
int exec();
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace CS
|
|||||||
CSMDoc::DocumentManager mDocumentManager;
|
CSMDoc::DocumentManager mDocumentManager;
|
||||||
CSVDoc::ViewManager mViewManager;
|
CSVDoc::ViewManager mViewManager;
|
||||||
CSVDoc::StartupDialogue mStartup;
|
CSVDoc::StartupDialogue mStartup;
|
||||||
FileDialog mFileDialog;
|
CSVDoc::FileDialog mFileDialog;
|
||||||
|
|
||||||
Files::ConfigurationManager mCfgMgr;
|
Files::ConfigurationManager mCfgMgr;
|
||||||
void setupDataFiles();
|
void setupDataFiles();
|
||||||
|
@ -10,15 +10,15 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
#include <components/fileorderlist/model/datafilesmodel.hpp>
|
#include <components/esxselector/model/datafilesmodel.hpp>
|
||||||
#include <components/fileorderlist/model/pluginsproxymodel.hpp>
|
#include <components/esxselector/model/pluginsproxymodel.hpp>
|
||||||
#include <components/fileorderlist/model/esm/esmfile.hpp>
|
#include <components/esxselector/model/esmfile.hpp>
|
||||||
|
|
||||||
#include <components/fileorderlist/utils/lineedit.hpp>
|
#include <components/esxselector/view/lineedit.hpp>
|
||||||
|
|
||||||
#include "components/fileorderlist/masterproxymodel.hpp"
|
#include "components/esxselector/model/masterproxymodel.hpp"
|
||||||
|
|
||||||
FileDialog::FileDialog(QWidget *parent) :
|
CSVDoc::FileDialog::FileDialog(QWidget *parent) :
|
||||||
ContentSelector(parent)
|
ContentSelector(parent)
|
||||||
{
|
{
|
||||||
// Hide the profile elements
|
// Hide the profile elements
|
||||||
@ -60,7 +60,7 @@ FileDialog::FileDialog(QWidget *parent) :
|
|||||||
// connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
// connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDialog::updateOpenButton(const QStringList &items)
|
void CSVDoc::FileDialog::updateOpenButton(const QStringList &items)
|
||||||
{
|
{
|
||||||
QPushButton *openButton = mButtonBox->button(QDialogButtonBox::Open);
|
QPushButton *openButton = mButtonBox->button(QDialogButtonBox::Open);
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ void FileDialog::updateOpenButton(const QStringList &items)
|
|||||||
openButton->setEnabled(!items.isEmpty());
|
openButton->setEnabled(!items.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDialog::updateCreateButton(const QString &name)
|
void CSVDoc::FileDialog::updateCreateButton(const QString &name)
|
||||||
{
|
{
|
||||||
if (!mCreateButton->isVisible())
|
if (!mCreateButton->isVisible())
|
||||||
return;
|
return;
|
||||||
@ -78,12 +78,12 @@ void FileDialog::updateCreateButton(const QString &name)
|
|||||||
mCreateButton->setEnabled(!name.isEmpty());
|
mCreateButton->setEnabled(!name.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FileDialog::fileName()
|
QString CSVDoc::FileDialog::fileName()
|
||||||
{
|
{
|
||||||
//return mNameLineEdit->text();
|
//return mNameLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDialog::openFile()
|
void CSVDoc::FileDialog::openFile()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Open"));
|
setWindowTitle(tr("Open"));
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ void FileDialog::openFile()
|
|||||||
activateWindow();
|
activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDialog::newFile()
|
void CSVDoc::FileDialog::newFile()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("New"));
|
setWindowTitle(tr("New"));
|
||||||
|
|
||||||
@ -118,12 +118,12 @@ void FileDialog::newFile()
|
|||||||
activateWindow();
|
activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDialog::accept()
|
void CSVDoc::FileDialog::accept()
|
||||||
{
|
{
|
||||||
emit openFiles();
|
emit openFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDialog::createButtonClicked()
|
void CSVDoc::FileDialog::createButtonClicked()
|
||||||
{
|
{
|
||||||
emit createNewFile();
|
emit createNewFile();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include "components/fileorderlist/contentselector.hpp"
|
#include "components/esxselector/view/contentselector.hpp"
|
||||||
#include "ui_datafilespage.h"
|
#include "ui_datafilespage.h"
|
||||||
|
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
@ -18,38 +18,40 @@ class QMenu;
|
|||||||
class DataFilesModel;
|
class DataFilesModel;
|
||||||
class PluginsProxyModel;
|
class PluginsProxyModel;
|
||||||
|
|
||||||
class FileDialog : public EsxSelector::ContentSelector
|
namespace CSVDoc
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class FileDialog : public EsxView::ContentSelector
|
||||||
public:
|
{
|
||||||
explicit FileDialog(QWidget *parent = 0);
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit FileDialog(QWidget *parent = 0);
|
||||||
|
|
||||||
void openFile();
|
void openFile();
|
||||||
void newFile();
|
void newFile();
|
||||||
void accepted();
|
void accepted();
|
||||||
|
|
||||||
QString fileName();
|
QString fileName();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openFiles();
|
void openFiles();
|
||||||
void createNewFile();
|
void createNewFile();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void accept();
|
|
||||||
|
|
||||||
private slots:
|
public slots:
|
||||||
//void updateViews();
|
void accept();
|
||||||
void updateOpenButton(const QStringList &items);
|
|
||||||
void updateCreateButton(const QString &name);
|
|
||||||
|
|
||||||
void createButtonClicked();
|
private slots:
|
||||||
|
//void updateViews();
|
||||||
|
void updateOpenButton(const QStringList &items);
|
||||||
|
void updateCreateButton(const QString &name);
|
||||||
|
|
||||||
private:
|
void createButtonClicked();
|
||||||
QLabel *mNameLabel;
|
|
||||||
//LineEdit *mNameLineEdit;
|
|
||||||
|
|
||||||
QPushButton *mCreateButton;
|
private:
|
||||||
QDialogButtonBox *mButtonBox;
|
QLabel *mNameLabel;
|
||||||
};
|
//LineEdit *mNameLineEdit;
|
||||||
|
|
||||||
|
QPushButton *mCreateButton;
|
||||||
|
QDialogButtonBox *mButtonBox;
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // FILEDIALOG_HPP
|
#endif // FILEDIALOG_HPP
|
||||||
|
@ -73,7 +73,7 @@ find_package(Qt4 COMPONENTS QtCore QtGui)
|
|||||||
if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
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/esm/esmfile model/naturalsort
|
model/pluginsproxymodel model/esmfile model/naturalsort
|
||||||
view/profilescombobox view/comboboxlineedit
|
view/profilescombobox view/comboboxlineedit
|
||||||
view/lineedit view/contentselector
|
view/lineedit view/contentselector
|
||||||
)
|
)
|
||||||
|
@ -2,33 +2,34 @@
|
|||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QtAlgorithms>
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <components/esm/esmreader.hpp>
|
#include <components/esm/esmreader.hpp>
|
||||||
|
|
||||||
#include "esm/esmfile.hpp"
|
#include "esmfile.hpp"
|
||||||
|
|
||||||
#include "datafilesmodel.hpp"
|
#include "datafilesmodel.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
DataFilesModel::DataFilesModel(QObject *parent) :
|
EsxModel::DataFilesModel::DataFilesModel(QObject *parent) :
|
||||||
QAbstractTableModel(parent)
|
QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
mEncoding = QString("win1252");
|
mEncoding = QString("win1252");
|
||||||
}
|
}
|
||||||
|
|
||||||
DataFilesModel::~DataFilesModel()
|
EsxModel::DataFilesModel::~DataFilesModel()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesModel::setEncoding(const QString &encoding)
|
void EsxModel::DataFilesModel::setEncoding(const QString &encoding)
|
||||||
{
|
{
|
||||||
mEncoding = encoding;
|
mEncoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesModel::setCheckState(const QModelIndex &index, Qt::CheckState state)
|
void EsxModel::DataFilesModel::setCheckState(const QModelIndex &index, Qt::CheckState state)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -45,24 +46,24 @@ void DataFilesModel::setCheckState(const QModelIndex &index, Qt::CheckState stat
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::CheckState DataFilesModel::checkState(const QModelIndex &index)
|
Qt::CheckState EsxModel::DataFilesModel::checkState(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
EsmFile *file = item(index.row());
|
EsmFile *file = item(index.row());
|
||||||
return mCheckStates[file->fileName()];
|
return mCheckStates[file->fileName()];
|
||||||
}
|
}
|
||||||
|
|
||||||
int DataFilesModel::columnCount(const QModelIndex &parent) const
|
int EsxModel::DataFilesModel::columnCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return parent.isValid() ? 0 : 9;
|
return parent.isValid() ? 0 : 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DataFilesModel::rowCount(const QModelIndex &parent) const
|
int EsxModel::DataFilesModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return parent.isValid() ? 0 : mFiles.count();
|
return parent.isValid() ? 0 : mFiles.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DataFilesModel::moveRow(int oldrow, int row, const QModelIndex &parent)
|
bool EsxModel::DataFilesModel::moveRow(int oldrow, int row, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
if (oldrow < 0 || row < 0 || oldrow == row)
|
if (oldrow < 0 || row < 0 || oldrow == row)
|
||||||
return false;
|
return false;
|
||||||
@ -76,7 +77,7 @@ bool DataFilesModel::moveRow(int oldrow, int row, const QModelIndex &parent)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DataFilesModel::data(const QModelIndex &index, int role) const
|
QVariant EsxModel::DataFilesModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -166,7 +167,7 @@ QVariant DataFilesModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const
|
Qt::ItemFlags EsxModel::DataFilesModel::flags(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
@ -192,7 +193,7 @@ Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DataFilesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant EsxModel::DataFilesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (role != Qt::DisplayRole)
|
if (role != Qt::DisplayRole)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -217,7 +218,7 @@ QVariant DataFilesModel::headerData(int section, Qt::Orientation orientation, in
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool 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;
|
||||||
@ -225,7 +226,7 @@ bool DataFilesModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lessThanEsmFile(const EsmFile *e1, const EsmFile *e2)
|
bool lessThanEsmFile(const EsxModel::EsmFile *e1, const EsxModel::EsmFile *e2)
|
||||||
{
|
{
|
||||||
//Masters first then alphabetically
|
//Masters first then alphabetically
|
||||||
if (e1->fileName().endsWith(".esm") && !e2->fileName().endsWith(".esm"))
|
if (e1->fileName().endsWith(".esm") && !e2->fileName().endsWith(".esm"))
|
||||||
@ -236,7 +237,7 @@ bool lessThanEsmFile(const EsmFile *e1, const EsmFile *e2)
|
|||||||
return e1->fileName().toLower() < e2->fileName().toLower();
|
return e1->fileName().toLower() < e2->fileName().toLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lessThanDate(const EsmFile *e1, const 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;
|
||||||
@ -245,7 +246,7 @@ bool lessThanDate(const EsmFile *e1, const EsmFile *e2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesModel::sort(int column, Qt::SortOrder order)
|
void EsxModel::DataFilesModel::sort(int column, Qt::SortOrder order)
|
||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
|
|
||||||
@ -258,14 +259,14 @@ void DataFilesModel::sort(int column, Qt::SortOrder order)
|
|||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesModel::addFile(EsmFile *file)
|
void EsxModel::DataFilesModel::addFile(EsmFile *file)
|
||||||
{
|
{
|
||||||
emit beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count());
|
emit beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count());
|
||||||
mFiles.append(file);
|
mFiles.append(file);
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesModel::addFiles(const QString &path)
|
void EsxModel::DataFilesModel::addFiles(const QString &path)
|
||||||
{
|
{
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
@ -330,7 +331,7 @@ void DataFilesModel::addFiles(const QString &path)
|
|||||||
delete decoder;
|
delete decoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex DataFilesModel::indexFromItem(EsmFile *item) const
|
QModelIndex EsxModel::DataFilesModel::indexFromItem(EsmFile *item) const
|
||||||
{
|
{
|
||||||
if (item)
|
if (item)
|
||||||
return createIndex(mFiles.indexOf(item), 0);
|
return createIndex(mFiles.indexOf(item), 0);
|
||||||
@ -338,7 +339,7 @@ QModelIndex DataFilesModel::indexFromItem(EsmFile *item) const
|
|||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
EsmFile* DataFilesModel::findItem(const QString &name)
|
EsxModel::EsmFile* EsxModel::DataFilesModel::findItem(const QString &name)
|
||||||
{
|
{
|
||||||
QList<EsmFile *>::ConstIterator it;
|
QList<EsmFile *>::ConstIterator it;
|
||||||
QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd();
|
QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd();
|
||||||
@ -356,7 +357,7 @@ EsmFile* DataFilesModel::findItem(const QString &name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EsmFile* DataFilesModel::item(int row) 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);
|
||||||
@ -364,7 +365,7 @@ EsmFile* DataFilesModel::item(int row) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList DataFilesModel::checkedItems()
|
QStringList EsxModel::DataFilesModel::checkedItems()
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
|
||||||
@ -386,7 +387,7 @@ QStringList DataFilesModel::checkedItems()
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList DataFilesModel::checkedItemsPaths()
|
QStringList EsxModel::DataFilesModel::checkedItemsPaths()
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
|
||||||
@ -405,14 +406,14 @@ QStringList DataFilesModel::checkedItemsPaths()
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesModel::uncheckAll()
|
void EsxModel::DataFilesModel::uncheckAll()
|
||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
mCheckStates.clear();
|
mCheckStates.clear();
|
||||||
emit layoutChanged();
|
emit layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList DataFilesModel::uncheckedItems()
|
QStringList EsxModel::DataFilesModel::uncheckedItems()
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
QStringList checked = checkedItems();
|
QStringList checked = checkedItems();
|
||||||
@ -433,7 +434,7 @@ QStringList DataFilesModel::uncheckedItems()
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataFilesModel::canBeChecked(EsmFile *file) const
|
bool EsxModel::DataFilesModel::canBeChecked(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())
|
||||||
|
@ -6,61 +6,62 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
|
namespace EsxModel
|
||||||
class EsmFile;
|
|
||||||
|
|
||||||
class DataFilesModel : public QAbstractTableModel
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class EsmFile;
|
||||||
|
|
||||||
public:
|
class DataFilesModel : public QAbstractTableModel
|
||||||
explicit DataFilesModel(QObject *parent = 0);
|
{
|
||||||
virtual ~DataFilesModel();
|
Q_OBJECT
|
||||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
||||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
||||||
|
|
||||||
bool moveRow(int oldrow, int row, const QModelIndex &parent = QModelIndex());
|
public:
|
||||||
|
explicit DataFilesModel(QObject *parent = 0);
|
||||||
|
virtual ~DataFilesModel();
|
||||||
|
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
bool moveRow(int oldrow, int row, const QModelIndex &parent = QModelIndex());
|
||||||
|
|
||||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) 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);
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||||
{ return QAbstractTableModel::index(row, column, parent); }
|
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
|
||||||
|
|
||||||
void setEncoding(const QString &encoding);
|
inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const
|
||||||
|
{ return QAbstractTableModel::index(row, column, parent); }
|
||||||
|
|
||||||
void addFiles(const QString &path);
|
void setEncoding(const QString &encoding);
|
||||||
|
|
||||||
void uncheckAll();
|
void addFiles(const QString &path);
|
||||||
|
|
||||||
QStringList checkedItems();
|
void uncheckAll();
|
||||||
QStringList uncheckedItems();
|
|
||||||
QStringList checkedItemsPaths();
|
|
||||||
|
|
||||||
Qt::CheckState checkState(const QModelIndex &index);
|
QStringList checkedItems();
|
||||||
void setCheckState(const QModelIndex &index, Qt::CheckState state);
|
QStringList uncheckedItems();
|
||||||
|
QStringList checkedItemsPaths();
|
||||||
|
|
||||||
QModelIndex indexFromItem(EsmFile *item) const;
|
Qt::CheckState checkState(const QModelIndex &index);
|
||||||
EsmFile* findItem(const QString &name);
|
void setCheckState(const QModelIndex &index, Qt::CheckState state);
|
||||||
EsmFile* item(int row) const;
|
|
||||||
|
|
||||||
signals:
|
QModelIndex indexFromItem(EsmFile *item) const;
|
||||||
void checkedItemsChanged(const QStringList &items);
|
EsmFile* findItem(const QString &name);
|
||||||
|
EsmFile* item(int row) const;
|
||||||
private:
|
|
||||||
bool canBeChecked(EsmFile *file) const;
|
|
||||||
void addFile(EsmFile *file);
|
|
||||||
|
|
||||||
QList<EsmFile *> mFiles;
|
|
||||||
QHash<QString, Qt::CheckState> mCheckStates;
|
|
||||||
|
|
||||||
QString mEncoding;
|
signals:
|
||||||
|
void checkedItemsChanged(const QStringList &items);
|
||||||
|
|
||||||
};
|
private:
|
||||||
|
bool canBeChecked(EsmFile *file) const;
|
||||||
|
void addFile(EsmFile *file);
|
||||||
|
|
||||||
|
QList<EsmFile *> mFiles;
|
||||||
|
QHash<QString, Qt::CheckState> mCheckStates;
|
||||||
|
|
||||||
|
QString mEncoding;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // DATAFILESMODEL_HPP
|
#endif // DATAFILESMODEL_HPP
|
||||||
|
50
components/esxselector/model/esmfile.cpp
Normal file
50
components/esxselector/model/esmfile.cpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#include "esmfile.hpp"
|
||||||
|
|
||||||
|
EsxModel::EsmFile::EsmFile(QString fileName, ModelItem *parent)
|
||||||
|
: ModelItem(parent)
|
||||||
|
{
|
||||||
|
mFileName = fileName;
|
||||||
|
mSize = 0;
|
||||||
|
mVersion = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::EsmFile::setFileName(const QString &fileName)
|
||||||
|
{
|
||||||
|
mFileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::EsmFile::setAuthor(const QString &author)
|
||||||
|
{
|
||||||
|
mAuthor = author;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::EsmFile::setSize(const int size)
|
||||||
|
{
|
||||||
|
mSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::EsmFile::setDates(const QDateTime &modified, const QDateTime &accessed)
|
||||||
|
{
|
||||||
|
mModified = modified;
|
||||||
|
mAccessed = accessed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::EsmFile::setVersion(float version)
|
||||||
|
{
|
||||||
|
mVersion = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::EsmFile::setPath(const QString &path)
|
||||||
|
{
|
||||||
|
mPath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::EsmFile::setMasters(const QStringList &masters)
|
||||||
|
{
|
||||||
|
mMasters = masters;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EsxModel::EsmFile::setDescription(const QString &description)
|
||||||
|
{
|
||||||
|
mDescription = description;
|
||||||
|
}
|
56
components/esxselector/model/esmfile.hpp
Normal file
56
components/esxselector/model/esmfile.hpp
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#ifndef ESMFILE_HPP
|
||||||
|
#define ESMFILE_HPP
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include "modelitem.hpp"
|
||||||
|
|
||||||
|
namespace EsxModel
|
||||||
|
{
|
||||||
|
class EsmFile : public ModelItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString filename READ fileName)
|
||||||
|
|
||||||
|
public:
|
||||||
|
EsmFile(QString fileName = QString(), ModelItem *parent = 0);
|
||||||
|
|
||||||
|
~EsmFile()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void setFileName(const QString &fileName);
|
||||||
|
void setAuthor(const QString &author);
|
||||||
|
void setSize(const int size);
|
||||||
|
void setDates(const QDateTime &modified, const QDateTime &accessed);
|
||||||
|
void setVersion(const float version);
|
||||||
|
void setPath(const QString &path);
|
||||||
|
void setMasters(const QStringList &masters);
|
||||||
|
void setDescription(const QString &description);
|
||||||
|
|
||||||
|
inline QString fileName() const { return mFileName; }
|
||||||
|
inline QString author() const { return mAuthor; }
|
||||||
|
inline int size() const { return mSize; }
|
||||||
|
inline QDateTime modified() const { return mModified; }
|
||||||
|
inline QDateTime accessed() const { return mAccessed; }
|
||||||
|
inline float version() const { return mVersion; }
|
||||||
|
inline QString path() const { return mPath; }
|
||||||
|
inline QStringList masters() const { return mMasters; }
|
||||||
|
inline QString description() const { return mDescription; }
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mFileName;
|
||||||
|
QString mAuthor;
|
||||||
|
int mSize;
|
||||||
|
QDateTime mModified;
|
||||||
|
QDateTime mAccessed;
|
||||||
|
float mVersion;
|
||||||
|
QString mPath;
|
||||||
|
QStringList mMasters;
|
||||||
|
QString mDescription;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -1,6 +1,6 @@
|
|||||||
#include "masterproxymodel.hpp"
|
#include "masterproxymodel.hpp"
|
||||||
|
|
||||||
EsxSelector::MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableModel* model) :
|
EsxModel::MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableModel* model) :
|
||||||
QSortFilterProxyModel(parent)
|
QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
setFilterRegExp(QString("game"));
|
setFilterRegExp(QString("game"));
|
||||||
@ -10,7 +10,7 @@ EsxSelector::MasterProxyModel::MasterProxyModel(QObject *parent, QAbstractTableM
|
|||||||
setSourceModel (model);
|
setSourceModel (model);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant EsxSelector::MasterProxyModel::data(const QModelIndex &index, int role) const
|
QVariant EsxModel::MasterProxyModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
return QSortFilterProxyModel::data (index, role);
|
return QSortFilterProxyModel::data (index, role);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
class QAbstractTableModel;
|
class QAbstractTableModel;
|
||||||
|
|
||||||
namespace EsxSelector
|
namespace EsxModel
|
||||||
{
|
{
|
||||||
class MasterProxyModel : public QSortFilterProxyModel
|
class MasterProxyModel : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
#include "modelitem.hpp"
|
#include "modelitem.hpp"
|
||||||
|
|
||||||
ModelItem::ModelItem(ModelItem *parent)
|
EsxModel::ModelItem::ModelItem(ModelItem *parent)
|
||||||
: mParentItem(parent)
|
: mParentItem(parent)
|
||||||
, QObject(parent)
|
, QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelItem::~ModelItem()
|
EsxModel::ModelItem::~ModelItem()
|
||||||
{
|
{
|
||||||
qDeleteAll(mChildItems);
|
qDeleteAll(mChildItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ModelItem *ModelItem::parent()
|
EsxModel::ModelItem *EsxModel::ModelItem::parent()
|
||||||
{
|
{
|
||||||
return mParentItem;
|
return mParentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ModelItem::row() const
|
int EsxModel::ModelItem::row() const
|
||||||
{
|
{
|
||||||
if (mParentItem)
|
if (mParentItem)
|
||||||
return 1;
|
return 1;
|
||||||
@ -28,30 +28,30 @@ int ModelItem::row() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ModelItem::childCount() const
|
int EsxModel::ModelItem::childCount() const
|
||||||
{
|
{
|
||||||
return mChildItems.count();
|
return mChildItems.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ModelItem::childRow(ModelItem *child) const
|
int EsxModel::ModelItem::childRow(ModelItem *child) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(child);
|
Q_ASSERT(child);
|
||||||
|
|
||||||
return mChildItems.indexOf(child);
|
return mChildItems.indexOf(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelItem *ModelItem::child(int row)
|
EsxModel::ModelItem *EsxModel::ModelItem::child(int row)
|
||||||
{
|
{
|
||||||
return mChildItems.value(row);
|
return mChildItems.value(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModelItem::appendChild(ModelItem *item)
|
void EsxModel::ModelItem::appendChild(ModelItem *item)
|
||||||
{
|
{
|
||||||
mChildItems.append(item);
|
mChildItems.append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelItem::removeChild(int row)
|
void EsxModel::ModelItem::removeChild(int row)
|
||||||
{
|
{
|
||||||
mChildItems.removeAt(row);
|
mChildItems.removeAt(row);
|
||||||
}
|
}
|
||||||
|
@ -4,29 +4,32 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
class ModelItem : public QObject
|
namespace EsxModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class ModelItem : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModelItem(ModelItem *parent = 0);
|
ModelItem(ModelItem *parent = 0);
|
||||||
~ModelItem();
|
~ModelItem();
|
||||||
|
|
||||||
ModelItem *parent();
|
ModelItem *parent();
|
||||||
int row() const;
|
int row() const;
|
||||||
|
|
||||||
int childCount() const;
|
int childCount() const;
|
||||||
int childRow(ModelItem *child) const;
|
int childRow(ModelItem *child) const;
|
||||||
ModelItem *child(int row);
|
ModelItem *child(int row);
|
||||||
|
|
||||||
void appendChild(ModelItem *child);
|
void appendChild(ModelItem *child);
|
||||||
void removeChild(int row);
|
void removeChild(int row);
|
||||||
|
|
||||||
//virtual bool acceptChild(ModelItem *child);
|
//virtual bool acceptChild(ModelItem *child);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ModelItem *mParentItem;
|
ModelItem *mParentItem;
|
||||||
QList<ModelItem*> mChildItems;
|
QList<ModelItem*> mChildItems;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
bool naturalSortLessThanCS( const QString &left, const QString &right );
|
bool naturalSortLessThanCS( const QString &left, const QString &right );
|
||||||
bool naturalSortLessThanCI( const QString &left, const QString &right );
|
bool naturalSortLessThanCI( const QString &left, const QString &right );
|
||||||
bool naturalSortGreaterThanCS( const QString &left, const QString &right );
|
bool naturalSortGreaterThanCS( const QString &left, const QString &right );
|
||||||
bool naturalSortGreaterThanCI( const QString &left, const QString &right );
|
bool naturalSortGreaterThanCI( const QString &left, const QString &right );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "pluginsproxymodel.hpp"
|
#include "pluginsproxymodel.hpp"
|
||||||
#include "datafilesmodel.hpp"
|
#include "datafilesmodel.hpp"
|
||||||
|
|
||||||
PluginsProxyModel::PluginsProxyModel(QObject *parent, DataFilesModel *model) :
|
EsxModel::PluginsProxyModel::PluginsProxyModel(QObject *parent, DataFilesModel *model) :
|
||||||
QSortFilterProxyModel(parent)
|
QSortFilterProxyModel(parent)
|
||||||
{
|
{
|
||||||
setFilterRegExp (QString("addon"));
|
setFilterRegExp (QString("addon"));
|
||||||
@ -12,11 +12,11 @@ PluginsProxyModel::PluginsProxyModel(QObject *parent, DataFilesModel *model) :
|
|||||||
setSourceModel (model);
|
setSourceModel (model);
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginsProxyModel::~PluginsProxyModel()
|
EsxModel::PluginsProxyModel::~PluginsProxyModel()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant PluginsProxyModel::data(const QModelIndex &index, int role) const
|
QVariant EsxModel::PluginsProxyModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
|
@ -5,18 +5,22 @@
|
|||||||
|
|
||||||
class QVariant;
|
class QVariant;
|
||||||
class QAbstractTableModel;
|
class QAbstractTableModel;
|
||||||
class DataFilesModel;
|
|
||||||
|
|
||||||
class PluginsProxyModel : public QSortFilterProxyModel
|
namespace EsxModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class DataFilesModel;
|
||||||
|
|
||||||
public:
|
class PluginsProxyModel : public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
explicit PluginsProxyModel(QObject *parent = 0, DataFilesModel *model = 0);
|
public:
|
||||||
~PluginsProxyModel();
|
|
||||||
|
|
||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
explicit PluginsProxyModel(QObject *parent = 0, DataFilesModel *model = 0);
|
||||||
};
|
~PluginsProxyModel();
|
||||||
|
|
||||||
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PLUGINSPROXYMODEL_HPP
|
#endif // PLUGINSPROXYMODEL_HPP
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "comboboxlineedit.hpp"
|
#include "comboboxlineedit.hpp"
|
||||||
|
|
||||||
ComboBoxLineEdit::ComboBoxLineEdit(QWidget *parent)
|
EsxView::ComboBoxLineEdit::ComboBoxLineEdit(QWidget *parent)
|
||||||
: QLineEdit(parent)
|
: QLineEdit(parent)
|
||||||
{
|
{
|
||||||
mClearButton = new QToolButton(this);
|
mClearButton = new QToolButton(this);
|
||||||
@ -21,7 +21,7 @@ ComboBoxLineEdit::ComboBoxLineEdit(QWidget *parent)
|
|||||||
setStyleSheet(QString("ComboBoxLineEdit { background-color: transparent; padding-right: %1px; } ").arg(mClearButton->sizeHint().width() + frameWidth + 1));
|
setStyleSheet(QString("ComboBoxLineEdit { background-color: transparent; padding-right: %1px; } ").arg(mClearButton->sizeHint().width() + frameWidth + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComboBoxLineEdit::resizeEvent(QResizeEvent *)
|
void EsxView::ComboBoxLineEdit::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
QSize sz = mClearButton->sizeHint();
|
QSize sz = mClearButton->sizeHint();
|
||||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||||
@ -29,7 +29,7 @@ void ComboBoxLineEdit::resizeEvent(QResizeEvent *)
|
|||||||
(rect().bottom() + 1 - sz.height())/2);
|
(rect().bottom() + 1 - sz.height())/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComboBoxLineEdit::updateClearButton(const QString& text)
|
void EsxView::ComboBoxLineEdit::updateClearButton(const QString& text)
|
||||||
{
|
{
|
||||||
mClearButton->setVisible(!text.isEmpty());
|
mClearButton->setVisible(!text.isEmpty());
|
||||||
}
|
}
|
||||||
|
@ -14,22 +14,24 @@
|
|||||||
|
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
|
||||||
class ComboBoxLineEdit : public QLineEdit
|
namespace EsxView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class ComboBoxLineEdit : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ComboBoxLineEdit(QWidget *parent = 0);
|
ComboBoxLineEdit(QWidget *parent = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateClearButton(const QString &text);
|
void updateClearButton(const QString &text);
|
||||||
|
|
||||||
private:
|
|
||||||
QToolButton *mClearButton;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QToolButton *mClearButton;
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // LIENEDIT_H
|
#endif // LIENEDIT_H
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "contentselector.hpp"
|
#include "contentselector.hpp"
|
||||||
|
|
||||||
#include "model/datafilesmodel.hpp"
|
#include "../model/datafilesmodel.hpp"
|
||||||
#include "masterproxymodel.hpp"
|
#include "../model/masterproxymodel.hpp"
|
||||||
#include "model/pluginsproxymodel.hpp"
|
#include "../model/pluginsproxymodel.hpp"
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
@ -10,20 +10,20 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
|
|
||||||
EsxSelector::ContentSelector::ContentSelector(QWidget *parent) :
|
EsxView::ContentSelector::ContentSelector(QWidget *parent) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
buildModelsAndViews();
|
buildModelsAndViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxSelector::ContentSelector::buildModelsAndViews()
|
void EsxView::ContentSelector::buildModelsAndViews()
|
||||||
{
|
{
|
||||||
// Models
|
// Models
|
||||||
mDataFilesModel = new DataFilesModel (this);
|
mDataFilesModel = new EsxModel::DataFilesModel (this);
|
||||||
|
|
||||||
mMasterProxyModel = new EsxSelector::MasterProxyModel (this, mDataFilesModel);
|
mMasterProxyModel = new EsxModel::MasterProxyModel (this, mDataFilesModel);
|
||||||
mPluginsProxyModel = new PluginsProxyModel (this, mDataFilesModel);
|
mPluginsProxyModel = new EsxModel::PluginsProxyModel (this, mDataFilesModel);
|
||||||
|
|
||||||
masterView->setModel(mMasterProxyModel);
|
masterView->setModel(mMasterProxyModel);
|
||||||
pluginView->setModel(mPluginsProxyModel);
|
pluginView->setModel(mPluginsProxyModel);
|
||||||
@ -35,7 +35,7 @@ void EsxSelector::ContentSelector::buildModelsAndViews()
|
|||||||
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentProfileIndexChanged(int)));
|
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentProfileIndexChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxSelector::ContentSelector::addFiles(const QString &path)
|
void EsxView::ContentSelector::addFiles(const QString &path)
|
||||||
{
|
{
|
||||||
mDataFilesModel->addFiles(path);
|
mDataFilesModel->addFiles(path);
|
||||||
mDataFilesModel->sort(3); // Sort by date accessed
|
mDataFilesModel->sort(3); // Sort by date accessed
|
||||||
@ -43,12 +43,12 @@ void EsxSelector::ContentSelector::addFiles(const QString &path)
|
|||||||
mDataFilesModel->uncheckAll();
|
mDataFilesModel->uncheckAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxSelector::ContentSelector::setEncoding(const QString &encoding)
|
void EsxView::ContentSelector::setEncoding(const QString &encoding)
|
||||||
{
|
{
|
||||||
mDataFilesModel->setEncoding(encoding);
|
mDataFilesModel->setEncoding(encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxSelector::ContentSelector::setCheckState(QModelIndex index, QSortFilterProxyModel *model)
|
void EsxView::ContentSelector::setCheckState(QModelIndex index, QSortFilterProxyModel *model)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
@ -66,12 +66,12 @@ void EsxSelector::ContentSelector::setCheckState(QModelIndex index, QSortFilterP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList EsxSelector::ContentSelector::checkedItemsPaths()
|
QStringList EsxView::ContentSelector::checkedItemsPaths()
|
||||||
{
|
{
|
||||||
return mDataFilesModel->checkedItemsPaths();
|
return mDataFilesModel->checkedItemsPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxSelector::ContentSelector::updateViews()
|
void EsxView::ContentSelector::updateViews()
|
||||||
{
|
{
|
||||||
// Ensure the columns are hidden because sort() re-enables them
|
// Ensure the columns are hidden because sort() re-enables them
|
||||||
pluginView->setColumnHidden(1, true);
|
pluginView->setColumnHidden(1, true);
|
||||||
@ -85,12 +85,12 @@ void EsxSelector::ContentSelector::updateViews()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxSelector::ContentSelector::slotCurrentProfileIndexChanged(int index)
|
void EsxView::ContentSelector::slotCurrentProfileIndexChanged(int index)
|
||||||
{
|
{
|
||||||
emit profileChanged(index);
|
emit profileChanged(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxSelector::ContentSelector::slotCurrentMasterIndexChanged(int index)
|
void EsxView::ContentSelector::slotCurrentMasterIndexChanged(int index)
|
||||||
{
|
{
|
||||||
QObject *object = QObject::sender();
|
QObject *object = QObject::sender();
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ void EsxSelector::ContentSelector::slotCurrentMasterIndexChanged(int index)
|
|||||||
setCheckState(mMasterProxyModel->index(index, 0), mMasterProxyModel);
|
setCheckState(mMasterProxyModel->index(index, 0), mMasterProxyModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsxSelector::ContentSelector::slotPluginTableItemClicked(const QModelIndex &index)
|
void EsxView::ContentSelector::slotPluginTableItemClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
setCheckState(index, mPluginsProxyModel);
|
setCheckState(index, mPluginsProxyModel);
|
||||||
}
|
}
|
||||||
|
@ -5,23 +5,26 @@
|
|||||||
|
|
||||||
#include "ui_datafilespage.h"
|
#include "ui_datafilespage.h"
|
||||||
|
|
||||||
class DataFilesModel;
|
namespace EsxModel
|
||||||
class PluginsProxyModel;
|
{
|
||||||
|
class DataFilesModel;
|
||||||
|
class PluginsProxyModel;
|
||||||
|
class MasterProxyModel;
|
||||||
|
}
|
||||||
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
|
|
||||||
namespace FileOrderList
|
namespace EsxView
|
||||||
{
|
{
|
||||||
class MasterProxyModel;
|
|
||||||
|
|
||||||
class ContentSelector : public QWidget, protected Ui::DataFilesPage
|
class ContentSelector : public QWidget, protected Ui::DataFilesPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
DataFilesModel *mDataFilesModel;
|
EsxModel::DataFilesModel *mDataFilesModel;
|
||||||
MasterProxyModel *mMasterProxyModel;
|
EsxModel::MasterProxyModel *mMasterProxyModel;
|
||||||
PluginsProxyModel *mPluginsProxyModel;
|
EsxModel::PluginsProxyModel *mPluginsProxyModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ContentSelector(QWidget *parent = 0);
|
explicit ContentSelector(QWidget *parent = 0);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "lineedit.hpp"
|
#include "lineedit.hpp"
|
||||||
|
|
||||||
LineEdit::LineEdit(QWidget *parent)
|
EsxView::LineEdit::LineEdit(QWidget *parent)
|
||||||
: QLineEdit(parent)
|
: QLineEdit(parent)
|
||||||
{
|
{
|
||||||
mClearButton = new QToolButton(this);
|
mClearButton = new QToolButton(this);
|
||||||
@ -24,7 +24,7 @@ LineEdit::LineEdit(QWidget *parent)
|
|||||||
qMax(msz.height(), mClearButton->sizeHint().height() + frameWidth * 2 + 2));
|
qMax(msz.height(), mClearButton->sizeHint().height() + frameWidth * 2 + 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::resizeEvent(QResizeEvent *)
|
void EsxView::LineEdit::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
QSize sz = mClearButton->sizeHint();
|
QSize sz = mClearButton->sizeHint();
|
||||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||||
@ -32,7 +32,7 @@ void LineEdit::resizeEvent(QResizeEvent *)
|
|||||||
(rect().bottom() + 1 - sz.height())/2);
|
(rect().bottom() + 1 - sz.height())/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::updateClearButton(const QString& text)
|
void EsxView::LineEdit::updateClearButton(const QString& text)
|
||||||
{
|
{
|
||||||
mClearButton->setVisible(!text.isEmpty());
|
mClearButton->setVisible(!text.isEmpty());
|
||||||
}
|
}
|
||||||
|
@ -14,22 +14,24 @@
|
|||||||
|
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
|
||||||
class LineEdit : public QLineEdit
|
namespace EsxView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class LineEdit : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LineEdit(QWidget *parent = 0);
|
LineEdit(QWidget *parent = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateClearButton(const QString &text);
|
void updateClearButton(const QString &text);
|
||||||
|
|
||||||
private:
|
|
||||||
QToolButton *mClearButton;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QToolButton *mClearButton;
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // LIENEDIT_H
|
#endif // LIENEDIT_H
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "profilescombobox.hpp"
|
#include "profilescombobox.hpp"
|
||||||
#include "comboboxlineedit.hpp"
|
#include "comboboxlineedit.hpp"
|
||||||
|
|
||||||
ProfilesComboBox::ProfilesComboBox(QWidget *parent) :
|
EsxView::ProfilesComboBox::ProfilesComboBox(QWidget *parent) :
|
||||||
QComboBox(parent)
|
QComboBox(parent)
|
||||||
{
|
{
|
||||||
mValidator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
mValidator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
||||||
@ -21,7 +21,7 @@ ProfilesComboBox::ProfilesComboBox(QWidget *parent) :
|
|||||||
setInsertPolicy(QComboBox::NoInsert);
|
setInsertPolicy(QComboBox::NoInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfilesComboBox::setEditEnabled(bool editable)
|
void EsxView::ProfilesComboBox::setEditEnabled(bool editable)
|
||||||
{
|
{
|
||||||
if (isEditable() == editable)
|
if (isEditable() == editable)
|
||||||
return;
|
return;
|
||||||
@ -47,7 +47,7 @@ void ProfilesComboBox::setEditEnabled(bool editable)
|
|||||||
SLOT(slotTextChanged(QString)));
|
SLOT(slotTextChanged(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfilesComboBox::slotTextChanged(const QString &text)
|
void EsxView::ProfilesComboBox::slotTextChanged(const QString &text)
|
||||||
{
|
{
|
||||||
QPalette *palette = new QPalette();
|
QPalette *palette = new QPalette();
|
||||||
palette->setColor(QPalette::Text,Qt::red);
|
palette->setColor(QPalette::Text,Qt::red);
|
||||||
@ -61,7 +61,7 @@ void ProfilesComboBox::slotTextChanged(const QString &text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfilesComboBox::slotEditingFinished()
|
void EsxView::ProfilesComboBox::slotEditingFinished()
|
||||||
{
|
{
|
||||||
QString current = currentText();
|
QString current = currentText();
|
||||||
QString previous = itemText(currentIndex());
|
QString previous = itemText(currentIndex());
|
||||||
@ -82,7 +82,7 @@ void ProfilesComboBox::slotEditingFinished()
|
|||||||
emit(profileRenamed(previous, current));
|
emit(profileRenamed(previous, current));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfilesComboBox::slotIndexChanged(int index)
|
void EsxView::ProfilesComboBox::slotIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
@ -91,7 +91,7 @@ void ProfilesComboBox::slotIndexChanged(int index)
|
|||||||
mOldProfile = itemText(index);
|
mOldProfile = itemText(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfilesComboBox::paintEvent(QPaintEvent *)
|
void EsxView::ProfilesComboBox::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QStylePainter painter(this);
|
QStylePainter painter(this);
|
||||||
painter.setPen(palette().color(QPalette::Text));
|
painter.setPen(palette().color(QPalette::Text));
|
||||||
|
@ -6,28 +6,31 @@
|
|||||||
class QString;
|
class QString;
|
||||||
class QRegExpValidator;
|
class QRegExpValidator;
|
||||||
|
|
||||||
class ProfilesComboBox : public QComboBox
|
namespace EsxView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class ProfilesComboBox : public QComboBox
|
||||||
public:
|
{
|
||||||
explicit ProfilesComboBox(QWidget *parent = 0);
|
Q_OBJECT
|
||||||
void setEditEnabled(bool editable);
|
public:
|
||||||
|
explicit ProfilesComboBox(QWidget *parent = 0);
|
||||||
signals:
|
void setEditEnabled(bool editable);
|
||||||
void profileChanged(const QString &previous, const QString ¤t);
|
|
||||||
void profileRenamed(const QString &oldName, const QString &newName);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void slotEditingFinished();
|
|
||||||
void slotIndexChanged(int index);
|
|
||||||
void slotTextChanged(const QString &text);
|
|
||||||
|
|
||||||
private:
|
signals:
|
||||||
QString mOldProfile;
|
void profileChanged(const QString &previous, const QString ¤t);
|
||||||
QRegExpValidator *mValidator;
|
void profileRenamed(const QString &oldName, const QString &newName);
|
||||||
|
|
||||||
protected:
|
private slots:
|
||||||
void paintEvent(QPaintEvent *);
|
void slotEditingFinished();
|
||||||
};
|
void slotIndexChanged(int index);
|
||||||
|
void slotTextChanged(const QString &text);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString mOldProfile;
|
||||||
|
QRegExpValidator *mValidator;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PROFILESCOMBOBOX_HPP
|
#endif // PROFILESCOMBOBOX_HPP
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="filterLayout">
|
<layout class="QHBoxLayout" name="filterLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="ProfilesComboBox" name="masterView">
|
<widget class="EsxView::ProfilesComboBox" name="masterView">
|
||||||
<property name="editable">
|
<property name="editable">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -79,7 +79,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="ProfilesComboBox" name="profilesComboBox">
|
<widget class="EsxView::ProfilesComboBox" name="profilesComboBox">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -168,9 +168,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>ProfilesComboBox</class>
|
<class>EsxView::ProfilesComboBox</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
<header location="global">components/fileorderlist/utils/profilescombobox.hpp</header>
|
<header location="global">components/esxselector/view/profilescombobox.hpp</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user