snark
Actions.h
1 // This file is part of snark, a generic and flexible library
2 // for robotics research.
3 //
4 // Copyright (C) 2011 The University of Sydney
5 //
6 // snark is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // snark is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 // for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with snark. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SNARK_GRAPHICS_APPLICATIONS_LABELPOINTS_ACTIONS_H_
20 #define SNARK_GRAPHICS_APPLICATIONS_LABELPOINTS_ACTIONS_H_
21 
22 #include <boost/function.hpp>
23 #include <qaction.h>
24 #include <qactiongroup.h>
25 
26 namespace snark { namespace graphics { namespace View { namespace Actions {
27 
28 class Action : public QAction // quick and dirty
29 {
30  Q_OBJECT
31 
32  public:
33  Action( const std::string& name, boost::function< void() > f );
34 
35  public slots:
36  void action();
37 
38  private:
39  boost::function< void() > m_action;
40 };
41 
42 class ToggleAction : public QAction
43 {
44  Q_OBJECT
45 
46  public:
47  ToggleAction( const std::string& name
48  , boost::function< void( bool ) > f
49  , const std::string& key = "" );
50 
51  ToggleAction( const QIcon& icon
52  , const std::string& name
53  , boost::function< void( bool ) > f
54  , const std::string& key = "" );
55 
56  public slots:
57  void action( bool checked );
58 
59  private:
60  boost::function< void( bool ) > m_functor;
61 };
62 
63 } } } } // namespace snark { namespace graphics { namespace View { namespace Actions {
64 
65 #endif // SNARK_GRAPHICS_APPLICATIONS_LABELPOINTS_ACTIONS_H_