diff options
Diffstat (limited to 'src/urlbar')
-rw-r--r-- | src/urlbar/bookmarkwidget.cpp | 61 | ||||
-rw-r--r-- | src/urlbar/bookmarkwidget.h | 4 |
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 |