summaryrefslogtreecommitdiff
path: root/src/bookmarks/bookmarkstreemodel.cpp
diff options
context:
space:
mode:
authorJon Ander Peñalba <jonan88@gmail.com>2010-08-20 12:03:14 +0200
committerJon Ander Peñalba <jonan88@gmail.com>2010-08-20 12:03:14 +0200
commit8d48c62aaf14e023b49c4701c26552732e7c609b (patch)
treee363e4492287c489a5954a54b1984475cc2ede5a /src/bookmarks/bookmarkstreemodel.cpp
parentBookmarks panel code clean-up (diff)
downloadrekonq-8d48c62aaf14e023b49c4701c26552732e7c609b.tar.xz
Bookmarks panel code reordered
Diffstat (limited to 'src/bookmarks/bookmarkstreemodel.cpp')
-rw-r--r--src/bookmarks/bookmarkstreemodel.cpp112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp
index 5bf1f769..8e95a615 100644
--- a/src/bookmarks/bookmarkstreemodel.cpp
+++ b/src/bookmarks/bookmarkstreemodel.cpp
@@ -250,6 +250,62 @@ QVariant BookmarksTreeModel::data(const QModelIndex &index, int role) const
}
+QStringList BookmarksTreeModel::mimeTypes() const
+{
+ return KBookmark::List::mimeDataTypes();
+}
+
+
+bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
+{
+ if (action != Qt::MoveAction || !data->hasFormat("application/rekonq-bookmark"))
+ return false;
+
+ QByteArray addresses = data->data("application/rekonq-bookmark");
+ KBookmark bookmark = Application::bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
+
+ KBookmarkGroup root;
+ if (parent.isValid())
+ root = bookmarkForIndex(parent).toGroup();
+ else
+ root = Application::bookmarkProvider()->rootGroup();
+
+ QModelIndex destIndex = index(row, column, parent);
+
+ if (destIndex.isValid() && row != -1)
+ {
+ root.moveBookmark(bookmark, root.previous(bookmarkForIndex(destIndex)));
+ }
+ else
+ {
+ root.deleteBookmark(bookmark);
+ root.addBookmark(bookmark);
+ }
+
+ Application::bookmarkProvider()->bookmarkManager()->emitChanged();
+
+ return true;
+}
+
+
+Qt::DropActions BookmarksTreeModel::supportedDropActions() const
+{
+ return Qt::MoveAction;
+}
+
+
+QMimeData* BookmarksTreeModel::mimeData(const QModelIndexList &indexes) const
+{
+ QMimeData *mimeData = new QMimeData;
+
+ QByteArray address = bookmarkForIndex(indexes.first()).address().toLatin1();
+ mimeData->setData("application/rekonq-bookmark", address);
+ bookmarkForIndex(indexes.first()).populateMimeData(mimeData);
+
+ return mimeData;
+}
+
+
void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress)
{
if (groupAddress.isEmpty())
@@ -325,59 +381,3 @@ KBookmark BookmarksTreeModel::bookmarkForIndex(const QModelIndex &index) const
{
return static_cast<BtmItem*>(index.internalPointer())->getBkm();
}
-
-
-Qt::DropActions BookmarksTreeModel::supportedDropActions() const
-{
- return Qt::MoveAction;
-}
-
-
-QStringList BookmarksTreeModel::mimeTypes() const
-{
- return KBookmark::List::mimeDataTypes();
-}
-
-
-QMimeData* BookmarksTreeModel::mimeData(const QModelIndexList &indexes) const
-{
- QMimeData *mimeData = new QMimeData;
-
- QByteArray address = bookmarkForIndex(indexes.first()).address().toLatin1();
- mimeData->setData("application/rekonq-bookmark", address);
- bookmarkForIndex(indexes.first()).populateMimeData(mimeData);
-
- return mimeData;
-}
-
-
-bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
-{
- if (action != Qt::MoveAction || !data->hasFormat("application/rekonq-bookmark"))
- return false;
-
- QByteArray addresses = data->data("application/rekonq-bookmark");
- KBookmark bookmark = Application::bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
-
- KBookmarkGroup root;
- if (parent.isValid())
- root = bookmarkForIndex(parent).toGroup();
- else
- root = Application::bookmarkProvider()->rootGroup();
-
- QModelIndex destIndex = index(row, column, parent);
-
- if (destIndex.isValid() && row != -1)
- {
- root.moveBookmark(bookmark, root.previous(bookmarkForIndex(destIndex)));
- }
- else
- {
- root.deleteBookmark(bookmark);
- root.addBookmark(bookmark);
- }
-
- Application::bookmarkProvider()->bookmarkManager()->emitChanged();
-
- return true;
-}