File indexing completed on 2024-05-05 17:01:32
0001 /*************************************************************************** 0002 This class derives from QObject and encapsulates a bookmark item. It 0003 is for use with QtQuick. 0004 ------------------- 0005 begin : Fr Mai 11 2013 0006 copyright : (C) 2013-2019 by Alexander Reinholdt 0007 email : alexander.reinholdt@kdemail.net 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 * This program is distributed in the hope that it will be useful, but * 0017 * WITHOUT ANY WARRANTY; without even the implied warranty of * 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0019 * General Public License for more details. * 0020 * * 0021 * You should have received a copy of the GNU General Public License * 0022 * along with this program; if not, write to the * 0023 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* 0024 * MA 02110-1335, USA * 0025 ***************************************************************************/ 0026 0027 #ifndef SMB4KBOOKMARKOBJECT_H 0028 #define SMB4KBOOKMARKOBJECT_H 0029 0030 // application specific includes 0031 #include "core/smb4kbookmark.h" 0032 0033 // Qt includes 0034 #include <QObject> 0035 #include <QString> 0036 #include <QScopedPointer> 0037 #include <QUrl> 0038 #include <QIcon> 0039 0040 // forward declarations 0041 class Smb4KBookmarkObjectPrivate; 0042 0043 /** 0044 * This class derives from QObject and makes the main functions of a 0045 * bookmark available. Its main purpose is to be used with QtQuick 0046 * and Plasma. 0047 * 0048 * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0049 * @since 1.1.0 0050 */ 0051 0052 class Q_DECL_EXPORT Smb4KBookmarkObject : public QObject 0053 { 0054 Q_OBJECT 0055 0056 friend class Smb4KBookmarkObjectPrivate; 0057 0058 Q_PROPERTY(QString workgroupName READ workgroupName WRITE setWorkgroupName NOTIFY changed) 0059 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY changed) 0060 Q_PROPERTY(QUrl url READ url WRITE setURL NOTIFY changed) 0061 Q_PROPERTY(QString groupName READ groupName WRITE setGroupName NOTIFY changed) 0062 Q_PROPERTY(bool isGroup READ isGroup WRITE setGroup NOTIFY changed) 0063 Q_PROPERTY(bool isMounted READ isMounted WRITE setMounted NOTIFY changed) 0064 Q_PROPERTY(QString hostName READ hostName CONSTANT) 0065 Q_PROPERTY(QString shareName READ shareName CONSTANT) 0066 Q_PROPERTY(QString login READ login WRITE setLogin NOTIFY changed) 0067 Q_PROPERTY(QString hostIP READ hostIP WRITE setHostIP NOTIFY changed) 0068 0069 public: 0070 /** 0071 * Constructor 0072 */ 0073 explicit Smb4KBookmarkObject(Smb4KBookmark *bookmark, QObject *parent = 0); 0074 0075 /** 0076 * Constructor for a bookmark group 0077 */ 0078 explicit Smb4KBookmarkObject(const QString &groupName, QObject *parent = 0); 0079 0080 /** 0081 * Empty constructor 0082 */ 0083 explicit Smb4KBookmarkObject(QObject *parent = 0); 0084 0085 /** 0086 * Destructor 0087 */ 0088 virtual ~Smb4KBookmarkObject(); 0089 0090 /** 0091 * This function returns the workgroup where the bookmarked 0092 * share is located. 0093 * 0094 * @returns the workgroup name 0095 */ 0096 QString workgroupName() const; 0097 0098 /** 0099 * Set the workgroup of the bookmark object. 0100 * 0101 * @param name The workgroup name 0102 */ 0103 void setWorkgroupName(const QString &name); 0104 0105 /** 0106 * This function returns the name of the host where the bookmarked 0107 * share is located. 0108 * @returns the host name 0109 */ 0110 QString hostName() const; 0111 0112 /** 0113 * This function returns the name of the bookmarked share. 0114 * @returns the share name 0115 */ 0116 QString shareName() const; 0117 0118 /** 0119 * This function returns the optional label of the bookmarked 0120 * share. 0121 * 0122 * @returns the label 0123 */ 0124 QString label() const; 0125 0126 /** 0127 * Set the label of the bookmarked share. 0128 * 0129 * @param label The label 0130 */ 0131 void setLabel(const QString &label); 0132 0133 /** 0134 * This function returns the URL of this bookmark. 0135 * 0136 * @returns the URL 0137 */ 0138 QUrl url() const; 0139 0140 /** 0141 * Set the URL of this bookmark. 0142 * 0143 * @param url The URL 0144 */ 0145 void setURL(const QUrl &url); 0146 0147 /** 0148 * This function returns the name of the group the bookmark is 0149 * in. 0150 * 0151 * @returns the group 0152 */ 0153 QString groupName() const; 0154 0155 /** 0156 * Set the name of the group this bookmark is in. 0157 * 0158 * @param name The group name 0159 */ 0160 void setGroupName(const QString &name); 0161 0162 /** 0163 * This function returns TRUE if this object represents a bookmark 0164 * group. 0165 * 0166 * @returns TRUE if this object is a bookmark group 0167 */ 0168 bool isGroup() const; 0169 0170 /** 0171 * For a bookmark group @p group has to be set to TRUE. 0172 * 0173 * @param group TRUE for a bookmark group and FALSE otherwise 0174 */ 0175 void setGroup(bool group); 0176 0177 /** 0178 * Returns TRUE if the share that is represented by this bookmark 0179 * is mounted. 0180 * 0181 * @returns TRUE if the bookmarked share is mounted 0182 */ 0183 bool isMounted() const; 0184 0185 /** 0186 * For a share that is mounted set this to TRUE. 0187 * 0188 * @param mounted Set to TRUE for a mounted share 0189 */ 0190 void setMounted(bool mounted); 0191 0192 /** 0193 * Returns the login for the bookmarked share. 0194 * 0195 * @returns the login name 0196 */ 0197 QString login() const; 0198 0199 /** 0200 * Set the login for the bookmarked share. 0201 * 0202 * @param name The login name 0203 */ 0204 void setLogin(const QString &name); 0205 0206 /** 0207 * Returns the IP address of the host 0208 * 0209 * @returns the IP address of the host 0210 */ 0211 QString hostIP() const; 0212 0213 /** 0214 * Set the IP address of the host 0215 * 0216 * @param ip The IP address 0217 */ 0218 void setHostIP(const QString &ip); 0219 0220 Q_SIGNALS: 0221 /** 0222 * This signal is emitted if something changed. 0223 */ 0224 void changed(); 0225 0226 private: 0227 const QScopedPointer<Smb4KBookmarkObjectPrivate> d; 0228 }; 0229 0230 #endif 0231