traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/core InputEngine.cpp InputEngine.h...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src/core InputEngine.cpp InputEngine.h...
Date: Tue, 24 Apr 2007 18:56:38 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/04/24 18:56:38

Modified files:
        src/core       : InputEngine.cpp InputEngine.h Song.cpp 

Log message:
        * Added 3 convenience return functions in IE to indicate if a performed 
action
        was succesfull, but doesn't need further processing (no Command object 
returned)
        or if it was a failure, and the broadcast need to be stopped, or
        if the action was successfull, but doesn't want to perform the action, 
but
        instead gives a lower level context item precedence.
        * Changed Song::go() to see if it worked, no functions need to be 
changed though due this change.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/InputEngine.cpp?cvsroot=traverso&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/InputEngine.h?cvsroot=traverso&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.cpp?cvsroot=traverso&r1=1.82&r2=1.83

Patches:
Index: InputEngine.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/InputEngine.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- InputEngine.cpp     16 Apr 2007 09:08:31 -0000      1.50
+++ InputEngine.cpp     24 Apr 2007 18:56:38 -0000      1.51
@@ -286,6 +286,9 @@
        PMESG("Trying to find IEAction for key sequence %s", 
action->keySequence.data());
        
        for (int i=0; i < list.size(); ++i) {
+               k = 0;
+               m_broadcastResult = 0;
+               
                item = list.at(i);
                
                if (!item) {
@@ -359,6 +362,7 @@
                }
                
                
+               // We first try to find if there is a match in the loaded 
plugins.
                if ( ! holdingCommand ) {
                        
                        if ( ! pluginname.isEmpty() ) {
@@ -373,13 +377,13 @@
                                                PMESG("InputEngine:: Using 
plugin %s for command %s",
                                                                
QS_C(pluginname), QS_C(data->commandname));
                                                k = plug->create(item, 
commandname, data->arguments);
-                                               break;
                                        }
                                }
-                               continue;
                        } 
                }
                
+               // Either the plugins didn't have a match, or were holding.
+               if ( ! k ) {
                
                IEAction::Data* delegatingdata;
                QString delegatedobject;
@@ -418,7 +422,6 @@
                        if (validobject) {
                                if (QMetaObject::invokeMethod(obj, QS_C(slot),  
Qt::DirectConnection, Q_RETURN_ARG(Command*, k))) {
                                        PMESG("HIT, invoking (delegated) 
%s::%s", QS_C(classname), QS_C(slot));
-                                       break;
                                } else {
                                        PMESG("Delegated object slot call 
didn't work out, sorry!");
                                        PMESG("%s::%s() --> %s::%s()", 
item->metaObject()->className(), QS_C(slot), QS_C(classname), QS_C(slot));
@@ -429,13 +432,34 @@
                } else {
                        if (QMetaObject::invokeMethod(item, 
QS_C(slotsignature), Qt::DirectConnection, Q_RETURN_ARG(Command*, k))) {
                                PMESG("HIT, invoking %s::%s", 
item->metaObject()->className(), QS_C(slotsignature));
-                               break;
                        } else {
                                PMESG("nope %s wasn't the right one, next ...", 
item->metaObject()->className());
                        }
                }
        }
        
+               
+               // Let's see if the ContextItem used either succes(), failure() 
or did_not_implement()
+               // return functions, so we can detect to either return happily, 
the action was succesfull
+               // but no command object needed to be returned, the action was 
not succesfull, and we 
+               // don't want to try lower level context items or the action 
was succesfull but we'd like 
+               // to give a lower level contextitem precedence over the 
current one.
+               if (m_broadcastResult) {
+                       if (m_broadcastResult == SUCCES) {
+                               PMESG("Broadcast Result indicates succes, but 
no returned Command object");
+                               return 1;
+                       }
+                       if (m_broadcastResult == FAILURE) {
+                               PMESG("Broadcast Result indicates failure, and 
doesn't want lower level items to be processed");
+                               return 0;
+                       }
+                       if (m_broadcastResult == DIDNOTIMPLEMENT) {
+                               PMESG("Broadcast Result indicates succes, but 
didn't want to perform it's action,"
+                                                "so we continue traversing the 
contextitem list");
+                               continue;
+                       }
+               }
+               
        if (k && (!isHolding)) {
                if (k->prepare_actions() != -1) {
                        k->set_valid(true);
@@ -452,6 +476,8 @@
                        delete k;
                        k = 0;
                }
+                       
+                       break;
        }
        
        if (k && isHolding) {
@@ -469,12 +495,33 @@
                        set_jogging( false );
                        wholeMapIndex = -1;
                }
+                       
+                       break;
        }
        
+       }
 
        return 1;
 }
 
+Command* InputEngine::succes()
+{
+       m_broadcastResult = SUCCES;
+       return 0;
+}
+
+Command* InputEngine::failure()
+{
+       m_broadcastResult = FAILURE;
+       return 0;
+}
+
+Command* InputEngine::did_not_implement()
+{
+       m_broadcastResult = DIDNOTIMPLEMENT;
+       return 0;
+}
+
 void InputEngine::jog()
 {
        PENTER3;

Index: InputEngine.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/InputEngine.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- InputEngine.h       13 Apr 2007 09:57:35 -0000      1.22
+++ InputEngine.h       24 Apr 2007 18:56:38 -0000      1.23
@@ -148,6 +148,10 @@
         void suspend();
        void clear_modifier_keys();
 
+       Command* succes();
+       Command* failure();
+       Command* did_not_implement();
+
 
         int init_map(const QString& mapFilename);
 
@@ -166,6 +170,13 @@
         static const int       PRESS_EVENT = 1;
         static const int       RELEASE_EVENT = 2;
 
+       enum BroadcastResult {
+               SUCCES=1,
+               FAILURE=2,
+               DIDNOTIMPLEMENT=3
+       };
+
+       
         QList<IEAction* >      m_ieActions;
        QList<int>              m_modifierKeys;
        QList<int>              m_activeModifierKeys;
@@ -203,6 +214,7 @@
         int                    assumeHoldTime;
         int                    doubleFactWaitTime;
         long                   eventTime[STACK_SIZE];
+       int                     m_broadcastResult;
 
         bool                   is_fake( int keyval);
         int                    identify_first_fact();

Index: Song.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.cpp,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- Song.cpp    23 Apr 2007 18:18:42 -0000      1.82
+++ Song.cpp    24 Apr 2007 18:56:38 -0000      1.83
@@ -53,6 +53,7 @@
 #include "ContextItem.h"
 #include "TimeLine.h"
 #include "Marker.h"
+#include "InputEngine.h"
 
 #include <Plugin.h>
 #include <PluginChain.h>
@@ -633,7 +634,11 @@
                realtimepath = true;
        }
        
+       if (group) {
        return group;
+       }
+       
+       return ie().succes();
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]