summaryrefslogtreecommitdiff
path: root/src/urlbar
diff options
context:
space:
mode:
authorYoann Laissus <yoann.laissus@gmail.com>2012-01-06 21:41:28 +0100
committerYoann Laissus <yoann.laissus@gmail.com>2012-01-06 21:41:28 +0100
commit32be794fba23d9045116cfc6ae0a69c308201fdc (patch)
tree3c34de3b6fd56a02d72b033f865e59245b0efdf4 /src/urlbar
parentCMakeLists.txt fix. (diff)
downloadrekonq-32be794fba23d9045116cfc6ae0a69c308201fdc.tar.xz
Add a folder combo box in the BookmarkWidget
Patch from Yusuf Amir Tezcan, many thanks for ! REVIEW: 103450
Diffstat (limited to 'src/urlbar')
-rw-r--r--src/urlbar/bookmarkwidget.cpp61
-rw-r--r--src/urlbar/bookmarkwidget.h4
2 files changed, 65 insertions, 0 deletions
diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp
index c144b8d0..5ac8d2e6 100644
--- a/src/urlbar/bookmarkwidget.cpp
+++ b/src/urlbar/bookmarkwidget.cpp
@@ -34,6 +34,7 @@
#include "bookmarkowner.h"
// KDE Includes
+#include <KComboBox>
#include <KLocalizedString>
#include <KIcon>
#include <KLineEdit>
@@ -75,6 +76,14 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent)
layout->addRow(bookmarkIcon, vLayout);
+ //Bookmark Folder
+ QLabel *folderLabel = new QLabel(this);
+ folderLabel->setText(i18n("Folder:"));
+
+ m_folder = new KComboBox(this);
+ layout->addRow(folderLabel, m_folder);
+ setupFolderComboBox();
+
// Bookmark name
QLabel *nameLabel = new QLabel(this);
nameLabel->setText(i18n("Name:"));
@@ -121,10 +130,62 @@ void BookmarkWidget::accept()
m_bookmark->setFullText(m_name->text());
rApp->bookmarkManager()->emitChanged();
}
+
+ QString folderAddress = m_folder->itemData(m_folder->currentIndex()).toString();
+ KBookmarkGroup a = rApp->bookmarkManager()->manager()->findByAddress(folderAddress).toGroup();
+
+ KBookmarkGroup parent = m_bookmark->parentGroup();
+ parent.deleteBookmark(*m_bookmark);
+ a.addBookmark(*m_bookmark);
+ rApp->bookmarkManager()->manager()->emitChanged(a);
+
close();
}
+void BookmarkWidget::setupFolderComboBox()
+{
+ KBookmarkGroup root = rApp->bookmarkManager()->manager()->toolbar();
+
+ if (rApp->bookmarkManager()->manager()->toolbar().address() == rApp->bookmarkManager()->manager()->root().address())
+ {
+ m_folder->addItem(i18n("Bookmark Toolbar"),
+ rApp->bookmarkManager()->manager()->toolbar().address());
+ }
+ else
+ {
+ m_folder->addItem(rApp->bookmarkManager()->manager()->toolbar().text(),
+ rApp->bookmarkManager()->manager()->toolbar().address());
+ }
+ m_folder->insertSeparator(1);
+
+ if (m_bookmark->parentGroup().address() != rApp->bookmarkManager()->manager()->toolbar().address())
+ {
+ m_folder->addItem(m_bookmark->parentGroup().text(),
+ m_bookmark->parentGroup().address());
+ m_folder->insertSeparator(3);
+ }
+
+ for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark))
+ {
+ if(bookmark.isGroup())
+ {
+ m_folder->addItem(bookmark.text(), bookmark.address());
+ }
+ }
+
+ if (m_bookmark->parentGroup().address() == root.address())
+ {
+ m_folder->setCurrentIndex(0);
+ }
+ else
+ {
+ int index = m_folder->findText(m_bookmark->parentGroup().text());
+ m_folder->setCurrentIndex(index);
+ }
+}
+
+
void BookmarkWidget::removeBookmark()
{
rApp->bookmarkManager()->owner()->deleteBookmark(*m_bookmark);
diff --git a/src/urlbar/bookmarkwidget.h b/src/urlbar/bookmarkwidget.h
index e294bf1b..025077c7 100644
--- a/src/urlbar/bookmarkwidget.h
+++ b/src/urlbar/bookmarkwidget.h
@@ -33,6 +33,7 @@
// Forward Declarations
class KBookmark;
class KLineEdit;
+class KComboBox;
class BookmarkWidget : public QMenu
@@ -55,6 +56,9 @@ private Q_SLOTS:
private:
KBookmark *m_bookmark;
KLineEdit *m_name;
+ KComboBox *m_folder;
+
+ void setupFolderComboBox();
};
#endif // BOOKMARKWIDGET_H