1/* This file is part of the KDE libraries
2 Copyright (C) 2001,2002,2003 Carsten Pfeiffer <pfeiffer@kde.org>
3 Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
4
5 library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation, version 2.
8
9 This library 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 GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KFILEPLACEEDITDIALOG_H
21#define KFILEPLACEEDITDIALOG_H
22
23// Not exported anymore, only used internally.
24//#include <kfile_export.h>
25
26#include <kdialog.h>
27#include <kurl.h>
28
29class QCheckBox;
30class KIconButton;
31class KLineEdit;
32class KUrlRequester;
33
34/**
35 * A dialog that allows editing entries of a KUrlBar ( KUrlBarItem).
36 * The dialog offers to configure a given url, label and icon.
37 * See the class-method getInformation() for easy usage.
38 *
39 * @author Carsten Pfeiffer <pfeiffer@kde.org>
40 */
41class KFilePlaceEditDialog : public KDialog
42{
43 Q_OBJECT
44
45public:
46 /**
47 * A convenience method to show the dialog and retrieve all the
48 * properties via the given parameters. The parameters are used to
49 * initialize the dialog and then return the user-configured values.
50 *
51 * @p allowGlobal if you set this to true, the dialog will have a checkbox
52 * for the user to decide if he wants the entry to be
53 * available globally or just for the current application.
54 * @p url the url of the item
55 * @p label a short, translated description of the item
56 * @p icon an icon for the item
57 * @p appLocal tells whether the item should be local for this application
58 * or be available globally
59 * @p iconSize determines the size of the icon that is shown/selectable
60 * @p parent the parent-widget for the dialog
61 *
62 * If you leave the icon empty, the default icon for the given url will be
63 * used (KMimeType::pixmapForUrl()).
64 */
65 static bool getInformation( bool allowGlobal, KUrl& url,
66 QString& label, QString& icon,
67 bool isAddingNewPlace,
68 bool& appLocal, int iconSize,
69 QWidget *parent = 0 );
70
71 /**
72 * Constructs a KFilePlaceEditDialog.
73 *
74 * @p allowGlobal if you set this to true, the dialog will have a checkbox
75 * for the user to decide if he wants the entry to be
76 * available globally or just for the current application.
77 * @p url the url of the item
78 * @p label a short, translated description of the item
79 * @p icon an icon for the item
80 * @p appLocal tells whether the item should be local for this application
81 * or be available globally
82 * @p iconSize determines the size of the icon that is shown/selectable
83 * @p parent the parent-widget for the dialog
84 *
85 * If you leave the icon empty, the default icon for the given url will be
86 * used (KMimeType::pixmapForUrl()).
87 */
88 KFilePlaceEditDialog(bool allowGlobal, const KUrl& url,
89 const QString& label, const QString &icon,
90 bool isAddingNewPlace,
91 bool appLocal = true,
92 int iconSize = KIconLoader::SizeMedium,
93 QWidget *parent = 0);
94 /**
95 * Destroys the dialog.
96 */
97 ~KFilePlaceEditDialog();
98
99 /**
100 * @returns the configured url
101 */
102 KUrl url() const;
103
104 /**
105 * @returns the configured label
106 */
107 QString label() const;
108
109 /**
110 * @returns the configured icon
111 */
112 const QString &icon() const;
113
114 /**
115 * @returns whether the item should be local to the application or global.
116 * If allowGlobal was set to false in the constructor, this will always
117 * return true.
118 */
119 bool applicationLocal() const;
120
121public Q_SLOTS:
122 void urlChanged(const QString & );
123
124private:
125 /**
126 * The KUrlRequester used for editing the url
127 */
128 KUrlRequester * m_urlEdit;
129 /**
130 * The KLineEdit used for editing the label
131 */
132 KLineEdit * m_labelEdit;
133 /**
134 * The KIconButton to configure the icon
135 */
136 KIconButton * m_iconButton;
137 /**
138 * The QCheckBox to modify the local/global setting
139 */
140 QCheckBox * m_appLocal;
141};
142
143
144#endif // KURLBAR_H
145