summaryrefslogtreecommitdiff
path: root/src/filetree.h
blob: 80704f7b97d9ca673df7eef9b06d204bca7d45bc (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
#ifndef MODORGANIZER_FILETREE_INCLUDED
#define MODORGANIZER_FILETREE_INCLUDED

#include "modinfo.h"
#include "modinfodialogfwd.h"

namespace MOShared { class FileEntry; }

class OrganizerCore;
class PluginContainer;
class FileTreeModel;
class FileTreeItem;

class FileTree : public QObject
{
  Q_OBJECT;

public:
  FileTree(OrganizerCore& core, PluginContainer& pc, QTreeView* tree);

  FileTreeModel* model();
  void refresh();
  void clear();

  void open();
  void openHooked();
  void preview();

  void addAsExecutable();
  void exploreOrigin();
  void openModInfo();

  void toggleVisibility();
  void hide();
  void unhide();

  void dumpToFile() const;

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

private:
  OrganizerCore& m_core;
  PluginContainer& m_plugins;
  QTreeView* m_tree;
  FileTreeModel* m_model;

  FileTreeItem* singleSelection();

  void onExpandedChanged(const QModelIndex& index, bool expanded);
  void onContextMenu(const QPoint &pos);
  bool showShellMenu(QPoint pos);

  void addDirectoryMenus(QMenu& menu, FileTreeItem& item);
  void addFileMenus(QMenu& menu, const MOShared::FileEntry& file, int originID);
  void addOpenMenus(QMenu& menu, const MOShared::FileEntry& file);
  void addCommonMenus(QMenu& menu);

  void toggleVisibility(bool b);

  void dumpToFile(
    QFile& out, const QString& parentPath,
    const MOShared::DirectoryEntry& entry) const;
};

#endif // MODORGANIZER_FILETREE_INCLUDED