mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Dolphin is now KBookmark* free.
svn path=/trunk/KDE/kdebase/apps/; revision=651766
This commit is contained in:
parent
714d08f17c
commit
30161a7b3f
|
@ -29,7 +29,7 @@ kde4_automoc(${dolphinprivate_LIB_SRCS})
|
|||
|
||||
kde4_add_library(dolphinprivate SHARED ${dolphinprivate_LIB_SRCS})
|
||||
|
||||
target_link_libraries(dolphinprivate ${KDE4_KDEUI_LIBS} konq)
|
||||
target_link_libraries(dolphinprivate ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} konq)
|
||||
|
||||
set_target_properties(dolphinprivate PROPERTIES VERSION 1.0.0 SOVERSION 1 )
|
||||
install(TARGETS dolphinprivate DESTINATION ${LIB_INSTALL_DIR} )
|
||||
|
@ -39,8 +39,6 @@ install(TARGETS dolphinprivate DESTINATION ${LIB_INSTALL_DIR} )
|
|||
|
||||
set(dolphin_SRCS
|
||||
applyviewpropsjob.cpp
|
||||
bookmarkssettingspage.cpp
|
||||
bookmarkssidebarpage.cpp
|
||||
columnviewsettingspage.cpp
|
||||
detailsviewsettingspage.cpp
|
||||
dolphinapplication.cpp
|
||||
|
@ -52,7 +50,6 @@ set(dolphin_SRCS
|
|||
dolphindirlister.cpp
|
||||
dolphincontextmenu.cpp
|
||||
dolphinsettingsdialog.cpp
|
||||
editbookmarkdialog.cpp
|
||||
filterbar.cpp
|
||||
generalsettingspage.cpp
|
||||
generalviewsettingspage.cpp
|
||||
|
|
|
@ -1,321 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz *
|
||||
* peter.penz@gmx.at *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "bookmarkssettingspage.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <qlayout.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlineedit.h>
|
||||
|
||||
//Added by qt3to4:
|
||||
#include <QPixmap>
|
||||
#include <Q3VBoxLayout>
|
||||
|
||||
#include <kbookmark.h>
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <kdialog.h>
|
||||
#include <kiconloader.h>
|
||||
#include <k3listview.h>
|
||||
#include <klocale.h>
|
||||
#include <kpushbutton.h>
|
||||
#include <kvbox.h>
|
||||
|
||||
#include "dolphinsettings.h"
|
||||
#include "editbookmarkdialog.h"
|
||||
|
||||
BookmarksSettingsPage::BookmarksSettingsPage(DolphinMainWindow* mainWindow,
|
||||
QWidget*parent) :
|
||||
SettingsPageBase(parent),
|
||||
m_mainWindow(mainWindow),
|
||||
m_addButton(0),
|
||||
m_removeButton(0),
|
||||
m_moveUpButton(0),
|
||||
m_moveDownButton(0)
|
||||
{
|
||||
Q3VBoxLayout* topLayout = new Q3VBoxLayout(this, 2, KDialog::spacingHint());
|
||||
|
||||
const int spacing = KDialog::spacingHint();
|
||||
|
||||
KHBox* hBox = new KHBox(this);
|
||||
hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
hBox->setSpacing(spacing);
|
||||
hBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
|
||||
|
||||
m_listView = new K3ListView(hBox);
|
||||
m_listView->addColumn(i18n("Icon"));
|
||||
m_listView->addColumn(i18n("Name"));
|
||||
m_listView->addColumn(i18n("Location"));
|
||||
m_listView->setResizeMode(Q3ListView::LastColumn);
|
||||
m_listView->setColumnAlignment(0, Qt::AlignHCenter);
|
||||
m_listView->setAllColumnsShowFocus(true);
|
||||
m_listView->setSorting(-1);
|
||||
connect(m_listView, SIGNAL(selectionChanged()),
|
||||
this, SLOT(updateButtons()));
|
||||
connect(m_listView, SIGNAL(pressed(Q3ListViewItem*)),
|
||||
this, SLOT(slotBookmarkPressed(Q3ListViewItem*)));
|
||||
connect(m_listView, SIGNAL(doubleClicked(Q3ListViewItem*, const QPoint&, int)),
|
||||
this, SLOT(slotBookmarkDoubleClicked(Q3ListViewItem*, const QPoint&, int)));
|
||||
|
||||
KVBox* buttonBox = new KVBox(hBox);
|
||||
buttonBox->setSpacing(spacing);
|
||||
|
||||
const QSizePolicy buttonSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||
|
||||
m_addButton = new KPushButton(i18n("Add..."), buttonBox);
|
||||
connect(m_addButton, SIGNAL(clicked()),
|
||||
this, SLOT(slotAddButtonClicked()));
|
||||
m_addButton->setSizePolicy(buttonSizePolicy);
|
||||
|
||||
m_editButton = new KPushButton(i18n("Edit..."), buttonBox);
|
||||
connect(m_editButton, SIGNAL(clicked()),
|
||||
this, SLOT(slotEditButtonClicked()));
|
||||
m_editButton->setSizePolicy(buttonSizePolicy);
|
||||
|
||||
m_removeButton = new KPushButton(i18n("Remove"), buttonBox);
|
||||
connect(m_removeButton, SIGNAL(clicked()),
|
||||
this, SLOT(slotRemoveButtonClicked()));
|
||||
m_removeButton->setSizePolicy(buttonSizePolicy);
|
||||
|
||||
m_moveUpButton = new KPushButton(i18n("Move Up"), buttonBox);
|
||||
connect(m_moveUpButton, SIGNAL(clicked()),
|
||||
this, SLOT(slotMoveUpButtonClicked()));
|
||||
m_moveUpButton->setSizePolicy(buttonSizePolicy);
|
||||
|
||||
m_moveDownButton = new KPushButton(i18n("Move Down"), buttonBox);
|
||||
connect(m_moveDownButton, SIGNAL(clicked()),
|
||||
this, SLOT(slotMoveDownButtonClicked()));
|
||||
m_moveDownButton->setSizePolicy(buttonSizePolicy);
|
||||
|
||||
// Add a dummy widget with no restriction regarding a vertical resizing.
|
||||
// This assures that the spacing between the buttons is not increased.
|
||||
new QWidget(buttonBox);
|
||||
|
||||
topLayout->addWidget(hBox);
|
||||
|
||||
// insert all editable bookmarks.
|
||||
KBookmarkGroup root = DolphinSettings::instance().bookmarkManager()->root();
|
||||
KBookmark bookmark = root.first();
|
||||
|
||||
Q3ListViewItem* prev = 0;
|
||||
while (!bookmark.isNull()) {
|
||||
Q3ListViewItem* item = new Q3ListViewItem(m_listView);
|
||||
item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
|
||||
item->setText(NameIdx, bookmark.text());
|
||||
item->setText(UrlIdx, bookmark.url().prettyUrl());
|
||||
|
||||
// add hidden column to be able to retrieve the icon name again
|
||||
item->setText(IconIdx, bookmark.icon());
|
||||
|
||||
m_listView->insertItem(item);
|
||||
if (prev != 0) {
|
||||
item->moveItem(prev);
|
||||
}
|
||||
prev = item;
|
||||
|
||||
bookmark = root.next(bookmark);
|
||||
}
|
||||
m_listView->setSelected(m_listView->firstChild(), true);
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
|
||||
BookmarksSettingsPage::~BookmarksSettingsPage()
|
||||
{
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::applySettings()
|
||||
{
|
||||
// delete all bookmarks
|
||||
KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager();
|
||||
KBookmarkGroup root = manager->root();
|
||||
KBookmark bookmark = root.first();
|
||||
while (!bookmark.isNull()) {
|
||||
root.deleteBookmark(bookmark);
|
||||
bookmark = root.first();
|
||||
}
|
||||
|
||||
// add all items as bookmarks
|
||||
Q3ListViewItem* item = m_listView->firstChild();
|
||||
while (item != 0) {
|
||||
root.addBookmark(manager,
|
||||
item->text(NameIdx),
|
||||
KUrl(item->text(UrlIdx)),
|
||||
item->text(IconIdx)); // hidden column
|
||||
item = item->itemBelow();
|
||||
}
|
||||
|
||||
manager->emitChanged(root);
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::updateButtons()
|
||||
{
|
||||
const Q3ListViewItem* selectedItem = m_listView->selectedItem();
|
||||
const bool hasSelection = (selectedItem != 0);
|
||||
|
||||
m_editButton->setEnabled(hasSelection);
|
||||
m_removeButton->setEnabled(hasSelection);
|
||||
|
||||
const bool enableMoveUp = hasSelection &&
|
||||
(selectedItem != m_listView->firstChild());
|
||||
m_moveUpButton->setEnabled(enableMoveUp);
|
||||
|
||||
const bool enableMoveDown = hasSelection &&
|
||||
(selectedItem != m_listView->lastChild());
|
||||
m_moveDownButton->setEnabled(enableMoveDown);
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::slotBookmarkDoubleClicked(Q3ListViewItem*,
|
||||
const QPoint&,
|
||||
int)
|
||||
{
|
||||
slotEditButtonClicked();
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::slotBookmarkPressed(Q3ListViewItem* item)
|
||||
{
|
||||
if (item == 0) {
|
||||
m_listView->setSelected(m_listView->currentItem(), true);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::slotAddButtonClicked()
|
||||
{
|
||||
KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add Bookmark"),
|
||||
i18n("New bookmark"),
|
||||
KUrl(),
|
||||
"bookmark");
|
||||
if (!bookmark.isNull()) {
|
||||
// insert bookmark into listview
|
||||
Q3ListViewItem* item = new Q3ListViewItem(m_listView);
|
||||
item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
|
||||
item->setText(NameIdx, bookmark.text());
|
||||
item->setText(UrlIdx, bookmark.url().prettyUrl());
|
||||
item->setText(IconIdx, bookmark.icon());
|
||||
m_listView->insertItem(item);
|
||||
|
||||
Q3ListViewItem* lastItem = m_listView->lastChild();
|
||||
if (lastItem != 0) {
|
||||
item->moveItem(lastItem);
|
||||
}
|
||||
|
||||
m_listView->setSelected(item, true);
|
||||
updateButtons();
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::slotEditButtonClicked()
|
||||
{
|
||||
Q3ListViewItem* item = m_listView->selectedItem();
|
||||
assert(item != 0); // 'edit' may not get invoked when having no items
|
||||
|
||||
KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Edit Bookmark"),
|
||||
item->text(NameIdx),
|
||||
KUrl(item->text(UrlIdx)),
|
||||
item->text(IconIdx));
|
||||
if (!bookmark.isNull()) {
|
||||
item->setPixmap(PixmapIdx, SmallIcon(bookmark.icon()));
|
||||
item->setText(NameIdx, bookmark.text());
|
||||
item->setText(UrlIdx, bookmark.url().prettyUrl());
|
||||
item->setText(IconIdx, bookmark.icon());
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::slotRemoveButtonClicked()
|
||||
{
|
||||
Q3ListViewItem* selectedItem = m_listView->selectedItem();
|
||||
assert(selectedItem != 0);
|
||||
Q3ListViewItem* nextItem = selectedItem->itemBelow();
|
||||
if (nextItem == 0) {
|
||||
nextItem = selectedItem->itemAbove();
|
||||
}
|
||||
|
||||
m_listView->takeItem(selectedItem);
|
||||
if (nextItem != 0) {
|
||||
m_listView->setSelected(nextItem, true);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::slotMoveUpButtonClicked()
|
||||
{
|
||||
moveBookmark(-1);
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::slotMoveDownButtonClicked()
|
||||
{
|
||||
moveBookmark(+1);
|
||||
}
|
||||
|
||||
int BookmarksSettingsPage::selectedBookmarkIndex() const
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
Q3ListViewItem* selectedItem = m_listView->selectedItem();
|
||||
if (selectedItem != 0) {
|
||||
index = 0;
|
||||
Q3ListViewItem* item = m_listView->firstChild();
|
||||
while (item != selectedItem) {
|
||||
item = item->nextSibling();
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
void BookmarksSettingsPage::moveBookmark(int direction)
|
||||
{
|
||||
// this implementation currently only allows moving of bookmarks
|
||||
// one step up or down
|
||||
assert((direction >= -1) && (direction <= +1));
|
||||
|
||||
// swap bookmarks in listview
|
||||
Q3ListViewItem* selectedItem = m_listView->selectedItem();
|
||||
assert(selectedItem != 0);
|
||||
Q3ListViewItem* item = (direction < 0) ? selectedItem->itemAbove() :
|
||||
selectedItem->itemBelow();
|
||||
assert(item != 0);
|
||||
|
||||
QPixmap pixmap;
|
||||
if (item->pixmap(0) != 0) {
|
||||
pixmap = *(item->pixmap(0));
|
||||
}
|
||||
QString name(item->text(NameIdx));
|
||||
QString url(item->text(UrlIdx));
|
||||
QString icon(item->text(IconIdx));
|
||||
|
||||
if (selectedItem->pixmap(0) != 0) {
|
||||
item->setPixmap(PixmapIdx, *(selectedItem->pixmap(0)));
|
||||
}
|
||||
item->setText(NameIdx, selectedItem->text(NameIdx));
|
||||
item->setText(UrlIdx, selectedItem->text(UrlIdx));
|
||||
item->setText(IconIdx, selectedItem->text(IconIdx));
|
||||
|
||||
selectedItem->setPixmap(PixmapIdx, pixmap);
|
||||
selectedItem->setText(NameIdx, name);
|
||||
selectedItem->setText(UrlIdx, url);
|
||||
selectedItem->setText(IconIdx, icon);
|
||||
|
||||
m_listView->setSelected(item, true);
|
||||
}
|
||||
|
||||
#include "bookmarkssettingspage.moc"
|
|
@ -1,95 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz *
|
||||
* peter.penz@gmx.at *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef BOOKMARKSSETTINGSPAGE_H
|
||||
#define BOOKMARKSSETTINGSPAGE_H
|
||||
|
||||
#include <settingspagebase.h>
|
||||
#include <q3valuelist.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class K3ListView;
|
||||
class KPushButton;
|
||||
class Q3ListViewItem;
|
||||
|
||||
/**
|
||||
* @brief Represents the page from the Dolphin Settings which allows
|
||||
* to modify the bookmarks.
|
||||
*/
|
||||
class BookmarksSettingsPage : public SettingsPageBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BookmarksSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
|
||||
|
||||
virtual ~BookmarksSettingsPage();
|
||||
|
||||
/** @see SettingsPageBase::applySettings */
|
||||
virtual void applySettings();
|
||||
|
||||
private slots:
|
||||
void updateButtons();
|
||||
void slotBookmarkDoubleClicked(Q3ListViewItem*, const QPoint&, int);
|
||||
void slotAddButtonClicked();
|
||||
void slotEditButtonClicked();
|
||||
void slotRemoveButtonClicked();
|
||||
void slotMoveUpButtonClicked();
|
||||
void slotMoveDownButtonClicked();
|
||||
|
||||
/**
|
||||
* Is connected with the signal QListView::pressed(QListViewItem* item)
|
||||
* and assures that always one bookmarks stays selected although a
|
||||
* click has been done on the viewport area.
|
||||
* TODO: this is a workaround, possibly there is a more easy approach
|
||||
* doing this...
|
||||
*/
|
||||
void slotBookmarkPressed(Q3ListViewItem* item);
|
||||
|
||||
private:
|
||||
enum ColumnIndex {
|
||||
PixmapIdx = 0,
|
||||
NameIdx = 1,
|
||||
UrlIdx = 2,
|
||||
IconIdx = 3
|
||||
};
|
||||
|
||||
DolphinMainWindow* m_mainWindow;
|
||||
K3ListView* m_listView;
|
||||
KPushButton* m_addButton;
|
||||
KPushButton* m_editButton;
|
||||
KPushButton* m_removeButton;
|
||||
KPushButton* m_moveUpButton;
|
||||
KPushButton* m_moveDownButton;
|
||||
|
||||
/**
|
||||
* Returns the index of the selected bookmark
|
||||
* inside the bookmarks listview.
|
||||
*/
|
||||
int selectedBookmarkIndex() const;
|
||||
|
||||
/**
|
||||
* Moves the currently selected bookmark up, if 'direction'
|
||||
* is < 0, otherwise the bookmark is moved down.
|
||||
*/
|
||||
void moveBookmark(int direction);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,246 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "bookmarkssidebarpage.h"
|
||||
|
||||
#include <q3listbox.h>
|
||||
#include <qlayout.h>
|
||||
#include <qpainter.h>
|
||||
//Added by qt3to4:
|
||||
#include <QPixmap>
|
||||
#include <Q3VBoxLayout>
|
||||
#include <QPaintEvent>
|
||||
#include <assert.h>
|
||||
#include <kmenu.h>
|
||||
|
||||
#include <kbookmark.h>
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include "dolphinsettings.h"
|
||||
#include "editbookmarkdialog.h"
|
||||
|
||||
BookmarksSidebarPage::BookmarksSidebarPage(QWidget* parent) :
|
||||
SidebarPage(parent)
|
||||
{
|
||||
Q3VBoxLayout* layout = new Q3VBoxLayout(this);
|
||||
m_bookmarksList = new BookmarksListBox(this);
|
||||
m_bookmarksList->setPaletteBackgroundColor(palette().brush(QPalette::Background).color());
|
||||
|
||||
layout->addWidget(m_bookmarksList);
|
||||
connect(m_bookmarksList, SIGNAL(mouseButtonClicked(int, Q3ListBoxItem*, const QPoint&)),
|
||||
this, SLOT(slotMouseButtonClicked(int, Q3ListBoxItem*)));
|
||||
connect(m_bookmarksList, SIGNAL(contextMenuRequested(Q3ListBoxItem*, const QPoint&)),
|
||||
this, SLOT(slotContextMenuRequested(Q3ListBoxItem*, const QPoint&)));
|
||||
|
||||
KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager();
|
||||
connect(manager, SIGNAL(changed(const QString&, const QString&)),
|
||||
this, SLOT(updateBookmarks()));
|
||||
|
||||
updateBookmarks();
|
||||
}
|
||||
|
||||
BookmarksSidebarPage::~BookmarksSidebarPage()
|
||||
{
|
||||
}
|
||||
|
||||
void BookmarksSidebarPage::setUrl(const KUrl& url)
|
||||
{
|
||||
if (!m_url.equals(url, KUrl::CompareWithoutTrailingSlash)) {
|
||||
m_url = url;
|
||||
adjustSelection(m_url);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksSidebarPage::updateBookmarks()
|
||||
{
|
||||
m_bookmarksList->clear();
|
||||
|
||||
KIconLoader iconLoader;
|
||||
|
||||
KBookmarkGroup root = DolphinSettings::instance().bookmarkManager()->root();
|
||||
KBookmark bookmark = root.first();
|
||||
while (!bookmark.isNull()) {
|
||||
QPixmap icon(iconLoader.loadIcon(bookmark.icon(),
|
||||
K3Icon::NoGroup,
|
||||
K3Icon::SizeMedium));
|
||||
BookmarkItem* item = new BookmarkItem(icon, bookmark.text());
|
||||
m_bookmarksList->insertItem(item);
|
||||
|
||||
bookmark = root.next(bookmark);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksSidebarPage::slotMouseButtonClicked(int button, Q3ListBoxItem* item)
|
||||
{
|
||||
if ((button != Qt::LeftButton) || (item == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int index = m_bookmarksList->index(item);
|
||||
KBookmark bookmark = DolphinSettings::instance().bookmark(index);
|
||||
emit changeUrl(bookmark.url());
|
||||
}
|
||||
|
||||
void BookmarksSidebarPage::slotContextMenuRequested(Q3ListBoxItem* item,
|
||||
const QPoint& pos)
|
||||
{
|
||||
const int insertID = 1;
|
||||
const int editID = 2;
|
||||
const int deleteID = 3;
|
||||
const int addID = 4;
|
||||
|
||||
KMenu* popup = new KMenu();
|
||||
if (item == 0) {
|
||||
QAction *action = popup->addAction(KIcon("document-new"), i18n("Add Bookmark..."));
|
||||
action->setData(addID);
|
||||
}
|
||||
else {
|
||||
QAction *action = popup->addAction(KIcon("document-new"), i18n("Insert Bookmark..."));
|
||||
action->setData(insertID);
|
||||
action = popup->addAction(KIcon("edit"), i18n("Edit..."));
|
||||
action->setData(editID);
|
||||
action = popup->addAction(KIcon("edit-delete"), i18n("Delete"));
|
||||
action->setData(deleteID);
|
||||
|
||||
}
|
||||
|
||||
KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager();
|
||||
KBookmarkGroup root = manager->root();
|
||||
const int index = m_bookmarksList->index(m_bookmarksList->selectedItem());
|
||||
QAction *result = popup->exec(pos);
|
||||
if( result)
|
||||
{
|
||||
switch(result->data().toInt()) {
|
||||
case insertID: {
|
||||
KBookmark newBookmark = EditBookmarkDialog::getBookmark(i18n("Insert Bookmark"),
|
||||
"New bookmark",
|
||||
KUrl(),
|
||||
"bookmark");
|
||||
if (!newBookmark.isNull()) {
|
||||
root.addBookmark(manager, newBookmark);
|
||||
if (index > 0) {
|
||||
KBookmark prevBookmark = DolphinSettings::instance().bookmark(index - 1);
|
||||
root.moveItem(newBookmark, prevBookmark);
|
||||
}
|
||||
else {
|
||||
// insert bookmark at first position (is a little bit tricky as KBookmarkGroup
|
||||
// only allows to move items after existing items)
|
||||
KBookmark firstBookmark = root.first();
|
||||
root.moveItem(newBookmark, firstBookmark);
|
||||
root.moveItem(firstBookmark, newBookmark);
|
||||
}
|
||||
manager->emitChanged(root);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case editID: {
|
||||
KBookmark oldBookmark = DolphinSettings::instance().bookmark(index);
|
||||
KBookmark newBookmark = EditBookmarkDialog::getBookmark(i18n("Edit Bookmark"),
|
||||
oldBookmark.text(),
|
||||
oldBookmark.url(),
|
||||
oldBookmark.icon());
|
||||
if (!newBookmark.isNull()) {
|
||||
root.addBookmark(manager, newBookmark);
|
||||
root.moveItem(newBookmark, oldBookmark);
|
||||
root.deleteBookmark(oldBookmark);
|
||||
manager->emitChanged(root);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case deleteID: {
|
||||
KBookmark bookmark = DolphinSettings::instance().bookmark(index);
|
||||
root.deleteBookmark(bookmark);
|
||||
manager->emitChanged(root);
|
||||
break;
|
||||
}
|
||||
|
||||
case addID: {
|
||||
KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add Bookmark"),
|
||||
"New bookmark",
|
||||
KUrl(),
|
||||
"bookmark");
|
||||
if (!bookmark.isNull()) {
|
||||
root.addBookmark(manager, bookmark);
|
||||
manager->emitChanged(root);
|
||||
}
|
||||
}
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
delete popup;
|
||||
popup = 0;
|
||||
}
|
||||
|
||||
|
||||
void BookmarksSidebarPage::adjustSelection(const KUrl& url)
|
||||
{
|
||||
KBookmarkGroup root = DolphinSettings::instance().bookmarkManager()->root();
|
||||
KBookmark bookmark = root.closestBookmark(url);
|
||||
|
||||
const bool block = m_bookmarksList->signalsBlocked();
|
||||
m_bookmarksList->blockSignals(true);
|
||||
if (bookmark.isNull()) {
|
||||
// no bookmark matches, hence deactivate any selection
|
||||
const int currentIndex = m_bookmarksList->index(m_bookmarksList->selectedItem());
|
||||
m_bookmarksList->setSelected(currentIndex, false);
|
||||
}
|
||||
else {
|
||||
// select the bookmark which is part of the current Url
|
||||
// TODO when porting to QListWidget, use the address as item data?
|
||||
int selectedIndex = bookmark.address().mid(1).toInt(); // convert "/5" to 5.
|
||||
m_bookmarksList->setSelected(selectedIndex, true);
|
||||
}
|
||||
m_bookmarksList->blockSignals(block);
|
||||
}
|
||||
|
||||
BookmarksListBox::BookmarksListBox(QWidget* parent) :
|
||||
Q3ListBox(parent)
|
||||
{
|
||||
}
|
||||
BookmarksListBox::~BookmarksListBox()
|
||||
{
|
||||
}
|
||||
|
||||
void BookmarksListBox::paintEvent(QPaintEvent* /* event */)
|
||||
{
|
||||
// don't invoke QListBox::paintEvent(event) to prevent
|
||||
// that any kind of frame is drawn
|
||||
}
|
||||
|
||||
BookmarkItem::BookmarkItem(const QPixmap& pixmap, const QString& text) :
|
||||
Q3ListBoxPixmap(pixmap, text)
|
||||
{
|
||||
}
|
||||
|
||||
BookmarkItem::~BookmarkItem()
|
||||
{
|
||||
}
|
||||
|
||||
int BookmarkItem::height(const Q3ListBox* listBox) const
|
||||
{
|
||||
return Q3ListBoxPixmap::height(listBox) + 8;
|
||||
}
|
||||
|
||||
#include "bookmarkssidebarpage.moc"
|
|
@ -1,110 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
#ifndef _BOOKMARKSSIDEBARPAGE_H_
|
||||
#define _BOOKMARKSSIDEBARPAGE_H_
|
||||
|
||||
#include <q3listbox.h>
|
||||
//Added by qt3to4:
|
||||
#include <QPaintEvent>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "sidebarpage.h"
|
||||
|
||||
class KUrl;
|
||||
class BookmarksListBox;
|
||||
|
||||
/**
|
||||
* @brief Sidebar page for accessing bookmarks.
|
||||
*
|
||||
* It is possible to add, remove and edit bookmarks
|
||||
* by a context menu. The selection of the bookmark
|
||||
* is automatically adjusted to the Url given by
|
||||
* the active view.
|
||||
*/
|
||||
class BookmarksSidebarPage : public SidebarPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BookmarksSidebarPage(QWidget* parent=0);
|
||||
virtual ~BookmarksSidebarPage();
|
||||
|
||||
public slots:
|
||||
void setUrl(const KUrl& url);
|
||||
|
||||
private slots:
|
||||
/** Fills the listbox with the bookmarks stored in DolphinSettings. */
|
||||
void updateBookmarks();
|
||||
|
||||
/**
|
||||
* Checks whether the left mouse button has been clicked above a bookmark.
|
||||
* If this is the case, the Url for the currently active view is adjusted.
|
||||
*/
|
||||
void slotMouseButtonClicked(int button, Q3ListBoxItem* item);
|
||||
|
||||
/** @see QListBox::slotContextMenuRequested */
|
||||
void slotContextMenuRequested(Q3ListBoxItem* item, const QPoint& pos);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Updates the selection dependent from the given Url \a url. The
|
||||
* Url must not match exactly to one of the available bookmarks:
|
||||
* The bookmark which is equal to the Url or at least is a parent Url
|
||||
* is selected. If there are more than one possible parent Url candidates,
|
||||
* the bookmark which covers the bigger range of the Url is selected.
|
||||
*/
|
||||
void adjustSelection(const KUrl& url);
|
||||
|
||||
BookmarksListBox* m_bookmarksList;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Listbox which contains a list of bookmarks.
|
||||
*
|
||||
* Only QListBox::paintEvent() has been overwritten to prevent
|
||||
* that a (not wanted) frameborder is drawn.
|
||||
*/
|
||||
class BookmarksListBox : public Q3ListBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BookmarksListBox(QWidget* parent);
|
||||
virtual ~BookmarksListBox();
|
||||
|
||||
protected:
|
||||
/** @see QWidget::paintEvent() */
|
||||
virtual void paintEvent(QPaintEvent* event);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Item which can be added to a BookmarksListBox.
|
||||
*
|
||||
* Only QListBoxPixmap::height() has been overwritten to get
|
||||
* a spacing between the items.
|
||||
*/
|
||||
class BookmarkItem : public Q3ListBoxPixmap
|
||||
{
|
||||
public:
|
||||
BookmarkItem(const QPixmap& pixmap, const QString& text);
|
||||
virtual ~BookmarkItem();
|
||||
virtual int height(const Q3ListBox* listBox) const;
|
||||
};
|
||||
|
||||
#endif // _BOOKMARKSSIDEBARPAGE_H_
|
|
@ -23,11 +23,9 @@
|
|||
#include "dolphinmainwindow.h"
|
||||
#include "dolphinsettings.h"
|
||||
#include "dolphinview.h"
|
||||
#include "editbookmarkdialog.h"
|
||||
|
||||
#include <kactioncollection.h>
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <kbookmark.h>
|
||||
#include <kfileplacesmodel.h>
|
||||
#include <kdesktopfile.h>
|
||||
#include <kglobal.h>
|
||||
#include <kiconloader.h>
|
||||
|
@ -183,15 +181,9 @@ void DolphinContextMenu::openItemContextMenu()
|
|||
|
||||
if ((bookmarkAction!= 0) && (activatedAction == bookmarkAction)) {
|
||||
const KUrl selectedUrl(m_fileInfo->url());
|
||||
KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add Folder as Bookmark"),
|
||||
selectedUrl.fileName(),
|
||||
selectedUrl,
|
||||
"bookmark");
|
||||
if (!bookmark.isNull()) {
|
||||
KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager();
|
||||
KBookmarkGroup root = manager->root();
|
||||
root.addBookmark(manager, bookmark);
|
||||
manager->emitChanged(root);
|
||||
if (selectedUrl.isValid()) {
|
||||
DolphinSettings::instance().placesModel()->addPlace(selectedUrl.fileName(),
|
||||
selectedUrl);
|
||||
}
|
||||
}
|
||||
else if (serviceActions.contains(activatedAction)) {
|
||||
|
@ -258,15 +250,8 @@ void DolphinContextMenu::openViewportContextMenu()
|
|||
}
|
||||
else if (activatedAction == bookmarkAction) {
|
||||
const KUrl& url = m_mainWindow->activeView()->url();
|
||||
KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add Folder as Bookmark"),
|
||||
url.fileName(),
|
||||
url,
|
||||
"bookmark");
|
||||
if (!bookmark.isNull()) {
|
||||
KBookmarkManager* manager = DolphinSettings::instance().bookmarkManager();
|
||||
KBookmarkGroup root = manager->root();
|
||||
root.addBookmark(manager, bookmark);
|
||||
manager->emitChanged(root);
|
||||
if (url.isValid()) {
|
||||
DolphinSettings::instance().placesModel()->addPlace(url.fileName(), url);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <config-kmetadata.h>
|
||||
#include "dolphinmainwindow.h"
|
||||
|
||||
#include "bookmarkssidebarpage.h"
|
||||
#include "dolphinapplication.h"
|
||||
#include "dolphinnewmenu.h"
|
||||
#include "dolphinsettings.h"
|
||||
|
@ -42,7 +41,6 @@
|
|||
|
||||
#include <kaction.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <kconfig.h>
|
||||
#include <kdesktopfile.h>
|
||||
#include <kdeversion.h>
|
||||
|
@ -976,17 +974,6 @@ void DolphinMainWindow::init()
|
|||
|
||||
DolphinSettings& settings = DolphinSettings::instance();
|
||||
|
||||
KBookmarkManager* manager = settings.bookmarkManager();
|
||||
Q_ASSERT(manager != 0);
|
||||
KBookmarkGroup root = manager->root();
|
||||
if (root.first().isNull()) {
|
||||
root.addBookmark(manager, i18n("Home"), settings.generalSettings()->homeUrl(), "folder-home");
|
||||
root.addBookmark(manager, i18n("Storage Media"), KUrl("media:/"), "hdd-mount");
|
||||
root.addBookmark(manager, i18n("Network"), KUrl("remote:/"), "network-local");
|
||||
root.addBookmark(manager, i18n("Root"), KUrl("/"), "folder-red");
|
||||
root.addBookmark(manager, i18n("Trash"), KUrl("trash:/"), "user-trash");
|
||||
}
|
||||
|
||||
setupActions();
|
||||
|
||||
const KUrl& homeUrl = settings.generalSettings()->homeUrl();
|
||||
|
@ -1288,20 +1275,6 @@ void DolphinMainWindow::setupDockWidgets()
|
|||
// TODO: there's a lot copy/paste code here. Provide a generic approach
|
||||
// after the dock concept has been finalized.
|
||||
|
||||
// setup "Bookmarks"
|
||||
QDockWidget* shortcutsDock = new QDockWidget(i18n("Bookmarks"), this);
|
||||
shortcutsDock->setObjectName("bookmarksDock");
|
||||
shortcutsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
SidebarPage* shortcutsWidget = new BookmarksSidebarPage(shortcutsDock);
|
||||
shortcutsDock->setWidget(shortcutsWidget);
|
||||
|
||||
|
||||
shortcutsDock->toggleViewAction()->setText(i18n("Show Bookmarks Panel"));
|
||||
actionCollection()->addAction("show_bookmarks_panel", shortcutsDock->toggleViewAction());
|
||||
|
||||
addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock);
|
||||
connectSidebarPage(shortcutsWidget);
|
||||
|
||||
// setup "Information"
|
||||
QDockWidget* infoDock = new QDockWidget(i18n("Information"), this);
|
||||
infoDock->setObjectName("infoDock");
|
||||
|
@ -1335,13 +1308,12 @@ void DolphinMainWindow::setupDockWidgets()
|
|||
treeViewDock->hide();
|
||||
}
|
||||
|
||||
// FIXME: To merge with the current bookmark sidebar
|
||||
QDockWidget *placesDock = new QDockWidget(i18n("Places"));
|
||||
placesDock->setObjectName("placesDock");
|
||||
placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
KFilePlacesView *listView = new KFilePlacesView(placesDock);
|
||||
placesDock->setWidget(listView);
|
||||
listView->setModel(new KFilePlacesModel(listView));
|
||||
listView->setModel(DolphinSettings::instance().placesModel());
|
||||
addDockWidget(Qt::LeftDockWidgetArea, placesDock);
|
||||
connect(listView, SIGNAL(urlChanged(KUrl)),
|
||||
this, SLOT(changeUrl(KUrl)));
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
#include "dolphinsettings.h"
|
||||
|
||||
#include <kbookmark.h>
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <kfileplacesmodel.h>
|
||||
#include <kcomponentdata.h>
|
||||
#include <klocale.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
@ -40,33 +39,12 @@ DolphinSettings& DolphinSettings::instance()
|
|||
return *instance;
|
||||
}
|
||||
|
||||
KBookmark DolphinSettings::bookmark(int index) const
|
||||
{
|
||||
return bookmarkManager()->findByAddress(QString('/') + QString::number(index));
|
||||
}
|
||||
|
||||
KBookmarkManager* DolphinSettings::bookmarkManager() const
|
||||
{
|
||||
QString basePath = KGlobal::mainComponent().componentName();
|
||||
basePath.append("/bookmarks.xml");
|
||||
const QString file = KStandardDirs::locateLocal("data", basePath);
|
||||
|
||||
return KBookmarkManager::managerForFile(file, "dolphin", false);
|
||||
}
|
||||
|
||||
void DolphinSettings::save()
|
||||
{
|
||||
m_generalSettings->writeConfig();
|
||||
m_iconsModeSettings->writeConfig();
|
||||
m_detailsModeSettings->writeConfig();
|
||||
m_columnModeSettings->writeConfig();
|
||||
|
||||
QString basePath = KGlobal::mainComponent().componentName();
|
||||
basePath.append("/bookmarks.xml");
|
||||
const QString file = KStandardDirs::locateLocal( "data", basePath);
|
||||
|
||||
KBookmarkManager* manager = KBookmarkManager::managerForFile(file, "dolphin", false);
|
||||
manager->save(false);
|
||||
}
|
||||
|
||||
DolphinSettings::DolphinSettings()
|
||||
|
@ -75,6 +53,7 @@ DolphinSettings::DolphinSettings()
|
|||
m_iconsModeSettings = new IconsModeSettings();
|
||||
m_detailsModeSettings = new DetailsModeSettings();
|
||||
m_columnModeSettings = new ColumnModeSettings();
|
||||
m_placesModel = new KFilePlacesModel();
|
||||
}
|
||||
|
||||
DolphinSettings::~DolphinSettings()
|
||||
|
@ -90,4 +69,7 @@ DolphinSettings::~DolphinSettings()
|
|||
|
||||
delete m_columnModeSettings;
|
||||
m_columnModeSettings = 0;
|
||||
|
||||
delete m_placesModel;
|
||||
m_placesModel = 0;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ class ColumnModeSettings;
|
|||
class DetailsModeSettings;
|
||||
class GeneralSettings;
|
||||
class IconsModeSettings;
|
||||
class KBookmark;
|
||||
class KBookmarkManager;
|
||||
class KFilePlacesModel;
|
||||
|
||||
/**
|
||||
* @brief Manages and stores all settings from Dolphin.
|
||||
|
@ -49,13 +48,7 @@ public:
|
|||
IconsModeSettings* iconsModeSettings() const { return m_iconsModeSettings; }
|
||||
DetailsModeSettings* detailsModeSettings() const { return m_detailsModeSettings; }
|
||||
ColumnModeSettings* columnModeSettings() const { return m_columnModeSettings; }
|
||||
|
||||
KBookmarkManager* bookmarkManager() const;
|
||||
|
||||
// TODO: should this really belong here or get moved to a derived KBookmarkManager?
|
||||
// Dolphin uses some lists where an index is given and the corresponding bookmark
|
||||
// should get retrieved...
|
||||
KBookmark bookmark(int index) const;
|
||||
KFilePlacesModel* placesModel() const { return m_placesModel; }
|
||||
|
||||
/** @see DolphinSettingsBase::save */
|
||||
virtual void save();
|
||||
|
@ -69,6 +62,7 @@ private:
|
|||
IconsModeSettings* m_iconsModeSettings;
|
||||
DetailsModeSettings* m_detailsModeSettings;
|
||||
ColumnModeSettings* m_columnModeSettings;
|
||||
KFilePlacesModel* m_placesModel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <kicon.h>
|
||||
#include "generalsettingspage.h"
|
||||
#include "viewsettingspage.h"
|
||||
#include "bookmarkssettingspage.h"
|
||||
#include "dolphinapplication.h"
|
||||
#include "dolphinmainwindow.h"
|
||||
//Added by qt3to4:
|
||||
|
@ -48,10 +47,6 @@ DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
|
|||
m_viewSettingsPage = new ViewSettingsPage(mainWindow, this);
|
||||
KPageWidgetItem* viewSettingsFrame = addPage(m_viewSettingsPage, i18n("View Modes"));
|
||||
viewSettingsFrame->setIcon(KIcon("view-choose"));
|
||||
|
||||
m_bookmarksSettingsPage = new BookmarksSettingsPage(mainWindow, this);
|
||||
KPageWidgetItem* bookmarksSettingsFrame = addPage(m_bookmarksSettingsPage, i18n("Bookmarks"));
|
||||
bookmarksSettingsFrame->setIcon(KIcon("bookmark"));
|
||||
}
|
||||
|
||||
DolphinSettingsDialog::~DolphinSettingsDialog()
|
||||
|
@ -70,7 +65,6 @@ void DolphinSettingsDialog::applySettings()
|
|||
{
|
||||
m_generalSettingsPage->applySettings();
|
||||
m_viewSettingsPage->applySettings();
|
||||
m_bookmarksSettingsPage->applySettings();
|
||||
DolphinApplication::app()->refreshMainWindows();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <kpagedialog.h>
|
||||
class GeneralSettingsPage;
|
||||
class ViewSettingsPage;
|
||||
class BookmarksSettingsPage;
|
||||
class DolphinMainWindow;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +48,6 @@ private:
|
|||
DolphinMainWindow* m_mainWindow;
|
||||
GeneralSettingsPage* m_generalSettingsPage;
|
||||
ViewSettingsPage* m_viewSettingsPage;
|
||||
BookmarksSettingsPage* m_bookmarksSettingsPage;
|
||||
|
||||
void applySettings();
|
||||
};
|
||||
|
|
|
@ -97,7 +97,7 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow,
|
|||
connect(clipboard, SIGNAL(dataChanged()),
|
||||
this, SLOT(updateCutItems()));
|
||||
|
||||
m_urlNavigator = new KUrlNavigator(new KFilePlacesModel(this), url, this);
|
||||
m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this);
|
||||
m_urlNavigator->setUrlEditable(DolphinSettings::instance().generalSettings()->editableUrl());
|
||||
m_urlNavigator->setHomeUrl(DolphinSettings::instance().generalSettings()->homeUrl());
|
||||
connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz *
|
||||
* peter.penz@gmx.at *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "editbookmarkdialog.h"
|
||||
#include <q3grid.h>
|
||||
//Added by qt3to4:
|
||||
#include <Q3VBoxLayout>
|
||||
#include <klocale.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlayout.h>
|
||||
#include <kiconloader.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <kurl.h>
|
||||
#include <kfiledialog.h>
|
||||
#include <kicondialog.h>
|
||||
#include <kvbox.h>
|
||||
|
||||
|
||||
EditBookmarkDialog::~EditBookmarkDialog()
|
||||
{
|
||||
}
|
||||
|
||||
KBookmark EditBookmarkDialog::getBookmark(const QString& title,
|
||||
const QString& name,
|
||||
const KUrl& url,
|
||||
const QString& icon)
|
||||
{
|
||||
EditBookmarkDialog dialog(title, name, url, icon);
|
||||
dialog.exec();
|
||||
return dialog.m_bookmark;
|
||||
}
|
||||
|
||||
void EditBookmarkDialog::slotButtonClicked(int button)
|
||||
{
|
||||
if (button==Ok) {
|
||||
m_bookmark = KBookmark::standaloneBookmark(m_name->text(),
|
||||
KUrl(m_location->text()),
|
||||
m_iconName);
|
||||
}
|
||||
|
||||
KDialog::slotButtonClicked(button);
|
||||
}
|
||||
|
||||
EditBookmarkDialog::EditBookmarkDialog(const QString& title,
|
||||
const QString& name,
|
||||
const KUrl& url,
|
||||
const QString& icon) :
|
||||
KDialog(),
|
||||
m_iconButton(0),
|
||||
m_name(0),
|
||||
m_location(0)
|
||||
{
|
||||
setCaption(title);
|
||||
setButtons(Ok|Cancel);
|
||||
setDefaultButton(Ok);
|
||||
|
||||
QWidget *page = new QWidget(this);
|
||||
setMainWidget(page);
|
||||
|
||||
Q3VBoxLayout* topLayout = new Q3VBoxLayout(page, 0, spacingHint());
|
||||
|
||||
Q3Grid* grid = new Q3Grid(2, Qt::Horizontal, page);
|
||||
grid->setSpacing(spacingHint());
|
||||
|
||||
// create icon widgets
|
||||
new QLabel(i18n("Icon:"), grid);
|
||||
m_iconName = icon;
|
||||
m_iconButton = new QPushButton(KIcon(m_iconName), QString(), grid);
|
||||
m_iconButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
connect(m_iconButton, SIGNAL(clicked()),
|
||||
this, SLOT(selectIcon()));
|
||||
|
||||
// create name widgets
|
||||
new QLabel(i18n("Name:"), grid);
|
||||
m_name = new QLineEdit(name, grid);
|
||||
m_name->selectAll();
|
||||
m_name->setFocus();
|
||||
|
||||
// create location widgets
|
||||
new QLabel(i18n("Location:"), grid);
|
||||
|
||||
KHBox* locationBox = new KHBox(grid);
|
||||
locationBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
locationBox->setSpacing(spacingHint());
|
||||
m_location = new QLineEdit(url.prettyUrl(), locationBox);
|
||||
m_location->setMinimumWidth(320);
|
||||
|
||||
QPushButton* selectLocationButton = new QPushButton(KIcon("folder"), QString(), locationBox);
|
||||
selectLocationButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
connect(selectLocationButton, SIGNAL(clicked()),
|
||||
this, SLOT(selectLocation()));
|
||||
|
||||
topLayout->addWidget(grid);
|
||||
}
|
||||
|
||||
void EditBookmarkDialog::selectIcon()
|
||||
{
|
||||
const QString iconName(KIconDialog::getIcon(K3Icon::Small, K3Icon::FileSystem));
|
||||
if (!iconName.isEmpty()) {
|
||||
m_iconName = iconName;
|
||||
m_iconButton->setIcon(KIcon(iconName));
|
||||
}
|
||||
}
|
||||
|
||||
void EditBookmarkDialog::selectLocation()
|
||||
{
|
||||
const QString location(m_location->text());
|
||||
KUrl url(KFileDialog::getExistingDirectoryUrl(location));
|
||||
if (!url.isEmpty()) {
|
||||
m_location->setText(url.prettyUrl());
|
||||
}
|
||||
}
|
||||
|
||||
#include "editbookmarkdialog.moc"
|
|
@ -1,82 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz *
|
||||
* peter.penz@gmx.at *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
#ifndef EDITBOOKMARKDIALOG_H
|
||||
#define EDITBOOKMARKDIALOG_H
|
||||
|
||||
#include <kbookmark.h>
|
||||
#include <kdialog.h>
|
||||
|
||||
class Bookmark;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
|
||||
/**
|
||||
* @brief Allows to edit the icon, Url and name of a bookmark.
|
||||
*
|
||||
* The default usage is like this:
|
||||
* \code
|
||||
* KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add Bookmark"),
|
||||
* i18n("New bookmark"),
|
||||
* KUrl(),
|
||||
* "bookmark");
|
||||
* if (!bookmark.isNull()) {
|
||||
* // ...
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
class EditBookmarkDialog : public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual ~EditBookmarkDialog();
|
||||
|
||||
/**
|
||||
* Opens a dialog where the current icon, Url and name of
|
||||
* an Url are editable. The title of the dialog is set to \a title.
|
||||
* @return A valid bookmark, if the user has pressed OK. Otherwise
|
||||
* a null bookmark is returned (see Bookmark::isNull()).
|
||||
*/
|
||||
static KBookmark getBookmark(const QString& title,
|
||||
const QString& name,
|
||||
const KUrl& url,
|
||||
const QString& icon);
|
||||
|
||||
protected slots:
|
||||
virtual void slotButtonClicked(int button);
|
||||
|
||||
protected:
|
||||
EditBookmarkDialog(const QString& title,
|
||||
const QString& name,
|
||||
const KUrl& url,
|
||||
const QString& icon);
|
||||
|
||||
private slots:
|
||||
void selectIcon();
|
||||
void selectLocation();
|
||||
|
||||
private:
|
||||
QString m_iconName;
|
||||
QPushButton* m_iconButton;
|
||||
QLineEdit* m_name;
|
||||
QLineEdit* m_location;
|
||||
KBookmark m_bookmark;
|
||||
};
|
||||
#endif
|
|
@ -33,7 +33,7 @@
|
|||
#include <QInputDialog>
|
||||
#include <QDir>
|
||||
|
||||
#include <kbookmarkmanager.h>
|
||||
#include <kfileplacesmodel.h>
|
||||
#include <klocale.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <kio/previewjob.h>
|
||||
|
@ -240,23 +240,21 @@ void InfoSidebarPage::startService(int index)
|
|||
|
||||
bool InfoSidebarPage::applyBookmark(const KUrl& url)
|
||||
{
|
||||
KBookmarkGroup root = DolphinSettings::instance().bookmarkManager()->root();
|
||||
KBookmark bookmark = root.first();
|
||||
while (!bookmark.isNull()) {
|
||||
if (url.equals(bookmark.url(), KUrl::CompareWithoutTrailingSlash)) {
|
||||
KFilePlacesModel *placesModel = DolphinSettings::instance().placesModel();
|
||||
int count = placesModel->rowCount();
|
||||
|
||||
for (int i=0; i<count; ++i) {
|
||||
QModelIndex index = placesModel->index(i, 0);
|
||||
|
||||
if (url.equals(placesModel->url(index), KUrl::CompareWithoutTrailingSlash)) {
|
||||
QString text("<b>");
|
||||
text.append(bookmark.text());
|
||||
text.append(placesModel->text(index));
|
||||
text.append("</b>");
|
||||
m_name->setText(text);
|
||||
|
||||
KIconLoader iconLoader;
|
||||
QPixmap icon = iconLoader.loadIcon(bookmark.icon(),
|
||||
K3Icon::NoGroup,
|
||||
K3Icon::SizeEnormous);
|
||||
m_preview->setPixmap(icon);
|
||||
m_preview->setPixmap(placesModel->icon(index).pixmap(128, 128));
|
||||
return true;
|
||||
}
|
||||
bookmark = root.next(bookmark);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
#include "treeviewsidebarpage.h"
|
||||
|
||||
#include "kbookmarkmanager.h"
|
||||
#include "dolphinmainwindow.h"
|
||||
#include "dolphinsortfilterproxymodel.h"
|
||||
#include "dolphinview.h"
|
||||
#include "sidebartreeview.h"
|
||||
#include "treeviewcontextmenu.h"
|
||||
|
||||
#include <kfileplacesmodel.h>
|
||||
#include <kdirlister.h>
|
||||
#include <kdirmodel.h>
|
||||
#include <kfileitem.h>
|
||||
|
@ -88,8 +88,8 @@ void TreeViewSidebarPage::setUrl(const KUrl& url)
|
|||
m_url = url;
|
||||
|
||||
// adjust the root of the tree to the base bookmark
|
||||
KBookmarkManager* bookmarkManager = DolphinSettings::instance().bookmarkManager();
|
||||
const KUrl baseUrl = bookmarkManager->root().closestBookmark(url).url();
|
||||
KFilePlacesModel *placesModel = DolphinSettings::instance().placesModel();
|
||||
const KUrl baseUrl = placesModel->url(placesModel->closestItem(url));
|
||||
if (m_dirLister->url() != baseUrl) {
|
||||
m_dirLister->stop();
|
||||
m_dirLister->openUrl(baseUrl);
|
||||
|
|
Loading…
Reference in a new issue