File indexing completed on 2024-12-08 07:35:48
0001 /* 0002 The configuration page for bookmarks 0003 0004 SPDX-FileCopyrightText: 2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef SMB4KCONFIGPAGEBOOKMARKS_H 0009 #define SMB4KCONFIGPAGEBOOKMARKS_H 0010 0011 // application specific includes 0012 #include "core/smb4kglobal.h" 0013 0014 // Qt includes 0015 #include <QLabel> 0016 #include <QTreeWidget> 0017 0018 // KDE includes 0019 #include <KComboBox> 0020 #include <KLineEdit> 0021 #include <QPushButton> 0022 0023 /** 0024 * This configuration page contains the bookmarks 0025 * 0026 * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net> 0027 * @since 3.3.0 0028 */ 0029 0030 class Smb4KConfigPageBookmarks : public QWidget 0031 { 0032 Q_OBJECT 0033 0034 public: 0035 /** 0036 * Constructor 0037 */ 0038 explicit Smb4KConfigPageBookmarks(QWidget *parent = nullptr); 0039 0040 /** 0041 * Destructor 0042 */ 0043 virtual ~Smb4KConfigPageBookmarks(); 0044 0045 /** 0046 * Returns TRUE if the bookmarks have possibly changed 0047 * and FALSE otherwise. 0048 */ 0049 bool bookmarksChanged() const; 0050 0051 /** 0052 * Set the completion items for the editor widgets on demand 0053 * 0054 * @param items A map containing the completion items for 0055 * each editor widget 0056 */ 0057 void setCompletionItems(const QMap<QString, QStringList> &items); 0058 0059 /** 0060 * Get the completion items from the editor widgets on demand 0061 */ 0062 QMap<QString, QStringList> completionItems() const; 0063 0064 protected: 0065 /** 0066 * Reimplemented from QObject 0067 */ 0068 bool eventFilter(QObject *obj, QEvent *e) override; 0069 0070 Q_SIGNALS: 0071 /** 0072 * Emitted when the bookmarks may have been modified. 0073 */ 0074 void bookmarksModified(); 0075 0076 public Q_SLOTS: 0077 /** 0078 * Load the bookmarks 0079 */ 0080 void loadBookmarks(); 0081 0082 /** 0083 * Save the bookmarks 0084 */ 0085 void saveBookmarks(); 0086 0087 protected Q_SLOTS: 0088 void slotResetButtonClicked(bool checked); 0089 void slotEditButtonClicked(bool checked); 0090 void slotAddCategoryButtonClicked(bool checked); 0091 void slotRemoveButtonClicked(bool checked); 0092 void slotClearButtonClicked(bool checked); 0093 void slotCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); 0094 void slotItemSelectionChanged(); 0095 void slotItemDoubleClicked(QTreeWidgetItem *item, int column); 0096 void slotLabelChanged(const QString &text); 0097 void slotLabelEdited(); 0098 void slotCategoryChanged(const QString &text); 0099 void slotCategoryEdited(); 0100 void slotUserNameChanged(const QString &text); 0101 void slotUserNameEdited(); 0102 void slotWorkgroupChanged(const QString &text); 0103 void slotWorkgroupEdited(); 0104 void slotIpAddressChanged(const QString &text); 0105 void slotIpAddressEdited(); 0106 void slotEnableButtons(); 0107 void slotIconSizeChanged(int group); 0108 void sortItems(); 0109 0110 private: 0111 void checkValues(); 0112 enum Role { TypeRole = Qt::UserRole, DataRole = Qt::UserRole + 1 }; 0113 enum Type { CategoryType = Qt::UserRole + 100, BookmarkType = Qt::UserRole + 101 }; 0114 QTreeWidgetItem *addCategoryItem(const QString &text); 0115 void startEditingCategoryItem(QTreeWidgetItem *item); 0116 void endEditingCategoryItem(QTreeWidgetItem *item); 0117 QList<BookmarkPtr> m_bookmarks; 0118 QTreeWidget *m_treeWidget; 0119 QWidget *m_editorWidget; 0120 QLabel *m_labelLabel; 0121 KLineEdit *m_labelEdit; 0122 QLabel *m_categoryLabel; 0123 KComboBox *m_categoryEdit; 0124 QLabel *m_userNameLabel; 0125 KLineEdit *m_userNameEdit; 0126 QLabel *m_workgroupLabel; 0127 KLineEdit *m_workgroupEdit; 0128 QLabel *m_ipAddressLabel; 0129 KLineEdit *m_ipAddressEdit; 0130 QPushButton *m_resetButton; 0131 QPushButton *m_editButton; 0132 QPushButton *m_addCategoryButton; 0133 QPushButton *m_removeButton; 0134 QPushButton *m_clearButton; 0135 bool m_bookmarksChanged; 0136 bool m_savingBookmarks; 0137 }; 0138 0139 #endif