libs/flake

KoSelection.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002 
00003    Copyright (C) 2006 Boudewijn Rempt <boud@valdyas.org>
00004    Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
00005    Copyright (C) 2007,2009 Thomas Zander <zander@kde.org>
00006    Copyright (C) 2006,2007 Jan Hambrecht <jaham@gmx.net>
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public
00010    License as published by the Free Software Foundation; either
00011    version 2 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Library General Public License
00019    along with this library; see the file COPYING.LIB.  If not, write to
00020    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021  * Boston, MA 02110-1301, USA.
00022 */
00023 
00024 #ifndef KOSELECTION_H
00025 #define KOSELECTION_H
00026 
00027 #include <QObject>
00028 #include <QSet>
00029 
00030 #include "KoShape.h"
00031 #include "KoViewConverter.h"
00032 #include "KoFlake.h"
00033 
00034 #include "flake_export.h"
00035 
00036 class KoShapeLayer;
00037 class KoSelectionPrivate;
00038 
00052 class FLAKE_EXPORT KoSelection : public QObject, public KoShape
00053 {
00054     Q_OBJECT
00055 
00056 public:
00057 
00058     KoSelection();
00059     virtual ~KoSelection();
00060 
00061     virtual void paint(QPainter &painter, const KoViewConverter &converter);
00062 
00077     void select(KoShape *shape, bool recursive = true);
00078 
00093     void deselect(KoShape *shape, bool recursive = true);
00094 
00096     void deselectAll();
00097 
00104     const QList<KoShape*> selectedShapes(KoFlake::SelectionType strip = KoFlake::FullSelection) const;
00105 
00111     KoShape *firstSelectedShape(KoFlake::SelectionType strip = KoFlake::FullSelection) const;
00112 
00114     bool isSelected(const KoShape *shape) const;
00115 
00117     int count() const;
00118 
00119     virtual bool hitTest(const QPointF &position) const;
00120 
00121     virtual QRectF boundingRect() const;
00122 
00127     void setActiveLayer(KoShapeLayer* layer);
00128 
00134     KoShapeLayer* activeLayer() const;
00135 
00137     void updateSizeAndPosition();
00138 
00139 signals:
00141     void selectionChanged();
00142 
00144     void currentLayerChanged(const KoShapeLayer *layer);
00145 
00146 private:
00147     virtual void saveOdf(KoShapeSavingContext &) const;
00148     virtual bool loadOdf(const KoXmlElement &, KoShapeLoadingContext &);
00149 
00150     Q_PRIVATE_SLOT(d_func(), void selectionChangedEvent())
00151     Q_DECLARE_PRIVATE_D(KoShape::d_ptr, KoSelection)
00152 };
00153 
00154 #endif