joachim99@82: /*************************************************************************** joachim99@82: kdiff3.h - description joachim99@82: ------------------- joachim99@82: begin : March 26 17:44 CEST 2002 joachim99@82: copyright : (c) 2008 by Valentin Rusu joachim99@82: email : kde at rusu.info joachim99@82: ***************************************************************************/ joachim99@82: joachim99@82: /*************************************************************************** joachim99@82: * * joachim99@82: * This program is free software; you can redistribute it and/or modify * joachim99@82: * it under the terms of the GNU General Public License as published by * joachim99@82: * the Free Software Foundation; either version 3 of the License, or * joachim99@82: * (at your option) any later version. * joachim99@82: * * joachim99@82: ***************************************************************************/ joachim99@82: joachim99@82: #include joachim99@82: #include joachim99@82: joachim99@82: namespace KDiff3 { joachim99@82: joachim99@82: template joachim99@82: T* createAction( joachim99@82: const QString& text, joachim99@82: const QObject* receiver, joachim99@82: const char* slot, joachim99@82: KActionCollection* ac, joachim99@82: const char* actionName); joachim99@82: joachim99@82: template <> joachim99@82: inline KAction* createAction( joachim99@82: const QString& text, joachim99@82: const QObject* receiver, joachim99@82: const char* slot, joachim99@82: KActionCollection* ac, joachim99@82: const char* actionName) { joachim99@82: assert( ac != 0 ); joachim99@82: KAction* theAction = ac->addAction( actionName ); joachim99@82: theAction->setText( text ); joachim99@82: QObject::connect( theAction, SIGNAL( triggered() ), receiver, slot ); joachim99@82: return theAction; joachim99@82: } joachim99@82: template <> joachim99@82: inline KToggleAction* createAction( joachim99@82: const QString& text, joachim99@82: const QObject* receiver, joachim99@82: const char* slot, joachim99@82: KActionCollection* ac, joachim99@82: const char* actionName) { joachim99@82: assert( ac != 0 ); joachim99@82: KToggleAction* theAction = new KToggleAction(ac); joachim99@82: ac->addAction( actionName, theAction ); joachim99@82: theAction->setText( text ); joachim99@95: QObject::connect( theAction, SIGNAL( triggered(bool) ), receiver, slot ); joachim99@82: return theAction; joachim99@82: } joachim99@82: joachim99@82: template joachim99@82: T* createAction( joachim99@82: const QString& text, joachim99@82: const KShortcut& shortcut, joachim99@82: const QObject* receiver, joachim99@82: const char* slot, joachim99@82: KActionCollection* ac, joachim99@82: const char* actionName) joachim99@82: { joachim99@82: T* theAction = createAction( text, receiver, slot, ac, actionName ); joachim99@82: theAction->setShortcut( shortcut ); joachim99@82: return theAction; joachim99@82: } joachim99@82: template joachim99@82: T* createAction( joachim99@82: const QString& text, joachim99@82: const QIcon& icon, joachim99@82: const QObject* receiver, joachim99@82: const char* slot, joachim99@82: KActionCollection* ac, joachim99@82: const char* actionName) joachim99@82: { joachim99@82: T* theAction = createAction( text, receiver, slot, ac, actionName ); joachim99@82: theAction->setIcon( icon ); joachim99@82: return theAction; joachim99@82: } joachim99@82: template joachim99@82: T* createAction( joachim99@82: const QString& text, joachim99@82: const QIcon& icon, joachim99@82: const QString& iconText, joachim99@82: const QObject* receiver, joachim99@82: const char* slot, joachim99@82: KActionCollection* ac, joachim99@82: const char* actionName) joachim99@82: { joachim99@82: T* theAction = createAction( text, receiver, slot, ac, actionName ); joachim99@82: theAction->setIcon( icon ); joachim99@82: theAction->setIconText( iconText ); joachim99@82: return theAction; joachim99@82: } joachim99@82: template joachim99@82: T* createAction( joachim99@82: const QString& text, joachim99@82: const QIcon& icon, joachim99@82: const KShortcut& shortcut, joachim99@82: const QObject* receiver, joachim99@82: const char* slot, joachim99@82: KActionCollection* ac, joachim99@82: const char* actionName) joachim99@82: { joachim99@82: T* theAction = createAction( text, shortcut, receiver, slot, ac, actionName ); joachim99@82: theAction->setIcon( icon ); joachim99@82: return theAction; joachim99@82: } joachim99@82: template joachim99@82: T* createAction( joachim99@82: const QString& text, joachim99@82: const QIcon& icon, joachim99@82: const QString& iconText, joachim99@82: const KShortcut& shortcut, joachim99@82: const QObject* receiver, joachim99@82: const char* slot, joachim99@82: KActionCollection* ac, joachim99@82: const char* actionName) joachim99@82: { joachim99@82: T* theAction = createAction( text, shortcut, receiver, slot, ac, actionName ); joachim99@82: theAction->setIcon( icon ); joachim99@82: theAction->setIconText( iconText ); joachim99@82: return theAction; joachim99@82: } joachim99@82: }