File indexing completed on 2024-03-24 16:27:17
0001 /*************************************************************************** 0002 Private classes for the bookmark handler 0003 ------------------- 0004 begin : Sun Mar 20 2011 0005 copyright : (C) 2011-2018 by Alexander Reinholdt 0006 email : alexander.reinholdt@kdemail.net 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * This program is free software; you can redistribute it and/or modify * 0011 * it under the terms of the GNU General Public License as published by * 0012 * the Free Software Foundation; either version 2 of the License, or * 0013 * (at your option) any later version. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, but * 0016 * WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0018 * General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program; if not, write to the * 0022 * Free Software Foundation, 51 Franklin Street, Suite 500, Boston, * 0023 * MA 02110-1335, USA * 0024 ***************************************************************************/ 0025 0026 #ifndef SMB4KBOOKMARKHANDLER_P_H 0027 #define SMB4KBOOKMARKHANDLER_P_H 0028 0029 // application specific includes 0030 #include "smb4kbookmarkhandler.h" 0031 #include "smb4kglobal.h" 0032 0033 // Qt includes 0034 #include <QString> 0035 #include <QUrl> 0036 #include <QTreeWidget> 0037 #include <QDialog> 0038 #include <QListWidget> 0039 #include <QAction> 0040 #include <QPushButton> 0041 #include <QPointer> 0042 0043 // KDE includes 0044 #include <KCompletion/KLineEdit> 0045 #include <KCompletion/KComboBox> 0046 #include <KWidgetsAddons/KActionMenu> 0047 0048 0049 class Q_DECL_EXPORT Smb4KBookmarkDialog : public QDialog 0050 { 0051 Q_OBJECT 0052 0053 public: 0054 /** 0055 * The constructor 0056 * 0057 * @param bookmarks The list of bookmarks that are to be saved 0058 * 0059 * @param groups The list of available bookmark groups 0060 * 0061 * @param parent The parent widget 0062 */ 0063 Smb4KBookmarkDialog(const QList<BookmarkPtr> &bookmarks, 0064 const QStringList &groups, 0065 QWidget *parent); 0066 0067 /** 0068 * The destructor 0069 */ 0070 ~Smb4KBookmarkDialog(); 0071 0072 /** 0073 * Returns the list of bookmarks including all changes that could 0074 * be made in the bookmark dialog. 0075 * 0076 * @returns the list of bookmarks. 0077 */ 0078 const QList<BookmarkPtr> &bookmarks(); 0079 0080 protected Q_SLOTS: 0081 /** 0082 * Called when a bookmark was clicked in the list widget. 0083 */ 0084 void slotBookmarkClicked(QListWidgetItem *bookmark_item); 0085 0086 /** 0087 * Called when the label is edited by the user 0088 */ 0089 void slotLabelEdited(); 0090 0091 /** 0092 * Called when the group is edited by the user 0093 */ 0094 void slotGroupEdited(); 0095 0096 /** 0097 * Called when the OK button was clicked 0098 */ 0099 void slotDialogAccepted(); 0100 0101 /** 0102 * Called when the icon size changed 0103 */ 0104 void slotIconSizeChanged(int group); 0105 0106 private: 0107 /** 0108 * Sets up the view 0109 */ 0110 void setupView(); 0111 0112 /** 0113 * Load the list of bookmarks and the one of the groups 0114 */ 0115 void loadLists(const QList<BookmarkPtr> &bookmarks, const QStringList &groups); 0116 0117 /** 0118 * Finds the bookmark in the list 0119 */ 0120 BookmarkPtr findBookmark(const QUrl &url); 0121 0122 /** 0123 * Ok push button 0124 */ 0125 QPushButton *m_ok_button; 0126 0127 /** 0128 * Cancel push button 0129 */ 0130 QPushButton *m_cancel_button; 0131 0132 /** 0133 * The list of bookmarks 0134 */ 0135 QList<BookmarkPtr> m_bookmarks; 0136 0137 /** 0138 * The list of groups 0139 */ 0140 QStringList m_groups; 0141 0142 /** 0143 * The tree widget for the potential bookmarks 0144 */ 0145 QListWidget *m_widget; 0146 0147 /** 0148 * The widget containing the editors 0149 */ 0150 QWidget *m_editors; 0151 0152 /** 0153 * The label 0154 */ 0155 KLineEdit *m_label_edit; 0156 0157 /** 0158 * The groups 0159 */ 0160 KComboBox *m_group_combo; 0161 }; 0162 0163 0164 class Smb4KBookmarkEditor : public QDialog 0165 { 0166 Q_OBJECT 0167 0168 public: 0169 /** 0170 * The constructor. 0171 * 0172 * @param bookmarks The list of all bookmarks 0173 * 0174 * @param parent The parent of this dialog. 0175 */ 0176 explicit Smb4KBookmarkEditor(const QList<BookmarkPtr> &bookmarks, QWidget *parent = 0); 0177 0178 /** 0179 * The destructor. 0180 */ 0181 ~Smb4KBookmarkEditor(); 0182 0183 /** 0184 * Load the bookmarks into the view 0185 */ 0186 void loadBookmarks(); 0187 0188 /** 0189 * Return the list of edited bookmarks 0190 */ 0191 QList<BookmarkPtr> editedBookmarks(); 0192 0193 protected: 0194 /** 0195 * Reimplemented from QObject 0196 */ 0197 bool eventFilter(QObject *obj, QEvent *e) override; 0198 0199 protected Q_SLOTS: 0200 /** 0201 * Called when a bookmark was clicked 0202 */ 0203 void slotItemClicked(QTreeWidgetItem *item, int col); 0204 0205 /** 0206 * Called when the context menu was requested 0207 */ 0208 void slotContextMenuRequested(const QPoint &pos); 0209 0210 /** 0211 * Called when the label is edited by the user 0212 */ 0213 void slotLabelEdited(); 0214 0215 /** 0216 * Called when the group is edited by the user 0217 */ 0218 void slotGroupEdited(); 0219 0220 /** 0221 * Called when the IP address is edited by the user 0222 */ 0223 void slotIPEdited(); 0224 0225 /** 0226 * Called when the login is edited by the user 0227 */ 0228 void slotLoginEdited(); 0229 0230 /** 0231 * Called when the add action was triggered 0232 */ 0233 void slotAddGroupTriggered(bool checked); 0234 0235 /** 0236 * Called when the delete action was triggered 0237 */ 0238 void slotDeleteTriggered(bool checked); 0239 0240 /** 0241 * Called when the clear action was triggered 0242 */ 0243 void slotClearTriggered(bool checked); 0244 0245 /** 0246 * Called when the Ok button was clicked 0247 */ 0248 void slotDialogAccepted(); 0249 0250 /** 0251 * Called when the Cancel button was clicked 0252 */ 0253 void slotDialogRejected(); 0254 0255 /** 0256 * Called when the icon size changed 0257 */ 0258 void slotIconSizeChanged(int group); 0259 0260 /** 0261 * Do adjustments in the list view 0262 */ 0263 void slotAdjust(); 0264 0265 private: 0266 /** 0267 * Set up the view 0268 */ 0269 void setupView(); 0270 0271 /** 0272 * Finds the bookmark in the list 0273 */ 0274 BookmarkPtr findBookmark(const QUrl &url); 0275 0276 /** 0277 * Ok push button 0278 */ 0279 QPushButton *m_ok_button; 0280 0281 /** 0282 * Cancel push button 0283 */ 0284 QPushButton *m_cancel_button; 0285 0286 /** 0287 * List of the bookmarks that are being processed 0288 */ 0289 QList<BookmarkPtr> m_bookmarks; 0290 0291 /** 0292 * Tree widget 0293 */ 0294 QTreeWidget *m_tree_widget; 0295 0296 /** 0297 * The widget containing the editors 0298 */ 0299 QWidget *m_editors; 0300 0301 /** 0302 * The label 0303 */ 0304 KLineEdit *m_label_edit; 0305 0306 /** 0307 * The IP address 0308 */ 0309 KLineEdit *m_ip_edit; 0310 0311 /** 0312 * The login 0313 */ 0314 KLineEdit *m_login_edit; 0315 0316 /** 0317 * The groups 0318 */ 0319 KComboBox *m_group_combo; 0320 0321 /** 0322 * The list of groups 0323 */ 0324 QStringList m_groups; 0325 0326 /** 0327 * Action menu 0328 */ 0329 KActionMenu *m_menu; 0330 0331 /** 0332 * Add group action 0333 */ 0334 QAction *m_add_group; 0335 0336 /** 0337 * Delete action 0338 */ 0339 QAction *m_delete; 0340 0341 /** 0342 * Clear action 0343 */ 0344 QAction *m_clear; 0345 }; 0346 0347 0348 class Smb4KBookmarkHandlerPrivate 0349 { 0350 public: 0351 QList<BookmarkPtr> bookmarks; 0352 QPointer<Smb4KBookmarkEditor> editor; 0353 }; 0354 0355 0356 class Smb4KBookmarkHandlerStatic 0357 { 0358 public: 0359 Smb4KBookmarkHandler instance; 0360 }; 0361 0362 #endif