summaryrefslogtreecommitdiff
path: root/src/datatab.h
blob: 0bc0d83e6e3815a6381856c814c766e39d279cff (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef MODORGANIZER_DATATAB_INCLUDED
#define MODORGANIZER_DATATAB_INCLUDED

#include "modinfo.h"
#include "modinfodialogfwd.h"
#include <QCheckBox>
#include <QPushButton>
#include <QTreeWidget>
#include <filterwidget.h>

namespace Ui
{
class MainWindow;
}
class OrganizerCore;
class Settings;
class PluginContainer;
class FileTree;

namespace MOShared
{
class DirectoryEntry;
}

class DataTab : public QObject
{
  Q_OBJECT;

public:
  DataTab(OrganizerCore& core, PluginContainer& pc, QWidget* parent,
          Ui::MainWindow* ui);

  void saveState(Settings& s) const;
  void restoreState(const Settings& s);
  void activated();

  // if the data tab is currently visible, trigger an update of the
  // tree, otherwise mark the tree has modified and will refresh when
  // the tab is activated
  //
  void updateTree();

signals:
  void executablesChanged();
  void originModified(int originID);
  void displayModInformation(ModInfo::Ptr m, unsigned int i, ModInfoTabIDs tab);

private:
  struct DataTabUi
  {
    QTabWidget* tabs;
    QWidget* tab;
    QPushButton* refresh;
    QTreeView* tree;
    QCheckBox* conflicts;
    QCheckBox* archives;
    QCheckBox* hiddenFiles;
  };

  OrganizerCore& m_core;
  PluginContainer& m_pluginContainer;
  QWidget* m_parent;
  DataTabUi ui;
  std::unique_ptr<FileTree> m_filetree;
  std::vector<QTreeWidgetItem*> m_removeLater;
  MOBase::FilterWidget m_filter;
  bool m_needUpdate;

  void onRefresh();
  void onItemExpanded(QTreeWidgetItem* item);
  void onConflicts();
  void onArchives();
  void onHiddenFiles();
  void updateOptions();
  void ensureFullyLoaded();
  bool isActive() const;
  void doUpdateTree();
};

#endif  // MODORGANIZER_DATATAB_INCLUDED