[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/lib/kofficeui
From:       Casper Boemann <cbr () boemann ! dk>
Date:       2006-02-26 14:47:57
Message-ID: 1140965277.204382.12631.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 513787 by boemann:

Add a method to KoCommandHistory that returns a pointer to the present command 
in the undo stack. That is, the command that would be undone by the next 
undo().



 M  +11 -2     KoCommandHistory.cpp  
 M  +6 -1      KoCommandHistory.h  


--- trunk/koffice/lib/kofficeui/KoCommandHistory.cpp #513786:513787
@@ -149,6 +149,11 @@
     delete d;
 }
 
+KCommand * KoCommandHistory::presentCommand ( )
+{   return d->m_present;
+}
+
+
 void KoCommandHistory::clear() {
     if (m_undo != 0) {
         m_undo->setEnabled(false);
@@ -220,8 +225,8 @@
         return;
 
     d->m_present->unexecute();
-    emit commandExecuted();
-    emit commandExecuted(d->m_present);
+    KCommand *commandUndone = d->m_present;
+
     if (m_redo != 0) {
         m_redo->setEnabled(true);
         m_redo->setText(i18n("&Redo: %1").arg(d->m_present->name()));
@@ -229,6 +234,8 @@
     int index;
     if((index=m_commands.findRef(d->m_present))!=-1 && m_commands.prev()!=0) {
         d->m_present=m_commands.current();
+        emit commandExecuted();
+        emit commandExecuted(commandUndone);
         if (m_undo != 0) {
             m_undo->setEnabled(true);
             m_undo->setText(i18n("&Undo: %1").arg(d->m_present->name()));
@@ -238,6 +245,8 @@
             emit documentRestored();
     }
     else {
+        emit commandExecuted();
+        emit commandExecuted(commandUndone);
         if (m_undo != 0) {
             m_undo->setEnabled(false);
             m_undo->setText(i18n("&Undo"));
--- trunk/koffice/lib/kofficeui/KoCommandHistory.h #513786:513787
@@ -123,6 +123,11 @@
      */
     void updateActions();
 
+    /**
+     * @return the current top item on the history stack
+     */
+    KCommand * presentCommand();
+
 public slots:
     /**
      * Undoes the last action.
@@ -167,7 +172,7 @@
      * You can use this to update the GUI, for instance.
      * @param command was executed
      */
-    void commandExecuted(KCommand *command);
+    void commandExecuted(KCommand *cmd);
 
     /**
      * Emitted every time we reach the index where you
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic