diff options
Diffstat (limited to 'src/bookmarks/bookmarkstreemodel.h')
-rw-r--r-- | src/bookmarks/bookmarkstreemodel.h | 64 |
1 files changed, 49 insertions, 15 deletions
diff --git a/src/bookmarks/bookmarkstreemodel.h b/src/bookmarks/bookmarkstreemodel.h index 9753999c..8dd0923c 100644 --- a/src/bookmarks/bookmarkstreemodel.h +++ b/src/bookmarks/bookmarkstreemodel.h @@ -3,6 +3,7 @@ * This file is a part of the rekonq project * * Copyright (C) 2009 by Nils Weigel <nehlsen at gmail dot com> +* Copyright (C) 2010 by Andrea Diamantini <adjam7 at gmail dot com> * * * This program is free software; you can redistribute it and/or @@ -27,13 +28,38 @@ #ifndef BOOKMARKSTREEMODEL_H #define BOOKMARKSTREEMODEL_H -// Qt Includes -#include <QAbstractItemModel> + +// Rekonq Includes +#include "rekonq_defines.h" // KDE includes #include <KBookmark> -class BookmarksTreeModel : public QAbstractItemModel +// Qt Includes +#include <QAbstractItemModel> + +class BtmItem +{ +public: + BtmItem(const KBookmark &bm); + ~BtmItem(); + QVariant data(int role = Qt::DisplayRole) const; + int row() const; + int childCount() const; + BtmItem* child(int n); + BtmItem* parent() const; + void appendChild(BtmItem *child); + void clear(); + KBookmark getBkm() const; + +private: + BtmItem *m_parent; + QList< BtmItem* > m_children; + KBookmark m_kbm; +}; + + +class REKONQ_TESTS_EXPORT BookmarksTreeModel : public QAbstractItemModel { Q_OBJECT Q_DISABLE_COPY(BookmarksTreeModel) @@ -42,28 +68,36 @@ public: explicit BookmarksTreeModel(QObject *parent = 0); ~BookmarksTreeModel(); - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - virtual Qt::ItemFlags flags(const QModelIndex &index) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; virtual QModelIndex parent(const QModelIndex &index) const; - virtual QVariant data(const QModelIndex &index, int role) const; -// virtual bool setData(const QModelIndex &index, const QVariant &value, int role); + virtual QVariant data(const QModelIndex &index, int role) const; + + virtual QStringList mimeTypes() const; + virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent); + virtual Qt::DropActions supportedDropActions() const; + virtual QMimeData *mimeData(const QModelIndexList & indexes) const; private slots: - void bookmarksChanged( const QString &groupAddress ); + void bookmarksChanged(); + void saveOnly(); + void reconnectManager(); -private: - class BtmItem; - BtmItem *m_root; +signals: + void bookmarksUpdated(); - void resetModel(); +private: + BtmItem *m_root; + void resetModel(); void setRoot(KBookmarkGroup bmg); - void populate( BtmItem *node, KBookmarkGroup bmg); + void populate(BtmItem *node, KBookmarkGroup bmg); + KBookmark bookmarkForIndex(const QModelIndex &index) const; }; #endif // BOOKMARKSTREEMODEL_H |