File indexing completed on 2024-04-21 05:01:36
0001 /* 0002 This is the bookmark container for Smb4K (next generation). 0003 0004 SPDX-FileCopyrightText: 2008-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef SMB4KBOOKMARK_H 0009 #define SMB4KBOOKMARK_H 0010 0011 // application specific includes 0012 #include "smb4kglobalenums.h" 0013 0014 // Qt includes 0015 #include <QIcon> 0016 #include <QMetaType> 0017 #include <QScopedPointer> 0018 #include <QString> 0019 #include <QUrl> 0020 0021 // forward declarations 0022 class Smb4KShare; 0023 class Smb4KBookmarkPrivate; 0024 0025 /** 0026 * This is the container class for bookmarks in Smb4K. It is a complete 0027 * rewrite of the previous class and comes with several improvements. 0028 * 0029 * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0030 */ 0031 0032 class Q_DECL_EXPORT Smb4KBookmark 0033 { 0034 friend class Smb4KBookmarkPrivate; 0035 0036 public: 0037 /** 0038 * The constructor. 0039 * 0040 * @param share The share for which the bookmark should 0041 * be created. 0042 * 0043 * @param label The optional bookmark label. 0044 */ 0045 explicit Smb4KBookmark(Smb4KShare *share, const QString &label = QString()); 0046 0047 /** 0048 * The copy constructor. 0049 * 0050 * @param bookmark The bookmark that should be copied. 0051 */ 0052 Smb4KBookmark(const Smb4KBookmark &bookmark); 0053 0054 /** 0055 * The empty constructor. 0056 */ 0057 Smb4KBookmark(); 0058 0059 /** 0060 * The destructor 0061 */ 0062 ~Smb4KBookmark(); 0063 0064 /** 0065 * Set the share item. 0066 * 0067 * @param share The share 0068 */ 0069 void setShare(Smb4KShare *share) const; 0070 0071 /** 0072 * Set the workgroup name. 0073 * 0074 * @param workgroup The workgroup where the share is located. 0075 */ 0076 void setWorkgroupName(const QString &workgroup) const; 0077 0078 /** 0079 * Returns the workgroup/domain name. 0080 * 0081 * @returns the workgroup/domain name. 0082 */ 0083 QString workgroupName() const; 0084 0085 /** 0086 * Returns the host name. 0087 * 0088 * @returns the host name. 0089 */ 0090 QString hostName() const; 0091 0092 /** 0093 * Returns the share name. 0094 * 0095 * @returns the share name. 0096 */ 0097 QString shareName() const; 0098 0099 /** 0100 * Set the host's IP address. 0101 * 0102 * @param ip The host's IP address 0103 */ 0104 void setHostIpAddress(const QString &ip) const; 0105 0106 /** 0107 * Returns the host's IP address. 0108 * 0109 * @returns the host's IP address. 0110 */ 0111 QString hostIpAddress() const; 0112 0113 /** 0114 * Set the share's type. 0115 * 0116 * @param type The type of the share. 0117 */ 0118 void setShareType(Smb4KGlobal::ShareType type) const; 0119 0120 /** 0121 * Returns the share's type. 0122 * 0123 * @returns the type of the share. 0124 */ 0125 Smb4KGlobal::ShareType shareType() const; 0126 0127 /** 0128 * Set the (optional) bookmark label. 0129 * 0130 * @param label The bookmark's label 0131 */ 0132 void setLabel(const QString &label) const; 0133 0134 /** 0135 * Returns the bookmark's label. 0136 * 0137 * @returns the bookmark's label. 0138 */ 0139 QString label() const; 0140 0141 /** 0142 * Sets the user name that is used to mount this share. 0143 * 0144 * @param name The user name 0145 */ 0146 void setUserName(const QString &name) const; 0147 0148 /** 0149 * Returns the user name that is used to mount this share. 0150 * 0151 * @returns the user name. 0152 */ 0153 QString userName() const; 0154 0155 /** 0156 * Sets the URL of the share after some checks are passed. 0157 * 0158 * @param url The URL of the network item 0159 */ 0160 void setUrl(const QUrl &url) const; 0161 0162 /** 0163 * Returns the URL of this bookmark. 0164 * 0165 * @returns the URL 0166 */ 0167 QUrl url() const; 0168 0169 /** 0170 * Set the category this bookmark belongs to. 0171 * 0172 * @param name The category name 0173 */ 0174 void setCategoryName(const QString &name) const; 0175 0176 /** 0177 * Returns the name of the category this bookmark is in. 0178 * 0179 * @returns the category name 0180 */ 0181 QString categoryName() const; 0182 0183 /** 0184 * Sets the profile this bookmark belongs to. The profile is meant 0185 * to distinguish between several network environments, like home 0186 * and work, and is not an alternative to the categories. 0187 * 0188 * @param profile The profile name 0189 */ 0190 void setProfile(const QString &profile) const; 0191 0192 /** 0193 * Returns the name of the profile this bookmark belongs to. 0194 * 0195 * @returns the profile name 0196 */ 0197 QString profile() const; 0198 0199 /** 0200 * This function sets the icon of the bookmark. 0201 * 0202 * @param icon The icon 0203 */ 0204 void setIcon(const QIcon &icon) const; 0205 0206 /** 0207 * This function returns the icon of the network item. By default, it 0208 * is the null icon. You must set the appropriate icon either in 0209 * a class that inherits this one or from somewhere else. 0210 * 0211 * @returns the network item's icon. 0212 */ 0213 QIcon icon() const; 0214 0215 /** 0216 * Returns the display string. Prefer this over all other alternatives in your 0217 * GUI. 0218 * @returns the display string. 0219 */ 0220 QString displayString() const; 0221 0222 /** 0223 * Copy assignment operator 0224 */ 0225 Smb4KBookmark &operator=(const Smb4KBookmark &other); 0226 0227 private: 0228 QScopedPointer<Smb4KBookmarkPrivate> d; 0229 }; 0230 0231 Q_DECLARE_METATYPE(Smb4KBookmark) 0232 0233 #endif