node_tree.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* docks/node_tree.h - Dock with node tree
  2. * Copyright (C) 2017-2018 caryoscelus
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef STUDIO_DOCKS_NODE_TREE_DOCK_H_85472C8A_FD7F_5252_A26B_79DF8D0503A0
  18. #define STUDIO_DOCKS_NODE_TREE_DOCK_H_85472C8A_FD7F_5252_A26B_79DF8D0503A0
  19. #include <generic/context_listener.h>
  20. #include <generic/dock_registry.h>
  21. #include "close_destroy_dock.h"
  22. namespace Ui {
  23. class NodeTreeDock;
  24. }
  25. class QMenu;
  26. namespace rainynite::studio {
  27. class NodeModel;
  28. class RecursiveFilterProxyModel;
  29. /**
  30. * Node graph tree representation dock.
  31. *
  32. * Until visual node editor is done, this is the main place for node
  33. * manipulation.
  34. */
  35. class NodeTreeDock : public DockWidget, public ContextListener {
  36. Q_OBJECT
  37. public:
  38. explicit NodeTreeDock(shared_ptr<EditorContext> context_, QWidget* parent_ = nullptr);
  39. virtual ~NodeTreeDock();
  40. public:
  41. void set_context(shared_ptr<EditorContext> context_) override;
  42. void active_node_index_changed(core::NodeTreeIndex index) override;
  43. protected:
  44. void contextMenuEvent(QContextMenuEvent* event) override;
  45. void apply_filter(QString const& s);
  46. private:
  47. void activate(QModelIndex const& index);
  48. void reload_model();
  49. private:
  50. unique_ptr<Ui::NodeTreeDock> ui;
  51. unique_ptr<NodeModel> model;
  52. unique_ptr<RecursiveFilterProxyModel> proxy_model;
  53. unique_ptr<QMenu> menu;
  54. };
  55. REGISTER_CONTEXT_DOCK("Node tree", NodeTreeDock, Qt::LeftDockWidgetArea);
  56. } // namespace rainynite::studio
  57. #endif