OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
datafilespage.hpp
Go to the documentation of this file.
1 #ifndef DATAFILESPAGE_H
2 #define DATAFILESPAGE_H
3 
4 #include "ui_datafilespage.h"
5 #include <QWidget>
6 
7 
8 #include <QDir>
9 #include <QFile>
10 
12 class QAbstractItemModel;
13 class QMenu;
14 
15 namespace Files { struct ConfigurationManager; }
16 namespace ContentSelectorView { class ContentSelector; }
17 namespace Config { class GameSettings;
18  class LauncherSettings; }
19 
20 namespace Launcher
21 {
22  class TextInputDialog;
23  class ProfilesComboBox;
24 
25  class DataFilesPage : public QWidget
26  {
27  Q_OBJECT
28 
30  Ui::DataFilesPage ui;
31 
32  public:
34  Config::LauncherSettings &launcherSettings, QWidget *parent = 0);
35 
37 
38  int profilesIndex() const;
39 
40  //void writeConfig(QString profile = QString());
41  void saveSettings(const QString &profile = "");
42  bool loadSettings();
43 
44  signals:
45  void signalProfileChanged (int index);
46 
47  public slots:
48  void slotProfileChanged (int index);
49 
50  private slots:
51 
52  void slotProfileChangedByUser(const QString &previous, const QString &current);
53  void slotProfileRenamed(const QString &previous, const QString &current);
54  void slotProfileDeleted(const QString &item);
55 
56  void updateOkButton(const QString &text);
57 
60 
61  public:
63  const static char *mDefaultContentListName;
64 
65  private:
66 
68 
70 
73 
75 
76  QString mDataLocal;
77 
78  void setPluginsCheckstates(Qt::CheckState state);
79 
80  void buildView();
81  void setupConfig();
82  void readConfig();
83  void setProfile (int index, bool savePrevious);
84  void setProfile (const QString &previous, const QString &current, bool savePrevious);
85  void removeProfile (const QString &profile);
86  bool showDeleteMessageBox (const QString &text);
87  void addProfile (const QString &profile, bool setAsCurrent);
89  void populateFileViews(const QString& contentModelName);
90 
92  {
93  QStringList::ConstIterator mCitEnd;
94  QStringList::ConstIterator mCitCurrent;
95  QStringList::ConstIterator mCitBegin;
96  QString mFile;
97  QString mFilePath;
98 
99  public:
100  PathIterator (const QStringList &list)
101  {
102  mCitBegin = list.constBegin();
104  mCitEnd = list.constEnd();
105  }
106 
107  QString findFirstPath (const QString &file)
108  {
110  mFile = file;
111  return path();
112  }
113 
114  QString findNextPath () { return path(); }
115 
116  private:
117 
118  QString path ()
119  {
120  bool success = false;
121  QDir dir;
122  QFileInfo file;
123 
124  while (!success)
125  {
126  if (mCitCurrent == mCitEnd)
127  break;
128 
129  dir.setPath (*(mCitCurrent++));
130  file.setFile (dir.absoluteFilePath (mFile));
131 
132  success = file.exists();
133  }
134 
135  if (success)
136  return file.absoluteFilePath();
137 
138  return "";
139  }
140 
141  };
142 
143  QStringList filesInProfile(const QString& profileName, PathIterator& pathIterator);
144  };
145 }
146 #endif
QString path()
Definition: datafilespage.hpp:118
Config::GameSettings & mGameSettings
Definition: datafilespage.hpp:71
QString findFirstPath(const QString &file)
Definition: datafilespage.hpp:107
static const struct @2 signals[]
Definition: contentselector.hpp:13
void addProfile(const QString &profile, bool setAsCurrent)
Definition: datafilespage.cpp:240
QAbstractItemModel * profilesModel() const
Definition: datafilespage.cpp:150
void buildView()
Definition: datafilespage.cpp:45
bool showDeleteMessageBox(const QString &text)
Definition: datafilespage.cpp:296
static const char * mDefaultContentListName
Content List that is always present.
Definition: datafilespage.hpp:63
QStringList::ConstIterator mCitBegin
Definition: datafilespage.hpp:95
TextInputDialog * mProfileDialog
Definition: datafilespage.hpp:67
void on_newProfileAction_triggered()
Definition: datafilespage.cpp:223
int list(Bsa::BSAFile &bsa, Arguments &info)
Definition: bsatool.cpp:183
Definition: configurationmanager.hpp:20
Definition: datafilespage.hpp:91
int profilesIndex() const
Definition: datafilespage.cpp:155
Files::ConfigurationManager & mCfgMgr
Definition: datafilespage.hpp:69
void checkForDefaultProfile()
Definition: datafilespage.cpp:287
QString findNextPath()
Definition: datafilespage.hpp:114
void slotProfileRenamed(const QString &previous, const QString &current)
Definition: datafilespage.cpp:200
Config::LauncherSettings & mLauncherSettings
Definition: datafilespage.hpp:72
QStringList::ConstIterator mCitCurrent
Definition: datafilespage.hpp:94
Definition: profilescombobox.hpp:11
void setProfile(int index, bool savePrevious)
Definition: datafilespage.cpp:160
void updateOkButton(const QString &text)
Definition: datafilespage.cpp:274
Definition: datafilespage.hpp:25
void saveSettings(const QString &profile="")
Definition: datafilespage.cpp:124
DataFilesPage(Files::ConfigurationManager &cfg, Config::GameSettings &gameSettings, Config::LauncherSettings &launcherSettings, QWidget *parent=0)
Definition: datafilespage.cpp:26
QString mFilePath
Definition: datafilespage.hpp:97
void signalProfileChanged(int index)
bool loadSettings()
Definition: datafilespage.cpp:73
Definition: launchersettings.hpp:9
void setPluginsCheckstates(Qt::CheckState state)
void populateFileViews(const QString &contentModelName)
Definition: datafilespage.cpp:90
Definition: textinputdialog.hpp:12
ContentSelectorView::ContentSelector * mSelector
Definition: datafilespage.hpp:29
void slotProfileChanged(int index)
Definition: datafilespage.cpp:214
QStringList filesInProfile(const QString &profileName, PathIterator &pathIterator)
Definition: datafilespage.cpp:108
QStringList::ConstIterator mCitEnd
Definition: datafilespage.hpp:93
Ui::DataFilesPage ui
Definition: datafilespage.hpp:30
void removeProfile(const QString &profile)
Definition: datafilespage.cpp:145
void slotProfileDeleted(const QString &item)
Definition: datafilespage.cpp:189
void on_deleteProfileAction_triggered()
Definition: datafilespage.cpp:252
QString mFile
Definition: datafilespage.hpp:96
void slotProfileChangedByUser(const QString &previous, const QString &current)
Definition: datafilespage.cpp:194
PathIterator(const QStringList &list)
Definition: datafilespage.hpp:100
QString mDataLocal
Definition: datafilespage.hpp:76
QString mPreviousProfile
Definition: datafilespage.hpp:74
Definition: gamesettings.hpp:20