1
/***************************************************************************
2
* Copyright (C) 2010 - 2011 by Ingomar Wesp <ingomar@wesp.name> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18
***************************************************************************/
19
#ifndef QUICKLAUNCH_POPUPLAUNCHERLIST_H
20
#define QUICKLAUNCH_POPUPLAUNCHERLIST_H
25
#include <QtCore/QList>
26
#include <QtCore/QPointF>
27
#include <QtGui/QGraphicsWidget>
33
#include <Plasma/Plasma>
36
#include "launcherdata.h"
41
class QGraphicsLayout;
42
class QGraphicsLinearLayout;
43
class QGraphicsSceneResizeEvent;
44
class QGraphicsSceneDragDropEvent;
45
class QGraphicsSceneMouseEvent;
51
namespace Quicklaunch {
57
* The PopupLauncherList is a QGraphicsWidget that displays and manages the
58
* launchers on Quicklaunch's popup.
59
* Since all launchers are managed by the PopupLauncherList and its layout,
60
* they should not be accessed directly, but rather added or removed by
61
* passing LauncherData objects.
63
* PopupLauncherList also takes care of drag & drop handling.
65
class PopupLauncherList : public QGraphicsWidget
72
* Creates a new PopupLauncherList with the given parent item.
74
* @param parent the parent QGraphicsItem
76
explicit PopupLauncherList(QGraphicsItem *parent = 0);
78
void setPreferredIconSize(int size);
81
* Indicates whether this PopupLauncherList is locked and thus does not allow
82
* adding, removing or reordering launchers by drag & drop.
87
* Locks or unlocks this PopupLauncherList.
89
* @param enable whether this PopupLauncherList should be locked, thereby
90
* disabling adding, removing or reordering launchers by drag & drop.
92
void setLocked(bool enable);
94
QGraphicsLinearLayout *layout() const;
96
int launcherCount() const;
99
void insert(int index, const LauncherData &launcherData);
100
void insert(int index, const QList<LauncherData> &launcherDataList);
101
void removeAt(int index);
102
LauncherData launcherAt(int index) const;
103
int launcherIndexAtPosition(const QPointF& pos) const;
105
bool eventFilter(QObject *watched, QEvent *event);
109
* Indicates a change to one or more of the displayed launchers.
111
void launchersChanged();
114
* Indicates that one of the launcher items was clicked.
116
void launcherClicked();
119
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
120
void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
121
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
122
void dropEvent(QGraphicsSceneDragDropEvent *event);
125
void onPlaceHolderActivated();
128
void initPlaceHolder();
129
void deletePlaceHolder();
130
int determineDropMarkerIndex(const QPointF &localPos) const;
132
QList<Launcher*> m_launchers;
133
QSizeF m_preferredIconSize;
136
QGraphicsLinearLayout *m_layout;
138
QPointF m_mousePressedPos;
139
DropMarker *m_dropMarker;
140
int m_dropMarkerIndex;
141
Plasma::IconWidget *m_placeHolder;
145
#endif /* QUICKLAUNCH_POPUPLAUNCHERLIST_H */