Kraxy/EBN: missing Q_OBJECT
[kphotoalbum.git] / ThumbnailView / SelectionInteraction.h
blob595b730136274a62d10cd74aa99431b8a6a2f9b4
1 /* Copyright (C) 2003-2009 Jesper K. Pedersen <blackie@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
18 #ifndef SELECTIONINTERACTION_H
19 #define SELECTIONINTERACTION_H
21 #include "ThumbnailComponent.h"
22 #include "enums.h"
23 #include "MouseInteraction.h"
24 #include <qobject.h>
26 namespace DB { class ResultId; }
28 class QMouseEvent;
29 namespace ThumbnailView
31 class ThumbnailFactory;
32 class Cell;
34 class SelectionInteraction : public QObject, public MouseInteraction, private ThumbnailComponent {
35 Q_OBJECT
37 public:
38 SelectionInteraction( ThumbnailFactory* factory );
39 virtual void mousePressEvent( QMouseEvent* );
40 virtual void mouseMoveEvent( QMouseEvent* );
41 virtual void mouseReleaseEvent( QMouseEvent* );
42 bool isDragging() const;
44 protected:
45 bool isMouseOverIcon( const QPoint& viewportPos ) const;
46 void startDrag();
47 bool atLeftSide( const QPoint& contentCoordinates );
48 bool atRightSide( const QPoint& contentCoordinates );
49 Cell prevCell( const Cell& cell );
50 Cell nextCell( const Cell& cell );
51 QRect iconRect( const QPoint& pos, CoordinateSystem ) const;
52 bool deselectSelection( const QMouseEvent* ) const;
54 protected slots:
55 void handleDragSelection();
56 void calculateSelection( Cell* pos1, Cell* pos2 );
58 private:
59 typedef QSet<DB::ResultId> IdSet;
60 /**
61 * This variable contains the position the mouse was pressed down.
62 * The point is in contents coordinates.
64 QPoint _mousePressPos;
66 /**
67 * Did the mouse interaction start with the mouse on top of an icon.
69 bool _isMouseDragOperation;
71 IdSet _originalSelectionBeforeDragStart;
72 QTimer* _dragTimer;
73 bool _dragInProgress;
74 bool _dragSelectionInProgress;
75 ThumbnailFactory* _JUMP;
80 #endif /* SELECTIONINTERACTION_H */