File indexing completed on 2024-05-05 09:16:38
0001 /* 0002 This class derives from QObject and encapsulates a bookmark item. It 0003 is for use with QtQuick. 0004 0005 SPDX-FileCopyrightText: 2013-2022 Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef SMB4KBOOKMARKOBJECT_H 0010 #define SMB4KBOOKMARKOBJECT_H 0011 0012 // application specific includes 0013 #include "core/smb4kbookmark.h" 0014 0015 // Qt includes 0016 #include <QIcon> 0017 #include <QObject> 0018 #include <QScopedPointer> 0019 #include <QString> 0020 #include <QUrl> 0021 0022 // forward declarations 0023 class Smb4KBookmarkObjectPrivate; 0024 0025 /** 0026 * This class derives from QObject and makes the main functions of a 0027 * bookmark available. Its main purpose is to be used with QtQuick 0028 * and Plasma. 0029 * 0030 * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0031 * @since 1.1.0 0032 */ 0033 0034 class Q_DECL_EXPORT Smb4KBookmarkObject : public QObject 0035 { 0036 Q_OBJECT 0037 0038 friend class Smb4KBookmarkObjectPrivate; 0039 0040 Q_PROPERTY(QString workgroupName READ workgroupName WRITE setWorkgroupName NOTIFY changed) 0041 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY changed) 0042 Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY changed) 0043 Q_PROPERTY(QString categoryName READ categoryName WRITE setCategoryName NOTIFY changed) 0044 Q_PROPERTY(bool isCategory READ isCategory WRITE setCategory NOTIFY changed) 0045 Q_PROPERTY(bool isMounted READ isMounted WRITE setMounted NOTIFY changed) 0046 Q_PROPERTY(QString hostName READ hostName CONSTANT) 0047 Q_PROPERTY(QString shareName READ shareName CONSTANT) 0048 Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY changed) 0049 Q_PROPERTY(QString hostIpAddress READ hostIpAddress WRITE setHostIpAddress NOTIFY changed) 0050 0051 public: 0052 /** 0053 * Constructor 0054 */ 0055 explicit Smb4KBookmarkObject(Smb4KBookmark *bookmark, QObject *parent = nullptr); 0056 0057 /** 0058 * Constructor for a bookmark group 0059 */ 0060 explicit Smb4KBookmarkObject(const QString &categoryName, QObject *parent = nullptr); 0061 0062 /** 0063 * Empty constructor 0064 */ 0065 explicit Smb4KBookmarkObject(QObject *parent = nullptr); 0066 0067 /** 0068 * Destructor 0069 */ 0070 virtual ~Smb4KBookmarkObject(); 0071 0072 /** 0073 * This function returns the workgroup where the bookmarked 0074 * share is located. 0075 * 0076 * @returns the workgroup name 0077 */ 0078 QString workgroupName() const; 0079 0080 /** 0081 * Set the workgroup of the bookmark object. 0082 * 0083 * @param name The workgroup name 0084 */ 0085 void setWorkgroupName(const QString &name); 0086 0087 /** 0088 * This function returns the name of the host where the bookmarked 0089 * share is located. 0090 * @returns the host name 0091 */ 0092 QString hostName() const; 0093 0094 /** 0095 * This function returns the name of the bookmarked share. 0096 * @returns the share name 0097 */ 0098 QString shareName() const; 0099 0100 /** 0101 * This function returns the optional label of the bookmarked 0102 * share. 0103 * 0104 * @returns the label 0105 */ 0106 QString label() const; 0107 0108 /** 0109 * Set the label of the bookmarked share. 0110 * 0111 * @param label The label 0112 */ 0113 void setLabel(const QString &label); 0114 0115 /** 0116 * This function returns the URL of this bookmark. 0117 * 0118 * @returns the URL 0119 */ 0120 QUrl url() const; 0121 0122 /** 0123 * Set the URL of this bookmark. 0124 * 0125 * @param url The URL 0126 */ 0127 void setUrl(const QUrl &url); 0128 0129 /** 0130 * This function returns the name of the group the bookmark is 0131 * in. 0132 * 0133 * @returns the group 0134 */ 0135 QString categoryName() const; 0136 0137 /** 0138 * Set the name of the group this bookmark is in. 0139 * 0140 * @param name The group name 0141 */ 0142 void setCategoryName(const QString &name); 0143 0144 /** 0145 * This function returns TRUE if this object represents a bookmark 0146 * group. 0147 * 0148 * @returns TRUE if this object is a bookmark group 0149 */ 0150 bool isCategory() const; 0151 0152 /** 0153 * For a bookmark category @p category has to be set to TRUE. 0154 * 0155 * @param category TRUE for a bookmark group and FALSE otherwise 0156 */ 0157 void setCategory(bool category); 0158 0159 /** 0160 * Returns TRUE if the share that is represented by this bookmark 0161 * is mounted. 0162 * 0163 * @returns TRUE if the bookmarked share is mounted 0164 */ 0165 bool isMounted() const; 0166 0167 /** 0168 * For a share that is mounted set this to TRUE. 0169 * 0170 * @param mounted Set to TRUE for a mounted share 0171 */ 0172 void setMounted(bool mounted); 0173 0174 /** 0175 * Returns the user name for the bookmarked share. 0176 * 0177 * @returns the user name 0178 */ 0179 QString userName() const; 0180 0181 /** 0182 * Set the user name for the bookmarked share. 0183 * 0184 * @param name The user name 0185 */ 0186 void setUserName(const QString &name); 0187 0188 /** 0189 * Returns the IP address of the host 0190 * 0191 * @returns the IP address of the host 0192 */ 0193 QString hostIpAddress() const; 0194 0195 /** 0196 * Set the IP address of the host 0197 * 0198 * @param ip The IP address 0199 */ 0200 void setHostIpAddress(const QString &ip); 0201 0202 Q_SIGNALS: 0203 /** 0204 * This signal is emitted if something changed. 0205 */ 0206 void changed(); 0207 0208 private: 0209 const QScopedPointer<Smb4KBookmarkObjectPrivate> d; 0210 }; 0211 0212 #endif