1 /*************************************************************************** 2 Private classes for the bookmark handler 3 ------------------- 4 begin : Sun Mar 20 2011 5 copyright : (C) 2011-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, 51 Franklin Street, Suite 500, Boston, * 23 * MA 02110-1335, USA * 24 ***************************************************************************/ 25 26 #ifndef SMB4KBOOKMARKHANDLER_P_H 27 #define SMB4KBOOKMARKHANDLER_P_H 28 29 // application specific includes 30 #include "smb4kbookmarkhandler.h" 31 #include "smb4kglobal.h" 32 33 // Qt includes 34 #include <QString> 35 #include <QUrl> 36 #include <QTreeWidget> 37 #include <QDialog> 38 #include <QListWidget> 39 #include <QAction> 40 #include <QPushButton> 41 #include <QPointer> 42 43 // KDE includes 44 #include <KCompletion/KLineEdit> 45 #include <KCompletion/KComboBox> 46 #include <KWidgetsAddons/KActionMenu> 47 48 49 class Q_DECL_EXPORT Smb4KBookmarkDialog : public QDialog 50 { 51 Q_OBJECT 52 53 public: 54 /** 55 * The constructor 56 * 57 * @param bookmarks The list of bookmarks that are to be saved 58 * 59 * @param categories The list of available bookmark categories 60 * 61 * @param parent The parent widget 62 */ 63 Smb4KBookmarkDialog(const QList<BookmarkPtr> &bookmarks, const QStringList &categories, QWidget *parent); 64 65 /** 66 * The destructor 67 */ 68 ~Smb4KBookmarkDialog(); 69 70 /** 71 * Returns the list of bookmarks including all changes that could 72 * be made in the bookmark dialog. 73 * 74 * @returns the list of bookmarks. 75 */ 76 const QList<BookmarkPtr> &bookmarks(); 77 78 protected Q_SLOTS: 79 /** 80 * Called when a bookmark was clicked in the list widget. 81 */ 82 void slotBookmarkClicked(QListWidgetItem *bookmarkItem); 83 84 /** 85 * Called when the label is edited by the user 86 */ 87 void slotLabelEdited(); 88 89 /** 90 * Called when the category is edited by the user 91 */ 92 void slotCategoryEdited(); 93 94 /** 95 * Called when the OK button was clicked 96 */ 97 void slotDialogAccepted(); 98 99 /** 100 * Called when the icon size changed 101 */ 102 void slotIconSizeChanged(int group); 103 104 private: 105 /** 106 * Sets up the view 107 */ 108 void setupView(); 109 110 /** 111 * Load the list of bookmarks and the one of the categories 112 */ 113 void loadLists(const QList<BookmarkPtr> &bookmarks, const QStringList &categories); 114 115 /** 116 * Finds the bookmark in the list 117 */ 118 BookmarkPtr findBookmark(const QUrl &url); 119 120 /** 121 * The list of bookmarks 122 */ 123 QList<BookmarkPtr> m_bookmarks; 124 125 /** 126 * The list of groups 127 */ 128 QStringList m_categories; 129 }; 130 131 132 class Smb4KBookmarkEditor : public QDialog 133 { 134 Q_OBJECT 135 136 public: 137 /** 138 * The constructor. 139 * 140 * @param bookmarks The list of all bookmarks 141 * 142 * @param parent The parent of this dialog. 143 */ 144 explicit Smb4KBookmarkEditor(const QList<BookmarkPtr> &bookmarks, QWidget *parent = 0); 145 146 /** 147 * The destructor. 148 */ 149 ~Smb4KBookmarkEditor(); 150 151 /** 152 * Load the bookmarks into the view 153 */ 154 void loadBookmarks(); 155 156 /** 157 * Return the list of edited bookmarks 158 */ 159 QList<BookmarkPtr> editedBookmarks(); 160 161 protected: 162 /** 163 * Reimplemented from QObject 164 */ 165 bool eventFilter(QObject *obj, QEvent *e) override; 166 167 protected Q_SLOTS: 168 /** 169 * Called when a bookmark was clicked 170 */ 171 void slotItemClicked(QTreeWidgetItem *item, int col); 172 173 /** 174 * Called when the context menu was requested 175 */ 176 void slotContextMenuRequested(const QPoint &pos); 177 178 /** 179 * Called when the label is edited by the user 180 */ 181 void slotLabelEdited(); 182 183 /** 184 * Called when the category is edited by the user 185 */ 186 void slotCategoryEdited(); 187 188 /** 189 * Called when the IP address is edited by the user 190 */ 191 void slotIpEdited(); 192 193 /** 194 * Called when the workgroup name is edited by the user 195 */ 196 void slotWorkgroupNameEdited(); 197 198 /** 199 * Called when the login is edited by the user 200 */ 201 void slotLoginEdited(); 202 203 /** 204 * Called when the add action was triggered 205 */ 206 void slotAddCategoryTriggered(bool checked); 207 208 /** 209 * Called when the delete action was triggered 210 */ 211 void slotDeleteTriggered(bool checked); 212 213 /** 214 * Called when the clear action was triggered 215 */ 216 void slotClearTriggered(bool checked); 217 218 /** 219 * Called when the Ok button was clicked 220 */ 221 void slotDialogAccepted(); 222 223 /** 224 * Called when the Cancel button was clicked 225 */ 226 void slotDialogRejected(); 227 228 /** 229 * Called when the icon size changed 230 */ 231 void slotIconSizeChanged(int group); 232 233 /** 234 * Do adjustments in the list view 235 */ 236 void slotAdjust(); 237 238 private: 239 /** 240 * Set up the view 241 */ 242 void setupView(); 243 244 /** 245 * Finds the bookmark in the list 246 */ 247 BookmarkPtr findBookmark(const QUrl &url); 248 249 /** 250 * List of the bookmarks that are being processed 251 */ 252 QList<BookmarkPtr> m_bookmarks; 253 254 /** 255 * The list of groups 256 */ 257 QStringList m_categories; 258 }; 259 260 261 class Smb4KBookmarkHandlerPrivate 262 { 263 public: 264 QList<BookmarkPtr> bookmarks; 265 QPointer<Smb4KBookmarkEditor> editor; 266 }; 267 268 269 class Smb4KBookmarkHandlerStatic 270 { 271 public: 272 Smb4KBookmarkHandler instance; 273 }; 274 275 #endif 276