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

« back to all changes in this revision

Viewing changes to libs/plasmagenericshell/widgetsexplorer/appletsfiltering.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 (C) 2009 by Ana Cecília Martins <anaceciliamb@gmail.com>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Library/Lesser General Public License
 
6
 *   version 2, or (at your option) any later version, as published by the
 
7
 *   Free Software Foundation
 
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/Lesser 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 APPLETSFILTERING_H
 
21
#define APPLETSFILTERING_H
 
22
 
 
23
#include <Plasma/PushButton>
 
24
 
 
25
#include "kcategorizeditemsviewmodels_p.h"
 
26
#include "plasmaappletitemmodel_p.h"
 
27
 
 
28
class KMenu;
 
29
namespace Plasma {
 
30
    class LineEdit;
 
31
    class OpenWidgetAssistant;
 
32
    class PushButton;
 
33
    class ToolButton;
 
34
    class WidgetExplorer;
 
35
}
 
36
 
 
37
class CategoriesWidget : public Plasma::PushButton
 
38
{
 
39
    Q_OBJECT
 
40
 
 
41
public:
 
42
    explicit CategoriesWidget(QGraphicsWidget *parent = 0);
 
43
    virtual ~CategoriesWidget();
 
44
 
 
45
    void setModel(QStandardItemModel *model);
 
46
 
 
47
Q_SIGNALS:
 
48
    void filterChanged(int index);
 
49
 
 
50
protected:
 
51
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
 
52
 
 
53
private:
 
54
    //uses model to populate the tabs
 
55
    void populateList();
 
56
    QStandardItem *getItemByProxyIndex(const QModelIndex &index) const;
 
57
 
 
58
private Q_SLOTS:
 
59
    void menuItemTriggered(QAction *);
 
60
    void unpressButton();
 
61
 
 
62
private:
 
63
    QStandardItemModel *m_model;
 
64
    QMenu *m_menu;
 
65
};
 
66
 
 
67
class FilteringWidget : public QGraphicsWidget
 
68
{
 
69
    Q_OBJECT
 
70
 
 
71
public:
 
72
    explicit FilteringWidget(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0);
 
73
    explicit FilteringWidget(Qt::Orientation orientation = Qt::Horizontal,
 
74
                             Plasma::WidgetExplorer* widgetExplorer = 0,
 
75
                             QGraphicsItem * parent = 0,
 
76
                             Qt::WindowFlags wFlags = 0);
 
77
    virtual ~FilteringWidget();
 
78
 
 
79
    void setModel(QStandardItemModel *model);
 
80
    void setListOrientation(Qt::Orientation orientation);
 
81
    Plasma::LineEdit *textSearch();
 
82
    void updateActions(const QList<QAction *> actions);
 
83
 
 
84
Q_SIGNALS:
 
85
    void filterChanged(int index);
 
86
    void closeClicked();
 
87
 
 
88
protected Q_SLOTS:
 
89
    void setMenuPos();
 
90
    void populateWidgetsMenu();
 
91
 
 
92
    /**
 
93
     * Launches a download dialog to retrieve new applets from the Internet
 
94
     *
 
95
     * @arg type the type of widget to download; an empty string means the default
 
96
     *           Plasma widgets will be accessed, any other value should map to a
 
97
     *           PackageStructure PluginInfo-Name entry that provides a widget browser.
 
98
     */
 
99
    void downloadWidgets(const QString &type = QString());
 
100
 
 
101
    /**
 
102
     * Opens a file dialog to open a widget from a local file
 
103
     */
 
104
    void openWidgetFile();
 
105
 
 
106
protected:
 
107
    void resizeEvent(QGraphicsSceneResizeEvent *event);
 
108
 
 
109
private:
 
110
    void init();
 
111
 
 
112
    QStandardItemModel *m_model;
 
113
    CategoriesWidget *m_categories;
 
114
    Plasma::LineEdit *m_textSearch;
 
115
    Qt::Orientation m_orientation;
 
116
    Plasma::PushButton *m_newWidgetsButton;
 
117
    KMenu *m_newWidgetsMenu;
 
118
    Plasma::WidgetExplorer *m_widgetExplorer;
 
119
    QList<QWeakPointer<Plasma::PushButton> > m_actionButtons;
 
120
    Plasma::ToolButton *m_closeButton;
 
121
    QWeakPointer<Plasma::OpenWidgetAssistant> m_openAssistant;
 
122
};
 
123
 
 
124
#endif // APPLETSFILTERING_H