1 /************************************************************************** 2 * Otter Browser: Web browser controlled by the user, not vice-versa. 3 <<<<<<< HEAD 4 * Copyright (C) 2015 - 2018 Michal Dutkiewicz aka Emdek <michal@emdek.pl> 5 ======= 6 * Copyright (C) 2015 - 2020 Michal Dutkiewicz aka Emdek <michal@emdek.pl> 7 >>>>>>> 97337a46c... Force layout reload after finishing drag 8 * 9 * This program is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 * 22 **************************************************************************/ 23 24 #ifndef OTTER_STARTPAGEMODEL_H 25 #define OTTER_STARTPAGEMODEL_H 26 27 #include "../../../core/BookmarksModel.h" 28 29 namespace Otter 30 { 31 32 class StartPageModel final : public QStandardItemModel 33 { 34 Q_OBJECT 35 36 public: 37 enum 38 { 39 IsDraggedRole = BookmarksModel::UserRole, 40 IsEmptyRole, 41 IsReloadingRole 42 }; 43 44 explicit StartPageModel(QObject *parent = nullptr); 45 46 QMimeData* mimeData(const QModelIndexList &indexes) const override; 47 static BookmarksModel::Bookmark* getBookmark(const QModelIndex &index); 48 static QString getThumbnailPath(quint64 identifier); 49 QVariant data(const QModelIndex &index, int role) const override; 50 QStringList mimeTypes() const override; 51 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; 52 bool event(QEvent *event) override; 53 54 public slots: 55 void reloadModel(); 56 void addTile(const QUrl &url); 57 void reloadTile(const QModelIndex &index, bool needsTitleUpdate = false); 58 59 protected: 60 struct ThumbnailRequestInformation final 61 { 62 quint64 bookmarkIdentifier = 0; 63 bool needsTitleUpdate = false; 64 }; 65 66 protected slots: 67 void handleOptionChanged(int identifier); 68 void handleDragEnded(); 69 void handleBookmarkModified(BookmarksModel::Bookmark *bookmark); 70 void handleBookmarkMoved(BookmarksModel::Bookmark *bookmark, BookmarksModel::Bookmark *previousParent); 71 void handleBookmarkRemoved(BookmarksModel::Bookmark *bookmark, BookmarksModel::Bookmark *previousParent); 72 void handleThumbnailCreated(const QUrl &url, const QPixmap &thumbnail, const QString &title); 73 74 private: 75 BookmarksModel::Bookmark *m_bookmark; 76 QHash<QUrl, ThumbnailRequestInformation> m_reloads; 77 78 signals: 79 void modelModified(); 80 void isReloadingTileChanged(const QModelIndex &index); 81 }; 82 83 } 84 85 #endif 86