summaryrefslogtreecommitdiff
path: root/src/modinfodialogtextfiles.h
blob: f6bd7d7b4135ddaee3219036c4fcf8ca92de753e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef MODINFODIALOGTEXTFILES_H
#define MODINFODIALOGTEXTFILES_H

#include "filterwidget.h"
#include "modinfodialogtab.h"
#include <QListView>
#include <QSplitter>

using namespace MOBase;

class FileListItem;
class FileListModel;
class TextEditor;

class GenericFilesTab : public ModInfoDialogTab
{
  Q_OBJECT;

public:
  void clear() override;
  bool canClose() override;
  bool feedFile(const QString& rootPath, const QString& fullPath) override;
  void update() override;
  void saveState(Settings& s) override;
  void restoreState(const Settings& s) override;

protected:
  QListView* m_list;
  TextEditor* m_editor;
  QSplitter* m_splitter;
  FileListModel* m_model;
  FilterWidget m_filter;

  GenericFilesTab(ModInfoDialogTabContext cx, QListView* list, QSplitter* splitter,
                  TextEditor* editor, QLineEdit* filter);

  virtual bool wantsFile(const QString& rootPath, const QString& fullPath) const = 0;

private:
  void onSelection(const QModelIndex& current, const QModelIndex& previous);
  void select(const QModelIndex& index);
};

class TextFilesTab : public GenericFilesTab
{
public:
  TextFilesTab(ModInfoDialogTabContext cx);

protected:
  bool wantsFile(const QString& rootPath, const QString& fullPath) const override;
};

class IniFilesTab : public GenericFilesTab
{
public:
  IniFilesTab(ModInfoDialogTabContext cx);

protected:
  bool wantsFile(const QString& rootPath, const QString& fullPath) const override;
};

#endif  // MODINFODIALOGTEXTFILES_H