mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-28 08:37:12 +00:00
Implemented profile function in launcher datafiles page
Implemented dependency sorting to ensure dependent files appear latest in the list.
This commit is contained in:
parent
a5a0f61533
commit
217a4d75b4
@ -11,7 +11,6 @@ set(LAUNCHER
|
|||||||
settings/launchersettings.cpp
|
settings/launchersettings.cpp
|
||||||
|
|
||||||
utils/checkablemessagebox.cpp
|
utils/checkablemessagebox.cpp
|
||||||
utils/textinputdialog.cpp
|
|
||||||
|
|
||||||
${CMAKE_SOURCE_DIR}/files/launcher/launcher.rc
|
${CMAKE_SOURCE_DIR}/files/launcher/launcher.rc
|
||||||
)
|
)
|
||||||
@ -32,8 +31,6 @@ set(LAUNCHER_HEADER
|
|||||||
settings/settingsbase.hpp
|
settings/settingsbase.hpp
|
||||||
|
|
||||||
utils/checkablemessagebox.hpp
|
utils/checkablemessagebox.hpp
|
||||||
utils/textinputdialog.hpp
|
|
||||||
|
|
||||||
)
|
)
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
LIST(APPEND LAUNCHER_HEADER unshieldthread.hpp)
|
LIST(APPEND LAUNCHER_HEADER unshieldthread.hpp)
|
||||||
@ -49,7 +46,6 @@ set(LAUNCHER_HEADER_MOC
|
|||||||
textslotmsgbox.hpp
|
textslotmsgbox.hpp
|
||||||
|
|
||||||
utils/checkablemessagebox.hpp
|
utils/checkablemessagebox.hpp
|
||||||
utils/textinputdialog.hpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
|
@ -17,177 +17,182 @@
|
|||||||
#include "settings/gamesettings.hpp"
|
#include "settings/gamesettings.hpp"
|
||||||
#include "settings/launchersettings.hpp"
|
#include "settings/launchersettings.hpp"
|
||||||
|
|
||||||
#include "utils/textinputdialog.hpp"
|
|
||||||
#include "components/contentselector/view/contentselector.hpp"
|
#include "components/contentselector/view/contentselector.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent)
|
DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent)
|
||||||
: mCfgMgr(cfg)
|
: mCfgMgr(cfg)
|
||||||
, mGameSettings(gameSettings)
|
, mGameSettings(gameSettings)
|
||||||
, mLauncherSettings(launcherSettings)
|
, mLauncherSettings(launcherSettings)
|
||||||
|
, QWidget(parent)
|
||||||
{
|
{
|
||||||
unsigned char flags;
|
setObjectName ("DataFilesPage");
|
||||||
|
|
||||||
flags = ContentSelectorView::Flag_Content | ContentSelectorView::Flag_Profile;
|
unsigned char flags;
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector::configure(this, flags);
|
flags = ContentSelectorView::Flag_Content | ContentSelectorView::Flag_Profile;
|
||||||
|
|
||||||
|
ContentSelectorView::ContentSelector::configure(this, flags);
|
||||||
|
mSelector = &ContentSelectorView::ContentSelector::instance();
|
||||||
|
|
||||||
setupDataFiles();
|
setupDataFiles();
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector &cSelector =
|
|
||||||
ContentSelectorView::ContentSelector::instance();
|
|
||||||
|
|
||||||
connect (&cSelector, SIGNAL (signalProfileRenamed (QString, QString)),
|
connect (mSelector, SIGNAL (signalProfileRenamed (QString, QString)),
|
||||||
this, SLOT (slotProfileRenamed (QString, QString)));
|
this, SLOT (slotProfileRenamed (QString, QString)));
|
||||||
|
|
||||||
connect (&cSelector, SIGNAL (signalProfileChanged (QString, QString)),
|
connect (mSelector, SIGNAL (signalProfileChangedByUser (QString, QString)),
|
||||||
this, SLOT (slotProfileChanged (QString, QString)));
|
this, SLOT (slotProfileChangedByUser (QString, QString)));
|
||||||
|
|
||||||
connect (&cSelector, SIGNAL (signalProfileDeleted (QString)),
|
connect (mSelector, SIGNAL (signalProfileDeleted (QString)),
|
||||||
this, SLOT (slotProfileDeleted (QString)));
|
this, SLOT (slotProfileDeleted (QString)));
|
||||||
|
|
||||||
connect (&cSelector, SIGNAL (signalProfileAdded ()),
|
connect (mSelector, SIGNAL (signalAddNewProfile (QString)),
|
||||||
this, SLOT (slotProfileAdded ()));
|
this, SLOT (slotAddNewProfile (QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::loadSettings()
|
void DataFilesPage::loadSettings()
|
||||||
{
|
{
|
||||||
|
QString profileName = mSelector->getProfileText();
|
||||||
|
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/game"), Qt::MatchExactly);
|
||||||
|
QStringList addons = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/addon"), Qt::MatchExactly);
|
||||||
|
|
||||||
if (profile.isEmpty())
|
mSelector->clearCheckStates();
|
||||||
return;
|
|
||||||
|
|
||||||
QStringList files = mLauncherSettings.values(QString("Profiles/") + profile + QString("/master"), Qt::MatchExactly);
|
if (files.size() > 0)
|
||||||
QStringList addons = mLauncherSettings.values(QString("Profiles/") + profile + QString("/plugin"), Qt::MatchExactly);
|
mSelector->setGameFile(files.at(0));
|
||||||
|
else
|
||||||
|
mSelector->setGameFile();
|
||||||
|
|
||||||
foreach (const QString &file, addons)
|
mSelector->setCheckStates(addons);
|
||||||
files.append(file);
|
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector::instance().setCheckStates(files);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::saveSettings()
|
void DataFilesPage::saveSettings(const QString &profile)
|
||||||
{
|
{
|
||||||
ContentSelectorModel::ContentFileList items =
|
QString profileName = profile;
|
||||||
ContentSelectorView::ContentSelector::instance().selectedFiles();
|
|
||||||
|
|
||||||
if (items.size() == 0)
|
if (profileName.isEmpty())
|
||||||
return;
|
profileName = mSelector->getProfileText();
|
||||||
|
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
//retrieve the files selected for the profile
|
||||||
|
ContentSelectorModel::ContentFileList items = mSelector->selectedFiles();
|
||||||
|
|
||||||
if (profile.isEmpty()) {
|
removeProfile (profileName);
|
||||||
profile = ContentSelectorView::ContentSelector::instance().getProfileText();
|
|
||||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master"));
|
mGameSettings.remove(QString("game"));
|
||||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
|
mGameSettings.remove(QString("addon"));
|
||||||
|
|
||||||
mGameSettings.remove(QString("master"));
|
//set the value of the current profile (not necessarily the profile being saved!)
|
||||||
mGameSettings.remove(QString("plugin"));
|
mLauncherSettings.setValue(QString("Profiles/currentprofile"), mSelector->getProfileText());
|
||||||
|
|
||||||
foreach(const ContentSelectorModel::EsmFile *item, items) {
|
foreach(const ContentSelectorModel::EsmFile *item, items) {
|
||||||
|
|
||||||
if (item->gameFiles().size() == 0) {
|
if (item->gameFiles().size() == 0) {
|
||||||
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/master"), item->fileName());
|
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName + QString("/game"), item->fileName());
|
||||||
mGameSettings.setMultiValue(QString("master"), item->fileName());
|
mGameSettings.setMultiValue(QString("game"), item->fileName());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mLauncherSettings.setMultiValue(QString("Profiles/") + profile + QString("/plugin"), item->fileName());
|
mLauncherSettings.setMultiValue(QString("Profiles/") + profileName + QString("/addon"), item->fileName());
|
||||||
mGameSettings.setMultiValue(QString("plugin"), item->fileName());
|
mGameSettings.setMultiValue(QString("addon"), item->fileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::slotProfileDeleted (const QString &item)
|
void DataFilesPage::removeProfile(const QString &profile)
|
||||||
{
|
{
|
||||||
mLauncherSettings.remove(QString("Profiles/") + item + QString("/master"));
|
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/game"));
|
||||||
mLauncherSettings.remove(QString("Profiles/") + item + QString("/plugin"));
|
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/addon"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::slotProfileChanged(const QString &previous, const QString ¤t)
|
void DataFilesPage::changeProfiles(const QString &previous, const QString ¤t, bool savePrevious)
|
||||||
{
|
{
|
||||||
if (previous.isEmpty())
|
//abort if no change (typically a duplicate signal)
|
||||||
|
if (previous == current)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ContentSelectorView::ContentSelector::instance().getProfileIndex (previous) == -1)
|
int index = -1;
|
||||||
return; // Profile was deleted
|
|
||||||
|
|
||||||
// Store the previous profile
|
if (!previous.isEmpty())
|
||||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), previous);
|
index = mSelector->getProfileIndex(previous);
|
||||||
saveSettings();
|
|
||||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), current);
|
// Store the previous profile if it exists
|
||||||
|
if ( (index != -1) && savePrevious)
|
||||||
|
saveSettings(previous);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataFilesPage::slotAddNewProfile(const QString &profile)
|
||||||
|
{
|
||||||
|
saveSettings();
|
||||||
|
mSelector->clearCheckStates();
|
||||||
|
mSelector->addProfile(profile, true);
|
||||||
|
mSelector->setGameFile();
|
||||||
|
saveSettings();
|
||||||
|
|
||||||
|
emit signalProfileChanged(mSelector->getProfileIndex(profile));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataFilesPage::slotProfileDeleted (const QString &item)
|
||||||
|
{
|
||||||
|
removeProfile (item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataFilesPage::slotProfileChangedByUser(const QString &previous, const QString ¤t)
|
||||||
|
{
|
||||||
|
changeProfiles(previous, current);
|
||||||
|
emit signalProfileChanged(mSelector->getProfileIndex(current));
|
||||||
|
}
|
||||||
|
|
||||||
void DataFilesPage::slotProfileRenamed(const QString &previous, const QString ¤t)
|
void DataFilesPage::slotProfileRenamed(const QString &previous, const QString ¤t)
|
||||||
{
|
{
|
||||||
if (previous.isEmpty())
|
if (previous.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Save the new profile name
|
// Save the new profile name
|
||||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), current);
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
||||||
// Remove the old one
|
// Remove the old one
|
||||||
mLauncherSettings.remove(QString("Profiles/") + previous + QString("/master"));
|
removeProfile (previous);
|
||||||
mLauncherSettings.remove(QString("Profiles/") + previous + QString("/plugin"));
|
|
||||||
|
|
||||||
// Remove the profile from the combobox
|
|
||||||
ContentSelectorView::ContentSelector::instance().removeProfile (previous);
|
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::slotProfileAdded()
|
void DataFilesPage::slotProfileChanged(int index)
|
||||||
{
|
{
|
||||||
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
|
mSelector->setProfile(index);
|
||||||
|
|
||||||
// connect(mNewDialog->lineEdit(), SIGNAL(textChanged(QString)),
|
|
||||||
// this, SLOT(updateOkButton(QString)));
|
|
||||||
|
|
||||||
if (newDialog.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
QString profile = newDialog.lineEdit()->text();
|
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector
|
|
||||||
::instance().addProfile(profile, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::setProfilesComboBoxIndex(int index)
|
|
||||||
{
|
|
||||||
ContentSelectorView::ContentSelector::instance().setProfileIndex(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::setupDataFiles()
|
void DataFilesPage::setupDataFiles()
|
||||||
{
|
{
|
||||||
ContentSelectorView::ContentSelector &cSelector =
|
|
||||||
ContentSelectorView::ContentSelector::instance();
|
|
||||||
|
|
||||||
QStringList paths = mGameSettings.getDataDirs();
|
QStringList paths = mGameSettings.getDataDirs();
|
||||||
|
|
||||||
foreach (const QString &path, paths)
|
foreach (const QString &path, paths)
|
||||||
cSelector.addFiles(path);
|
mSelector->addFiles(path);
|
||||||
|
|
||||||
QString dataLocal = mGameSettings.getDataLocal();
|
QString dataLocal = mGameSettings.getDataLocal();
|
||||||
|
|
||||||
if (!dataLocal.isEmpty())
|
if (!dataLocal.isEmpty())
|
||||||
cSelector.addFiles(dataLocal);
|
mSelector->addFiles(dataLocal);
|
||||||
|
|
||||||
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||||
|
|
||||||
|
|
||||||
foreach (const QString &item, profiles)
|
foreach (const QString &item, profiles)
|
||||||
cSelector.addProfile (item);
|
mSelector->addProfile (item);
|
||||||
|
|
||||||
cSelector.addProfile (profile, true);
|
mSelector->addProfile (profile, true);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QAbstractItemModel *DataFilesPage::profilesModel() const
|
||||||
|
{
|
||||||
|
return mSelector->profilesModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
int DataFilesPage::profilesIndex() const
|
||||||
|
{
|
||||||
|
return mSelector->getProfileIndex(mSelector->getProfileText());
|
||||||
|
}
|
||||||
|
@ -15,22 +15,26 @@ class LauncherSettings;
|
|||||||
|
|
||||||
|
|
||||||
namespace Files { struct ConfigurationManager; }
|
namespace Files { struct ConfigurationManager; }
|
||||||
|
namespace ContentSelectorView { class ContentSelector; }
|
||||||
|
|
||||||
class DataFilesPage : public QWidget
|
class DataFilesPage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
ContentSelectorView::ContentSelector *mSelector;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent = 0);
|
DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent = 0);
|
||||||
|
|
||||||
QAbstractItemModel* profilesComboBoxModel();
|
QAbstractItemModel* profilesModel() const;
|
||||||
int profilesComboBoxIndex();
|
int profilesIndex() const;
|
||||||
|
|
||||||
void writeConfig(QString profile = QString());
|
void writeConfig(QString profile = QString());
|
||||||
void saveSettings();
|
void saveSettings(const QString &profile = "");
|
||||||
|
void loadSettings();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void profileChanged(int index);
|
void signalProfileChanged(int index);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//void showContextMenu(const QPoint &point);
|
//void showContextMenu(const QPoint &point);
|
||||||
@ -38,11 +42,11 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void slotProfileAdded();
|
void slotAddNewProfile(const QString &profile);
|
||||||
void slotProfileChanged(const QString &previous, const QString ¤t);
|
void slotProfileChangedByUser(const QString &previous, const QString ¤t);
|
||||||
|
void slotProfileChanged(int);
|
||||||
void slotProfileRenamed(const QString &previous, const QString ¤t);
|
void slotProfileRenamed(const QString &previous, const QString ¤t);
|
||||||
void slotProfileDeleted(const QString &item);
|
void slotProfileDeleted(const QString &item);
|
||||||
void setProfilesComboBoxIndex(int index);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -58,8 +62,8 @@ private:
|
|||||||
void setupDataFiles();
|
void setupDataFiles();
|
||||||
void setupConfig();
|
void setupConfig();
|
||||||
void readConfig();
|
void readConfig();
|
||||||
|
void removeProfile (const QString &profile);
|
||||||
void loadSettings();
|
void changeProfiles(const QString &previous, const QString ¤t, bool savePrevious = true);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,6 +38,7 @@ GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &g
|
|||||||
, mGraphicsSettings(graphicsSetting)
|
, mGraphicsSettings(graphicsSetting)
|
||||||
, QWidget(parent)
|
, QWidget(parent)
|
||||||
{
|
{
|
||||||
|
setObjectName ("GraphicsPage");
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
// Set the maximum res we can set in windowed mode
|
// Set the maximum res we can set in windowed mode
|
||||||
|
@ -106,10 +106,10 @@ void MainDialog::createPages()
|
|||||||
mPlayPage = new PlayPage(this);
|
mPlayPage = new PlayPage(this);
|
||||||
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this);
|
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this);
|
||||||
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
|
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
|
||||||
/// reimplement datafilespage functions to provide access
|
|
||||||
// Set the combobox of the play page to imitate the combobox on the datafilespage
|
// Set the combobox of the play page to imitate the combobox on the datafilespage
|
||||||
// mPlayPage->setProfilesComboBoxModel(mDataFilesPage->profilesComboBoxModel());
|
mPlayPage->setProfilesModel(mDataFilesPage->profilesModel());
|
||||||
// mPlayPage->setProfilesComboBoxIndex(mDataFilesPage->profilesComboBoxIndex());
|
mPlayPage->setProfilesIndex(mDataFilesPage->profilesIndex());
|
||||||
|
|
||||||
// Add the pages to the stacked widget
|
// Add the pages to the stacked widget
|
||||||
pagesWidget->addWidget(mPlayPage);
|
pagesWidget->addWidget(mPlayPage);
|
||||||
@ -121,8 +121,8 @@ void MainDialog::createPages()
|
|||||||
|
|
||||||
connect(mPlayPage, SIGNAL(playButtonClicked()), this, SLOT(play()));
|
connect(mPlayPage, SIGNAL(playButtonClicked()), this, SLOT(play()));
|
||||||
|
|
||||||
connect(mPlayPage, SIGNAL(profileChanged(int)), mDataFilesPage, SLOT(setProfilesComboBoxIndex(int)));
|
connect(mPlayPage, SIGNAL(signalProfileChanged(int)), mDataFilesPage, SLOT(slotProfileChanged(int)));
|
||||||
connect(mDataFilesPage, SIGNAL(profileChanged(int)), mPlayPage, SLOT(setProfilesComboBoxIndex(int)));
|
connect(mDataFilesPage, SIGNAL(signalProfileChanged(int)), mPlayPage, SLOT(setProfilesIndex(int)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +316,25 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
|||||||
if (!current)
|
if (!current)
|
||||||
current = previous;
|
current = previous;
|
||||||
|
|
||||||
pagesWidget->setCurrentIndex(iconWidget->row(current));
|
int currentIndex = iconWidget->row(current);
|
||||||
|
int previousIndex = iconWidget->row(previous);
|
||||||
|
|
||||||
|
pagesWidget->setCurrentIndex(currentIndex);
|
||||||
|
|
||||||
|
DataFilesPage *previousPage = dynamic_cast<DataFilesPage *>(pagesWidget->widget(previousIndex));
|
||||||
|
DataFilesPage *currentPage = dynamic_cast<DataFilesPage *>(pagesWidget->widget(currentIndex));
|
||||||
|
|
||||||
|
//special call to update/save data files page list view when it's displayed/hidden.
|
||||||
|
if (previousPage)
|
||||||
|
{
|
||||||
|
if (previousPage->objectName() == "DataFilesPage")
|
||||||
|
previousPage->saveSettings();
|
||||||
|
}
|
||||||
|
else if (currentPage)
|
||||||
|
{
|
||||||
|
if (currentPage->objectName() == "DataFilesPage")
|
||||||
|
currentPage->loadSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainDialog::setupLauncherSettings()
|
bool MainDialog::setupLauncherSettings()
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
|
setObjectName ("PlayPage");
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
// Hacks to get the stylesheet look properly
|
// Hacks to get the stylesheet look properly
|
||||||
@ -17,26 +18,21 @@ PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
|||||||
#endif
|
#endif
|
||||||
profilesComboBox->setView(new QListView());
|
profilesComboBox->setView(new QListView());
|
||||||
|
|
||||||
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentIndexChanged(int)));
|
connect(profilesComboBox, SIGNAL(activated(int)), this, SIGNAL (signalProfileChanged(int)));
|
||||||
connect(playButton, SIGNAL(clicked()), this, SLOT(slotPlayClicked()));
|
connect(playButton, SIGNAL(clicked()), this, SLOT(slotPlayClicked()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayPage::setProfilesComboBoxModel(QAbstractItemModel *model)
|
void PlayPage::setProfilesModel(QAbstractItemModel *model)
|
||||||
{
|
{
|
||||||
profilesComboBox->setModel(model);
|
profilesComboBox->setModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayPage::setProfilesComboBoxIndex(int index)
|
void PlayPage::setProfilesIndex(int index)
|
||||||
{
|
{
|
||||||
profilesComboBox->setCurrentIndex(index);
|
profilesComboBox->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayPage::slotCurrentIndexChanged(int index)
|
|
||||||
{
|
|
||||||
emit profileChanged(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayPage::slotPlayClicked()
|
void PlayPage::slotPlayClicked()
|
||||||
{
|
{
|
||||||
emit playButtonClicked();
|
emit playButtonClicked();
|
||||||
|
@ -15,17 +15,16 @@ class PlayPage : public QWidget, private Ui::PlayPage
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
PlayPage(QWidget *parent = 0);
|
PlayPage(QWidget *parent = 0);
|
||||||
void setProfilesComboBoxModel(QAbstractItemModel *model);
|
void setProfilesModel(QAbstractItemModel *model);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void profileChanged(int index);
|
void signalProfileChanged(int index);
|
||||||
void playButtonClicked();
|
void playButtonClicked();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setProfilesComboBoxIndex(int index);
|
void setProfilesIndex(int index);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotCurrentIndexChanged(int index);
|
|
||||||
void slotPlayClicked();
|
void slotPlayClicked();
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ void CSVDoc::FileDialog::addFiles(const QString &path)
|
|||||||
|
|
||||||
QString CSVDoc::FileDialog::filename()
|
QString CSVDoc::FileDialog::filename()
|
||||||
{
|
{
|
||||||
return ContentSelectorView::ContentSelector::instance().filename();
|
return ContentSelectorView::ContentSelector::instance().projectFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CSVDoc::FileDialog::selectedFilePaths()
|
QStringList CSVDoc::FileDialog::selectedFilePaths()
|
||||||
|
@ -85,6 +85,8 @@ if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
|||||||
view/profilescombobox view/comboboxlineedit
|
view/profilescombobox view/comboboxlineedit
|
||||||
view/lineedit view/contentselector
|
view/lineedit view/contentselector
|
||||||
view/filewidget view/adjusterwidget
|
view/filewidget view/adjusterwidget
|
||||||
|
view/textinputdialog
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
include(${QT_USE_FILE})
|
include(${QT_USE_FILE})
|
||||||
|
@ -391,7 +391,6 @@ bool ContentSelectorModel::ContentModel::canBeChecked(const EsmFile *file) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,6 +447,39 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete decoder;
|
delete decoder;
|
||||||
|
|
||||||
|
sortFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentSelectorModel::ContentModel::sortFiles()
|
||||||
|
{
|
||||||
|
//first, sort the model such that all dependencies are ordered upstream (gamefile) first.
|
||||||
|
bool movedFiles = true;
|
||||||
|
int fileCount = mFiles.size();
|
||||||
|
|
||||||
|
//Dependency sort
|
||||||
|
//iterate until no sorting of files occurs
|
||||||
|
while (movedFiles)
|
||||||
|
{
|
||||||
|
movedFiles = false;
|
||||||
|
//iterate each file, obtaining a reference to it's gamefiles list
|
||||||
|
for (int i = 0; i < fileCount; i++)
|
||||||
|
{
|
||||||
|
const QStringList &gamefiles = mFiles.at(i)->gameFiles();
|
||||||
|
//iterate each file after the current file, verifying that none of it's
|
||||||
|
//dependencies appear.
|
||||||
|
for (int j = i + 1; j < fileCount; j++)
|
||||||
|
{
|
||||||
|
if (gamefiles.contains(mFiles.at(j)->fileName()))
|
||||||
|
{
|
||||||
|
mFiles.move(j, i);
|
||||||
|
movedFiles = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (movedFiles)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContentSelectorModel::ContentModel::isChecked(const QString& name) const
|
bool ContentSelectorModel::ContentModel::isChecked(const QString& name) const
|
||||||
@ -460,6 +492,7 @@ bool ContentSelectorModel::ContentModel::isChecked(const QString& name) const
|
|||||||
|
|
||||||
void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool checkState)
|
void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool checkState)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -469,9 +502,14 @@ void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool
|
|||||||
state = Qt::Checked;
|
state = Qt::Checked;
|
||||||
|
|
||||||
mCheckStates[name] = state;
|
mCheckStates[name] = state;
|
||||||
|
emit dataChanged(indexFromItem(item(name)), indexFromItem(item(name)));
|
||||||
|
|
||||||
const EsmFile *file = item(name);
|
const EsmFile *file = item(name);
|
||||||
|
|
||||||
|
if (file->isGameFile())
|
||||||
|
emit dataChanged (index(0,0), index(rowCount()-1,0));
|
||||||
|
|
||||||
|
//if we're checking an item, ensure all "upstream" files (dependencies) are checked as well.
|
||||||
if (state == Qt::Checked)
|
if (state == Qt::Checked)
|
||||||
{
|
{
|
||||||
foreach (const QString &upstreamName, file->gameFiles())
|
foreach (const QString &upstreamName, file->gameFiles())
|
||||||
@ -482,24 +520,23 @@ void ContentSelectorModel::ContentModel::setCheckState(const QString &name, bool
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!isChecked(upstreamName))
|
if (!isChecked(upstreamName))
|
||||||
{
|
|
||||||
mCheckStates[upstreamName] = Qt::Checked;
|
mCheckStates[upstreamName] = Qt::Checked;
|
||||||
emit dataChanged(indexFromItem(upstreamFile), indexFromItem(upstreamFile));
|
|
||||||
}
|
emit dataChanged(indexFromItem(upstreamFile), indexFromItem(upstreamFile));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (state == Qt::Unchecked)
|
//otherwise, if we're unchecking an item (or the file is a game file) ensure all downstream files are unchecked.
|
||||||
|
if (state == Qt::Unchecked)
|
||||||
{
|
{
|
||||||
foreach (const EsmFile *downstreamFile, mFiles)
|
foreach (const EsmFile *downstreamFile, mFiles)
|
||||||
{
|
{
|
||||||
if (downstreamFile->gameFiles().contains(name))
|
if (downstreamFile->gameFiles().contains(name))
|
||||||
{
|
{
|
||||||
if (mCheckStates.contains(downstreamFile->fileName()))
|
if (mCheckStates.contains(downstreamFile->fileName()))
|
||||||
{
|
|
||||||
mCheckStates[downstreamFile->fileName()] = Qt::Unchecked;
|
mCheckStates[downstreamFile->fileName()] = Qt::Unchecked;
|
||||||
emit dataChanged(indexFromItem(downstreamFile), indexFromItem(downstreamFile));
|
|
||||||
}
|
emit dataChanged(indexFromItem(downstreamFile), indexFromItem(downstreamFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,19 +56,20 @@ namespace ContentSelectorModel
|
|||||||
EsmFile *item(int row);
|
EsmFile *item(int row);
|
||||||
|
|
||||||
bool canBeChecked(const EsmFile *file) const;
|
bool canBeChecked(const EsmFile *file) const;
|
||||||
|
void sortFiles();
|
||||||
|
|
||||||
ContentFileList mFiles;
|
ContentFileList mFiles;
|
||||||
QHash<QString, Qt::CheckState> mCheckStates;
|
QHash<QString, Qt::CheckState> mCheckStates;
|
||||||
QTextCodec *mCodec;
|
QTextCodec *mCodec;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QString mMimeType;
|
QString mMimeType;
|
||||||
QStringList mMimeTypes;
|
QStringList mMimeTypes;
|
||||||
int mColumnCount;
|
int mColumnCount;
|
||||||
Qt::ItemFlags mDragDropFlags;
|
Qt::ItemFlags mDragDropFlags;
|
||||||
Qt::ItemFlags mDefaultFlags;
|
Qt::ItemFlags mDefaultFlags;
|
||||||
Qt::DropActions mDropActions;
|
Qt::DropActions mDropActions;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // CONTENTMODEL_HPP
|
#endif // CONTENTMODEL_HPP
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
@ -14,6 +13,9 @@
|
|||||||
|
|
||||||
#include "filewidget.hpp"
|
#include "filewidget.hpp"
|
||||||
#include "adjusterwidget.hpp"
|
#include "adjusterwidget.hpp"
|
||||||
|
#include "textinputdialog.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector *ContentSelectorView::ContentSelector::mInstance = 0;
|
ContentSelectorView::ContentSelector *ContentSelectorView::ContentSelector::mInstance = 0;
|
||||||
QStringList ContentSelectorView::ContentSelector::mFilePaths;
|
QStringList ContentSelectorView::ContentSelector::mFilePaths;
|
||||||
@ -33,7 +35,8 @@ ContentSelectorView::ContentSelector& ContentSelectorView::ContentSelector::inst
|
|||||||
|
|
||||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, unsigned char flags) :
|
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, unsigned char flags) :
|
||||||
QWidget(parent), mFlags (flags),
|
QWidget(parent), mFlags (flags),
|
||||||
mAdjusterWidget (0), mFileWidget (0)
|
mAdjusterWidget (0), mFileWidget (0),
|
||||||
|
mIgnoreProfileSignal (false)
|
||||||
{
|
{
|
||||||
|
|
||||||
ui.setupUi (this);
|
ui.setupUi (this);
|
||||||
@ -53,14 +56,6 @@ ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, unsigned
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
QString ContentSelectorView::ContentSelector::getNewProfileName()
|
|
||||||
{
|
|
||||||
// Create a dialog for the new profile name input
|
|
||||||
//mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this);
|
|
||||||
|
|
||||||
//connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString)));
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContentSelectorView::ContentSelector::isFlagged(SelectorFlags flag) const
|
bool ContentSelectorView::ContentSelector::isFlagged(SelectorFlags flag) const
|
||||||
{
|
{
|
||||||
@ -94,6 +89,8 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.gameFileView->setVisible (true);
|
||||||
|
|
||||||
mGameFileProxyModel = new QSortFilterProxyModel(this);
|
mGameFileProxyModel = new QSortFilterProxyModel(this);
|
||||||
mGameFileProxyModel->setFilterRegExp(QString::number((int)ContentSelectorModel::ContentType_GameFile));
|
mGameFileProxyModel->setFilterRegExp(QString::number((int)ContentSelectorModel::ContentType_GameFile));
|
||||||
mGameFileProxyModel->setFilterRole (Qt::UserRole);
|
mGameFileProxyModel->setFilterRole (Qt::UserRole);
|
||||||
@ -102,7 +99,7 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
|||||||
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
||||||
ui.gameFileView->setModel(mGameFileProxyModel);
|
ui.gameFileView->setModel(mGameFileProxyModel);
|
||||||
|
|
||||||
connect(ui.gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
connect (ui.gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
||||||
|
|
||||||
ui.gameFileView->setCurrentIndex(-1);
|
ui.gameFileView->setCurrentIndex(-1);
|
||||||
}
|
}
|
||||||
@ -115,6 +112,8 @@ void ContentSelectorView::ContentSelector::buildAddonView()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.addonView->setVisible (true);
|
||||||
|
|
||||||
mAddonProxyModel = new QSortFilterProxyModel(this);
|
mAddonProxyModel = new QSortFilterProxyModel(this);
|
||||||
mAddonProxyModel->setFilterRegExp (QString::number((int)ContentSelectorModel::ContentType_Addon));
|
mAddonProxyModel->setFilterRegExp (QString::number((int)ContentSelectorModel::ContentType_Addon));
|
||||||
mAddonProxyModel->setFilterRole (Qt::UserRole);
|
mAddonProxyModel->setFilterRole (Qt::UserRole);
|
||||||
@ -129,31 +128,48 @@ void ContentSelectorView::ContentSelector::buildAddonView()
|
|||||||
void ContentSelectorView::ContentSelector::buildProfilesView()
|
void ContentSelectorView::ContentSelector::buildProfilesView()
|
||||||
{
|
{
|
||||||
if (!isFlagged (Flag_Profile))
|
if (!isFlagged (Flag_Profile))
|
||||||
|
{
|
||||||
|
ui.profileGroupBox->setVisible(false);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.profileGroupBox->setVisible (true);
|
||||||
|
|
||||||
// Add the actions to the toolbuttons
|
// Add the actions to the toolbuttons
|
||||||
ui.newProfileButton->setDefaultAction (ui.newProfileAction);
|
ui.newProfileButton->setDefaultAction (ui.newProfileAction);
|
||||||
ui.deleteProfileButton->setDefaultAction (ui.deleteProfileAction);
|
ui.deleteProfileButton->setDefaultAction (ui.deleteProfileAction);
|
||||||
|
|
||||||
|
//enable ui elements
|
||||||
ui.profilesComboBox->addItem ("Default");
|
ui.profilesComboBox->addItem ("Default");
|
||||||
ui.profilesComboBox->setPlaceholderText (QString("Select a profile..."));
|
ui.profilesComboBox->setPlaceholderText (QString("Select a profile..."));
|
||||||
|
|
||||||
|
if (!ui.profilesComboBox->isEnabled())
|
||||||
|
ui.profilesComboBox->setEnabled(true);
|
||||||
|
|
||||||
|
if (!ui.deleteProfileAction->isEnabled())
|
||||||
|
ui.deleteProfileAction->setEnabled(true);
|
||||||
|
|
||||||
|
//establish connections
|
||||||
connect (ui.profilesComboBox, SIGNAL (currentIndexChanged(int)), this, SLOT(slotCurrentProfileIndexChanged(int)));
|
connect (ui.profilesComboBox, SIGNAL (currentIndexChanged(int)), this, SLOT(slotCurrentProfileIndexChanged(int)));
|
||||||
connect (ui.profilesComboBox, SIGNAL (profileRenamed(QString,QString)), this, SIGNAL(signalProfileRenamed(QString,QString)));
|
connect (ui.profilesComboBox, SIGNAL (profileRenamed(QString,QString)), this, SIGNAL(signalProfileRenamed(QString,QString)));
|
||||||
connect (ui.profilesComboBox, SIGNAL (profileChanged(QString,QString)), this, SIGNAL(signalProfileChanged(QString,QString)));
|
connect (ui.profilesComboBox, SIGNAL (signalProfileChanged(QString,QString)), this, SIGNAL(signalProfileChangedByUser(QString,QString)));
|
||||||
connect (ui.profilesComboBox, SIGNAL (signalProfileTextChanged(QString)), this, SLOT (slotProfileTextChanged (QString)));
|
connect (ui.profilesComboBox, SIGNAL (signalProfileTextChanged(QString)), this, SLOT (slotProfileTextChanged (QString)));
|
||||||
|
|
||||||
ui.profileGroupBox->setVisible (true);
|
ui.profileGroupBox->setVisible (true);
|
||||||
|
ui.projectButtonBox->setVisible (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::buildLoadAddonView()
|
void ContentSelectorView::ContentSelector::buildLoadAddonView()
|
||||||
{
|
{
|
||||||
if (!isFlagged (Flag_LoadAddon))
|
if (!isFlagged (Flag_LoadAddon))
|
||||||
{
|
{
|
||||||
ui.projectGroupBox->setVisible (false);
|
if (!isFlagged (Flag_NewAddon))
|
||||||
|
ui.projectGroupBox->setVisible (false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.projectGroupBox->setVisible (true);
|
||||||
ui.projectCreateButton->setVisible (false);
|
ui.projectCreateButton->setVisible (false);
|
||||||
ui.projectGroupBox->setTitle ("");
|
ui.projectGroupBox->setTitle ("");
|
||||||
|
|
||||||
@ -165,10 +181,14 @@ void ContentSelectorView::ContentSelector::buildNewAddonView()
|
|||||||
{
|
{
|
||||||
if (!isFlagged (Flag_NewAddon))
|
if (!isFlagged (Flag_NewAddon))
|
||||||
{
|
{
|
||||||
ui.profileGroupBox->setVisible (false);
|
if (!isFlagged (Flag_LoadAddon))
|
||||||
|
ui.projectGroupBox->setVisible (false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.projectGroupBox->setVisible (true);
|
||||||
|
|
||||||
mFileWidget = new CSVDoc::FileWidget (this);
|
mFileWidget = new CSVDoc::FileWidget (this);
|
||||||
mAdjusterWidget = new CSVDoc::AdjusterWidget (this);
|
mAdjusterWidget = new CSVDoc::AdjusterWidget (this);
|
||||||
|
|
||||||
@ -190,18 +210,36 @@ void ContentSelectorView::ContentSelector::buildNewAddonView()
|
|||||||
connect(ui.projectButtonBox, SIGNAL(rejected()), this, SIGNAL(rejected()));
|
connect(ui.projectButtonBox, SIGNAL(rejected()), this, SIGNAL(rejected()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
|
||||||
|
{
|
||||||
|
int index = -1;
|
||||||
|
|
||||||
|
if (!filename.isEmpty())
|
||||||
|
{
|
||||||
|
index = ui.gameFileView->findText(filename);
|
||||||
|
|
||||||
|
//verify that the current index is also checked in the model
|
||||||
|
mContentModel->setCheckState(filename, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.gameFileView->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::clearCheckStates()
|
||||||
|
{
|
||||||
|
mContentModel->uncheckAll();
|
||||||
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::setCheckStates(const QStringList &list)
|
void ContentSelectorView::ContentSelector::setCheckStates(const QStringList &list)
|
||||||
{
|
{
|
||||||
if (list.isEmpty())
|
if (list.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mContentModel->uncheckAll();
|
|
||||||
|
|
||||||
foreach (const QString &file, list)
|
foreach (const QString &file, list)
|
||||||
mContentModel->setCheckState(file, Qt::Checked);
|
mContentModel->setCheckState(file, Qt::Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ContentSelectorView::ContentSelector::filename() const
|
QString ContentSelectorView::ContentSelector::projectFilename() const
|
||||||
{
|
{
|
||||||
QString filepath = "";
|
QString filepath = "";
|
||||||
|
|
||||||
@ -211,26 +249,13 @@ QString ContentSelectorView::ContentSelector::filename() const
|
|||||||
return filepath;
|
return filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ContentSelectorView::ContentSelector::selectedFilePaths() const
|
|
||||||
{
|
|
||||||
QStringList filePaths;
|
|
||||||
|
|
||||||
if (mContentModel)
|
|
||||||
{
|
|
||||||
foreach (ContentSelectorModel::EsmFile *file, mContentModel->checkedItems())
|
|
||||||
filePaths.append(file->path());
|
|
||||||
}
|
|
||||||
|
|
||||||
return filePaths;
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentSelectorModel::ContentFileList
|
ContentSelectorModel::ContentFileList
|
||||||
ContentSelectorView::ContentSelector::selectedFiles() const
|
ContentSelectorView::ContentSelector::selectedFiles() const
|
||||||
{
|
{
|
||||||
if (mContentModel)
|
if (!mContentModel)
|
||||||
return mContentModel->checkedItems();
|
return ContentSelectorModel::ContentFileList();
|
||||||
|
|
||||||
return ContentSelectorModel::ContentFileList();
|
return mContentModel->checkedItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -243,41 +268,39 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
|||||||
{
|
{
|
||||||
mInstance->mContentModel->addFiles(path);
|
mInstance->mContentModel->addFiles(path);
|
||||||
mInstance->ui.gameFileView->setCurrentIndex(-1);
|
mInstance->ui.gameFileView->setCurrentIndex(-1);
|
||||||
mInstance->mContentModel->uncheckAll();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::removeProfile(const QString &item)
|
|
||||||
{
|
|
||||||
int idx = ui.profilesComboBox->findText(item);
|
|
||||||
|
|
||||||
if (idx != -1)
|
|
||||||
ui.profilesComboBox->removeItem(idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ContentSelectorView::ContentSelector::getProfileIndex ( const QString &item) const
|
int ContentSelectorView::ContentSelector::getProfileIndex ( const QString &item) const
|
||||||
{
|
{
|
||||||
return ui.profilesComboBox->findText (item);
|
return ui.profilesComboBox->findText (item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::setProfileIndex(int index)
|
|
||||||
{
|
|
||||||
if (index >=0 && index < ui.profilesComboBox->count())
|
|
||||||
ui.profilesComboBox->setCurrentIndex(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::addProfile (const QString &item, bool setAsCurrent)
|
void ContentSelectorView::ContentSelector::addProfile (const QString &item, bool setAsCurrent)
|
||||||
{
|
{
|
||||||
if (item.isEmpty())
|
if (item.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QString previous = ui.profilesComboBox->currentText();
|
||||||
|
|
||||||
if (ui.profilesComboBox->findText(item) == -1)
|
if (ui.profilesComboBox->findText(item) == -1)
|
||||||
ui.profilesComboBox->addItem(item);
|
ui.profilesComboBox->addItem(item);
|
||||||
|
|
||||||
if (setAsCurrent)
|
if (setAsCurrent)
|
||||||
ui.profilesComboBox->setCurrentIndex(ui.profilesComboBox->findText(item));
|
setProfile (ui.profilesComboBox->findText(item));
|
||||||
|
}
|
||||||
|
|
||||||
enableProfilesComboBox();
|
void ContentSelectorView::ContentSelector::setProfile(int index)
|
||||||
|
{
|
||||||
|
//programmatic change requires second call to non-signalized "slot" since no signal responses
|
||||||
|
//occur for programmatic changes to the profilesComboBox.
|
||||||
|
if (index >= -1 && index < ui.profilesComboBox->count())
|
||||||
|
{
|
||||||
|
QString previous = ui.profilesComboBox->itemText(ui.profilesComboBox->currentIndex());
|
||||||
|
QString current = ui.profilesComboBox->itemText(index);
|
||||||
|
|
||||||
|
ui.profilesComboBox->setCurrentIndex(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ContentSelectorView::ContentSelector::getProfileText() const
|
QString ContentSelectorView::ContentSelector::getProfileText() const
|
||||||
@ -285,36 +308,18 @@ QString ContentSelectorView::ContentSelector::getProfileText() const
|
|||||||
return ui.profilesComboBox->currentText();
|
return ui.profilesComboBox->currentText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::enableProfilesComboBox()
|
QAbstractItemModel *ContentSelectorView::ContentSelector::profilesModel() const
|
||||||
{
|
{
|
||||||
if (!ui.profilesComboBox->isEnabled())
|
return ui.profilesComboBox->model();
|
||||||
ui.profilesComboBox->setEnabled(true);
|
|
||||||
|
|
||||||
if (!ui.deleteProfileAction->isEnabled())
|
|
||||||
ui.deleteProfileAction->setEnabled(true);
|
|
||||||
|
|
||||||
ui.projectButtonBox->button(QDialogButtonBox::Open)->setEnabled (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList ContentSelectorView::ContentSelector::checkedItemsPaths()
|
|
||||||
{
|
|
||||||
QStringList itemPaths;
|
|
||||||
|
|
||||||
foreach( const ContentSelectorModel::EsmFile *file, mContentModel->checkedItems())
|
|
||||||
itemPaths << file->path();
|
|
||||||
|
|
||||||
return itemPaths;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotCurrentProfileIndexChanged(int index)
|
void ContentSelectorView::ContentSelector::slotCurrentProfileIndexChanged(int index)
|
||||||
{
|
{
|
||||||
//don't allow deleting "Default" profile
|
//don't allow deleting "Default" profile
|
||||||
bool success = (ui.profilesComboBox->itemText(index) == "Default");
|
bool success = (ui.profilesComboBox->itemText(index) != "Default");
|
||||||
|
|
||||||
ui.deleteProfileAction->setEnabled(success);
|
ui.deleteProfileAction->setEnabled(success);
|
||||||
ui.profilesComboBox->setEditEnabled(success);
|
ui.profilesComboBox->setEditEnabled(success);
|
||||||
|
|
||||||
emit signalProfileChanged(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int index)
|
void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int index)
|
||||||
@ -370,10 +375,12 @@ void ContentSelectorView::ContentSelector::slotUpdateCreateButton(bool)
|
|||||||
ui.projectCreateButton->setEnabled(validGameFile && validFilename);
|
ui.projectCreateButton->setEnabled(validGameFile && validFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::on_newProfileAction_triggered()
|
void ContentSelectorView::ContentSelector::on_newProfileAction_triggered()
|
||||||
{
|
{
|
||||||
emit signalProfileAdded();
|
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
|
||||||
|
|
||||||
|
if (newDialog.exec() == QDialog::Accepted)
|
||||||
|
emit signalAddNewProfile(newDialog.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::on_deleteProfileAction_triggered()
|
void ContentSelectorView::ContentSelector::on_deleteProfileAction_triggered()
|
||||||
@ -402,11 +409,6 @@ void ContentSelectorView::ContentSelector::on_deleteProfileAction_triggered()
|
|||||||
|
|
||||||
//signal for removal from model
|
//signal for removal from model
|
||||||
emit signalProfileDeleted (profile);
|
emit signalProfileDeleted (profile);
|
||||||
}
|
|
||||||
/*
|
|
||||||
void ContentSelectorView::ContentSelector::slotUpdateOkButton(const QString &text)
|
|
||||||
{
|
|
||||||
bool success = (ui.profilesComboBox->findText(text) == -1);
|
|
||||||
|
|
||||||
mNewDialog->setOkButtonEnabled(success);
|
slotCurrentProfileIndexChanged(ui.profilesComboBox->currentIndex());
|
||||||
}*/
|
}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include "../model/contentmodel.hpp"
|
#include "../model/contentmodel.hpp"
|
||||||
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class TextInputDialog;
|
|
||||||
|
|
||||||
namespace CSVDoc
|
namespace CSVDoc
|
||||||
{
|
{
|
||||||
@ -29,6 +28,7 @@ namespace ContentSelectorView
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
unsigned char mFlags;
|
unsigned char mFlags;
|
||||||
|
bool mIgnoreProfileSignal;
|
||||||
|
|
||||||
static ContentSelector *mInstance;
|
static ContentSelector *mInstance;
|
||||||
static QStringList mFilePaths;
|
static QStringList mFilePaths;
|
||||||
@ -36,8 +36,6 @@ namespace ContentSelectorView
|
|||||||
CSVDoc::FileWidget *mFileWidget;
|
CSVDoc::FileWidget *mFileWidget;
|
||||||
CSVDoc::AdjusterWidget *mAdjusterWidget;
|
CSVDoc::AdjusterWidget *mAdjusterWidget;
|
||||||
|
|
||||||
TextInputDialog *mNewDialog;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
ContentSelectorModel::ContentModel *mContentModel;
|
ContentSelectorModel::ContentModel *mContentModel;
|
||||||
@ -45,26 +43,28 @@ namespace ContentSelectorView
|
|||||||
QSortFilterProxyModel *mAddonProxyModel;
|
QSortFilterProxyModel *mAddonProxyModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit ContentSelector(QWidget *parent = 0, unsigned char flags = Flag_Content);
|
explicit ContentSelector(QWidget *parent = 0, unsigned char flags = Flag_Content);
|
||||||
|
|
||||||
static void configure(QWidget *subject, unsigned char flags = Flag_Content);
|
static void configure(QWidget *subject, unsigned char flags = Flag_Content);
|
||||||
static ContentSelector &instance();
|
static ContentSelector &instance();
|
||||||
static void addFiles(const QString &path);
|
static void addFiles(const QString &path);
|
||||||
|
|
||||||
|
void clearCheckStates();
|
||||||
void setCheckStates (const QStringList &list);
|
void setCheckStates (const QStringList &list);
|
||||||
QStringList checkedItemsPaths();
|
|
||||||
ContentSelectorModel::ContentFileList *CheckedItems();
|
ContentSelectorModel::ContentFileList *CheckedItems();
|
||||||
|
|
||||||
QString filename() const;
|
QString projectFilename() const;
|
||||||
ContentSelectorModel::ContentFileList selectedFiles() const;
|
ContentSelectorModel::ContentFileList selectedFiles() const;
|
||||||
QStringList selectedFilePaths() const;
|
|
||||||
|
|
||||||
|
QAbstractItemModel *profilesModel() const;
|
||||||
|
void setGameFile (const QString &filename = "");
|
||||||
void addProfile (const QString &item, bool setAsCurrent = false);
|
void addProfile (const QString &item, bool setAsCurrent = false);
|
||||||
void removeProfile (const QString &item);
|
void setProfile (int index);
|
||||||
int getProfileIndex (const QString &item) const;
|
int getProfileIndex (const QString &item) const;
|
||||||
void setProfileIndex (int index);
|
|
||||||
QString getProfileText() const;
|
QString getProfileText() const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ui::DataFilesPage ui;
|
Ui::DataFilesPage ui;
|
||||||
@ -77,22 +77,18 @@ namespace ContentSelectorView
|
|||||||
void buildLoadAddonView();
|
void buildLoadAddonView();
|
||||||
|
|
||||||
bool isFlagged(SelectorFlags flag) const;
|
bool isFlagged(SelectorFlags flag) const;
|
||||||
QString getNewProfileName();
|
|
||||||
void enableProfilesComboBox();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void accepted();
|
void accepted();
|
||||||
void rejected();
|
void rejected();
|
||||||
|
|
||||||
void signalProfileChanged(int index);
|
|
||||||
void signalGameFileChanged(int value);
|
|
||||||
|
|
||||||
void signalCreateButtonClicked();
|
void signalCreateButtonClicked();
|
||||||
|
|
||||||
void signalProfileRenamed(QString,QString);
|
void signalProfileRenamed(QString,QString);
|
||||||
void signalProfileChanged(QString,QString);
|
void signalProfileChangedByUser(QString,QString);
|
||||||
void signalProfileDeleted(QString);
|
void signalProfileDeleted(QString);
|
||||||
void signalProfileAdded();
|
void signalAddNewProfile(QString);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
@ -102,7 +98,6 @@ namespace ContentSelectorView
|
|||||||
void slotAddonTableItemClicked(const QModelIndex &index);
|
void slotAddonTableItemClicked(const QModelIndex &index);
|
||||||
|
|
||||||
void slotUpdateCreateButton (bool);
|
void slotUpdateCreateButton (bool);
|
||||||
// void slotUpdateOpenButton(const QStringList &items);
|
|
||||||
|
|
||||||
// Action slots
|
// Action slots
|
||||||
void on_newProfileAction_triggered();
|
void on_newProfileAction_triggered();
|
||||||
|
@ -15,8 +15,8 @@ ContentSelectorView::ProfilesComboBox::ProfilesComboBox(QWidget *parent) :
|
|||||||
setValidator(mValidator);
|
setValidator(mValidator);
|
||||||
setCompleter(0);
|
setCompleter(0);
|
||||||
|
|
||||||
connect(this, SIGNAL(currentIndexChanged(int)), this,
|
connect(this, SIGNAL(activated(int)), this,
|
||||||
SLOT(slotIndexChanged(int)));
|
SLOT(slotIndexChangedByUser(int)));
|
||||||
|
|
||||||
setInsertPolicy(QComboBox::NoInsert);
|
setInsertPolicy(QComboBox::NoInsert);
|
||||||
}
|
}
|
||||||
@ -85,13 +85,13 @@ void ContentSelectorView::ProfilesComboBox::slotEditingFinished()
|
|||||||
emit(profileRenamed(previous, current));
|
emit(profileRenamed(previous, current));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ProfilesComboBox::slotIndexChanged(int index)
|
void ContentSelectorView::ProfilesComboBox::slotIndexChangedByUser(int index)
|
||||||
{
|
{
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
emit(profileChanged(mOldProfile, currentText()));
|
emit (signalProfileChanged(mOldProfile, currentText()));
|
||||||
mOldProfile = itemText(index);
|
mOldProfile = currentText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ProfilesComboBox::paintEvent(QPaintEvent *)
|
void ContentSelectorView::ProfilesComboBox::paintEvent(QPaintEvent *)
|
||||||
|
@ -14,17 +14,19 @@ namespace ContentSelectorView
|
|||||||
public:
|
public:
|
||||||
explicit ProfilesComboBox(QWidget *parent = 0);
|
explicit ProfilesComboBox(QWidget *parent = 0);
|
||||||
void setEditEnabled(bool editable);
|
void setEditEnabled(bool editable);
|
||||||
void setPlaceholderText (const QString &text);
|
void setPlaceholderText(const QString &text);
|
||||||
|
// void indexChanged(int index);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalProfileTextChanged (const QString &item);
|
void signalProfileTextChanged(const QString &item);
|
||||||
void profileChanged(const QString &previous, const QString ¤t);
|
void signalProfileChanged(const QString &previous, const QString ¤t);
|
||||||
|
void signalProfileChanged(int index);
|
||||||
void profileRenamed(const QString &oldName, const QString &newName);
|
void profileRenamed(const QString &oldName, const QString &newName);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void slotEditingFinished();
|
void slotEditingFinished();
|
||||||
void slotIndexChanged(int index);
|
void slotIndexChangedByUser(int index);
|
||||||
void slotTextChanged(const QString &text);
|
void slotTextChanged(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -16,6 +16,7 @@ TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWid
|
|||||||
mButtonBox = new QDialogButtonBox(this);
|
mButtonBox = new QDialogButtonBox(this);
|
||||||
mButtonBox->addButton(QDialogButtonBox::Ok);
|
mButtonBox->addButton(QDialogButtonBox::Ok);
|
||||||
mButtonBox->addButton(QDialogButtonBox::Cancel);
|
mButtonBox->addButton(QDialogButtonBox::Cancel);
|
||||||
|
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false);
|
||||||
|
|
||||||
// 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
|
||||||
@ -38,11 +39,11 @@ TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWid
|
|||||||
Q_UNUSED(title);
|
Q_UNUSED(title);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setOkButtonEnabled(false);
|
|
||||||
setModal(true);
|
setModal(true);
|
||||||
|
|
||||||
connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
connect(mLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotUpdateOkButton(QString)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,19 +54,23 @@ int TextInputDialog::exec()
|
|||||||
return QDialog::exec();
|
return QDialog::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextInputDialog::setOkButtonEnabled(bool enabled)
|
QString TextInputDialog::getText() const
|
||||||
{
|
{
|
||||||
QPushButton *okButton = mButtonBox->button(QDialogButtonBox::Ok);
|
return mLineEdit->text();
|
||||||
okButton->setEnabled(enabled);
|
}
|
||||||
|
|
||||||
QPalette *palette = new QPalette();
|
void TextInputDialog::slotUpdateOkButton(QString text)
|
||||||
palette->setColor(QPalette::Text,Qt::red);
|
{
|
||||||
|
bool enabled = !(text.isEmpty());
|
||||||
|
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(enabled);
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled)
|
||||||
mLineEdit->setPalette(QApplication::palette());
|
mLineEdit->setPalette(QApplication::palette());
|
||||||
} else {
|
else
|
||||||
|
{
|
||||||
// Existing profile name, make the text red
|
// Existing profile name, make the text red
|
||||||
|
QPalette *palette = new QPalette();
|
||||||
|
palette->setColor(QPalette::Text,Qt::red);
|
||||||
mLineEdit->setPalette(*palette);
|
mLineEdit->setPalette(*palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -13,18 +13,19 @@ namespace ContentSelectorView {
|
|||||||
class TextInputDialog : public QDialog
|
class TextInputDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
|
||||||
explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0);
|
|
||||||
inline ContentSelectorView::LineEdit *lineEdit() { return mLineEdit; }
|
|
||||||
void setOkButtonEnabled(bool enabled);
|
|
||||||
|
|
||||||
ContentSelectorView::LineEdit *mLineEdit;
|
ContentSelectorView::LineEdit *mLineEdit;
|
||||||
|
QDialogButtonBox *mButtonBox;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0);
|
||||||
|
QString getText() const;
|
||||||
|
|
||||||
int exec();
|
int exec();
|
||||||
|
|
||||||
private:
|
private slots:
|
||||||
QDialogButtonBox *mButtonBox;
|
void slotUpdateOkButton(QString text);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>518</width>
|
<width>518</width>
|
||||||
<height>424</height>
|
<height>436</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -242,11 +242,6 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Default</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user