Warning, file /office/calligra/libs/main/KoStandardAction.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE libraries
0002    Copyright (C) 2009 Thomas Zander <zander@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License version 2 as published by the Free Software Foundation.
0007 
0008    This library is distributed in the hope that it will be useful,
0009    but WITHOUT ANY WARRANTY; without even the implied warranty of
0010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011    Library General Public License for more details.
0012 
0013    You should have received a copy of the GNU Library General Public License
0014    along with this library; see the file COPYING.LIB.  If not, write to
0015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0016    Boston, MA 02110-1301, USA.
0017 */
0018 
0019 #include "KoStandardAction.h"
0020 
0021 #include <kactioncollection.h>
0022 #include <ktoggleaction.h>
0023 #include <klocalizedstring.h>
0024 
0025 QAction *KoStandardAction::create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)
0026 {
0027     QAction *newAction = 0;
0028 
0029     switch (id) {
0030     case ShowGuides: {
0031         KToggleAction *toggle = new KToggleAction(i18n("Show Guides"), parent);
0032         toggle->setToolTip(i18n("Shows or hides guides"));
0033         newAction = toggle;
0034         break;
0035     }
0036     case ActionNone:
0037         return 0;
0038     }
0039 
0040     Q_ASSERT(newAction);
0041     newAction->setObjectName(name(id));
0042 
0043     if (recvr && slot)
0044         QObject::connect(newAction, SIGNAL(triggered(bool)), recvr, slot);
0045 
0046     KActionCollection *collection = qobject_cast<KActionCollection *>(parent);
0047     if (collection)
0048         collection->addAction(newAction->objectName(), newAction);
0049 
0050     return newAction;
0051 }
0052 
0053 const char* KoStandardAction::name(StandardAction id)
0054 {
0055     switch (id) {
0056     case ShowGuides:
0057         return "view_show_guides";
0058     default:
0059         return 0;
0060     };
0061 }
0062 
0063 KToggleAction *KoStandardAction::showGuides(const QObject *receiver, const char *slot, QObject *parent)
0064 {
0065     return static_cast<KToggleAction*>(create(ShowGuides, receiver, slot, parent));
0066 }