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"
23 #include "MouseInteraction.h"
26 namespace DB
{ class ResultId
; }
29 namespace ThumbnailView
31 class ThumbnailFactory
;
34 class SelectionInteraction
: public QObject
, public MouseInteraction
, private ThumbnailComponent
{
38 SelectionInteraction( ThumbnailFactory
* factory
);
39 virtual void mousePressEvent( QMouseEvent
* );
40 virtual void mouseMoveEvent( QMouseEvent
* );
41 virtual void mouseReleaseEvent( QMouseEvent
* );
42 bool isDragging() const;
45 bool isMouseOverIcon( const QPoint
& viewportPos
) const;
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;
55 void handleDragSelection();
56 void calculateSelection( Cell
* pos1
, Cell
* pos2
);
59 typedef QSet
<DB::ResultId
> IdSet
;
61 * This variable contains the position the mouse was pressed down.
62 * The point is in contents coordinates.
64 QPoint _mousePressPos
;
67 * Did the mouse interaction start with the mouse on top of an icon.
69 bool _isMouseDragOperation
;
71 IdSet _originalSelectionBeforeDragStart
;
74 bool _dragSelectionInProgress
;
75 ThumbnailFactory
* _JUMP
;
80 #endif /* SELECTIONINTERACTION_H */