node_menu.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* node_menu.h - node context menu
  2. * Copyright (C) 2017 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_GENERIC_NODE_MENU_H_0B8A2DD1_AED8_52B2_AF1C_E607DC12CB26
  18. #define STUDIO_GENERIC_NODE_MENU_H_0B8A2DD1_AED8_52B2_AF1C_E607DC12CB26
  19. #include <core/std/memory.h>
  20. #include <core/std/set.h>
  21. #include <QMenu>
  22. class QItemSelectionModel;
  23. class QLineEdit;
  24. namespace rainynite::core {
  25. class NodeInfo;
  26. class Time;
  27. }
  28. namespace rainynite::studio {
  29. class NodeContextMenu : public QMenu {
  30. public:
  31. NodeContextMenu(NodeModel* model, QItemSelectionModel* selection_model, core::Time time);
  32. private:
  33. void update_node_list();
  34. void add_custom_property();
  35. private:
  36. vector<QAction*> convert_actions;
  37. NodeModel* model;
  38. QModelIndex index;
  39. QList<QModelIndex> selection;
  40. set<core::NodeInfo const*> node_infos;
  41. core::Time time;
  42. QLineEdit* search_widget = nullptr;
  43. };
  44. inline unique_ptr<QMenu> node_context_menu(NodeModel* model, QItemSelectionModel* selection_model, core::Time time) {
  45. return make_unique<NodeContextMenu>(model, selection_model, time);
  46. }
  47. } // namespace rainynite::studio
  48. #endif