src/platform/qt/library/LibraryTree.h (view raw)
1/* Copyright (c) 2014-2017 waddlesplash
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef QGBA_LIBRARY_TREE
7#define QGBA_LIBRARY_TREE
8
9#include <QTreeWidget>
10
11#include "LibraryController.h"
12
13namespace QGBA {
14
15class LibraryTree final : public AbstractGameList {
16
17public:
18 enum Columns {
19 COL_NAME = 0,
20 COL_LOCATION = 1,
21 COL_PLATFORM = 2,
22 COL_SIZE = 3,
23 COL_CRC32 = 4,
24 };
25
26 explicit LibraryTree(LibraryController* parent = nullptr);
27 ~LibraryTree();
28
29 // AbstractGameList stuff
30 virtual LibraryEntryRef selectedEntry() override;
31 virtual void selectEntry(LibraryEntryRef game) override;
32
33 virtual void setViewStyle(LibraryStyle newStyle) override;
34
35 virtual void addEntries(QList<LibraryEntryRef> items) override;
36 virtual void addEntry(LibraryEntryRef item) override;
37 virtual void removeEntry(LibraryEntryRef item) override;
38
39 virtual QWidget* widget() override { return m_widget; }
40
41private:
42 QTreeWidget* m_widget;
43 LibraryStyle m_currentStyle;
44
45 LibraryController* m_controller;
46
47 bool m_deferredTreeRebuild = false;
48 QMap<LibraryEntryRef, QTreeWidgetItem*> m_items;
49 QMap<QString, QTreeWidgetItem*> m_pathNodes;
50
51 void rebuildTree();
52 void resizeAllCols();
53};
54
55}
56
57#endif