From 14664e54b1a2dbe9c06f474a0918a262dba04e20 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 25 Jul 2011 19:48:41 +0200 Subject: clean up - QL1S - one stupid kDebug less - codingstyle --- src/bookmarks/bookmarkstoolbar.cpp | 112 ++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'src/bookmarks/bookmarkstoolbar.cpp') diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp index efa1e1cc..6fa8fdec 100644 --- a/src/bookmarks/bookmarkstoolbar.cpp +++ b/src/bookmarks/bookmarkstoolbar.cpp @@ -70,7 +70,7 @@ BookmarkMenu::~BookmarkMenu() KMenu * BookmarkMenu::contextMenu(QAction *act) { KBookmarkActionInterface* action = dynamic_cast(act); - if(!action) + if (!action) return 0; return new BookmarksContextMenu(action->bookmark(), manager(), static_cast(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(sender()); - if(action) + if (action) rApp->mainWindow()->notifyMessage(action->bookmark().url().url()); } @@ -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(toolBar()->actionAt(point)); KBookmark bookmark = rApp->bookmarkProvider()->bookmarkManager()->toolbar(); bool nullAction = true; - if(action) + if (action) { bookmark = action->bookmark(); nullAction = false; @@ -222,27 +222,27 @@ 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() + 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(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())); } - else if(event->type() == QEvent::MouseButtonPress && act) + else if (event->type() == QEvent::MouseButtonPress && act) { m_currentMenu->hide(); } @@ -250,11 +250,11 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) return QObject::eventFilter(watched, event); } - switch(event->type()) + switch (event->type()) { case QEvent::Show: { - if(!m_filled) + if (!m_filled) { rApp->bookmarkProvider()->fillBookmarkBar(this); m_filled = true; @@ -265,10 +265,10 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::ActionRemoved: { QActionEvent *actionEvent = static_cast(event); - if(actionEvent && actionEvent->action() != m_dropAction) + if (actionEvent && actionEvent->action() != m_dropAction) { QWidget *widget = toolBar()->widgetForAction(actionEvent->action()); - if(widget) + if (widget) { widget->removeEventFilter(this); } @@ -279,10 +279,10 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::ParentChange: { QActionEvent *actionEvent = static_cast(event); - if(actionEvent && actionEvent->action() != m_dropAction) + if (actionEvent && actionEvent->action() != m_dropAction) { QWidget *widget = toolBar()->widgetForAction(actionEvent->action()); - if(widget) + if (widget) { widget->removeEventFilter(this); } @@ -293,7 +293,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::DragEnter: { QDragEnterEvent *dragEvent = static_cast(event); - if(dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain")) + 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); @@ -308,7 +308,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) { QDragLeaveEvent *dragEvent = static_cast(event); - if(m_checkedAction) + if (m_checkedAction) { m_checkedAction->setCheckable(false); m_checkedAction->setChecked(false); @@ -323,26 +323,26 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::DragMove: { QDragMoveEvent *dragEvent = static_cast(event); - if(dragEvent->mimeData()->hasFormat("application/rekonq-bookmark") || dragEvent->mimeData()->hasFormat("text/uri-list") || dragEvent->mimeData()->hasFormat("text/plain")) + 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(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) + if (m_checkedAction) { 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); } @@ -358,9 +358,9 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } else { - if((dragEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75)) + if ((dragEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75)) { - 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); } @@ -369,7 +369,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) toolBar()->addAction(m_dropAction); } } - else if((dragEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25)) + else if ((dragEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25)) { toolBar()->insertAction(overAction, m_dropAction); } @@ -394,14 +394,14 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) KBookmark bookmark; KBookmarkGroup root = rApp->bookmarkProvider()->bookmarkManager()->toolbar(); - if(dropEvent->mimeData()->hasFormat("application/rekonq-bookmark")) + 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()) + if (bookmark.isNull()) return false; } - else if(dropEvent->mimeData()->hasFormat("text/uri-list")) + else if (dropEvent->mimeData()->hasFormat("text/uri-list")) { // DROP is URL QString url = dropEvent->mimeData()->urls().at(0).toString(); @@ -410,12 +410,12 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) : url; bookmark = root.addBookmark(title, url); } - else if(dropEvent->mimeData()->hasFormat("text/plain")) + else if (dropEvent->mimeData()->hasFormat("text/plain")) { // DROP is TEXT QString url = dropEvent->mimeData()->text(); KUrl u(url); - if(u.isValid()) + if (u.isValid()) { QString title = url.contains(rApp->mainWindow()->currentTab()->url().url()) ? rApp->mainWindow()->currentTab()->view()->title() @@ -429,9 +429,9 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } QAction *destAction = toolBar()->actionAt(dropEvent->pos()); - if(destAction && destAction == m_dropAction) + if (destAction && destAction == m_dropAction) { - if(toolBar()->actions().indexOf(m_dropAction) > 0) + if (toolBar()->actions().indexOf(m_dropAction) > 0) { destAction = toolBar()->actions().at(toolBar()->actions().indexOf(m_dropAction) - 1); } @@ -441,19 +441,19 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } } - if(destAction) + if (destAction) { KBookmarkActionInterface *destBookmarkAction = dynamic_cast(destAction); QWidget *widgetAction = toolBar()->widgetForAction(destAction); - if(destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction + if (destBookmarkAction && !destBookmarkAction->bookmark().isNull() && widgetAction && bookmark.address() != destBookmarkAction->bookmark().address()) { KBookmark destBookmark = destBookmarkAction->bookmark(); - if(!destBookmark.isGroup()) + 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); } @@ -464,11 +464,11 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } else { - if((dropEvent->pos().x() - widgetAction->pos().x()) >= (widgetAction->width() * 0.75)) + 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)) + else if ((dropEvent->pos().x() - widgetAction->pos().x()) <= (widgetAction->width() * 0.25)) { root.moveBookmark(bookmark, destBookmark.parentGroup().previous(destBookmark)); } @@ -486,7 +486,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) { root.deleteBookmark(bookmark); bookmark = root.addBookmark(bookmark); - if(dropEvent->pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x()) + if (dropEvent->pos().x() < toolBar()->widgetForAction(toolBar()->actions().first())->pos().x()) { root.moveBookmark(bookmark, KBookmark()); } @@ -502,22 +502,22 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) } // 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(toolBar()->actionAt(pos)); - if(action) + 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()) + if (action->bookmark().isGroup()) return true; } } @@ -526,7 +526,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) case QEvent::MouseMove: { int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength(); - if(!m_currentMenu && distance >= QApplication::startDragDistance()) + if (!m_currentMenu && distance >= QApplication::startDragDistance()) { startDrag(); } @@ -538,7 +538,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) int distance = (toolBar()->mapFromGlobal(QCursor::pos()) - m_startDragPos).manhattanLength(); KBookmarkActionInterface *action = dynamic_cast(toolBar()->actionAt(m_startDragPos)); - if(action && action->bookmark().isGroup() && distance < QApplication::startDragDistance()) + if (action && action->bookmark().isGroup() && distance < QApplication::startDragDistance()) { KBookmarkActionMenu *menu = dynamic_cast(toolBar()->actionAt(m_startDragPos)); QPoint actionPos = toolBar()->mapToGlobal(toolBar()->widgetForAction(menu)->pos()); @@ -559,7 +559,7 @@ bool BookmarkToolBar::eventFilter(QObject *watched, QEvent *event) void BookmarkToolBar::actionHovered() { KBookmarkActionInterface* action = dynamic_cast(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(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); -- cgit v1.2.1