~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/netbook/containments/sal/itemview.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2009 by Marco Martin <notmart@gmail.com>
 
3
 *
 
4
 *
 
5
 *   This program is free software; you can redistribute it and/or modify
 
6
 *   it under the terms of the GNU Library General Public License version 2,
 
7
 *   or (at your option) any later version.
 
8
 *
 
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
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License 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
 
 
20
#ifndef ITEMVIEW_H
 
21
#define ITEMVIEW_H
 
22
 
 
23
#include <QGraphicsWidget>
 
24
#include <QModelIndex>
 
25
 
 
26
#include <Plasma/ScrollWidget>
 
27
 
 
28
#include "itemcontainer.h"
 
29
 
 
30
 
 
31
namespace Plasma
 
32
{
 
33
    class IconWidget;
 
34
}
 
35
 
 
36
class QTimer;
 
37
 
 
38
class ItemView : public Plasma::ScrollWidget
 
39
{
 
40
    Q_OBJECT
 
41
 
 
42
public:
 
43
    enum ScrollBarNeeded {
 
44
        NoScrollBar = 0,
 
45
        HorizontalScrollBar = 1,
 
46
        VerticalScrollBar = 2,
 
47
        AllScrollBars = HorizontalScrollBar|VerticalScrollBar
 
48
    };
 
49
    Q_DECLARE_FLAGS(ScrollBarFlags, ScrollBarNeeded)
 
50
 
 
51
    ItemView(QGraphicsWidget *parent);
 
52
    ~ItemView();
 
53
 
 
54
    void setCurrentItem(ResultWidget *currentItem);
 
55
    ResultWidget *currentItem() const;
 
56
 
 
57
    void setOrientation(Qt::Orientation orientation);
 
58
    Qt::Orientation orientation() const;
 
59
 
 
60
    void showSpacer(const QPointF &pos);
 
61
 
 
62
    void setIconSize(int size);
 
63
    int iconSize() const;
 
64
 
 
65
    QList<ResultWidget *>items() const;
 
66
 
 
67
    void setDragAndDropMode(ItemContainer::DragAndDropMode mode);
 
68
    ItemContainer::DragAndDropMode dragAndDropMode() const;
 
69
 
 
70
    qreal positionToWeight(const QPointF &point);
 
71
    void setModel(QAbstractItemModel *model);
 
72
    QAbstractItemModel *model() const;
 
73
    void setRootIndex(QModelIndex index);
 
74
    QModelIndex rootIndex() const;
 
75
    int rowForPosition(const QPointF &point);
 
76
 
 
77
public Q_SLOTS:
 
78
    void setScrollPositionFromDragPosition(const QPointF &point);
 
79
 
 
80
protected:
 
81
    void resizeEvent(QGraphicsSceneResizeEvent *event);
 
82
    bool eventFilter(QObject *watched, QEvent *event);
 
83
    void focusInEvent(QFocusEvent *event);
 
84
 
 
85
protected Q_SLOTS:
 
86
    void selectItem(ResultWidget *icon);
 
87
 
 
88
Q_SIGNALS:
 
89
    void itemSelected(ResultWidget *);
 
90
    void itemActivated(const QModelIndex &index);
 
91
    void resetRequested();
 
92
    void scrollBarsNeededChanged(ItemView::ScrollBarFlags);
 
93
    void itemAskedReorder(const QModelIndex &index, const QPointF &point);
 
94
    void dragStartRequested(const QModelIndex &index);
 
95
    void addActionTriggered(const QModelIndex &index);
 
96
 
 
97
private:
 
98
    ItemContainer *m_itemContainer;
 
99
    QTimer *m_noActivateTimer;
 
100
};
 
101
 
 
102
#endif