summaryrefslogtreecommitdiff
path: root/src/bookmarks
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-07-17 16:46:24 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-07-17 16:46:24 +0200
commit82167d2422a4b6e3071dca68cf65a66e1da41ab4 (patch)
tree03c1f95a2aa60c48822a463cc3812b5c3415991e /src/bookmarks
parentImproving tab previews (diff)
downloadrekonq-82167d2422a4b6e3071dca68cf65a66e1da41ab4.tar.xz
A round of the "new" astyle 2.01...
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/bookmarkowner.cpp58
-rw-r--r--src/bookmarks/bookmarkprovider.cpp68
-rw-r--r--src/bookmarks/bookmarkscontextmenu.cpp22
-rw-r--r--src/bookmarks/bookmarkspanel.cpp24
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp492
-rw-r--r--src/bookmarks/bookmarkstreemodel.cpp80
6 files changed, 372 insertions, 372 deletions
diff --git a/src/bookmarks/bookmarkowner.cpp b/src/bookmarks/bookmarkowner.cpp
index da006801..75b5f12d 100644
--- a/src/bookmarks/bookmarkowner.cpp
+++ b/src/bookmarks/bookmarkowner.cpp
@@ -48,16 +48,16 @@
BookmarkOwner::BookmarkOwner(KBookmarkManager *manager, QObject *parent)
- : QObject(parent)
- , KBookmarkOwner()
- , m_manager(manager)
+ : QObject(parent)
+ , KBookmarkOwner()
+ , m_manager(manager)
{
}
KAction* BookmarkOwner::createAction(const KBookmark &bookmark, const BookmarkAction &bmAction)
{
- switch (bmAction)
+ switch(bmAction)
{
case OPEN:
return createAction(i18n("Open"), "tab-new",
@@ -119,7 +119,7 @@ QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const
MainView *view = rApp->mainWindow()->mainView();
int tabNumber = view->count();
- for (int i = 0; i < tabNumber; ++i)
+ for(int i = 0; i < tabNumber; ++i)
{
QPair<QString, QString> item;
item.first = view->webTab(i)->view()->title();
@@ -135,7 +135,7 @@ void BookmarkOwner::openBookmark(const KBookmark &bookmark,
Qt::MouseButtons mouseButtons,
Qt::KeyboardModifiers keyboardModifiers)
{
- if (keyboardModifiers & Qt::ControlModifier || mouseButtons & Qt::MidButton)
+ if(keyboardModifiers & Qt::ControlModifier || mouseButtons & Qt::MidButton)
openBookmarkInNewTab(bookmark);
else
openBookmark(bookmark);
@@ -146,19 +146,19 @@ void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bkGoup)
{
QList<KUrl> urlList = bkGoup.groupUrlList();
- if (urlList.length() > 8)
+ if(urlList.length() > 8)
{
- if (KMessageBox::warningContinueCancel(
+ if(KMessageBox::warningContinueCancel(
rApp->mainWindow(),
i18ncp("%1=Number of tabs. Value is always >=8",
"You are about to open %1 tabs.\nAre you sure?",
"You are about to open %1 tabs.\nAre you sure?", urlList.length()))
!= KMessageBox::Continue
- )
+ )
return;
}
- Q_FOREACH(const KUrl &url, urlList)
+ Q_FOREACH(const KUrl & url, urlList)
{
emit openUrl(url, Rekonq::NewFocusedTab);
}
@@ -194,9 +194,9 @@ KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark)
{
KBookmarkGroup parent;
- if (!bookmark.isNull())
+ if(!bookmark.isNull())
{
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
parent = bookmark.toGroup();
else
parent = bookmark.parentGroup();
@@ -207,7 +207,7 @@ KBookmark BookmarkOwner::bookmarkCurrentPage(const KBookmark &bookmark)
}
KBookmark newBk = parent.addBookmark(currentTitle(), KUrl(currentUrl()));
- if (!bookmark.isNull())
+ if(!bookmark.isNull())
parent.moveBookmark(newBk, bookmark);
m_manager->emitChanged(parent);
@@ -221,16 +221,16 @@ KBookmarkGroup BookmarkOwner::newBookmarkFolder(const KBookmark &bookmark)
KBookmarkDialog *dialog = bookmarkDialog(m_manager, 0);
QString folderName = i18n("New folder");
- if (!bookmark.isNull())
+ if(!bookmark.isNull())
{
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
{
newBk = dialog->createNewFolder(folderName, bookmark);
}
else
{
newBk = dialog->createNewFolder(folderName, bookmark.parentGroup());
- if (!newBk.isNull())
+ if(!newBk.isNull())
{
KBookmarkGroup parent = newBk.parentGroup();
parent.moveBookmark(newBk, bookmark);
@@ -252,9 +252,9 @@ KBookmark BookmarkOwner::newSeparator(const KBookmark &bookmark)
{
KBookmark newBk;
- if (!bookmark.isNull())
+ if(!bookmark.isNull())
{
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
{
newBk = bookmark.toGroup().createNewSeparator();
}
@@ -278,7 +278,7 @@ KBookmark BookmarkOwner::newSeparator(const KBookmark &bookmark)
void BookmarkOwner::copyLink(const KBookmark &bookmark)
{
- if (bookmark.isNull())
+ if(bookmark.isNull())
return;
QApplication::clipboard()->setText(bookmark.url().url());
@@ -287,7 +287,7 @@ void BookmarkOwner::copyLink(const KBookmark &bookmark)
void BookmarkOwner::editBookmark(KBookmark bookmark)
{
- if (bookmark.isNull())
+ if(bookmark.isNull())
return;
KBookmarkDialog *dialog = bookmarkDialog(m_manager, 0);
@@ -299,18 +299,18 @@ void BookmarkOwner::editBookmark(KBookmark bookmark)
bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark)
{
- if (bookmark.isNull())
+ if(bookmark.isNull())
return false;
KBookmarkGroup bmg = bookmark.parentGroup();
QString dialogCaption, dialogText;
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
{
dialogCaption = i18n("Bookmark Folder Deletion");
dialogText = i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bookmark.fullText());
}
- else if (bookmark.isSeparator())
+ else if(bookmark.isSeparator())
{
dialogCaption = i18n("Separator Deletion");
dialogText = i18n("Are you sure you wish to remove this separator?");
@@ -321,7 +321,7 @@ bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark)
dialogText = i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bookmark.fullText());
}
- if (KMessageBox::warningContinueCancel(
+ if(KMessageBox::warningContinueCancel(
0,
dialogText,
dialogCaption,
@@ -329,7 +329,7 @@ bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark)
KStandardGuiItem::cancel(),
"bookmarkDeletition_askAgain")
!= KMessageBox::Continue
- )
+ )
return false;
bmg.deleteBookmark(bookmark);
@@ -340,7 +340,7 @@ bool BookmarkOwner::deleteBookmark(const KBookmark &bookmark)
void BookmarkOwner::setToolBarFolder(KBookmark bookmark)
{
- if (!bookmark.isGroup())
+ if(!bookmark.isGroup())
return;
unsetToolBarFolder();
@@ -354,7 +354,7 @@ void BookmarkOwner::setToolBarFolder(KBookmark bookmark)
void BookmarkOwner::unsetToolBarFolder()
{
KBookmarkGroup toolbar = m_manager->toolbar();
- if (!toolbar.isNull())
+ if(!toolbar.isNull())
{
toolbar.internalElement().setAttribute("toolbar", "no");
toolbar.setIcon("");
@@ -378,8 +378,8 @@ KAction* BookmarkOwner::createAction(const QString &text, const QString &icon,
CustomBookmarkAction::CustomBookmarkAction(const KBookmark &bookmark, const KIcon &icon, const QString &text, QObject *parent)
- : KAction(icon, text, parent)
- , m_bookmark(bookmark)
+ : KAction(icon, text, parent)
+ , m_bookmark(bookmark)
{
connect(this, SIGNAL(triggered()), this, SLOT(onActionTriggered()));
}
diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp
index fc351320..0d1b1ada 100644
--- a/src/bookmarks/bookmarkprovider.cpp
+++ b/src/bookmarks/bookmarkprovider.cpp
@@ -57,7 +57,7 @@ BookmarkProvider::BookmarkProvider(QObject *parent)
m_manager = KBookmarkManager::userBookmarksManager();
const QString bookmarksFile = KStandardDirs::locateLocal("data", QString::fromLatin1("konqueror/bookmarks.xml"));
- if (!QFile::exists(bookmarksFile))
+ if(!QFile::exists(bookmarksFile))
{
kDebug() << "copying of defaultbookmarks.xbel ...";
@@ -91,21 +91,21 @@ BookmarkProvider::~BookmarkProvider()
KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent)
{
kDebug() << "creating a bookmarks action menu...";
-
+
KMenu *menu = new KMenu(parent);
KActionMenu *bookmarkActionMenu = new KActionMenu(menu);
bookmarkActionMenu->setMenu(menu);
bookmarkActionMenu->setText(i18n("&Bookmarks"));
BookmarkMenu *bMenu = new BookmarkMenu(m_manager, m_owner, menu, m_actionCollection);
bMenu->setParent(menu);
-
+
return bookmarkActionMenu;
}
void BookmarkProvider::registerBookmarkBar(BookmarkToolBar *toolbar)
{
- if (m_bookmarkToolBars.contains(toolbar))
+ if(m_bookmarkToolBars.contains(toolbar))
return;
m_bookmarkToolBars.append(toolbar);
@@ -120,7 +120,7 @@ void BookmarkProvider::removeBookmarkBar(BookmarkToolBar *toolbar)
void BookmarkProvider::registerBookmarkPanel(BookmarksPanel *panel)
{
- if (panel && !m_bookmarkPanels.contains(panel))
+ if(panel && !m_bookmarkPanels.contains(panel))
{
m_bookmarkPanels.append(panel);
connect(panel, SIGNAL(expansionChanged()), this, SLOT(slotPanelChanged()));
@@ -130,13 +130,13 @@ void BookmarkProvider::registerBookmarkPanel(BookmarksPanel *panel)
void BookmarkProvider::removeBookmarkPanel(BookmarksPanel *panel)
{
- if (!panel)
+ if(!panel)
return;
m_bookmarkPanels.removeOne(panel);
panel->disconnect(this);
- if (m_bookmarkPanels.isEmpty())
+ if(m_bookmarkPanels.isEmpty())
rApp->bookmarkProvider()->bookmarkManager()->emitChanged();
}
@@ -144,7 +144,7 @@ void BookmarkProvider::removeBookmarkPanel(BookmarksPanel *panel)
QAction* BookmarkProvider::actionByName(const QString &name)
{
QAction *action = m_actionCollection->action(name);
- if (action)
+ if(action)
return action;
return new QAction(this);
}
@@ -161,8 +161,8 @@ QList<KBookmark> BookmarkProvider::find(const QString &text)
QList<KBookmark> list;
KBookmarkGroup root = rApp->bookmarkProvider()->rootGroup();
- if (!root.isNull())
- for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark))
+ if(!root.isNull())
+ for(KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark))
find(&list, bookmark, text);
return list;
@@ -172,7 +172,7 @@ QList<KBookmark> BookmarkProvider::find(const QString &text)
KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url)
{
KBookmarkGroup root = rootGroup();
- if (root.isNull())
+ if(root.isNull())
return KBookmark();
return bookmarkForUrl(root, url);
@@ -181,15 +181,15 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KUrl &url)
void BookmarkProvider::slotBookmarksChanged()
{
- foreach(BookmarkToolBar *bookmarkToolBar, m_bookmarkToolBars)
+ foreach(BookmarkToolBar * bookmarkToolBar, m_bookmarkToolBars)
{
- if (bookmarkToolBar)
+ if(bookmarkToolBar)
{
bookmarkToolBar->toolBar()->clear();
fillBookmarkBar(bookmarkToolBar);
}
}
- if (rApp->mainWindow() && rApp->mainWindow()->currentTab() && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks"))
+ if(rApp->mainWindow() && rApp->mainWindow()->currentTab() && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks"))
rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab);
}
@@ -197,25 +197,25 @@ void BookmarkProvider::slotBookmarksChanged()
void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar)
{
KBookmarkGroup root = m_manager->toolbar();
- if (root.isNull())
+ if(root.isNull())
return;
- for (KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark))
+ for(KBookmark bookmark = root.first(); !bookmark.isNull(); bookmark = root.next(bookmark))
{
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
{
KBookmarkActionMenu *menuAction = new KBookmarkActionMenu(bookmark.toGroup(), this);
menuAction->setDelayed(false);
BookmarkMenu *bMenu = new BookmarkMenu(bookmarkManager(), bookmarkOwner(), menuAction->menu(), bookmark.address());
bMenu->setParent(menuAction->menu());
-
+
connect(menuAction->menu(), SIGNAL(aboutToShow()), toolBar, SLOT(menuDisplayed()));
connect(menuAction->menu(), SIGNAL(aboutToHide()), toolBar, SLOT(menuHidden()));
toolBar->toolBar()->addAction(menuAction);
toolBar->toolBar()->widgetForAction(menuAction)->installEventFilter(toolBar);
}
- else if (bookmark.isSeparator())
+ else if(bookmark.isSeparator())
{
toolBar->toolBar()->addSeparator();
}
@@ -233,38 +233,38 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar)
void BookmarkProvider::slotPanelChanged()
{
- foreach(BookmarksPanel *panel, m_bookmarkPanels)
+ foreach(BookmarksPanel * panel, m_bookmarkPanels)
{
- if (panel && panel != sender())
+ if(panel && panel != sender())
panel->loadFoldedState();
}
- if (rApp->mainWindow() && rApp->mainWindow()->currentTab() && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks"))
+ if(rApp->mainWindow() && rApp->mainWindow()->currentTab() && rApp->mainWindow()->currentTab()->url().toMimeDataString().contains("about:bookmarks"))
rApp->loadUrl(KUrl("about:bookmarks"), Rekonq::CurrentTab);
}
void BookmarkProvider::find(QList<KBookmark> *list, const KBookmark &bookmark, const QString &text)
{
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
{
KBookmarkGroup group = bookmark.toGroup();
- for (KBookmark bm = group.first(); !bm.isNull(); bm = group.next(bm))
+ for(KBookmark bm = group.first(); !bm.isNull(); bm = group.next(bm))
find(list, bm, text);
}
else
{
QStringList words = text.split(' ');
bool matches = true;
- foreach(const QString &word, words)
+ foreach(const QString & word, words)
{
- if (!bookmark.url().url().contains(word, Qt::CaseInsensitive)
+ if(!bookmark.url().url().contains(word, Qt::CaseInsensitive)
&& !bookmark.fullText().contains(word, Qt::CaseInsensitive))
{
matches = false;
break;
}
}
- if (matches)
+ if(matches)
*list << bookmark;
}
}
@@ -274,18 +274,18 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl
{
KBookmark found;
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
{
KBookmarkGroup group = bookmark.toGroup();
KBookmark bookmark = group.first();
- while (!bookmark.isNull() && found.isNull())
+ while(!bookmark.isNull() && found.isNull())
{
found = bookmarkForUrl(bookmark, url);
bookmark = group.next(bookmark);
}
}
- else if (!bookmark.isSeparator() && bookmark.url() == url)
+ else if(!bookmark.isSeparator() && bookmark.url() == url)
{
found = bookmark;
}
@@ -297,19 +297,19 @@ KBookmark BookmarkProvider::bookmarkForUrl(const KBookmark &bookmark, const KUrl
void BookmarkProvider::copyBookmarkGroup(const KBookmarkGroup &groupToCopy, KBookmarkGroup destGroup)
{
KBookmark bookmark = groupToCopy.first();
- while (!bookmark.isNull())
+ while(!bookmark.isNull())
{
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
{
KBookmarkGroup newDestGroup = destGroup.createNewFolder(bookmark.text());
- if (bookmark.toGroup().isToolbarGroup())
+ if(bookmark.toGroup().isToolbarGroup())
{
newDestGroup.internalElement().setAttribute("toolbar", "yes");
newDestGroup.setIcon("bookmark-toolbar");
}
copyBookmarkGroup(bookmark.toGroup(), newDestGroup);
}
- else if (bookmark.isSeparator())
+ else if(bookmark.isSeparator())
{
destGroup.createNewSeparator();
}
diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp
index 1def2592..16936682 100644
--- a/src/bookmarks/bookmarkscontextmenu.cpp
+++ b/src/bookmarks/bookmarkscontextmenu.cpp
@@ -37,9 +37,9 @@
BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark, KBookmarkManager *manager, BookmarkOwner *owner, bool nullForced, QWidget *parent)
- : KBookmarkContextMenu(bookmark, manager, owner, parent)
- , m_bmOwner(owner)
- , m_nullForced(nullForced)
+ : KBookmarkContextMenu(bookmark, manager, owner, parent)
+ , m_bmOwner(owner)
+ , m_nullForced(nullForced)
{
}
@@ -70,7 +70,7 @@ void BookmarksContextMenu::addFolderActions()
{
KBookmarkGroup group = bookmark().toGroup();
- if (bookmark().internalElement().attributeNode("toolbar").value() == "yes")
+ if(bookmark().internalElement().attributeNode("toolbar").value() == "yes")
{
addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER));
}
@@ -79,16 +79,16 @@ void BookmarksContextMenu::addFolderActions()
addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::SET_TOOLBAR_FOLDER));
}
- if (!group.first().isNull())
+ if(!group.first().isNull())
{
KBookmark child = group.first();
- while (child.isGroup() || child.isSeparator())
+ while(child.isGroup() || child.isSeparator())
{
child = group.next(child);
}
- if (!child.isNull())
+ if(!child.isNull())
{
addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_FOLDER));
addSeparator();
@@ -121,7 +121,7 @@ void BookmarksContextMenu::addSeparatorActions()
void BookmarksContextMenu::addNullActions()
{
KBookmarkManager *manager = rApp->bookmarkProvider()->bookmarkManager();
- if (manager->toolbar().hasParent())
+ if(manager->toolbar().hasParent())
{
addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER));
}
@@ -133,15 +133,15 @@ void BookmarksContextMenu::addNullActions()
void BookmarksContextMenu::addActions()
{
- if (bookmark().isNull() || m_nullForced)
+ if(bookmark().isNull() || m_nullForced)
{
addNullActions();
}
- else if (bookmark().isSeparator())
+ else if(bookmark().isSeparator())
{
addSeparatorActions();
}
- else if (bookmark().isGroup())
+ else if(bookmark().isGroup())
{
addFolderActions();
}
diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp
index 94a3de94..8ad15309 100644
--- a/src/bookmarks/bookmarkspanel.cpp
+++ b/src/bookmarks/bookmarkspanel.cpp
@@ -43,9 +43,9 @@
BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags)
- : UrlPanel(title, parent, flags)
- , _bkTreeModel(new BookmarksTreeModel(this))
- , _loadingState(false)
+ : UrlPanel(title, parent, flags)
+ , _bkTreeModel(new BookmarksTreeModel(this))
+ , _loadingState(false)
{
setObjectName("bookmarksPanel");
setVisible(ReKonfig::showBookmarksPanel());
@@ -71,7 +71,7 @@ void BookmarksPanel::loadFoldedState()
void BookmarksPanel::contextMenu(const QPoint &pos)
{
- if (_loadingState)
+ if(_loadingState)
return;
BookmarksContextMenu menu(bookmarkForIndex(panelTreeView()->indexAt(pos)),
@@ -86,7 +86,7 @@ void BookmarksPanel::contextMenu(const QPoint &pos)
void BookmarksPanel::deleteBookmark()
{
QModelIndex index = panelTreeView()->currentIndex();
- if (_loadingState || !index.isValid())
+ if(_loadingState || !index.isValid())
return;
rApp->bookmarkProvider()->bookmarkOwner()->deleteBookmark(bookmarkForIndex(index));
@@ -95,7 +95,7 @@ void BookmarksPanel::deleteBookmark()
void BookmarksPanel::onCollapse(const QModelIndex &index)
{
- if (_loadingState)
+ if(_loadingState)
return;
bookmarkForIndex(index).internalElement().setAttribute("folded", "yes");
@@ -105,7 +105,7 @@ void BookmarksPanel::onCollapse(const QModelIndex &index)
void BookmarksPanel::onExpand(const QModelIndex &index)
{
- if (_loadingState)
+ if(_loadingState)
return;
bookmarkForIndex(index).internalElement().setAttribute("folded", "no");
@@ -129,19 +129,19 @@ void BookmarksPanel::setup()
void BookmarksPanel::loadFoldedState(const QModelIndex &root)
{
QAbstractItemModel *model = panelTreeView()->model();
- if (!model)
+ if(!model)
return;
int count = model->rowCount(root);
QModelIndex index;
- for (int i = 0; i < count; ++i)
+ for(int i = 0; i < count; ++i)
{
index = model->index(i, 0, root);
- if (index.isValid())
+ if(index.isValid())
{
KBookmark bm = bookmarkForIndex(index);
- if (bm.isGroup())
+ if(bm.isGroup())
{
panelTreeView()->setExpanded(index, bm.toGroup().isOpen());
loadFoldedState(index);
@@ -153,7 +153,7 @@ void BookmarksPanel::loadFoldedState(const QModelIndex &root)
KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index)
{
- if (!index.isValid())
+ if(!index.isValid())
return KBookmark();
const UrlFilterProxyModel *proxyModel = static_cast<const UrlFilterProxyModel*>(index.model());
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp
index b3ee8b18..ec91ad3a 100644
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ b/src/bookmarks/bookmarkstoolbar.cpp
@@ -47,7 +47,7 @@ BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,
KBookmarkOwner *owner,
KMenu *menu,
KActionCollection* actionCollection)
- : KBookmarkMenu(manager, owner, menu, actionCollection)
+ : KBookmarkMenu(manager, owner, menu, actionCollection)
{
}
@@ -56,7 +56,7 @@ BookmarkMenu::BookmarkMenu(KBookmarkManager *manager,
KBookmarkOwner *owner,
KMenu *parentMenu,
const QString &parentAddress)
- : KBookmarkMenu(manager, owner, parentMenu, parentAddress)
+ : KBookmarkMenu(manager, owner, parentMenu, parentAddress)
{
}
@@ -70,7 +70,7 @@ BookmarkMenu::~BookmarkMenu()
KMenu * BookmarkMenu::contextMenu(QAction *act)
{
KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(act);
- if (!action)
+ if(!action)
return 0;
return new BookmarksContextMenu(action->bookmark(), manager(), static_cast<BookmarkOwner*>(owner()));
}
@@ -78,7 +78,7 @@ KMenu * BookmarkMenu::contextMenu(QAction *act)
QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark)
{
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
{
KBookmarkActionMenu *actionMenu = new KBookmarkActionMenu(bookmark, this);
BookmarkMenu *menu = new BookmarkMenu(manager(), owner(), actionMenu->menu(), bookmark.address());
@@ -86,7 +86,7 @@ QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark)
connect(actionMenu, SIGNAL(hovered()), menu, SLOT(slotAboutToShow()));
return actionMenu;
}
- else if (bookmark.isSeparator())
+ else if(bookmark.isSeparator())
{
return KBookmarkMenu::actionForBookmark(bookmark);
}
@@ -105,10 +105,10 @@ void BookmarkMenu::refill()
clear();
fillBookmarks();
- if (parentMenu()->actions().count() > 0)
+ if(parentMenu()->actions().count() > 0)
parentMenu()->addSeparator();
- if (isRoot())
+ if(isRoot())
{
addAddBookmark();
addAddBookmarksList();
@@ -129,16 +129,16 @@ void BookmarkMenu::addOpenFolderInTabs()
{
KBookmarkGroup group = manager()->findByAddress(parentAddress()).toGroup();
- if (!group.first().isNull())
+ if(!group.first().isNull())
{
KBookmark bookmark = group.first();
- while (bookmark.isGroup() || bookmark.isSeparator())
+ while(bookmark.isGroup() || bookmark.isSeparator())
{
bookmark = group.next(bookmark);
}
- if (!bookmark.isNull())
+ if(!bookmark.isNull())
{
parentMenu()->addAction(rApp->bookmarkProvider()->bookmarkOwner()->createAction(group, BookmarkOwner::OPEN_FOLDER));
}
@@ -149,7 +149,7 @@ void BookmarkMenu::addOpenFolderInTabs()
void BookmarkMenu::actionHovered()
{
KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(sender());
- if (action)
+ if(action)
rApp->mainWindow()->notifyMessage(action->bookmark().url().url());
}
@@ -158,13 +158,13 @@ void BookmarkMenu::actionHovered()
BookmarkToolBar::BookmarkToolBar(KToolBar *toolBar, QObject *parent)
- : QObject(parent)
- , m_toolBar(toolBar)
- , m_currentMenu(0)
- , m_dragAction(0)
- , m_dropAction(0)
- , m_checkedAction(0)
- , m_filled(false)
+ : QObject(parent)
+ , m_toolBar(toolBar)
+ , m_currentMenu(0)
+ , m_dragAction(0)
+ , m_dropAction(0)
+ , m_checkedAction(0)
+ , m_filled(false)
{
toolBar->setContextMenuPolicy(Qt::CustomContextMenu);
connect(toolBar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &)));
@@ -173,7 +173,7 @@ BookmarkToolBar::BookmarkToolBar(KToolBar *toolBar, QObject *parent)
toolBar->installEventFilter(this);
toolBar->setShortcutEnabled(false);
- if (toolBar->isVisible())
+ if(toolBar->isVisible())
{
rApp->bookmarkProvider()->fillBookmarkBar(this);
m_filled = true;
@@ -192,7 +192,7 @@ void BookmarkToolBar::contextMenu(const QPoint &point)
KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface*>(toolBar()->actionAt(point));
KBookmark bookmark = rApp->bookmarkProvider()->bookmarkManager()->toolbar();
bool nullAction = true;
- if (action)
+ if(action)
{
bookmark = action->bookmark();
nullAction = false;
@@ -222,333 +222,333 @@ void BookmarkToolBar::menuHidden()
void BookmarkToolBar::hideMenu()
{
- if (m_currentMenu)
+ if(m_currentMenu)
m_currentMenu->hide();
}
bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
{
- if (m_currentMenu && m_currentMenu->isVisible()
- && !m_currentMenu->rect().contains(m_currentMenu->mapFromGlobal(QCursor::pos())))
+ if(m_currentMenu && m_currentMenu->isVisible()
+ && !m_currentMenu->rect().contains(m_currentMenu->mapFromGlobal(QCursor::pos())))
{
// To switch root folders as in a menubar
KBookmarkActionMenu* act = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(toolBar()->mapFromGlobal(QCursor::pos())));
- if (event->type() == QEvent::MouseMove && act && act->menu() != m_currentMenu)
+ if(event->type() == QEvent::MouseMove && act && act->menu() != m_currentMenu)
{
- m_currentMenu->hide();
- QPoint pos = toolBar()->mapToGlobal(toolBar()->widgetForAction(act)->pos());
- act->menu()->popup(QPoint(pos.x(), pos.y() + toolBar()->widgetForAction(act)->height()));
+ m_currentMenu->hide();
+ QPoint pos = toolBar()->mapToGlobal(toolBar()->widgetForAction(act)->pos());
+ act->menu()->popup(QPoint(pos.x(), pos.y() + toolBar()->widgetForAction(act)->height()));
}
- else if (event->type() == QEvent::MouseButtonPress && act)
+ else if(event->type() == QEvent::MouseButtonPress && act)
{
m_currentMenu->hide();
}
-
+
return QObject::eventFilter(watched, event);
}
-
- switch (event->type())
+
+ switch(event->type())
{
- case QEvent::Show:
+ case QEvent::Show:
+ {
+ if(!m_filled)
{
- if (!m_filled)
- {
- rApp->bookmarkProvider()->fillBookmarkBar(this);
- m_filled = true;
- }
+ rApp->bookmarkProvider()->fillBookmarkBar(this);
+ m_filled = true;
}
- break;
+ }
+ break;
- case QEvent::ActionRemoved:
+ case QEvent::ActionRemoved:
+ {
+ QActionEvent *actionEvent = static_cast<QActionEvent*>(event);
+ if(actionEvent && actionEvent->action() != m_dropAction)
{
- QActionEvent *actionEvent = static_cast<QActionEvent*>(event);
- if (actionEvent && actionEvent->action() != m_dropAction)
+ QWidget *widget = toolBar()->widgetForAction(actionEvent->action());
+ if(widget)
{
- QWidget *widget = toolBar()->widgetForAction(actionEvent->action());
- if (widget)
- {
- widget->removeEventFilter(this);
- }
+ widget->removeEventFilter(this);
}
}
- break;
+ }
+ break;
- case QEvent::ParentChange:
+ case QEvent::ParentChange:
+ {
+ QActionEvent *actionEvent = static_cast<QActionEvent*>(event);
+ if(actionEvent && actionEvent->action() != m_dropAction)
{
- QActionEvent *actionEvent = static_cast<QActionEvent*>(event);
- if (actionEvent && actionEvent->action() != m_dropAction)
+ QWidget *widget = toolBar()->widgetForAction(actionEvent->action());
+ if(widget)
{
- QWidget *widget = toolBar()->widgetForAction(actionEvent->action());
- if (widget)
- {
- widget->removeEventFilter(this);
- }
+ widget->removeEventFilter(this);
}
}
- break;
+ }
+ break;
- case QEvent::DragEnter:
+ case QEvent::DragEnter:
+ {
+ QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent*>(event);
+ if(dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain"))
{
- QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent*>(event);
- if (dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain"))
- {
- QFrame* dropIndicatorWidget = new QFrame(toolBar());
- dropIndicatorWidget->setFrameShape(QFrame::VLine);
- m_dropAction = toolBar()->insertWidget(toolBar()->actionAt(dragEvent->pos()), dropIndicatorWidget);
+ QFrame* dropIndicatorWidget = new QFrame(toolBar());
+ dropIndicatorWidget->setFrameShape(QFrame::VLine);
+ m_dropAction = toolBar()->insertWidget(toolBar()->actionAt(dragEvent->pos()), dropIndicatorWidget);
- dragEvent->accept();
- }
+ dragEvent->accept();
}
- break;
-
- case QEvent::DragLeave:
- {
- QDragLeaveEvent *dragEvent = static_cast<QDragLeaveEvent*>(event);
+ }
+ break;
- if (m_checkedAction)
- {
- m_checkedAction->setCheckable(false);
- m_checkedAction->setChecked(false);
- }
+ case QEvent::DragLeave:
+ {
+ QDragLeaveEvent *dragEvent = static_cast<QDragLeaveEvent*>(event);
- delete m_dropAction;
- m_dropAction = 0;
- dragEvent->accept();
+ if(m_checkedAction)
+ {
+ m_checkedAction->setCheckable(false);
+ m_checkedAction->setChecked(false);
}
- break;
- case QEvent::DragMove:
+ delete m_dropAction;
+ m_dropAction = 0;
+ dragEvent->accept();
+ }
+ break;
+
+ case QEvent::DragMove:
+ {
+ QDragMoveEvent *dragEvent = static_cast<QDragMoveEvent*>(event);
+ if(dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain"))
{
- QDragMoveEvent *dragEvent = static_cast<QDragMoveEvent*>(event);
- if (dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain"))
- {
- QAction *overAction = toolBar()->actionAt(dragEvent->pos());
- KBookmarkActionInterface *overActionBK = dynamic_cast<KBookmarkActionInterface*>(overAction);
- QWidget *widgetAction = toolBar()->widgetForAction(overAction);
+ QAction *overAction = toolBar()->actionAt(dragEvent->pos());
+ KBookmarkActionInterface *overActionBK = dynamic_cast<KBookmarkActionInterface*>(overAction);
+ QWidget *widgetAction = toolBar()->widgetForAction(overAction);
- if (overAction != m_dropAction && overActionBK && widgetAction && m_dropAction)
+ if(overAction != m_dropAction && overActionBK && widgetAction && m_dropAction)
+ {
+ toolBar()->removeAction(m_dropAction);
+ if(m_checkedAction)
{
- toolBar()->removeAction(m_dropAction);
- if (m_checkedAction)
- {
- m_checkedAction->setCheckable(false);
- m_checkedAction->setChecked(false);
- }
+ m_checkedAction->setCheckable(false);
+ m_checkedAction->setChecked(false);
+ }
- if (!overActionBK->bookmark().isGroup())
+ if(!overActionBK->bookmark().isGroup())
+ {
+ if((dragEvent->pos().x() - widgetAction->pos().x()) > (widgetAction->width() / 2))
{
- if ((dragEvent->pos().x() - widgetAction->pos().x()) > (widgetAction->width() / 2))
+ if(toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1)
{
- if (toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1)
- {
- toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction);
- }
- else
- {
- toolBar()->addAction(m_dropAction);
- }
+ toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction);
}
else
{
- toolBar()->insertAction(overAction, m_dropAction);
+ toolBar()->addAction(m_dropAction);
}
}
else
{
- if ((dragEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75))
- {
- if (toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1)
- {
- toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction);
- }
- else
- {
- toolBar()->addAction(m_dropAction);
- }
- }
- else if ((dragEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25))
+ toolBar()->insertAction(overAction, m_dropAction);
+ }
+ }
+ else
+ {
+ if((dragEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75))
+ {
+ if(toolBar()->actions().count() > toolBar()->actions().indexOf(overAction) + 1)
{
- toolBar()->insertAction(overAction, m_dropAction);
+ toolBar()->insertAction(toolBar()->actions().at(toolBar()->actions().indexOf(overAction) + 1), m_dropAction);
}
else
{
- overAction->setCheckable(true);
- overAction->setChecked(true);
- m_checkedAction = overAction;
+ toolBar()->addAction(m_dropAction);
}
}
-
- dragEvent->accept();
+ else if((dragEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25))
+ {
+ toolBar()->insertAction(overAction, m_dropAction);
+ }
+ else
+ {
+ overAction->setCheckable(true);
+ overAction->setChecked(true);
+ m_checkedAction = overAction;
+ }
}
+
+ dragEvent->accept();
}
}
- break;
+ }
+ break;
- case QEvent::Drop:
- {
- QDropEvent *dropEvent = static_cast<QDropEvent*>(event);
- KBookmark bookmark;
- KBookmarkGroup root = rApp->bookmarkProvider()->bookmarkManager()->toolbar();
+ case QEvent::Drop:
+ {
+ QDropEvent *dropEvent = static_cast<QDropEvent*>(event);
+ KBookmark bookmark;
+ KBookmarkGroup root = rApp->bookmarkProvider()->bookmarkManager()->toolbar();
- if (dropEvent->mimeData()->hasFormat("application/rekonq-bookmark"))
- {
- QByteArray addresses = dropEvent->mimeData()->data("application/rekonq-bookmark");
- bookmark = rApp->bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
- if (bookmark.isNull())
- return false;
- }
- else if (dropEvent->mimeData()->hasFormat("text/uri-list"))
+ if(dropEvent->mimeData()->hasFormat("application/rekonq-bookmark"))
+ {
+ QByteArray addresses = dropEvent->mimeData()->data("application/rekonq-bookmark");
+ bookmark = rApp->bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
+ if(bookmark.isNull())
+ return false;
+ }
+ else if(dropEvent->mimeData()->hasFormat("text/uri-list"))
+ {
+ kDebug() << "DROP is URL";
+ QString url = dropEvent->mimeData()->urls().at(0).toString();
+ QString title = url.contains(rApp->mainWindow()->currentTab()->url().url())
+ ? rApp->mainWindow()->currentTab()->view()->title()
+ : url;
+ bookmark = root.addBookmark(title, url);
+ }
+ else if(dropEvent->mimeData()->hasFormat("text/plain"))
+ {
+ kDebug() << "DROP is TEXT";
+ QString url = dropEvent->mimeData()->text();
+ KUrl u(url);
+ if(u.isValid())
{
- kDebug() << "DROP is URL";
- QString url = dropEvent->mimeData()->urls().at(0).toString();
- QString title = url.contains( rApp->mainWindow()->currentTab()->url().url() )
- ? rApp->mainWindow()->currentTab()->view()->title()
- : url;
+ QString title = url.contains(rApp->mainWindow()->currentTab()->url().url())
+ ? rApp->mainWindow()->currentTab()->view()->title()
+ : url;
bookmark = root.addBookmark(title, url);
}
- else if (dropEvent->mimeData()->hasFormat("text/plain"))
+ }
+ else
+ {
+ return false;
+ }
+
+ QAction *destAction = toolBar()->actionAt(dropEvent->pos());
+ if(destAction && destAction == m_dropAction)
+ {
+ if(toolBar()->actions().indexOf(m_dropAction) > 0)
{
- kDebug() << "DROP is TEXT";
- QString url = dropEvent->mimeData()->text();
- KUrl u(url);
- if (u.isValid())
- {
- QString title = url.contains( rApp->mainWindow()->currentTab()->url().url() )
- ? rApp->mainWindow()->currentTab()->view()->title()
- : url;
- bookmark = root.addBookmark(title, url);
- }
+ destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1);
}
else
{
- return false;
+ destAction = toolBar()->actions().at(1);
}
+ }
- QAction *destAction = toolBar()->actionAt(dropEvent->pos());
- if (destAction && destAction == m_dropAction)
- {
- if (toolBar()->actions().indexOf(m_dropAction) > 0)
- {
- destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1);
- }
- else
- {
- destAction = toolBar()->actions().at(1);
- }
- }
+ if(destAction)
+ {
+ KBookmarkActionInterface *destBookmarkAction = dynamic_cast<KBookmarkActionInterface *>(destAction);
+ QWidget *widgetAction = toolBar()->widgetForAction(destAction);
- if (destAction)
+ if(destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction
+ && bookmark.address() != destBookmarkAction->bookmark().address())
{
- KBookmarkActionInterface *destBookmarkAction = dynamic_cast<KBookmarkActionInterface *>(destAction);
- QWidget *widgetAction = toolBar()->widgetForAction(destAction);
+ KBookmark destBookmark = destBookmarkAction->bookmark();
- if (destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction
- && bookmark.address() != destBookmarkAction->bookmark().address())
+ if(!destBookmark.isGroup())
{
- KBookmark destBookmark = destBookmarkAction->bookmark();
-
- if (!destBookmark.isGroup())
+ if((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() / 2))
{
- if ((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() / 2))
- {
- root.moveBookmark(bookmark, destBookmark);
- }
- else
- {
- root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));
- }
+ root.moveBookmark(bookmark, destBookmark);
}
else
{
- if ((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75))
- {
- root.moveBookmark(bookmark, destBookmark);
- }
- else if ((dropEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25))
- {
- root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));
- }
- else
- {
- destBookmark.toGroup().addBookmark(bookmark);
- }
+ root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));
}
-
-
- rApp->bookmarkProvider()->bookmarkManager()->emitChanged();
}
- }
- else
- {
- root.deleteBookmark(bookmark);
- bookmark = root.addBookmark(bookmark);
- if (dropEvent->pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x())
+ else
{
- root.moveBookmark(bookmark, KBookmark());
+ if((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75))
+ {
+ root.moveBookmark(bookmark, destBookmark);
+ }
+ else if((dropEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25))
+ {
+ root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark));
+ }
+ else
+ {
+ destBookmark.toGroup().addBookmark(bookmark);
+ }
}
+
rApp->bookmarkProvider()->bookmarkManager()->emitChanged();
}
- dropEvent->accept();
}
- break;
+ else
+ {
+ root.deleteBookmark(bookmark);
+ bookmark = root.addBookmark(bookmark);
+ if(dropEvent->pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x())
+ {
+ root.moveBookmark(bookmark, KBookmark());
+ }
- default:
- break;
+ rApp->bookmarkProvider()->bookmarkManager()->emitChanged();
+ }
+ dropEvent->accept();
+ }
+ break;
+
+ default:
+ break;
}
// These events need to be handled only for Bookmark actions and not the bar
- if (watched != toolBar())
+ if(watched != toolBar())
{
- switch (event->type())
+ switch(event->type())
{
- case QEvent::MouseButtonPress: // drag handling
- {
- QPoint pos = toolBar()->mapFromGlobal(QCursor::pos());
- KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(pos));
+ case QEvent::MouseButtonPress: // drag handling
+ {
+ QPoint pos = toolBar()->mapFromGlobal(QCursor::pos());
+ KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(pos));
- if (action)
- {
- m_dragAction = toolBar()->actionAt(pos);
- m_startDragPos = pos;
+ if(action)
+ {
+ m_dragAction = toolBar()->actionAt(pos);
+ m_startDragPos = pos;
- // The menu is displayed only when the mouse button is released
- if (action->bookmark().isGroup())
- return true;
- }
+ // The menu is displayed only when the mouse button is released
+ if(action->bookmark().isGroup())
+ return true;
}
- break;
+ }
+ break;
- case QEvent::MouseMove:
+ case QEvent::MouseMove:
+ {
+ int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength();
+ if(!m_currentMenu && distance >= QApplication::startDragDistance())
{
- int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength();
- if (!m_currentMenu && distance >= QApplication::startDragDistance())
- {
- startDrag();
- }
+ startDrag();
}
- break;
+ }
+ break;
- case QEvent::MouseButtonRelease:
- {
- int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength();
- KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(m_startDragPos));
+ case QEvent::MouseButtonRelease:
+ {
+ int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength();
+ KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(toolBar()->actionAt(m_startDragPos));
- if (action && action->bookmark().isGroup() && distance < QApplication::startDragDistance())
- {
- KBookmarkActionMenu *menu = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(m_startDragPos));
- QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos());
- menu->menu()->popup(QPoint(actionPos.x(), actionPos.y() + toolBar()->widgetForAction(menu)->height()));
- }
+ if(action && action->bookmark().isGroup() && distance < QApplication::startDragDistance())
+ {
+ KBookmarkActionMenu *menu = dynamic_cast<KBookmarkActionMenu *>(toolBar()->actionAt(m_startDragPos));
+ QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos());
+ menu->menu()->popup(QPoint(actionPos.x(), actionPos.y() + toolBar()->widgetForAction(menu)->height()));
}
- break;
+ }
+ break;
- default:
- break;
+ default:
+ break;
}
}
@@ -559,7 +559,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event)
void BookmarkToolBar::actionHovered()
{
KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(sender());
- if (action)
+ if(action)
rApp->mainWindow()->notifyMessage(action->bookmark().url().url());
}
@@ -567,7 +567,7 @@ void BookmarkToolBar::actionHovered()
void BookmarkToolBar::startDrag()
{
KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(m_dragAction);
- if (action)
+ if(action)
{
QMimeData *mimeData = new QMimeData;
KBookmark bookmark = action->bookmark();
@@ -579,7 +579,7 @@ void BookmarkToolBar::startDrag()
QDrag *drag = new QDrag(toolBar());
drag->setMimeData(mimeData);
- if (bookmark.isGroup())
+ if(bookmark.isGroup())
{
drag->setPixmap(KIcon(bookmark.icon()).pixmap(24, 24));
}
@@ -597,7 +597,7 @@ void BookmarkToolBar::startDrag()
void BookmarkToolBar::dragDestroyed()
{
// A workaround to get rid of the checked state of the dragged action
- if (m_dragAction)
+ if(m_dragAction)
{
m_dragAction->setVisible(false);
m_dragAction->setVisible(true);
diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp
index 1e2e462f..f29e866f 100644
--- a/src/bookmarks/bookmarkstreemodel.cpp
+++ b/src/bookmarks/bookmarkstreemodel.cpp
@@ -44,8 +44,8 @@
BtmItem::BtmItem(const KBookmark &bm)
- : m_parent(0)
- , m_kbm(bm)
+ : m_parent(0)
+ , m_kbm(bm)
{
}
@@ -58,45 +58,45 @@ BtmItem::~BtmItem()
QVariant BtmItem::data(int role) const
{
- if (m_kbm.isNull())
+ if(m_kbm.isNull())
return QVariant(); // should only happen for root item
- if (role == Qt::DisplayRole)
+ if(role == Qt::DisplayRole)
return m_kbm.text();
- if (role == Qt::DecorationRole)
+ if(role == Qt::DecorationRole)
{
// NOTE
// this should be:
// return KIcon(m_kbm.icon());
// but I cannot let it work :(
// I really cannot understand how let this work properly...
- if (m_kbm.isGroup() || m_kbm.isSeparator())
+ if(m_kbm.isGroup() || m_kbm.isSeparator())
return KIcon(m_kbm.icon());
else
return rApp->iconManager()->iconForUrl(KUrl(m_kbm.url()));
}
- if (role == Qt::UserRole)
+ if(role == Qt::UserRole)
return m_kbm.url();
- if (role == Qt::ToolTipRole)
+ if(role == Qt::ToolTipRole)
{
QString tooltip = m_kbm.fullText();
- if (m_kbm.isGroup())
+ if(m_kbm.isGroup())
tooltip += i18ncp("%1=Number of items in bookmark folder", " (1 item)", " (%1 items)", childCount());
QString url = m_kbm.url().url();
- if (!url.isEmpty())
+ if(!url.isEmpty())
{
- if (!tooltip.isEmpty())
+ if(!tooltip.isEmpty())
tooltip += '\n';
tooltip += url;
}
- if (!m_kbm.description().isEmpty())
+ if(!m_kbm.description().isEmpty())
{
- if (!tooltip.isEmpty())
+ if(!tooltip.isEmpty())
tooltip += '\n';
tooltip += m_kbm.description();
}
@@ -110,7 +110,7 @@ QVariant BtmItem::data(int role) const
int BtmItem::row() const
{
- if (m_parent)
+ if(m_parent)
return m_parent->m_children.indexOf(const_cast< BtmItem* >(this));
return 0;
}
@@ -139,7 +139,7 @@ BtmItem* BtmItem::parent() const
void BtmItem::appendChild(BtmItem *child)
{
- if (!child)
+ if(!child)
return;
child->m_parent = this;
@@ -163,8 +163,8 @@ KBookmark BtmItem::getBkm() const
BookmarksTreeModel::BookmarksTreeModel(QObject *parent)
- : QAbstractItemModel(parent)
- , m_root(0)
+ : QAbstractItemModel(parent)
+ , m_root(0)
{
resetModel();
connect(rApp->bookmarkProvider()->bookmarkManager(), SIGNAL(changed(const QString &, const QString &)), this, SLOT(bookmarksChanged(const QString &)));
@@ -180,7 +180,7 @@ BookmarksTreeModel::~BookmarksTreeModel()
int BookmarksTreeModel::rowCount(const QModelIndex &parent) const
{
BtmItem *parentItem = 0;
- if (!parent.isValid())
+ if(!parent.isValid())
{
parentItem = m_root;
}
@@ -203,12 +203,12 @@ Qt::ItemFlags BookmarksTreeModel::flags(const QModelIndex &index) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
- if (!index.isValid())
+ if(!index.isValid())
return flags | Qt::ItemIsDropEnabled;
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
- if (bookmarkForIndex(index).isGroup())
+ if(bookmarkForIndex(index).isGroup())
flags |= Qt::ItemIsDropEnabled;
return flags;
@@ -217,18 +217,18 @@ Qt::ItemFlags BookmarksTreeModel::flags(const QModelIndex &index) const
QModelIndex BookmarksTreeModel::index(int row, int column, const QModelIndex &parent) const
{
- if (!hasIndex(row, column, parent))
+ if(!hasIndex(row, column, parent))
return QModelIndex();
BtmItem *parentItem;
- if (!parent.isValid())
+ if(!parent.isValid())
parentItem = m_root;
else
parentItem = static_cast<BtmItem*>(parent.internalPointer());
BtmItem *childItem = parentItem->child(row);
- if (childItem)
+ if(childItem)
return createIndex(row, column, childItem);
return QModelIndex();
@@ -237,13 +237,13 @@ QModelIndex BookmarksTreeModel::index(int row, int column, const QModelIndex &pa
QModelIndex BookmarksTreeModel::parent(const QModelIndex &index) const
{
- if (!index.isValid())
+ if(!index.isValid())
return QModelIndex();
BtmItem *childItem = static_cast<BtmItem*>(index.internalPointer());
BtmItem *parentItem = childItem->parent();
- if (parentItem == m_root)
+ if(parentItem == m_root)
return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem);
@@ -252,20 +252,20 @@ QModelIndex BookmarksTreeModel::parent(const QModelIndex &index) const
QVariant BookmarksTreeModel::data(const QModelIndex &index, int role) const
{
- if (!index.isValid())
+ if(!index.isValid())
return QVariant();
BtmItem *node = static_cast<BtmItem*>(index.internalPointer());
- if (node && node == m_root)
+ if(node && node == m_root)
{
- if (role == Qt::DisplayRole)
+ if(role == Qt::DisplayRole)
return i18n("Bookmarks");
- if (role == Qt::DecorationRole)
+ if(role == Qt::DecorationRole)
return KIcon("bookmarks");
}
else
{
- if (node)
+ if(node)
return node->data(role);
}
@@ -281,21 +281,21 @@ QStringList BookmarksTreeModel::mimeTypes() const
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"))
+ if(action != Qt::MoveAction || !data->hasFormat("application/rekonq-bookmark"))
return false;
QByteArray addresses = data->data("application/rekonq-bookmark");
KBookmark bookmark = rApp->bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
KBookmarkGroup root;
- if (parent.isValid())
+ if(parent.isValid())
root = bookmarkForIndex(parent).toGroup();
else
root = rApp->bookmarkProvider()->rootGroup();
QModelIndex destIndex = index(row, column, parent);
- if (destIndex.isValid() && row != -1)
+ if(destIndex.isValid() && row != -1)
{
root.moveBookmark(bookmark, root.previous(bookmarkForIndex(destIndex)));
}
@@ -331,7 +331,7 @@ QMimeData* BookmarksTreeModel::mimeData(const QModelIndexList &indexes) const
void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress)
{
- if (groupAddress.isEmpty())
+ if(groupAddress.isEmpty())
{
resetModel();
}
@@ -344,13 +344,13 @@ void BookmarksTreeModel::bookmarksChanged(const QString &groupAddress)
QStringList indexChain(groupAddress.split('/', QString::SkipEmptyParts));
bool ok;
int i;
- foreach(const QString &sIndex, indexChain)
+ foreach(const QString & sIndex, indexChain)
{
i = sIndex.toInt(&ok);
- if (!ok)
+ if(!ok)
break;
- if (i < 0 || i >= node->childCount())
+ if(i < 0 || i >= node->childCount())
break;
node = node->child(i);
@@ -384,14 +384,14 @@ void BookmarksTreeModel::populate(BtmItem *node, KBookmarkGroup bmg)
{
node->clear();
- if (bmg.isNull())
+ if(bmg.isNull())
return;
KBookmark bm = bmg.first();
- while (!bm.isNull())
+ while(!bm.isNull())
{
BtmItem *newChild = new BtmItem(bm);
- if (bm.isGroup())
+ if(bm.isGroup())
populate(newChild, bm.toGroup());
node->appendChild(newChild);