You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw/components/contentselector/view/contentselector.hpp

94 lines
2.5 KiB
C++

#ifndef CONTENTSELECTOR_HPP
#define CONTENTSELECTOR_HPP
#include <memory>
#include <QComboBox>
12 years ago
#include <QDialog>
#include <QMenu>
#include <QToolButton>
#include <components/contentselector/model/contentmodel.hpp>
class QSortFilterProxyModel;
namespace Ui
{
class ContentSelector;
}
namespace ContentSelectorView
{
class ContentSelector : public QObject
{
Q_OBJECT
QMenu* mContextMenu;
protected:
ContentSelectorModel::ContentModel* mContentModel;
QSortFilterProxyModel* mAddonProxyModel;
public:
explicit ContentSelector(QWidget* parent = nullptr, bool showOMWScripts = false);
~ContentSelector() override;
QString currentFile() const;
void addFiles(const QString& path, bool newfiles = false);
void sortFiles();
bool containsDataFiles(const QString& path);
void clearFiles();
Track source of settings This one's a biggie. The basic idea's that GameSettings should know: * what the interpreted value of a setting is, so it can actually be used. * what the original value the user put in their config was, so it can be put back when the config's saved. * which path it's processing the openmw.cfg from so relative paths can be resolved correctly. * whether a setting's a user setting that can be modified, or from one of the other openmw.cfg files that can't necessarily be modified. This had fairly wide-reaching implications. The first is that paths are resolved properly in cases where they previously wouldn't have been. Without this commit, if the launcher saw a relative path in an openmw.cfg, it'd be resolved relative to the process' working directory (which we always set to the binary directory for reasons I won't get into). That's not what the engine does, so is bad. It's also not something a user's likely to suspect. This mess is no longer a problem as paths are resolved correctly when they're loaded instead of on demand when they're used by whatever uses them. Another problem was that if paths used slugs like ?userconfig? would be written back to openmw.cfg with the slugs replaced, which defeats the object of using the slugs. This is also fixed. Tracking which settings are user settings and which are in a non-editable openmw.cfg allows the launcher to grey out rows so they can't be edited (which is sensible as they can't be edited on-disk) while still being aware of content files that are provided by non-user data directories etc. This is done in a pretty straightforward way for the data directories and fallback-archives, as those bits of UI are basic, but it's more complicated for content files as that uses a nmodel/view approach and has a lot more moving parts. Thankfully, I'd already implemented that when dealing with builtin.omwscripts, so it just needed wiring up. One more thing of note is that I made the SettingValue struct storable as a QVariant so it could be attached to the UI widgets as userdata, and then I could just grab the original representation and use it instead of needing any complicated mapping from display value to on-disk value.
10 months ago
void setNonUserContent(const QStringList& fileList);
void setProfileContent(const QStringList& fileList);
void clearCheckStates();
void setEncoding(const QString& encoding);
void setContentList(const QStringList& list);
ContentSelectorModel::ContentFileList selectedFiles() const;
void setGameFile(const QString& filename = QString(""));
bool isGamefileSelected() const;
QWidget* uiWidget() const;
QComboBox* languageBox() const;
QToolButton* refreshButton() const;
QLineEdit* searchFilter() const;
private:
std::unique_ptr<Ui::ContentSelector> ui;
void buildContentModel(bool showOMWScripts);
void buildGameFileView();
void buildAddonView();
void buildContextMenu();
void setGameFileSelected(int index, bool selected);
void setCheckStateForMultiSelectedItems(bool checked);
signals:
void signalCurrentGamefileIndexChanged(int);
void signalAddonDataChanged(const QModelIndex& topleft, const QModelIndex& bottomright);
void signalSelectedFilesChanged(QStringList selectedFiles);
private slots:
void slotCurrentGameFileIndexChanged(int index);
void slotAddonTableItemActivated(const QModelIndex& index);
void slotShowContextMenu(const QPoint& pos);
void slotCheckMultiSelectedItems();
void slotUncheckMultiSelectedItems();
void slotCopySelectedItemsPaths();
void slotSearchFilterTextChanged(const QString& newText);
void slotRowsMoved();
};
}
#endif // CONTENTSELECTOR_HPP