aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_bsplugins/src/BSPluginList/PluginListView.h
blob: 5302b86d4909883816fdb50423982d5b08b2fd3c (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
#ifndef BSPLUGINLIST_PLUGINLISTVIEW_H
#define BSPLUGINLIST_PLUGINLISTVIEW_H

#include <QSet>
#include <QTreeView>

namespace BSPluginList
{

struct MarkerInfos
{
  QSet<uint> overriding;
  QSet<uint> overridden;
  QSet<uint> overwritingAux;
  QSet<uint> overwrittenAux;
  QSet<uint> highlight;
};

class PluginListModel;
class PluginSortFilterProxyModel;

class PluginListView final : public QTreeView
{
  Q_OBJECT

public:
  explicit PluginListView(QWidget* parent = nullptr);

  void setup();

  void setModel(QAbstractItemModel* model) override;
  QRect visualRect(const QModelIndex& index) const override;

  [[nodiscard]] QColor markerColor(const QModelIndex& index) const;
  [[nodiscard]] uint fileFlags(const QModelIndex& index) const;
  [[nodiscard]] uint conflictFlags(const QModelIndex& index) const;

public slots:
  void setHighlightedOrigins(const QStringList& origins);
  void clearOverwriteMarkers();
  void updateOverwriteMarkers();

signals:
  void openOriginExplorer(const QModelIndex& index);

protected:
  bool event(QEvent* event) override;
  void dragMoveEvent(QDragMoveEvent* event) override;
  void paintEvent(QPaintEvent* event) override;

  bool moveSelection(int key);
  bool toggleSelectionState();

private:
  friend class PluginListContextMenu;

  QModelIndex indexViewToModel(const QModelIndex& index,
                               const QAbstractItemModel* model) const;

  QModelIndexList indexViewToModel(const QModelIndexList& indices,
                                   const QAbstractItemModel* model,
                                   bool includeChildren = true) const;

private slots:
  void onGroupRenameRequested(const QModelIndex& index, const QString& name);

private:
  bool m_FirstPaint = true;
  MarkerInfos m_Markers;
  PluginListModel* m_PluginModel;
  PluginSortFilterProxyModel* m_SortProxy;
};

}  // namespace BSPluginList

#endif  // BSPLUGINLIST_PLUGINLISTVIEW_H