File indexing completed on 2024-04-21 04:58:16

0001 /* This file is part of the KDE project
0002     SPDX-FileCopyrightText: 2009 Pino Toscano <pino@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KONQ_HISTORYMODEL_H
0008 #define KONQ_HISTORYMODEL_H
0009 
0010 #include <QAbstractItemModel>
0011 
0012 #include "konq_historyentry.h"
0013 
0014 namespace KHM
0015 {
0016 struct Entry;
0017 struct GroupEntry;
0018 struct RootEntry;
0019 struct HistoryEntry;
0020 }
0021 
0022 class KonqHistoryModel : public QAbstractItemModel
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     explicit KonqHistoryModel(QObject *parent = nullptr);
0028     ~KonqHistoryModel() override;
0029 
0030     // reimplementations from QAbstractItemModel
0031     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0032     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0033     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
0034     QModelIndex parent(const QModelIndex &index) const override;
0035     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0036 
0037     void deleteItem(const QModelIndex &index);
0038 
0039 public Q_SLOTS:
0040     void clear();
0041 
0042 private Q_SLOTS:
0043     void slotEntryAdded(const KonqHistoryEntry &);
0044     void slotEntryRemoved(const KonqHistoryEntry &);
0045 
0046 private:
0047     enum SignalEmission { EmitSignals, DontEmitSignals };
0048     KHM::Entry *entryFromIndex(const QModelIndex &index, bool returnRootIfNull = false) const;
0049     KHM::GroupEntry *getGroupItem(const QUrl &url, SignalEmission se);
0050     QModelIndex indexFor(KHM::HistoryEntry *entry) const;
0051     QModelIndex indexFor(KHM::GroupEntry *entry) const;
0052 
0053     KHM::RootEntry *m_root;
0054 };
0055 
0056 #endif // KONQ_HISTORYMODEL_H