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