diff options
| author | 2016-04-08 19:28:54 +0300 | |
|---|---|---|
| committer | 2016-09-22 13:52:52 +0800 | |
| commit | f69a543110703e09adc830bbc65e3c39be0cc52b (patch) | |
| tree | 6698d241fb60109d5eae43ff6ece00fef9aa91d8 /src/citra_qt/debugger/wait_tree.h | |
| parent | Merge pull request #2099 from citra-emu/fix-clang-format (diff) | |
| download | yuzu-f69a543110703e09adc830bbc65e3c39be0cc52b.tar.gz yuzu-f69a543110703e09adc830bbc65e3c39be0cc52b.tar.xz yuzu-f69a543110703e09adc830bbc65e3c39be0cc52b.zip | |
implement wait tree widget
Diffstat (limited to 'src/citra_qt/debugger/wait_tree.h')
| -rw-r--r-- | src/citra_qt/debugger/wait_tree.h | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/src/citra_qt/debugger/wait_tree.h b/src/citra_qt/debugger/wait_tree.h new file mode 100644 index 000000000..5d1d964d1 --- /dev/null +++ b/src/citra_qt/debugger/wait_tree.h | |||
| @@ -0,0 +1,186 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <boost/container/flat_set.hpp> | ||
| 6 | |||
| 7 | #include <QAbstractItemModel> | ||
| 8 | #include <QDockWidget> | ||
| 9 | #include <QTreeView> | ||
| 10 | |||
| 11 | #include "core/core.h" | ||
| 12 | #include "core/hle/kernel/kernel.h" | ||
| 13 | |||
| 14 | class EmuThread; | ||
| 15 | |||
| 16 | namespace Kernel { | ||
| 17 | class WaitObject; | ||
| 18 | class Event; | ||
| 19 | class Mutex; | ||
| 20 | class Semaphore; | ||
| 21 | class Session; | ||
| 22 | class Thread; | ||
| 23 | class Timer; | ||
| 24 | } | ||
| 25 | |||
| 26 | class WaitTreeThread; | ||
| 27 | |||
| 28 | class WaitTreeItem : public QObject { | ||
| 29 | Q_OBJECT | ||
| 30 | public: | ||
| 31 | virtual bool IsExpandable() const; | ||
| 32 | virtual std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const; | ||
| 33 | virtual QString GetText() const = 0; | ||
| 34 | virtual QColor GetColor() const; | ||
| 35 | virtual ~WaitTreeItem(); | ||
| 36 | void Expand(); | ||
| 37 | WaitTreeItem* Parent() const; | ||
| 38 | const std::vector<std::unique_ptr<WaitTreeItem>>& Children() const; | ||
| 39 | std::size_t Row() const; | ||
| 40 | static std::vector<std::unique_ptr<WaitTreeThread>> MakeThreadItemList(); | ||
| 41 | |||
| 42 | private: | ||
| 43 | std::size_t row; | ||
| 44 | bool expanded = false; | ||
| 45 | WaitTreeItem* parent = nullptr; | ||
| 46 | std::vector<std::unique_ptr<WaitTreeItem>> children; | ||
| 47 | }; | ||
| 48 | |||
| 49 | class WaitTreeText : public WaitTreeItem { | ||
| 50 | Q_OBJECT | ||
| 51 | public: | ||
| 52 | WaitTreeText(const QString& text); | ||
| 53 | QString GetText() const override; | ||
| 54 | |||
| 55 | private: | ||
| 56 | QString text; | ||
| 57 | }; | ||
| 58 | |||
| 59 | class WaitTreeExpandableItem : public WaitTreeItem { | ||
| 60 | Q_OBJECT | ||
| 61 | public: | ||
| 62 | bool IsExpandable() const override; | ||
| 63 | }; | ||
| 64 | |||
| 65 | class WaitTreeWaitObject : public WaitTreeExpandableItem { | ||
| 66 | Q_OBJECT | ||
| 67 | public: | ||
| 68 | WaitTreeWaitObject(const Kernel::WaitObject& object); | ||
| 69 | static std::unique_ptr<WaitTreeWaitObject> make(const Kernel::WaitObject& object); | ||
| 70 | QString GetText() const override; | ||
| 71 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 72 | |||
| 73 | protected: | ||
| 74 | const Kernel::WaitObject& object; | ||
| 75 | |||
| 76 | static QString GetResetTypeQString(Kernel::ResetType reset_type); | ||
| 77 | }; | ||
| 78 | |||
| 79 | class WaitTreeObjectList : public WaitTreeExpandableItem { | ||
| 80 | Q_OBJECT | ||
| 81 | public: | ||
| 82 | WaitTreeObjectList(const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& list, | ||
| 83 | bool wait_all); | ||
| 84 | QString GetText() const override; | ||
| 85 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 86 | |||
| 87 | private: | ||
| 88 | const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& object_list; | ||
| 89 | bool wait_all; | ||
| 90 | }; | ||
| 91 | |||
| 92 | class WaitTreeThread : public WaitTreeWaitObject { | ||
| 93 | Q_OBJECT | ||
| 94 | public: | ||
| 95 | WaitTreeThread(const Kernel::Thread& thread); | ||
| 96 | QString GetText() const override; | ||
| 97 | QColor GetColor() const override; | ||
| 98 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 99 | }; | ||
| 100 | |||
| 101 | class WaitTreeEvent : public WaitTreeWaitObject { | ||
| 102 | Q_OBJECT | ||
| 103 | public: | ||
| 104 | WaitTreeEvent(const Kernel::Event& object); | ||
| 105 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 106 | }; | ||
| 107 | |||
| 108 | class WaitTreeMutex : public WaitTreeWaitObject { | ||
| 109 | Q_OBJECT | ||
| 110 | public: | ||
| 111 | WaitTreeMutex(const Kernel::Mutex& object); | ||
| 112 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 113 | }; | ||
| 114 | |||
| 115 | class WaitTreeSemaphore : public WaitTreeWaitObject { | ||
| 116 | Q_OBJECT | ||
| 117 | public: | ||
| 118 | WaitTreeSemaphore(const Kernel::Semaphore& object); | ||
| 119 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 120 | }; | ||
| 121 | |||
| 122 | class WaitTreeTimer : public WaitTreeWaitObject { | ||
| 123 | Q_OBJECT | ||
| 124 | public: | ||
| 125 | WaitTreeTimer(const Kernel::Timer& object); | ||
| 126 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 127 | }; | ||
| 128 | |||
| 129 | class WaitTreeMutexList : public WaitTreeExpandableItem { | ||
| 130 | Q_OBJECT | ||
| 131 | public: | ||
| 132 | WaitTreeMutexList(const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& list); | ||
| 133 | QString GetText() const override; | ||
| 134 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 135 | |||
| 136 | private: | ||
| 137 | const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& mutex_list; | ||
| 138 | }; | ||
| 139 | |||
| 140 | class WaitTreeThreadList : public WaitTreeExpandableItem { | ||
| 141 | Q_OBJECT | ||
| 142 | public: | ||
| 143 | WaitTreeThreadList(const std::vector<Kernel::SharedPtr<Kernel::Thread>>& list); | ||
| 144 | QString GetText() const override; | ||
| 145 | std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override; | ||
| 146 | |||
| 147 | private: | ||
| 148 | const std::vector<Kernel::SharedPtr<Kernel::Thread>>& thread_list; | ||
| 149 | }; | ||
| 150 | |||
| 151 | class WaitTreeModel : public QAbstractItemModel { | ||
| 152 | Q_OBJECT | ||
| 153 | |||
| 154 | public: | ||
| 155 | WaitTreeModel(QObject* parent = nullptr); | ||
| 156 | |||
| 157 | QVariant data(const QModelIndex& index, int role) const override; | ||
| 158 | QModelIndex index(int row, int column, const QModelIndex& parent) const override; | ||
| 159 | QModelIndex parent(const QModelIndex& index) const override; | ||
| 160 | int rowCount(const QModelIndex& parent) const override; | ||
| 161 | int columnCount(const QModelIndex& parent) const override; | ||
| 162 | |||
| 163 | void ClearItems(); | ||
| 164 | void InitItems(); | ||
| 165 | |||
| 166 | private: | ||
| 167 | std::vector<std::unique_ptr<WaitTreeThread>> thread_items; | ||
| 168 | }; | ||
| 169 | |||
| 170 | class WaitTreeWidget : public QDockWidget { | ||
| 171 | Q_OBJECT | ||
| 172 | |||
| 173 | public: | ||
| 174 | WaitTreeWidget(QWidget* parent = nullptr); | ||
| 175 | |||
| 176 | public slots: | ||
| 177 | void OnDebugModeEntered(); | ||
| 178 | void OnDebugModeLeft(); | ||
| 179 | |||
| 180 | void OnEmulationStarting(EmuThread* emu_thread); | ||
| 181 | void OnEmulationStopping(); | ||
| 182 | |||
| 183 | private: | ||
| 184 | QTreeView* view; | ||
| 185 | WaitTreeModel* model; | ||
| 186 | }; | ||