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#pragma once
7
8#include <QTreeWidget>
9
10#include "LibraryController.h"
11
12namespace QGBA {
13
14class LibraryTree final : public AbstractGameList {
15
16public:
17 enum Columns {
18 COL_NAME = 0,
19 COL_LOCATION = 1,
20 COL_PLATFORM = 2,
21 COL_SIZE = 3,
22 COL_CRC32 = 4,
23 };
24
25 explicit LibraryTree(LibraryController* parent = nullptr);
26 ~LibraryTree();
27
28 // AbstractGameList stuff
29 virtual LibraryEntryRef selectedEntry() override;
30 virtual void selectEntry(LibraryEntryRef game) override;
31
32 virtual void setViewStyle(LibraryStyle newStyle) override;
33
34 virtual void addEntries(QList<LibraryEntryRef> items) override;
35 virtual void addEntry(LibraryEntryRef item) override;
36 virtual void removeEntry(LibraryEntryRef item) override;
37
38 virtual QWidget* widget() override { return m_widget; }
39
40private:
41 QTreeWidget* m_widget;
42 LibraryStyle m_currentStyle;
43
44 LibraryController* m_controller;
45
46 bool m_deferredTreeRebuild = false;
47 QMap<LibraryEntryRef, QTreeWidgetItem*> m_items;
48 QMap<QString, QTreeWidgetItem*> m_pathNodes;
49
50 void rebuildTree();
51 void resizeAllCols();
52};
53
54}