Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/QtToolBar.cpp

    rc01fec r8859b5  
    2828 */
    2929
     30
     31
     32
    3033// include config.h
    3134#ifdef HAVE_CONFIG_H
     
    3336#endif
    3437
     38
    3539#include "QtToolBar.hpp"
    3640
    3741#include "CodePatterns/MemDebug.hpp"
    3842
    39 #include "CodePatterns/Observer/Notification.hpp"
    40 
    41 #include "Actions/ActionQueue.hpp"
    42 
    4343QtToolBar::QtToolBar(QWidget * _parent) :
    44   QToolBar(_parent),
    45   Observer("QToolBar"),
    46   ActionQueue_observing(false),
    47   undoaction(addActionItem("undo", "undo the last Action", "edit-undo")),
    48   redoaction(addActionItem("redo", "redo the last Action", "edit-redo"))
     44  QToolBar(_parent)
    4945{
    50   // gray out undo/redo buttons initially
    51   undoaction->setEnabled(false);
    52   redoaction->setEnabled(false);
    53 
    54   // sign in
    55   MoleCuilder::ActionQueue::getInstance().signOn(this, MoleCuilder::ActionQueue::ActionQueued);
    56   ActionQueue_observing = true;
     46  addActionItem("undo", "undo the last Action", "edit-undo");
     47  addActionItem("redo", "redo the last Action", "edit-redo");
    5748}
    5849
     
    6051QtToolBar::~QtToolBar()
    6152{
    62   // sign off
    63   if (ActionQueue_observing)
    64     MoleCuilder::ActionQueue::getInstance().signOff(this, MoleCuilder::ActionQueue::ActionQueued);
    6553}
    6654
    6755
    68 QAction * QtToolBar::addActionItem(
    69     const std::string &token,
    70     const std::string &description,
    71     const std::string &icon_name)
     56void QtToolBar::addActionItem(const std::string &token, const std::string &description, const std::string &icon_name)
    7257{
    7358  QAction *action = addAction(QString(description.c_str()));
     
    7863  plumbing.push_back(pipe);
    7964  present_actions.insert( token );
    80   return action;
    8165}
    8266
     
    8872}
    8973
    90 void QtToolBar::update(Observable *publisher)
    91 {
    92   ASSERT(0, "QtToolBar::update() - this should never be called, we are only subscribed to channels.");
    93 }
    94 
    95 void QtToolBar::subjectKilled(Observable *publisher)
    96 {
    97   ActionQueue_observing = false;
    98 }
    99 
    100 void QtToolBar::recieveNotification(Observable *publisher, Notification_ptr notification)
    101 {
    102   if (dynamic_cast<MoleCuilder::ActionQueue *>(publisher) != NULL) {
    103     switch(notification->getChannelNo()) {
    104       case MoleCuilder::ActionQueue::ActionQueued:
    105         undoaction->setEnabled(MoleCuilder::ActionQueue::getInstance().canUndo());
    106         redoaction->setEnabled(MoleCuilder::ActionQueue::getInstance().canRedo());
    107         break;
    108       default:
    109         ASSERT(0, "QtToolBar::recieveNotification() - cannot get here, not subscribed to channel "
    110             +toString(notification->getChannelNo()));
    111         break;
    112     }
    113   } else {
    114     ASSERT(0, "QtToolBar::recieveNotification() - cannot get here, we are only subscribed to ActionQueue.");
    115   }
    116 }
Note: See TracChangeset for help on using the changeset viewer.