File indexing completed on 2023-09-24 09:52:43
0001 /* This file is part of the KDE project 0002 Copyright (C) 2005 Daniel Teske <teske@squorn.de> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License version 2 as published by the Free Software Foundation. 0007 0008 This program is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 General Public License for more details. 0012 0013 You should have received a copy of the GNU General Public License 0014 along with this program; see the file COPYING. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef __bookmarklistview_h 0020 #define __bookmarklistview_h 0021 0022 #include <QSortFilterProxyModel> 0023 #include <QTreeView> 0024 0025 #include "kbookmarkmodel/view.h" 0026 0027 class KBookmarkModel; 0028 class BookmarkListView; 0029 class BookmarkFolderViewFilterModel; 0030 0031 class BookmarkFolderView : public KBookmarkView 0032 { 0033 Q_OBJECT 0034 public: 0035 explicit BookmarkFolderView(BookmarkListView *view, QWidget *parent = nullptr); 0036 ~BookmarkFolderView() override; 0037 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override; 0038 KBookmark bookmarkForIndex(const QModelIndex &idx) const override; 0039 private Q_SLOTS: 0040 void slotReset(); 0041 0042 private: 0043 BookmarkListView *mview; 0044 BookmarkFolderViewFilterModel *mmodel; 0045 }; 0046 0047 class BookmarkListView : public KBookmarkView 0048 { 0049 Q_OBJECT 0050 public: 0051 explicit BookmarkListView(QWidget *parent = nullptr); 0052 ~BookmarkListView() override; 0053 void loadColumnSetting(); 0054 void saveColumnSetting(); 0055 void setModel(QAbstractItemModel *model) override; 0056 KBookmark bookmarkForIndex(const QModelIndex &idx) const override; 0057 KBookmarkModel *bookmarkModel() const; 0058 0059 protected: 0060 void contextMenuEvent(QContextMenuEvent *e) override; 0061 }; 0062 0063 class BookmarkFolderViewFilterModel : public QSortFilterProxyModel 0064 { 0065 Q_OBJECT 0066 public: 0067 explicit BookmarkFolderViewFilterModel(QObject *parent = nullptr); 0068 ~BookmarkFolderViewFilterModel() override; 0069 QStringList mimeTypes() const override; 0070 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; 0071 0072 protected: 0073 bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const override; 0074 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; 0075 // FIXME check 0076 Qt::DropActions supportedDropActions() const override 0077 { 0078 return sourceModel()->supportedDropActions(); 0079 } 0080 }; 0081 #endif