summaryrefslogtreecommitdiff
path: root/src/bookmarks/bookmarkspanel.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/bookmarkspanel.cpp
parentBookmarks panel code clean-up (diff)
downloadrekonq-8d48c62aaf14e023b49c4701c26552732e7c609b.tar.xz
Bookmarks panel code reordered
Diffstat (limited to 'src/bookmarks/bookmarkspanel.cpp')
-rw-r--r--src/bookmarks/bookmarkspanel.cpp150
1 files changed, 75 insertions, 75 deletions
diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp
index 557fabc2..22701baa 100644
--- a/src/bookmarks/bookmarkspanel.cpp
+++ b/src/bookmarks/bookmarkspanel.cpp
@@ -76,6 +76,81 @@ void BookmarksPanel::showing(bool b)
}
+void BookmarksPanel::startLoadFoldedState()
+{
+ m_loadingState = true;
+ loadFoldedState(QModelIndex());
+ m_loadingState = false;
+}
+
+
+void BookmarksPanel::contextMenu(const QPoint &pos)
+{
+ if (m_loadingState)
+ return;
+
+ BookmarksContextMenu menu(bookmarkForIndex( m_treeView->indexAt(pos) ),
+ Application::bookmarkProvider()->bookmarkManager(),
+ Application::bookmarkProvider()->bookmarkOwner(),
+ this
+ );
+
+ menu.exec(m_treeView->mapToGlobal(pos));
+}
+
+
+void BookmarksPanel::deleteBookmark()
+{
+ QModelIndex index = m_treeView->currentIndex();
+ if (m_loadingState || !index.isValid())
+ return;
+
+ Application::bookmarkProvider()->bookmarkOwner()->bookmarkSelected(bookmarkForIndex(index));
+ Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark();
+}
+
+
+void BookmarksPanel::onCollapse(const QModelIndex &index)
+{
+ if (m_loadingState)
+ return;
+
+ bookmarkForIndex(index).internalElement().setAttribute("folded", "yes");
+ emit expansionChanged();
+}
+
+
+void BookmarksPanel::onExpand(const QModelIndex &index)
+{
+ if (m_loadingState)
+ return;
+
+ bookmarkForIndex(index).internalElement().setAttribute("folded", "no");
+ emit expansionChanged();
+}
+
+
+void BookmarksPanel::loadFoldedState(const QModelIndex &root)
+{
+ int count = m_treeView->model()->rowCount(root);
+ QModelIndex index;
+
+ for (int i = 0; i < count; ++i)
+ {
+ index = m_treeView->model()->index(i, 0, root);
+ if (index.isValid())
+ {
+ KBookmark bm = bookmarkForIndex(index);
+ if (bm.isGroup())
+ {
+ m_treeView->setExpanded(index, bm.toGroup().isOpen());
+ loadFoldedState(index);
+ }
+ }
+ }
+}
+
+
void BookmarksPanel::setup()
{
kDebug() << "Loading bookmarks panel setup...";
@@ -143,78 +218,3 @@ KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index)
BtmItem *node = static_cast<BtmItem*>(originalIndex.internalPointer());
return node->getBkm();
}
-
-
-void BookmarksPanel::onCollapse(const QModelIndex &index)
-{
- if (m_loadingState)
- return;
-
- bookmarkForIndex(index).internalElement().setAttribute("folded", "yes");
- emit expansionChanged();
-}
-
-
-void BookmarksPanel::onExpand(const QModelIndex &index)
-{
- if (m_loadingState)
- return;
-
- bookmarkForIndex(index).internalElement().setAttribute("folded", "no");
- emit expansionChanged();
-}
-
-
-void BookmarksPanel::startLoadFoldedState()
-{
- m_loadingState = true;
- loadFoldedState(QModelIndex());
- m_loadingState = false;
-}
-
-
-void BookmarksPanel::loadFoldedState(const QModelIndex &root)
-{
- int count = m_treeView->model()->rowCount(root);
- QModelIndex index;
-
- for (int i = 0; i < count; ++i)
- {
- index = m_treeView->model()->index(i, 0, root);
- if (index.isValid())
- {
- KBookmark bm = bookmarkForIndex(index);
- if (bm.isGroup())
- {
- m_treeView->setExpanded(index, bm.toGroup().isOpen());
- loadFoldedState(index);
- }
- }
- }
-}
-
-
-void BookmarksPanel::contextMenu(const QPoint &pos)
-{
- if (m_loadingState)
- return;
-
- BookmarksContextMenu menu(bookmarkForIndex( m_treeView->indexAt(pos) ),
- Application::bookmarkProvider()->bookmarkManager(),
- Application::bookmarkProvider()->bookmarkOwner(),
- this
- );
-
- menu.exec(m_treeView->mapToGlobal(pos));
-}
-
-
-void BookmarksPanel::deleteBookmark()
-{
- QModelIndex index = m_treeView->currentIndex();
- if (m_loadingState || !index.isValid())
- return;
-
- Application::bookmarkProvider()->bookmarkOwner()->bookmarkSelected(bookmarkForIndex(index));
- Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark();
-}