Warning, file /office/calligra/libs/flake/KoCopyController.h 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 project
0002  * Copyright (C) 2006-2007 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 as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 #ifndef KOCOPYCONTROLLER_H
0020 #define KOCOPYCONTROLLER_H
0021 
0022 #include "flake_export.h"
0023 
0024 #include <QObject>
0025 
0026 class QAction;
0027 class KoCanvasBase;
0028 class KoCopyControllerPrivate;
0029 
0030 /**
0031  * This class takes care of the copy actions integration into flake.
0032  * Whenever the copy (KStandardAction::Copy) action is triggered the controller
0033  * will use the currently selected tool and try to copy to the clipboard using that tool.
0034  * Additionally; when the tool does not allow copying (KoToolBase::hasSelection() returns false)
0035  * the signal copyRequested will be emitted for applications to connect to.
0036  */
0037 class FLAKE_EXPORT KoCopyController : public QObject
0038 {
0039     Q_OBJECT
0040 public:
0041     /**
0042      * Constructor
0043      * @param canvas the canvas this controller will work on.
0044      * @param copyAction the action that we will listen to and respond to when it is activated.  Additionally, the
0045      *     action is used as a parent for the QObject for memory management purposes.
0046      */
0047     KoCopyController(KoCanvasBase *canvas, QAction *copyAction);
0048     ~KoCopyController() override;
0049 
0050 Q_SIGNALS:
0051     /// emitted when the user pressed copy and the current tool had no selection.
0052     void copyRequested();
0053 
0054 public Q_SLOTS:
0055     /**
0056      * Notify whether the application has a selection.
0057      * The copy-action will only be enabled when either the current tool or the application has a selection.
0058      * @param selection if true the application is marked to allow copying.
0059      * @see copyRequested()
0060      */
0061     void hasSelection(bool selection);
0062 
0063 private:
0064     Q_PRIVATE_SLOT(d, void copy())
0065     Q_PRIVATE_SLOT(d, void cut())
0066     Q_PRIVATE_SLOT(d, void selectionChanged(bool))
0067 
0068 protected:
0069     friend class KoCopyControllerPrivate;
0070     KoCopyControllerPrivate * const d;
0071 };
0072 
0073 #endif