2011-04-07 22:04:09 +00:00
|
|
|
#ifndef DATAFILESPAGE_H
|
|
|
|
#define DATAFILESPAGE_H
|
|
|
|
|
2013-10-23 02:52:35 +00:00
|
|
|
#include "ui_datafilespage.h"
|
2011-04-07 22:04:09 +00:00
|
|
|
#include <QWidget>
|
|
|
|
|
2013-11-03 05:02:46 +00:00
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
|
2011-05-11 18:04:25 +00:00
|
|
|
class QSortFilterProxyModel;
|
2013-03-05 02:47:57 +00:00
|
|
|
class QAbstractItemModel;
|
2011-06-07 18:21:01 +00:00
|
|
|
class QMenu;
|
2013-02-11 14:01:00 +00:00
|
|
|
|
2012-01-21 00:14:35 +00:00
|
|
|
namespace Files { struct ConfigurationManager; }
|
2013-10-07 02:13:47 +00:00
|
|
|
namespace ContentSelectorView { class ContentSelector; }
|
2012-01-21 00:14:35 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
namespace Launcher
|
2011-04-07 22:04:09 +00:00
|
|
|
{
|
2013-10-25 16:17:26 +00:00
|
|
|
class TextInputDialog;
|
|
|
|
class GameSettings;
|
|
|
|
class LauncherSettings;
|
|
|
|
class ProfilesComboBox;
|
2013-09-22 04:06:29 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
class DataFilesPage : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2013-10-07 02:13:47 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
ContentSelectorView::ContentSelector *mSelector;
|
|
|
|
Ui::DataFilesPage ui;
|
2013-10-23 02:52:35 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
public:
|
|
|
|
explicit DataFilesPage (Files::ConfigurationManager &cfg, GameSettings &gameSettings,
|
|
|
|
LauncherSettings &launcherSettings, QWidget *parent = 0);
|
2011-04-07 22:04:09 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
QAbstractItemModel* profilesModel() const;
|
2013-03-05 02:47:57 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
int profilesIndex() const;
|
2013-02-11 14:01:00 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
//void writeConfig(QString profile = QString());
|
|
|
|
void saveSettings(const QString &profile = "");
|
|
|
|
void loadSettings();
|
2011-04-24 21:03:21 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
signals:
|
|
|
|
void signalProfileChanged (int index);
|
2011-04-07 22:04:09 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
public slots:
|
|
|
|
void slotProfileChanged (int index);
|
2013-03-05 02:47:57 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
private slots:
|
2013-10-02 02:29:45 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
void slotProfileChangedByUser(const QString &previous, const QString ¤t);
|
|
|
|
void slotProfileRenamed(const QString &previous, const QString ¤t);
|
|
|
|
void slotProfileDeleted(const QString &item);
|
2013-10-23 02:52:35 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
void on_newProfileAction_triggered();
|
|
|
|
void on_deleteProfileAction_triggered();
|
2012-10-10 20:58:04 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
private:
|
2013-10-02 02:29:45 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
QMenu *mContextMenu;
|
2012-02-22 07:34:47 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
Files::ConfigurationManager &mCfgMgr;
|
2012-02-22 07:34:47 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
GameSettings &mGameSettings;
|
|
|
|
LauncherSettings &mLauncherSettings;
|
2012-01-21 00:14:35 +00:00
|
|
|
|
2013-11-03 05:02:46 +00:00
|
|
|
QString mDataLocal;
|
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
void setPluginsCheckstates(Qt::CheckState state);
|
2011-04-07 22:04:09 +00:00
|
|
|
|
2013-10-25 16:17:26 +00:00
|
|
|
void buildView();
|
|
|
|
void setupDataFiles();
|
|
|
|
void setupConfig();
|
|
|
|
void readConfig();
|
|
|
|
void setProfile (int index, bool savePrevious);
|
|
|
|
void setProfile (const QString &previous, const QString ¤t, bool savePrevious);
|
|
|
|
void removeProfile (const QString &profile);
|
|
|
|
bool showDeleteMessageBox (const QString &text);
|
|
|
|
void addProfile (const QString &profile, bool setAsCurrent);
|
|
|
|
void checkForDefaultProfile();
|
2013-11-03 05:02:46 +00:00
|
|
|
|
|
|
|
class PathIterator
|
|
|
|
{
|
|
|
|
QStringList::ConstIterator mCitEnd;
|
|
|
|
QStringList::ConstIterator mCitCurrent;
|
|
|
|
QStringList::ConstIterator mCitBegin;
|
|
|
|
QString mFile;
|
|
|
|
QString mFilePath;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PathIterator (const QStringList &list)
|
|
|
|
{
|
|
|
|
mCitBegin = list.constBegin();
|
|
|
|
mCitCurrent = mCitBegin;
|
|
|
|
mCitEnd = list.constEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString findFirstPath (const QString &file)
|
|
|
|
{
|
|
|
|
mCitCurrent = mCitBegin;
|
|
|
|
mFile = file;
|
|
|
|
return path();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString findNextPath () { return path(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
QString path ()
|
|
|
|
{
|
|
|
|
bool success = false;
|
|
|
|
QDir dir;
|
|
|
|
QFileInfo file;
|
|
|
|
|
|
|
|
while (!success)
|
|
|
|
{
|
|
|
|
if (mCitCurrent == mCitEnd)
|
|
|
|
break;
|
|
|
|
|
|
|
|
dir.setPath (*(mCitCurrent++));
|
|
|
|
file.setFile (dir.absoluteFilePath (mFile));
|
|
|
|
|
|
|
|
success = file.exists();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
return file.absoluteFilePath();
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2013-10-25 16:17:26 +00:00
|
|
|
};
|
|
|
|
}
|
2011-04-24 19:42:56 +00:00
|
|
|
#endif
|