pActionsNode.sip 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*!
  2. \file pActionsNode.h
  3. \brief It's the class used for storing indexes data in pActionsNodeModel.
  4. \author Filipe Azevedo aka Nox P\@sNox <pasnox@gmail.com>
  5. */
  6. /*!
  7. \ingroup Gui
  8. \class pActionsNode
  9. \brief It's the class used for storing indexes data in pActionsNodeModel.
  10. It handle basic data of a node like the icon, text and shortcut.
  11. The internal data is explicitly shared so it's easy to use the api.
  12. */
  13. class pActionsNode
  14. {
  15. %TypeHeaderCode
  16. #include <gui/actionmanager/pActionsNode.h>
  17. %End
  18. public:
  19. /*! This enum defines the differents types of node. */
  20. enum Type {
  21. Invalid, /*!< An invalid type */
  22. Path, /*!< This type represents a path node (ie: a possible hierarchy where to integrate the actions nodes) */
  23. Action /*!< This type represente an action node (ie: it represente a QAction) */
  24. };
  25. enum Role {
  26. ShortcutRole = Qt::UserRole,
  27. DefaultShortcutRole
  28. };
  29. /*!
  30. Create an invalid node.
  31. */
  32. pActionsNode();
  33. /*!
  34. Create a node that is a copy of \a other node.
  35. */
  36. pActionsNode( const pActionsNode& other );
  37. /*!
  38. Create a node having type \a type and path \a path
  39. */
  40. pActionsNode( pActionsNode::Type type, const QString& path );
  41. /*!
  42. Return true if this node is equal to \a other else false.
  43. */
  44. bool operator==( const pActionsNode& other ) const;
  45. /*!
  46. Return true if this node is different than \a other else false.
  47. */
  48. bool operator!=( const pActionsNode& other ) const;
  49. /*!
  50. Return true if this node is valid else false.
  51. A valid node has a type different than pActionsNode::Invalid.
  52. */
  53. bool isValid() const;
  54. /*!
  55. Return true if this node has children else false.
  56. */
  57. bool hasChildren() const;
  58. /*!
  59. Return the pActionsNode::Type of this node.
  60. */
  61. pActionsNode::Type type() const;
  62. /*!
  63. Return the path of this node.
  64. */
  65. QString path() const;
  66. /*!
  67. Return the QAction associated with this node.
  68. */
  69. QAction* action() const;
  70. /*!
  71. Return the icon of this node.
  72. */
  73. QIcon icon() const;
  74. /*!
  75. Return the text of this node.
  76. */
  77. QString text() const;
  78. /*!
  79. Return the parent node of this node.
  80. */
  81. pActionsNode parent() const;
  82. /*!
  83. Return a list of all children of this node.
  84. */
  85. QList<pActionsNode> children() const;
  86. /*!
  87. Set the node icon, updating the QAction's icon if needed.
  88. */
  89. void setIcon( const QIcon& icon );
  90. /*!
  91. Set the node text, updating the QAction's text if needed.
  92. */
  93. void setText( const QString& text );
  94. /*!
  95. Return the shortcut of this node.
  96. */
  97. QKeySequence shortcut() const;
  98. /*!
  99. Set the node shortcut, updating the QAction's shortcut if needed.
  100. */
  101. bool setShortcut( const QKeySequence& shortcut );
  102. /*!
  103. Return the node default shortcut.
  104. */
  105. QKeySequence defaultShortcut() const;
  106. /*!
  107. Set the node default shortcut, updating the node shortcut if possible.
  108. */
  109. void setDefaultShortcut( const QKeySequence& shortcut );
  110. /*!
  111. A convenience function to create a path node.
  112. */
  113. static pActionsNode pathNode( const QString& path, const QString& text = QString::null, const QIcon& icon = QIcon() );
  114. /*!
  115. A convenience function to create an action node.
  116. */
  117. static pActionsNode actionNode( const QString& path, QAction* action );
  118. };