diff options
author | Mark Janes <mark.a.janes@intel.com> | 2017-11-21 17:25:06 -0800 |
---|---|---|
committer | Mark Janes <mark.a.janes@intel.com> | 2017-11-27 11:29:21 -0800 |
commit | d0a6ff896e48e77f27a2375d74ec547b13376b23 (patch) | |
tree | 091aaac723c18e223877736e2277cd041819ea3b /retrace | |
parent | 10a789b1187cacd232435e336f73963fa37bcdf6 (diff) |
State: Add a search box for state items
Typing into the search box quickly narrows the set of displayed state.
Diffstat (limited to 'retrace')
-rw-r--r-- | retrace/daemon/ui/glframe_state_model.cpp | 43 | ||||
-rw-r--r-- | retrace/daemon/ui/glframe_state_model.hpp | 3 | ||||
-rw-r--r-- | retrace/daemon/ui/qml/StateControl.qml | 43 |
3 files changed, 76 insertions, 13 deletions
diff --git a/retrace/daemon/ui/glframe_state_model.cpp b/retrace/daemon/ui/glframe_state_model.cpp index fe878e64..cfb32e19 100644 --- a/retrace/daemon/ui/glframe_state_model.cpp +++ b/retrace/daemon/ui/glframe_state_model.cpp @@ -317,21 +317,40 @@ QStateModel::refresh() { ScopedLock s(m_protect); m_states.clear(); for (auto i : m_state_by_name) { - bool visible = true; - for (auto f : m_filter_paths) { - if (strncmp(f.first.c_str(), i.first.path.c_str(), - f.first.length()) == 0) { - // do not filter the collapsed directories themselves - if ((i.first.path == f.first) && (i.first.name.length() == 0)) - visible = true; - else - visible = false; - } - } - i.second->setVisible(visible); m_states.push_back(i.second); } + set_visible(); } emit stateChanged(); } +void +QStateModel::set_visible() { + for (auto i : m_state_by_name) { + bool visible = true; + for (auto f : m_filter_paths) { + if (strncmp(f.first.c_str(), i.first.path.c_str(), + f.first.length()) == 0) { + // do not filter the collapsed directories themselves + if ((i.first.path == f.first) && (i.first.name.length() == 0)) { + visible = true; + } else { + visible = false; + break; + } + } + } + if (visible && m_search.length() > 0) { + if ((!i.second->path().contains(m_search, Qt::CaseInsensitive)) && + (!i.second->name().contains(m_search, Qt::CaseInsensitive))) + visible = false; + } + i.second->setVisible(visible); + } +} + +void +QStateModel::search(const QString &_search) { + m_search = _search; + set_visible(); +} diff --git a/retrace/daemon/ui/glframe_state_model.hpp b/retrace/daemon/ui/glframe_state_model.hpp index 6d78b230..358dc9f2 100644 --- a/retrace/daemon/ui/glframe_state_model.hpp +++ b/retrace/daemon/ui/glframe_state_model.hpp @@ -121,6 +121,7 @@ class QStateModel : public QObject, const QString &value); Q_INVOKABLE void collapse(const QString &path); Q_INVOKABLE void expand(const QString &path); + Q_INVOKABLE void search(const QString &_search); signals: void stateExperiment(); @@ -128,6 +129,7 @@ class QStateModel : public QObject, private: void refresh(); + void set_visible(); IFrameRetrace *m_retrace; SelectionId m_sel_count; @@ -139,6 +141,7 @@ class QStateModel : public QObject, QList<QStateValue*> m_states; std::vector<QStateValue*> m_for_deletion; std::vector<RenderId> m_renders; + QString m_search; mutable std::mutex m_protect; }; diff --git a/retrace/daemon/ui/qml/StateControl.qml b/retrace/daemon/ui/qml/StateControl.qml index ff54c76d..1280ab97 100644 --- a/retrace/daemon/ui/qml/StateControl.qml +++ b/retrace/daemon/ui/qml/StateControl.qml @@ -6,8 +6,49 @@ import ApiTrace 1.0 Item { property QStateModel stateModel + Item { + id: searchItem + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: 10 + height: textRect.height + + Text { + anchors.left: parent.left + anchors.top: parent.top + anchors.topMargin: 5 + id: searchText + text: "Search:" + } + Rectangle { + anchors.top: parent.top + anchors.left: searchText.right + anchors.leftMargin: 20 + height: searchText.height * 1.5 + border.width: 1 + width: searchItem.width/2 + id: textRect + TextInput { + height: searchText.height + width: parent.width + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 4 + id: stateSearch + text: "" + onDisplayTextChanged: { + stateModel.search(displayText) + } + } + } + } + ScrollView { - anchors.fill: parent + anchors.top: searchItem.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom ListView { id: stateList model: stateModel.state |