From: <su...@us...> - 2015-04-18 17:17:18
|
Revision: 1418 http://sourceforge.net/p/canorus/code/1418 Author: suamor Date: 2015-04-18 17:17:16 +0000 (Sat, 18 Apr 2015) Log Message: ----------- ActionsEditor: Replace context by description in some more places SingleAction: Remove context (no longer needed) SettingsDialog: Replace QAction by QSingleAction Settings: Replace/Add QAction by/with QSingleAction (as Base) Modified Paths: -------------- trunk/src/core/settings.cpp trunk/src/core/settings.h trunk/src/ui/settingsdialog.cpp trunk/src/ui/singleaction.cpp trunk/src/ui/singleaction.h trunk/src/widgets/actionseditor.cpp Modified: trunk/src/core/settings.cpp =================================================================== --- trunk/src/core/settings.cpp 2015-04-12 16:39:32 UTC (rev 1417) +++ trunk/src/core/settings.cpp 2015-04-18 17:17:16 UTC (rev 1418) @@ -96,7 +96,7 @@ void CASettings::initSettings() { - _poEmptyEntry = new QAction( this ); + _poEmptyEntry = new CASingleAction( this ); } CASettings::~CASettings() { @@ -104,6 +104,16 @@ if( _poEmptyEntry ) delete _poEmptyEntry; _poEmptyEntry = 0; + if( false == _oActionList.isEmpty() ) + { + CASingleAction *poActionEntry; + foreach(poActionEntry, _oActionList) + { + delete poActionEntry; + poActionEntry = 0; + } + _oActionList.clear(); + } } /*! @@ -340,27 +350,49 @@ Search one single action in the list of actions (-1: entry not found) Returns an empty action element when the command was not found */ -int CASettings::getSingleAction(QString oCommand, QAction *&poResAction) +int CASettings::getSingleAction(QString oCommandName, QAction *&poResAction) { + CASingleAction *poEntryAction; for (int i=0; i < _oActionList.count(); i++) { - poResAction = &getSingleAction(i, _oActionList); - if( poResAction->objectName() == oCommand ) + poEntryAction = _oActionList[i]; + if( poEntryAction->getCommandName() == oCommandName ) + { + poResAction = poEntryAction; return i; + } } poResAction = _poEmptyEntry; - return -1; + return -1; } +int CASettings::getSingleAction(QString oCommandName, CASingleAction *&poResAction) +{ + CASingleAction *poEntryAction; + for (int i=0; i < _oActionList.count(); i++) { + poEntryAction = _oActionList[i]; + if( poEntryAction->getCommandName() == oCommandName ) + { + poResAction = poEntryAction; + return i; + } + } + poResAction = _poEmptyEntry; + return -1; +} + /*! Updates an action in the action list Return 'true' if the update was successfull - Warning: The action cannot be copied! + Warning: 1) The action will not be copied + 2) Only shortcut and no midi information is updated + 3) Description cannot be updated */ bool CASettings::setSingleAction(QAction oSingleAction, int iPos) { bool bRet = false; if( iPos >= 0 && iPos < _oActionList.count() ) { - _oActionList[iPos] = &oSingleAction; + _oActionList[iPos]->setCommandName( oSingleAction.objectName() ); + _oActionList[iPos]->setShortCutAsString( oSingleAction.shortcut().toString() ); bRet = true; } return bRet; @@ -372,13 +404,14 @@ Else: According to Qt doc "assigns the other list to this list" Warning: The actions themselves cannot be copied! */ -void CASettings::setActionList(QList<QAction *> &oActionList) +void CASettings::setActionList(QList<CASingleAction *> &oActionList) { #ifdef COPY_ACTIONLIST_ELEMS_MANUALLY _oActionList.clear(); + CASingleAction *pActionEntry; for (int i=0; i < oActionList.count(); i++) { - poResAction = &getSingleAction(i, oActionList); - addSingleAction(*poResAction); + pActionEntry = &getSingleAction(i, oActionList); + addSingleAction(*pActionEntry); } #else _oActionList = oActionList; @@ -387,21 +420,35 @@ /*! Adds a single action to the action list - Warning: The action cannot be copied! + Warning: The action will be referenced! */ -void CASettings::addSingleAction(QAction oSingleAction) +void CASettings::addSingleAction(CASingleAction &oSingleAction) { - _oActionList.append( &oSingleAction ); + CASingleAction *pActionEntry = new CASingleAction(0); // parent ? + pActionEntry->setCommandName( oSingleAction.getCommandName() ); + pActionEntry->setDescription( oSingleAction.getDescription() ); + pActionEntry->setShortCutAsString( oSingleAction.getShortCutAsString() ); + pActionEntry->setMidiKeySequence( oSingleAction.getMidiKeySequence() ); + pActionEntry->setActionGroup( oSingleAction.actionGroup() ); + pActionEntry->setAutoRepeat( oSingleAction.autoRepeat() ); + pActionEntry->setCheckable( oSingleAction.isCheckable() ); + pActionEntry->setChecked( oSingleAction.isChecked() ); + pActionEntry->setData( oSingleAction.data() ); +#ifdef COPY_ACTIONLIST_ELEMS_MANUALLY + _oActionList.append( pActionEntry ); +#else + _oActionList.append( &oSingleAction ); +#endif } /*! Removes a single action from the action list Return 'true' when succesfull - Warning: The action itself cannot be deleted! + Warning: The action itself is not deleted! */ bool CASettings::deleteSingleAction(QString oCommand) { - QAction *poResAction; + CASingleAction *poResAction; bool bRet = false; int iPos = getSingleAction(oCommand, poResAction); if( iPos >= 0 ) // Double entries should not be in the list @@ -409,6 +456,9 @@ _oActionList.removeOne( poResAction ); bRet = true; } +#ifdef COPY_ACTIONLIST_ELEMS_MANUALLY + delete poResAction; +#endif return bRet; } Modified: trunk/src/core/settings.h =================================================================== --- trunk/src/core/settings.h 2015-04-12 16:39:32 UTC (rev 1417) +++ trunk/src/core/settings.h 2015-04-18 17:17:16 UTC (rev 1418) @@ -11,8 +11,8 @@ #include <QSettings> #ifndef SWIG #include <QColor> -//#include "ui/singleaction.h" -#include <QAction> +#include "ui/singleaction.h" +//#include <QAction> #endif #include <QDir> #include "core/fileformats.h" @@ -140,8 +140,9 @@ inline void setLatestShortcutsDirectory( QDir d ) { _latestShortcutsDirectory = d; } static const QDir DEFAULT_SHORTCUTS_DIRECTORY; #ifndef SWIG - int getSingleAction(QString oCommand, QAction *&poResAction); - /*! + int getSingleAction(QString oCommandName, QAction *&poResAction); + int getSingleAction(QString oCommandName, CASingleAction *&poResAction); + /*! Re one single action in the list of actions Does not check for the correct position in the list to be fast! */ @@ -150,10 +151,10 @@ return *poResAction; } bool setSingleAction(QAction oSingleAction, int iPos); - inline const QList<QAction*>& getActionList() { return _oActionList; } - void setActionList(QList<QAction *> &oActionList); - void addSingleAction(QAction oSingleAction); - bool deleteSingleAction(QString oCommand); + inline const QList<CASingleAction*>& getActionList() { return _oActionList; } + void setActionList(QList<CASingleAction *> &oActionList); + void addSingleAction(CASingleAction &oSingleAction); + bool deleteSingleAction(QString oCommandName); #endif private: @@ -234,8 +235,8 @@ QDir _latestShortcutsDirectory; // save location of shortcuts/midi commands // @ToDo: QAction can be exported to SWIG ? Abstract interface but requires QObject #ifndef SWIG - QList<QAction *> _oActionList; - QAction *_poEmptyEntry; // Entry is unused for search function + QList<CASingleAction *> _oActionList; + CASingleAction *_poEmptyEntry; // Entry is unused for search function #endif }; Modified: trunk/src/ui/settingsdialog.cpp =================================================================== --- trunk/src/ui/settingsdialog.cpp 2015-04-12 16:39:32 UTC (rev 1417) +++ trunk/src/ui/settingsdialog.cpp 2015-04-18 17:17:16 UTC (rev 1418) @@ -193,7 +193,7 @@ { int i; QWidget oSingleActions; // all actions added here - const QList<QAction *> &roSAList = CACanorus::settings()->getActionList(); + const QList<CASingleAction *> &roSAList = CACanorus::settings()->getActionList(); _commandsEditor = new CAActionsEditor( 0 ); _commandsEditor->setObjectName(QString::fromUtf8("commandsEditor")); commandsSettingsVBoxLayout->addWidget(_commandsEditor); Modified: trunk/src/ui/singleaction.cpp =================================================================== --- trunk/src/ui/singleaction.cpp 2015-04-12 16:39:32 UTC (rev 1417) +++ trunk/src/ui/singleaction.cpp 2015-04-18 17:17:16 UTC (rev 1418) @@ -29,12 +29,6 @@ } } -void CASingleAction::setContext( QString oContext ) -{ - if( !oContext.isEmpty() ) - _oContext = oContext; -} - void CASingleAction::setDescription( QString oDescription ) { if( !oDescription.isEmpty() ) Modified: trunk/src/ui/singleaction.h =================================================================== --- trunk/src/ui/singleaction.h 2015-04-12 16:39:32 UTC (rev 1417) +++ trunk/src/ui/singleaction.h 2015-04-18 17:17:16 UTC (rev 1418) @@ -26,7 +26,6 @@ // Getter methods for all single action parameters inline QString getCommandName() { return _oCommandName; } - inline QString getContext() { return _oContext; } inline QString getDescription() { return _oDescription; } inline QString getShortCutAsString() { return _oShortCut; } inline QString getMidiKeySequence() { return _oMidiKeySequence; } @@ -38,7 +37,6 @@ // Setter methods void setCommandName( QString oCommandName ); - void setContext( QString oContext ); void setDescription( QString oDescription ); void setShortCutAsString( QString oShortCut ); void setMidiKeySequence( QString oMidiKeySequence, bool combined = false ); @@ -46,7 +44,6 @@ protected: // Action parameters to be stored / loaded via Settings Dialog QString _oCommandName; - QString _oContext; QString _oDescription; QString _oShortCut; QString _oMidiKeySequence; Modified: trunk/src/widgets/actionseditor.cpp =================================================================== --- trunk/src/widgets/actionseditor.cpp 2015-04-12 16:39:32 UTC (rev 1417) +++ trunk/src/widgets/actionseditor.cpp 2015-04-18 17:17:16 UTC (rev 1418) @@ -201,7 +201,7 @@ actionsTable->setRowCount( actionsList.count() ); CASingleAction *action; - QString accelText, midi_com, context; + QString accelText, midi_com, description; //#if !USE_SHORTCUTGETTER dont_validate = true; @@ -217,7 +217,7 @@ //#else accelText = action->getShortCutAsString(); //#endif - context = action->getContext(); + description = action->getDescription(); midi_com = action->getMidiKeySequence(); QTableWidgetItem * i_conf = new QTableWidgetItem(); @@ -226,7 +226,7 @@ QTableWidgetItem * i_command = new QTableWidgetItem(action->text()); // Context column - QTableWidgetItem * i_context = new QTableWidgetItem( context ); + QTableWidgetItem * i_context = new QTableWidgetItem( description ); // Shortcut column QTableWidgetItem * i_shortcut = new QTableWidgetItem(accelText); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |