Commit 45383192 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove unused classes: KoCopyController and KoCutController

parent 399273c7
......@@ -14,8 +14,6 @@ set(kritaflake_SRCS
KoDocumentResourceManager.cpp
KoCanvasObserverBase.cpp
KoCanvasSupervisor.cpp
KoCutController.cpp
KoCopyController.cpp
KoDockFactoryBase.cpp
KoDockRegistry.cpp
KoDataCenterBase.cpp
......
/* This file is part of the KDE project
* Copyright (C) 2006-2008 Thomas Zander <zander@kde.org>
* Copyright (C) 2011 Boudewijn Rempt <boud@valdyas.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoCopyController.h"
#include <KoToolBase.h>
#include <KoCanvasBase.h>
#include <KoToolProxy.h>
#include <KoToolSelection.h>
#include <FlakeDebug.h>
#include <QAction>
// KoCopyControllerPrivate
class KoCopyControllerPrivate
{
public:
KoCopyControllerPrivate(KoCopyController *p, KoCanvasBase *c, QAction *a);
// request to start the actual copy
void copy();
// request to start the actual cut
void cut();
void selectionChanged(bool hasSelection);
KoCopyController *parent;
KoCanvasBase *canvas;
QAction *action;
bool appHasSelection;
};
KoCopyControllerPrivate::KoCopyControllerPrivate(KoCopyController *p, KoCanvasBase *c, QAction *a)
: parent(p),
canvas(c),
action(a)
{
appHasSelection = false;
}
void KoCopyControllerPrivate::copy()
{
if (canvas->toolProxy()->hasSelection())
// means the copy can be done by a flake tool
canvas->toolProxy()->copy();
else // if not; then the application gets a request to do the copy
emit parent->copyRequested();
}
void KoCopyControllerPrivate::cut()
{
if (canvas->toolProxy()->hasSelection()) {
canvas->toolProxy()->cut();
}
else {
emit parent->copyRequested();
}
}
void KoCopyControllerPrivate::selectionChanged(bool hasSelection)
{
action->setEnabled(appHasSelection || hasSelection);
}
// KoCopyController
KoCopyController::KoCopyController(KoCanvasBase *canvas, QAction *copyAction)
: QObject(copyAction),
d(new KoCopyControllerPrivate(this, canvas, copyAction))
{
connect(canvas->toolProxy(), SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));
hasSelection(false);
}
KoCopyController::~KoCopyController()
{
delete d;
}
void KoCopyController::hasSelection(bool selection)
{
d->appHasSelection = selection;
d->action->setEnabled(d->appHasSelection ||
d->canvas->toolProxy()->hasSelection());
}
//have to include this because of Q_PRIVATE_SLOT
#include "moc_KoCopyController.cpp"
/* This file is part of the KDE project
* Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOCOPYCONTROLLER_H
#define KOCOPYCONTROLLER_H
#include "kritaflake_export.h"
#include <QObject>
class QAction;
class KoCanvasBase;
class KoCopyControllerPrivate;
/**
* This class takes care of the copy actions integration into flake.
* Whenever the copy (KStandardAction::Copy) action is triggered the controller
* will use the currently selected tool and try to copy to the clipboard using that tool.
* Additionally; when the tool does not allow copying (KoToolBase::hasSelection() returns false)
* the signal copyRequested will be emitted for applications to connect to.
*/
class KRITAFLAKE_EXPORT KoCopyController : public QObject
{
Q_OBJECT
public:
/**
* Constructor
* @param canvas the canvas this controller will work on.
* @param copyAction the action that we will listen to and respond to when it is activated. Additionally, the
* action is used as a parent for the QObject for memory management purposes.
*/
KoCopyController(KoCanvasBase *canvas, QAction *copyAction);
virtual ~KoCopyController();
Q_SIGNALS:
/// emitted when the user pressed copy and the current tool had no selection.
void copyRequested();
public Q_SLOTS:
/**
* Notify whether the application has a selection.
* The copy-action will only be enabled when either the current tool or the application has a selection.
* @param selection if true the application is marked to allow copying.
* @see copyRequested()
*/
void hasSelection(bool selection);
private:
Q_PRIVATE_SLOT(d, void copy())
Q_PRIVATE_SLOT(d, void cut())
Q_PRIVATE_SLOT(d, void selectionChanged(bool))
protected:
friend class KoCopyControllerPrivate;
KoCopyControllerPrivate * const d;
};
#endif
/* This file is part of the KDE project
* Copyright (C) 2006-2008 Thomas Zander <zander@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOCOPYCONTROLLER_P_H
#define KOCOPYCONTROLLER_P_H
#include "KoCopyController.h"
class KoCanvasBase;
class QAction;
class KoCopyControllerPrivate
{
public:
KoCopyControllerPrivate(KoCopyController *p, KoCanvasBase *c, QAction *a);
// request to start the actual copy
void copy();
void selectionChanged(bool hasSelection);
KoCopyController *parent;
KoCanvasBase *canvas;
QAction *action;
bool appHasSelection;
};
#endif
/* This file is part of the KDE project
* Copyright (C) 2008 Thomas Zander <zander@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoCutController.h"
#include <QAction>
KoCutController::KoCutController(KoCanvasBase *canvas, QAction *cutAction)
: KoCopyController(canvas, cutAction)
{
disconnect(cutAction, SIGNAL(triggered()), this, SLOT(copy())); // countering the super
connect(cutAction, SIGNAL(triggered()), this, SLOT(cut()));
}
/* This file is part of the KDE project
* Copyright (C) 2008 Thomas Zander <zander@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOCUTCONTROLLER_H
#define KOCUTCONTROLLER_H
#include "KoCopyController.h"
#include "kritaflake_export.h"
/**
* This class takes care of the cut actions integration into flake.
* Whenever the copy (KStandardAction::Cut) action is triggered the controller
* will use the currently selected tool and try to cut to the clipboard using that tool.
* Additionally; when the tool does not allow copying (KoToolBase::hasSelection() returns false)
* the signal copyRequested will be emitted for applications to connect to.
*/
class KRITAFLAKE_EXPORT KoCutController : public KoCopyController
{
Q_OBJECT
public:
/**
* Constructor
* @param canvas the canvas this controller will work on.
* @param cutAction the action that we will listen to and respond to when it is activated. Additionally, the
* action is used as a parent for the QObject for memory management purposes.
*/
KoCutController(KoCanvasBase *canvas, QAction *cutAction);
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment