qscicommandset.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // This defines the interface to the QsciCommandSet class.
  2. //
  3. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  4. //
  5. // This file is part of QScintilla.
  6. //
  7. // This file may be used under the terms of the GNU General Public License
  8. // version 3.0 as published by the Free Software Foundation and appearing in
  9. // the file LICENSE included in the packaging of this file. Please review the
  10. // following information to ensure the GNU General Public License version 3.0
  11. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  12. //
  13. // If you do not wish to use this file under the terms of the GPL version 3.0
  14. // then you may purchase a commercial license. For more information contact
  15. // info@riverbankcomputing.com.
  16. //
  17. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  18. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. #ifndef QSCICOMMANDSET_H
  20. #define QSCICOMMANDSET_H
  21. #include <qglobal.h>
  22. #include <QList>
  23. #include <Qsci/qsciglobal.h>
  24. #include <Qsci/qscicommand.h>
  25. QT_BEGIN_NAMESPACE
  26. class QSettings;
  27. QT_END_NAMESPACE
  28. class QsciScintilla;
  29. //! \brief The QsciCommandSet class represents the set of all internal editor
  30. //! commands that may have keys bound.
  31. //!
  32. //! Methods are provided to access the individual commands and to read and
  33. //! write the current bindings from and to settings files.
  34. class QSCINTILLA_EXPORT QsciCommandSet
  35. {
  36. public:
  37. //! The key bindings for each command in the set are read from the
  38. //! settings \a qs. \a prefix is prepended to the key of each entry.
  39. //! true is returned if there was no error.
  40. //!
  41. //! \sa writeSettings()
  42. bool readSettings(QSettings &qs, const char *prefix = "/Scintilla");
  43. //! The key bindings for each command in the set are written to the
  44. //! settings \a qs. \a prefix is prepended to the key of each entry.
  45. //! true is returned if there was no error.
  46. //!
  47. //! \sa readSettings()
  48. bool writeSettings(QSettings &qs, const char *prefix = "/Scintilla");
  49. //! The commands in the set are returned as a list.
  50. QList<QsciCommand *> &commands() {return cmds;}
  51. //! The primary keys bindings for all commands are removed.
  52. void clearKeys();
  53. //! The alternate keys bindings for all commands are removed.
  54. void clearAlternateKeys();
  55. // Find the command that is bound to \a key.
  56. QsciCommand *boundTo(int key) const;
  57. // Find a specific command \a command.
  58. QsciCommand *find(QsciCommand::Command command) const;
  59. private:
  60. friend class QsciScintilla;
  61. QsciCommandSet(QsciScintilla *qs);
  62. ~QsciCommandSet();
  63. QsciScintilla *qsci;
  64. QList<QsciCommand *> cmds;
  65. QsciCommandSet(const QsciCommandSet &);
  66. QsciCommandSet &operator=(const QsciCommandSet &);
  67. };
  68. #endif