1/***************************************************************************
2 * Copyright (C) 2006 by Aaron J. Seigo (<aseigo@kde.org>) *
3 * Copyright (C) 2009 by Peter Penz (<peter.penz@kde.org>) *
4 * *
5 * This library is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU Lesser General Public *
7 * License as published by the Free Software Foundation; either *
8 * version 2 of the License, or (at your option) any later version. *
9 * *
10 * This library is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * Lesser General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Lesser General Public *
16 * License along with this library; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21#ifndef KURLNAVIGATORPROTOCOLCOMBO_P_H
22#define KURLNAVIGATORPROTOCOLCOMBO_P_H
23
24#include "kurlnavigatorbuttonbase_p.h"
25
26#include <QtCore/QHash>
27
28class QMenu;
29
30namespace KDEPrivate
31{
32
33/**
34 * @brief A combobox listing available protocols.
35 *
36 * The widget is used by the URL navigator for offering the available
37 * protocols for non-local URLs.
38 *
39 * @see KUrlNavigator
40 */
41class KUrlNavigatorProtocolCombo : public KUrlNavigatorButtonBase
42{
43 Q_OBJECT
44
45public:
46 explicit KUrlNavigatorProtocolCombo(const QString& protocol, QWidget* parent = 0);
47
48 QString currentProtocol() const;
49
50 void setCustomProtocols(const QStringList &protocols);
51
52 virtual QSize sizeHint() const;
53
54public Q_SLOTS:
55 void setProtocol(const QString& protocol);
56
57Q_SIGNALS:
58 void activated(const QString& protocol);
59
60protected:
61 virtual void showEvent(QShowEvent* event);
62 virtual void paintEvent(QPaintEvent* event);
63
64private Q_SLOTS:
65 void setProtocol(QAction* action);
66
67private:
68 void updateMenu();
69 void initializeCategories();
70
71 enum ProtocolCategory
72 {
73 CoreCategory,
74 PlacesCategory,
75 DevicesCategory,
76 SubversionCategory,
77 OtherCategory,
78 CategoryCount // mandatory last entry
79 };
80
81 QMenu* m_menu;
82 QStringList m_protocols;
83 QHash<QString, ProtocolCategory> m_categories;
84};
85
86} // namespace KDEPrivate
87
88#endif
89