/* * QtToolBar.hpp * * Created on: Apr 26, 2012 * Author: ankele */ #ifndef QTTOOLBAR_HPP_ #define QTTOOLBAR_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include "Menu/Qt4/QtMenuPipe.hpp" #include #include #include #include "CodePatterns/Observer/Observer.hpp" class QtToolBar : public QToolBar { Q_OBJECT public: QtToolBar(QWidget * _parent=0); virtual ~QtToolBar(); /** Adds an action named \a token to the toolbar. * * @param token token of Action * @param description description to appear as tooltip * @param icon_name name of icon */ void addActionItem(const std::string &token, const std::string &description, const std::string &icon_name); /** Function to add a set of favorite actions. * * @param _max maximum number of actions to add */ void addFavoriteActionItems(const unsigned int _max); //!> typedef for a set of action tokens typedef std::set present_actions_t; /** Getter for current set of present action on this toolbar. * * @return set of action tokens */ const present_actions_t & getPresentActions() const { return present_actions; } private: std::list plumbing; /** This class knows about all Actions being called and stores their frequency. * * This is used to know about the topmost used Actions and creating placeholder * toolbar icons for these on program launch. * */ class QtFavoriteActions : public Observer { public: QtFavoriteActions(); ~QtFavoriteActions(); void addToolBarActions( QtToolBar &_toolbar, const unsigned int _max) const; void update(Observable *publisher); void subjectKilled(Observable *publisher); void recieveNotification(Observable *publisher, Notification_ptr notification); QIcon getIcon( const std::string &_token, const std::string &_icon_name ) const; private: QIcon createIconPlaceholder( const std::string &_token ) const; private: //!> typedef for the action counts typedef std::map ActionCounts_t; //!> map counts how often each action has been called ActionCounts_t ActionCounts; //!> sign in to ActionQueue? bool ActionQueue_observing; }; //!> instance dealing with favorite action icons QtFavoriteActions FavActions; //!> set of already present action icons present_actions_t present_actions; }; #endif /* QTTOOLBAR_HPP_ */