1 /***************************************************************************
2     This is the bookmark container for Smb4K (next generation).
3                              -------------------
4     begin                : So Jun 8 2008
5     copyright            : (C) 2008-2020 by Alexander Reinholdt
6     email                : alexander.reinholdt@kdemail.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *   This program is free software; you can redistribute it and/or modify  *
11  *   it under the terms of the GNU General Public License as published by  *
12  *   the Free Software Foundation; either version 2 of the License, or     *
13  *   (at your option) any later version.                                   *
14  *                                                                         *
15  *   This program is distributed in the hope that it will be useful, but   *
16  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
18  *   General Public License for more details.                              *
19  *                                                                         *
20  *   You should have received a copy of the GNU General Public License     *
21  *   along with this program; if not, write to the                         *
22  *   Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,*
23  *   MA 02110-1335, USA                                                    *
24  ***************************************************************************/
25 
26 #ifndef SMB4KBOOKMARK_H
27 #define SMB4KBOOKMARK_H
28 
29 // application specific includes
30 #include "smb4kglobal.h"
31 
32 // Qt includes
33 #include <QString>
34 #include <QScopedPointer>
35 #include <QUrl>
36 #include <QIcon>
37 
38 
39 // forward declarations
40 class Smb4KShare;
41 class Smb4KBookmarkPrivate;
42 
43 /**
44  * This is the container class for bookmarks in Smb4K. It is a complete
45  * rewrite of the previous class and comes with several improvements.
46  *
47  * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
48  */
49 
50 class Q_DECL_EXPORT Smb4KBookmark
51 {
52   friend class Smb4KBookmarkPrivate;
53 
54   public:
55     /**
56      * The constructor.
57      *
58      * @param share           The share for which the bookmark should
59      *                        be created.
60      *
61      * @param label           The optional bookmark label.
62      */
63     explicit Smb4KBookmark(Smb4KShare *share, const QString &label = QString());
64 
65     /**
66      * The copy constructor.
67      *
68      * @param bookmark        The bookmark that should be copied.
69      */
70     Smb4KBookmark(const Smb4KBookmark &bookmark);
71 
72     /**
73      * The empty constructor.
74      */
75     Smb4KBookmark();
76 
77     /**
78      * The destructor
79      */
80     ~Smb4KBookmark();
81 
82     /**
83      * Set the workgroup name.
84      *
85      * @param workgroup       The workgroup where the share is located.
86      */
87     void setWorkgroupName(const QString &workgroup);
88 
89     /**
90      * Returns the workgroup/domain name.
91      *
92      * @returns the workgroup/domain name.
93      */
94     QString workgroupName() const;
95 
96     /**
97      * Set the host name.
98      *
99      * @param host            The host where the share is located.
100      */
101     void setHostName(const QString &host);
102 
103     /**
104      * Returns the host name.
105      *
106      * @returns the host name.
107      */
108     QString hostName() const;
109 
110     /**
111      * Set the share name.
112      *
113      * @param share           The share name
114      */
115     void setShareName(const QString &share);
116 
117     /**
118      * Returns the share name.
119      *
120      * @returns the share name.
121      */
122     QString shareName() const;
123 
124     /**
125      * Set the host's IP address.
126      *
127      * @param ip              The host's IP address
128      */
129     void setHostIpAddress(const QString &ip);
130 
131     /**
132      * Returns the host's IP address.
133      *
134      * @returns the host's IP address.
135      */
136     QString hostIpAddress() const;
137 
138     /**
139      * Set the share's type.
140      *
141      * @param type            The type of the share.
142      */
143     void setShareType(Smb4KGlobal::ShareType type);
144 
145     /**
146      * Returns the share's type.
147      *
148      * @returns the type of the share.
149      */
150     Smb4KGlobal::ShareType shareType() const;
151 
152     /**
153      * Set the (optional) bookmark label.
154      *
155      * @param label           The bookmark's label
156      */
157     void setLabel(const QString &label);
158 
159     /**
160      * Returns the bookmark's label.
161      *
162      * @returns the bookmark's label.
163      */
164     QString label() const;
165 
166     /**
167      * Sets the login that is used to mount this share.
168      *
169      * @param login           The login
170      */
171     void setLogin(const QString &login);
172 
173     /**
174      * Returns the login that is used to mount this share.
175      *
176      * @returns the login.
177      */
178     QString login() const;
179 
180     /**
181      * Sets the URL of the share after some checks are passed.
182      *
183      * @param url             The URL of the network item
184      */
185     void setUrl(const QUrl &url);
186 
187     /**
188      * Sets the URL of the share.
189      *
190      * @param url             The URL of the network item
191      */
192     void setUrl(const QString &url);
193 
194     /**
195      * Returns the URL of this bookmark.
196      *
197      * @returns the URL
198      */
199     QUrl url() const;
200 
201     /**
202      * Set the category this bookmark belongs to.
203      *
204      * @param name            The category name
205      */
206     void setCategoryName(const QString &name);
207 
208     /**
209      * Returns the name of the category this bookmark is in.
210      *
211      * @returns the category name
212      */
213     QString categoryName() const;
214 
215     /**
216      * Sets the profile this bookmark belongs to. The profile is meant
217      * to distinguish between several network environments, like home
218      * and work, and is not an alternative to the categories.
219      *
220      * @param profile         The profile name
221      */
222     void setProfile(const QString &profile);
223 
224     /**
225      * Returns the name of the profile this bookmark belongs to.
226      *
227      * @returns the profile name
228      */
229     QString profile() const;
230 
231     /**
232      * This function sets the icon of the bookmark.
233      *
234      * @param icon          The icon
235      */
236     void setIcon(const QIcon &icon);
237 
238     /**
239      * This function returns the icon of the network item. By default, it
240      * is the null icon. You must set the appropriate icon either in
241      * a class that inherits this one or from somewhere else.
242      *
243      * @returns the network item's icon.
244      */
245     QIcon icon() const;
246 
247     /**
248      * Returns the display string. Prefer this over all other alternatives in your
249      * GUI.
250      * @returns the display string.
251      */
252     QString displayString() const;
253 
254   private:
255     const QScopedPointer<Smb4KBookmarkPrivate> d;
256 };
257 
258 #endif
259