diff options
Diffstat (limited to 'src/bookmarks')
-rw-r--r-- | src/bookmarks/bookmarkcontextmenu.cpp | 48 | ||||
-rw-r--r-- | src/bookmarks/bookmarksmanager.cpp | 66 | ||||
-rw-r--r-- | src/bookmarks/bookmarksmanager.h | 14 | ||||
-rw-r--r-- | src/bookmarks/bookmarkspanel.cpp | 46 | ||||
-rw-r--r-- | src/bookmarks/bookmarksproxy.cpp | 18 | ||||
-rw-r--r-- | src/bookmarks/bookmarksproxy.h | 6 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstreemodel.cpp | 172 | ||||
-rw-r--r-- | src/bookmarks/bookmarkstreemodel.h | 12 |
8 files changed, 194 insertions, 188 deletions
diff --git a/src/bookmarks/bookmarkcontextmenu.cpp b/src/bookmarks/bookmarkcontextmenu.cpp index aab6af90..df8bf5e0 100644 --- a/src/bookmarks/bookmarkcontextmenu.cpp +++ b/src/bookmarks/bookmarkcontextmenu.cpp @@ -42,8 +42,8 @@ BookmarkContextMenu::BookmarkContextMenu(const KBookmark & bookmark, KBookmarkManager *manager, KBookmarkOwner *owner, QWidget *parent) - : KBookmarkContextMenu(bookmark, manager, owner, parent) - , m_ac(new KActionCollection(this)) + : KBookmarkContextMenu(bookmark, manager, owner, parent) + , m_ac(new KActionCollection(this)) { setupActions(); } @@ -120,7 +120,7 @@ void BookmarkContextMenu::addBookmarkActions() void BookmarkContextMenu::addFolderActions() { - if(!bookmark().toGroup().first().isNull()) + if (!bookmark().toGroup().first().isNull()) { addAction(m_ac->action("open_all")); addSeparator(); @@ -151,17 +151,17 @@ void BookmarkContextMenu::addSeparatorActions() void BookmarkContextMenu::addActions() { - if(bookmark().isGroup()) + if (bookmark().isGroup()) { addFolderActions(); } - else if(bookmark().isSeparator()) + else if (bookmark().isSeparator()) { addSeparatorActions(); } - else if(bookmark().isNull()) + else if (bookmark().isNull()) { addAction(m_ac->action("bookmark_page")); addAction(m_ac->action("folder_new")); @@ -195,7 +195,7 @@ void BookmarkContextMenu::openInNewWindow() void BookmarkContextMenu::copyToClipboard() { - if(bookmark().isNull()) + if (bookmark().isNull()) return; QClipboard *cb = QApplication::clipboard(); @@ -209,14 +209,14 @@ void BookmarkContextMenu::deleteBookmark() bool folder = bm.isGroup(); if (KMessageBox::warningContinueCancel( - QApplication::activeWindow(), - folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bm.text()) - : i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bm.text()), - folder ? i18n("Bookmark Folder Deletion") - : i18n("Bookmark Deletion"), - KStandardGuiItem::del()) - != KMessageBox::Continue - ) + QApplication::activeWindow(), + folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bm.text()) + : i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bm.text()), + folder ? i18n("Bookmark Folder Deletion") + : i18n("Bookmark Deletion"), + KStandardGuiItem::del()) + != KMessageBox::Continue + ) return; bm.parentGroup().deleteBookmark(bm); @@ -236,7 +236,7 @@ void BookmarkContextMenu::editBookmark() void BookmarkContextMenu::openFolderInTabs() { - if(bookmark().isGroup()) + if (bookmark().isGroup()) owner()->openFolderinTabs(bookmark().toGroup()); } @@ -246,9 +246,9 @@ void BookmarkContextMenu::newBookmarkGroup() KBookmark selected = bookmark(); KBookmarkDialog *dialog = owner()->bookmarkDialog(manager(), QApplication::activeWindow()); - if(!selected.isNull()) + if (!selected.isNull()) { - if(selected.isGroup()) + if (selected.isGroup()) { dialog->createNewFolder("New folder", selected); } @@ -275,9 +275,9 @@ void BookmarkContextMenu::newSeparator() KBookmark selected = bookmark(); KBookmark newBk; - if(!selected.isNull()) + if (!selected.isNull()) { - if(selected.isGroup()) + if (selected.isGroup()) newBk = selected.toGroup().createNewSeparator(); else newBk = selected.parentGroup().createNewSeparator(); @@ -292,7 +292,7 @@ void BookmarkContextMenu::newSeparator() newBk.setIcon(("edit-clear")); parent.addBookmark(newBk); - if(!selected.isNull()) + if (!selected.isNull()) parent.moveBookmark(newBk, selected); manager()->emitChanged(); @@ -304,11 +304,11 @@ void BookmarkContextMenu::bookmarkCurrentPage() KBookmarkGroup parent = Application::bookmarkProvider()->rootGroup(); KBookmark selected = bookmark(); - if(!selected.isNull()) + if (!selected.isNull()) { parent = selected.parentGroup(); - if(selected.isGroup()) + if (selected.isGroup()) parent = selected.toGroup(); KBookmark newBk = parent.addBookmark(owner()->currentTitle(), KUrl(owner()->currentUrl()), "text-html"); @@ -317,7 +317,7 @@ void BookmarkContextMenu::bookmarkCurrentPage() else { - parent.addBookmark(owner()->currentTitle(), KUrl(owner()->currentUrl()), "text-html"); + parent.addBookmark(owner()->currentTitle(), KUrl(owner()->currentUrl()), "text-html"); } manager()->emitChanged(); diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp index b3354c57..a8866fe7 100644 --- a/src/bookmarks/bookmarksmanager.cpp +++ b/src/bookmarks/bookmarksmanager.cpp @@ -13,9 +13,9 @@ * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy +* by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. -* +* * 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 @@ -55,8 +55,8 @@ BookmarkOwner::BookmarkOwner(QObject *parent) - : QObject(parent) - , KBookmarkOwner() + : QObject(parent) + , KBookmarkOwner() { } @@ -98,9 +98,9 @@ void BookmarkOwner::openFolderinTabs(const KBookmarkGroup &bookmark) { QList<KUrl> urlList = bookmark.groupUrlList(); - if(urlList.length() > 8) + if (urlList.length() > 8) { - if(!(KMessageBox::warningContinueCancel(Application::instance()->mainWindow(), i18n("You are about to open %1 tabs.\nAre you sure ?", QString::number(urlList.length()))) == KMessageBox::Continue)) + if (!(KMessageBox::warningContinueCancel(Application::instance()->mainWindow(), i18n("You are about to open %1 tabs.\nAre you sure ?", QString::number(urlList.length()))) == KMessageBox::Continue)) return; } @@ -117,7 +117,7 @@ QList< QPair<QString, QString> > BookmarkOwner::currentBookmarkList() const QList< QPair<QString, QString> > bkList; int tabNumber = Application::instance()->mainWindow()->mainView()->count(); - for(int i = 0; i < tabNumber; i++) + for (int i = 0; i < tabNumber; i++) { QPair<QString, QString> item; item.first = Application::instance()->mainWindow()->mainView()->webTab(i)->view()->title(); @@ -135,10 +135,10 @@ BookmarkMenu::BookmarkMenu(KBookmarkManager *manager, KBookmarkOwner *owner, KMenu *menu, KActionCollection* actionCollection) - : KBookmarkMenu(manager, owner, menu, actionCollection) + : KBookmarkMenu(manager, owner, menu, actionCollection) { KAction *a = KStandardAction::addBookmark(this, SLOT(slotAddBookmark()), this); - actionCollection->addAction(QLatin1String("rekonq_add_bookmark"),a); + actionCollection->addAction(QLatin1String("rekonq_add_bookmark"), a); refill(); } @@ -147,7 +147,7 @@ BookmarkMenu::BookmarkMenu(KBookmarkManager *manager, KBookmarkOwner *owner, KMenu *parentMenu, const QString &parentAddress) - : KBookmarkMenu(manager, owner, parentMenu, parentAddress) + : KBookmarkMenu(manager, owner, parentMenu, parentAddress) { refill(); } @@ -162,9 +162,9 @@ KMenu * BookmarkMenu::contextMenu(QAction *act) { KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(act); - if (!action) - return 0; - return new BookmarkContextMenu(action->bookmark(), manager(), owner()); + if (!action) + return 0; + return new BookmarkContextMenu(action->bookmark(), manager(), owner()); } @@ -186,20 +186,20 @@ void BookmarkMenu::slotAddBookmark() QAction * BookmarkMenu::actionForBookmark(const KBookmark &bookmark) { - if(bookmark.isGroup()) + if (bookmark.isGroup()) { KBookmarkActionMenu *actionMenu = new KBookmarkActionMenu(bookmark, this); new BookmarkMenu(manager(), owner(), actionMenu->menu(), bookmark.address()); return actionMenu; } - else if(bookmark.isSeparator()) + else if (bookmark.isSeparator()) { return KBookmarkMenu::actionForBookmark(bookmark); } else { Application::bookmarkProvider()->completionObject()->addItem(bookmark.url().url()); - return new KBookmarkAction( bookmark, owner(), this ); + return new KBookmarkAction(bookmark, owner(), this); } } @@ -208,10 +208,10 @@ void BookmarkMenu::refill() { fillBookmarks(); - if(parentMenu()->actions().count() > 0) + if (parentMenu()->actions().count() > 0) parentMenu()->addSeparator(); - if(isRoot()) + if (isRoot()) { addAddBookmark(); addAddBookmarksList(); @@ -234,19 +234,19 @@ void BookmarkMenu::addOpenFolderInTabs() KAction *action; 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()) { action = new KAction(KIcon("tab-new"), i18n("Open Folder in Tabs"), this); - action->setHelpText( i18n( "Open all bookmarks in this folder as a new tab." ) ); + action->setHelpText(i18n("Open all bookmarks in this folder as a new tab.")); connect(action, SIGNAL(triggered(bool)), this, SLOT(slotOpenFolderInTabs())); parentMenu()->addAction(action); } @@ -267,7 +267,7 @@ BookmarkProvider::BookmarkProvider(QObject *parent) { // take care of the completion object m_completion = new KCompletion; - m_completion->setOrder( KCompletion::Weighted ); + m_completion->setOrder(KCompletion::Weighted); KUrl bookfile = KUrl("~/.kde/share/apps/konqueror/bookmarks.xml"); // share konqueror bookmarks @@ -287,7 +287,7 @@ BookmarkProvider::BookmarkProvider(QObject *parent) } m_manager = KBookmarkManager::managerForFile(bookfile.path(), "rekonq"); - + connect(m_manager, SIGNAL(changed(const QString &, const QString &)), this, SLOT(slotBookmarksChanged(const QString &, const QString &))); @@ -353,11 +353,11 @@ QAction *BookmarkProvider::actionByName(const QString &name) void BookmarkProvider::contextMenu(const QPoint &point) { - if(m_bookmarkToolBars.isEmpty()) + if (m_bookmarkToolBars.isEmpty()) return; KToolBar *bookmarkToolBar = m_bookmarkToolBars.at(0); - if(!bookmarkToolBar) + if (!bookmarkToolBar) return; KBookmarkActionInterface* action = dynamic_cast<KBookmarkActionInterface *>(bookmarkToolBar->actionAt(point)); @@ -386,10 +386,10 @@ KActionMenu* BookmarkProvider::bookmarkActionMenu(QWidget *parent) void BookmarkProvider::fillBookmarkBar(KToolBar *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()) { @@ -400,7 +400,7 @@ void BookmarkProvider::fillBookmarkBar(KToolBar *toolBar) toolBar->addAction(menuAction); } - else if(bookmark.isSeparator()) + else if (bookmark.isSeparator()) { toolBar->addSeparator(); } @@ -440,12 +440,12 @@ QString BookmarkProvider::titleForBookmarkUrl(QString url) title = titleForBookmarkUrl(bookmark, url); bookmark = bookGroup.next(bookmark); } - + if (title.isEmpty()) { title = url; } - + return title; } @@ -463,10 +463,10 @@ QString BookmarkProvider::titleForBookmarkUrl(const KBookmark &bookmark, QString bm = group.next(bm); } } - else if(!bookmark.isSeparator() && bookmark.url()==url) + else if (!bookmark.isSeparator() && bookmark.url() == url) { title = bookmark.fullText(); } - + return title; } diff --git a/src/bookmarks/bookmarksmanager.h b/src/bookmarks/bookmarksmanager.h index 38726724..05426243 100644 --- a/src/bookmarks/bookmarksmanager.h +++ b/src/bookmarks/bookmarksmanager.h @@ -224,9 +224,15 @@ public: */ KBookmarkGroup rootGroup(); - KBookmarkManager *bookmarkManager() { return m_manager; } - BookmarkOwner *bookmarkOwner() { return m_owner; } - + KBookmarkManager *bookmarkManager() + { + return m_manager; + } + BookmarkOwner *bookmarkOwner() + { + return m_owner; + } + /** * @returns the KCompletion object. */ @@ -260,7 +266,7 @@ public slots: */ void slotBookmarksChanged(const QString &group, const QString &caller); - + private: void fillBookmarkBar(KToolBar *toolBar); QString titleForBookmarkUrl(const KBookmark &bookmark, QString url); diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp index 0caf0f31..0f4e64b8 100644 --- a/src/bookmarks/bookmarkspanel.cpp +++ b/src/bookmarks/bookmarkspanel.cpp @@ -51,9 +51,9 @@ BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags) - : QDockWidget(title, parent, flags) - , m_treeView(new PanelTreeView(this)) - , m_loadingState(false) + : QDockWidget(title, parent, flags) + , m_treeView(new PanelTreeView(this)) + , m_loadingState(false) { setup(); setShown(ReKonfig::showBookmarksPanel()); @@ -81,7 +81,7 @@ void BookmarksPanel::setup() KLineEdit *search = new KLineEdit; search->setClearButtonShown(true); searchLayout->addWidget(search); - searchLabel->setBuddy( search ); + searchLabel->setBuddy(search); // setup tree view m_treeView->setUniformRowHeights(true); @@ -103,10 +103,10 @@ void BookmarksPanel::setup() ui->setLayout(vBoxLayout); setWidget(ui); - BookmarksTreeModel *model = new BookmarksTreeModel( this ); + BookmarksTreeModel *model = new BookmarksTreeModel(this); BookmarksProxy *proxy = new BookmarksProxy(ui); - proxy->setSourceModel( model ); - m_treeView->setModel( proxy ); + proxy->setSourceModel(model); + m_treeView->setModel(proxy); connect(m_treeView, SIGNAL(contextMenuItemRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); connect(m_treeView, SIGNAL(contextMenuGroupRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); @@ -121,20 +121,20 @@ void BookmarksPanel::setup() KBookmark BookmarksPanel::bookmarkForIndex(const QModelIndex &index) { - if(!index.isValid()) + if (!index.isValid()) return KBookmark(); const QAbstractProxyModel* proxyModel = dynamic_cast< const QAbstractProxyModel* >(index.model()); QModelIndex originalIndex = proxyModel->mapToSource(index); - BtmItem *node = static_cast< BtmItem* >( originalIndex.internalPointer() ); + BtmItem *node = static_cast< BtmItem* >(originalIndex.internalPointer()); return node->getBkm(); } void BookmarksPanel::onCollapse(const QModelIndex &index) { - if(m_loadingState) + if (m_loadingState) return; KBookmark bookmark = bookmarkForIndex(index); @@ -145,7 +145,7 @@ void BookmarksPanel::onCollapse(const QModelIndex &index) void BookmarksPanel::onExpand(const QModelIndex &index) { - if(m_loadingState) + if (m_loadingState) return; KBookmark bookmark = bookmarkForIndex(index); @@ -168,10 +168,10 @@ void BookmarksPanel::loadFoldedState(const QModelIndex &root) int count = m_treeView->model()->rowCount(root); QModelIndex index; - for(int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { index = m_treeView->model()->index(i, 0, root); - if(index.isValid() && bookmarkForIndex(index).isGroup()) + if (index.isValid() && bookmarkForIndex(index).isGroup()) { m_treeView->setExpanded(index, bookmarkForIndex(index).toGroup().isOpen()); loadFoldedState(index); @@ -183,7 +183,7 @@ void BookmarksPanel::loadFoldedState(const QModelIndex &root) void BookmarksPanel::contextMenu(const QPoint &pos) { QModelIndex index = m_treeView->indexAt(pos); - if(m_loadingState) + if (m_loadingState) return; KBookmark selected = bookmarkForIndex(index); @@ -196,21 +196,21 @@ void BookmarksPanel::contextMenu(const QPoint &pos) void BookmarksPanel::deleteBookmark() { QModelIndex index = m_treeView->currentIndex(); - if(!index.isValid()) + if (!index.isValid()) return; KBookmark bm = bookmarkForIndex(index); bool folder = bm.isGroup(); if (KMessageBox::warningContinueCancel( - QApplication::activeWindow(), - folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bm.text()) - : i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bm.text()), - folder ? i18n("Bookmark Folder Deletion") - : i18n("Bookmark Deletion"), - KStandardGuiItem::del()) - != KMessageBox::Continue - ) + QApplication::activeWindow(), + folder ? i18n("Are you sure you wish to remove the bookmark folder\n\"%1\"?", bm.text()) + : i18n("Are you sure you wish to remove the bookmark\n\"%1\"?", bm.text()), + folder ? i18n("Bookmark Folder Deletion") + : i18n("Bookmark Deletion"), + KStandardGuiItem::del()) + != KMessageBox::Continue + ) return; diff --git a/src/bookmarks/bookmarksproxy.cpp b/src/bookmarks/bookmarksproxy.cpp index 7fa34b3f..4e4b4f06 100644 --- a/src/bookmarks/bookmarksproxy.cpp +++ b/src/bookmarks/bookmarksproxy.cpp @@ -30,27 +30,27 @@ #include "bookmarksproxy.moc" -BookmarksProxy::BookmarksProxy( QObject *parent ) - : QSortFilterProxyModel( parent ) +BookmarksProxy::BookmarksProxy(QObject *parent) + : QSortFilterProxyModel(parent) { } -bool BookmarksProxy::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const +bool BookmarksProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { - QModelIndex idx = sourceModel()->index( source_row, 0, source_parent ); - return recursiveMatch( idx ); + QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); + return recursiveMatch(idx); } -bool BookmarksProxy::recursiveMatch( const QModelIndex &index ) const +bool BookmarksProxy::recursiveMatch(const QModelIndex &index) const { - if( index.data().toString().contains( filterRegExp() ) ) + if (index.data().toString().contains(filterRegExp())) return true; - for( int childRow = 0; childRow < sourceModel()->rowCount( index ); ++childRow ) + for (int childRow = 0; childRow < sourceModel()->rowCount(index); ++childRow) { - if( recursiveMatch( sourceModel()->index( childRow, 0, index ) ) ) + if (recursiveMatch(sourceModel()->index(childRow, 0, index))) return true; } return false; diff --git a/src/bookmarks/bookmarksproxy.h b/src/bookmarks/bookmarksproxy.h index 2bf1d63a..8b2cf95e 100644 --- a/src/bookmarks/bookmarksproxy.h +++ b/src/bookmarks/bookmarksproxy.h @@ -42,13 +42,13 @@ class REKONQ_TESTS_EXPORT BookmarksProxy : public QSortFilterProxyModel Q_DISABLE_COPY(BookmarksProxy) public: - BookmarksProxy( QObject *parent = 0 ); + BookmarksProxy(QObject *parent = 0); protected: - virtual bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const; + virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; // returns true if any child(or children-child...) matches filter - bool recursiveMatch( const QModelIndex &index ) const; + bool recursiveMatch(const QModelIndex &index) const; }; #endif // BOOKMARKSPROXY_H diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp index 836401a6..5fffa3da 100644 --- a/src/bookmarks/bookmarkstreemodel.cpp +++ b/src/bookmarks/bookmarkstreemodel.cpp @@ -42,8 +42,8 @@ BtmItem::BtmItem(const KBookmark &bm) - : m_parent(0) - , m_kbm(bm) + : m_parent(0) + , m_kbm(bm) { } @@ -54,32 +54,32 @@ BtmItem::~BtmItem() } -QVariant BtmItem::data( int role ) const +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 ) - return KIcon( m_kbm.icon() ); - if( role == Qt::UserRole ) + if (role == Qt::DecorationRole) + return KIcon(m_kbm.icon()); + if (role == Qt::UserRole) return m_kbm.url(); - if( role == Qt::ToolTipRole) + if (role == Qt::ToolTipRole) { QString tooltip = ""; - - if(!m_kbm.text().isEmpty()) - { + + if (!m_kbm.text().isEmpty()) + { tooltip += m_kbm.text(); - } - if(m_kbm.isGroup()) - { + } + if (m_kbm.isGroup()) + { tooltip += " [" + QString::number(childCount()) + " " + i18n("Items") + "]"; - } - if(!m_kbm.url().url().isEmpty()) + } + if (!m_kbm.url().url().isEmpty()) { - if(!tooltip.isEmpty()) + if (!tooltip.isEmpty()) tooltip += "\n"; tooltip += m_kbm.url().url(); } @@ -92,8 +92,8 @@ QVariant BtmItem::data( int role ) const int BtmItem::row() const { - if(m_parent) - return m_parent->m_children.indexOf( const_cast< BtmItem* >( this ) ); + if (m_parent) + return m_parent->m_children.indexOf(const_cast< BtmItem* >(this)); return 0; } @@ -104,10 +104,10 @@ int BtmItem::childCount() const } -BtmItem* BtmItem::child( int n ) +BtmItem* BtmItem::child(int n) { - Q_ASSERT(n>=0); - Q_ASSERT(n<childCount()); + Q_ASSERT(n >= 0); + Q_ASSERT(n < childCount()); return m_children.at(n); } @@ -121,7 +121,7 @@ BtmItem* BtmItem::parent() const void BtmItem::appendChild(BtmItem *child) { - if( !child ) + if (!child) return; child->m_parent = this; @@ -144,13 +144,13 @@ KBookmark BtmItem::getBkm() const BookmarksTreeModel::BookmarksTreeModel(QObject *parent) - : QAbstractItemModel(parent) - , m_root(0) + : QAbstractItemModel(parent) + , m_root(0) { resetModel(); - connect( this, SIGNAL(bookmarksUpdated()), parent, SLOT(loadFoldedState())); - connect( Application::bookmarkProvider()->bookmarkManager(), SIGNAL( changed(QString,QString) ), this, SLOT( bookmarksChanged() ) ); - connect( parent, SIGNAL(saveOnlyRequested()), this, SLOT(saveOnly()) ); + connect(this, SIGNAL(bookmarksUpdated()), parent, SLOT(loadFoldedState())); + connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString, QString)), this, SLOT(bookmarksChanged())); + connect(parent, SIGNAL(saveOnlyRequested()), this, SLOT(saveOnly())); } @@ -163,13 +163,13 @@ BookmarksTreeModel::~BookmarksTreeModel() int BookmarksTreeModel::rowCount(const QModelIndex &parent) const { BtmItem *parentItem = 0; - if( !parent.isValid() ) + if (!parent.isValid()) { parentItem = m_root; } - else + else { - parentItem = static_cast< BtmItem* >( parent.internalPointer() ); + parentItem = static_cast< BtmItem* >(parent.internalPointer()); } return parentItem->childCount(); @@ -186,11 +186,11 @@ int BookmarksTreeModel::columnCount(const QModelIndex &parent) const QVariant BookmarksTreeModel::headerData(int section, Qt::Orientation orientation, int role) const { - if( orientation == Qt::Horizontal - && role == Qt::DisplayRole - && section == 0 - ) - return i18n( "Bookmark" ); + if (orientation == Qt::Horizontal + && role == Qt::DisplayRole + && section == 0 + ) + return i18n("Bookmark"); return QVariant(); } @@ -199,41 +199,41 @@ QVariant BookmarksTreeModel::headerData(int section, Qt::Orientation orientation 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; } 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 + else { - parentItem = static_cast< BtmItem* >( parent.internalPointer() ); + parentItem = static_cast< BtmItem* >(parent.internalPointer()); } - BtmItem *childItem = parentItem->child( row ); - if( childItem ) + BtmItem *childItem = parentItem->child(row); + if (childItem) { - return createIndex( row, column, childItem ); + return createIndex(row, column, childItem); } return QModelIndex(); @@ -242,42 +242,42 @@ 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 *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 ); + return createIndex(parentItem->row(), 0, parentItem); } 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 ) + BtmItem *node = static_cast< BtmItem* >(index.internalPointer()); + if (node && node == m_root) { - if( role == Qt::DisplayRole ) - return i18n( "Bookmarks" ); - if( role == Qt::DecorationRole ) - return KIcon( "bookmarks" ); + if (role == Qt::DisplayRole) + return i18n("Bookmarks"); + if (role == Qt::DecorationRole) + return KIcon("bookmarks"); } - else + else { - if( node ) - return node->data( role ); + if (node) + return node->data(role); } return QVariant(); @@ -302,30 +302,30 @@ void BookmarksTreeModel::setRoot(KBookmarkGroup bmg) delete m_root; m_root = new BtmItem(KBookmark()); - if( bmg.isNull() ) + if (bmg.isNull()) return; - populate( m_root, bmg ); + populate(m_root, bmg); reset(); } -void BookmarksTreeModel::populate( BtmItem *node, KBookmarkGroup bmg) +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() ) - populate( newChild, bm.toGroup() ); + BtmItem *newChild = new BtmItem(bm); + if (bm.isGroup()) + populate(newChild, bm.toGroup()); - node->appendChild( newChild ); - bm = bmg.next( bm ); + node->appendChild(newChild); + bm = bmg.next(bm); } } @@ -338,36 +338,36 @@ KBookmark BookmarksTreeModel::bookmarkForIndex(const QModelIndex index) const void BookmarksTreeModel::saveOnly() { - disconnect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString,QString)), this, SLOT(bookmarksChanged())); - connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString,QString)), this, SLOT(reconnectManager())); + disconnect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString, QString)), this, SLOT(bookmarksChanged())); + connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString, QString)), this, SLOT(reconnectManager())); Application::bookmarkProvider()->bookmarkManager()->emitChanged(); } void BookmarksTreeModel::reconnectManager() { - connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL( changed(QString,QString) ), this, SLOT(bookmarksChanged())); + connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(QString, QString)), this, SLOT(bookmarksChanged())); } -Qt::DropActions BookmarksTreeModel::supportedDropActions () const +Qt::DropActions BookmarksTreeModel::supportedDropActions() const { return Qt::MoveAction; } -QStringList BookmarksTreeModel::mimeTypes () const +QStringList BookmarksTreeModel::mimeTypes() const { return KBookmark::List::mimeDataTypes(); } -QMimeData* BookmarksTreeModel::mimeData( const QModelIndexList & indexes ) const +QMimeData* BookmarksTreeModel::mimeData(const QModelIndexList & indexes) const { QMimeData *mimeData = new QMimeData; QByteArray addresse = bookmarkForIndex(indexes.first()).address().toLatin1(); - mimeData->setData( "application/rekonq-bookmark", addresse); + mimeData->setData("application/rekonq-bookmark", addresse); bookmarkForIndex(indexes.first()).populateMimeData(mimeData); return mimeData; @@ -376,9 +376,9 @@ QMimeData* BookmarksTreeModel::mimeData( const QModelIndexList & indexes ) const bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex & parent) { - if(action == Qt::MoveAction) + if (action == Qt::MoveAction) { - if(data->hasFormat("application/rekonq-bookmark")) + if (data->hasFormat("application/rekonq-bookmark")) { QByteArray addresses = data->data("application/rekonq-bookmark"); KBookmark bookmark = Application::bookmarkProvider()->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data())); @@ -386,16 +386,16 @@ bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction acti QModelIndex destIndex = index(row, column, parent); KBookmark dropDestBookmark; - if(destIndex.isValid()) + if (destIndex.isValid()) dropDestBookmark = bookmarkForIndex(destIndex); KBookmarkGroup root = Application::bookmarkProvider()->rootGroup(); - if(parent.isValid()) + if (parent.isValid()) root = bookmarkForIndex(parent).toGroup(); - if(!destIndex.isValid()) + if (!destIndex.isValid()) { - if(!parent.isValid()) // Drop into a blank area + if (!parent.isValid()) // Drop into a blank area { Application::bookmarkProvider()->rootGroup().deleteBookmark(bookmark); Application::bookmarkProvider()->rootGroup().addBookmark(bookmark); @@ -409,7 +409,7 @@ bool BookmarksTreeModel::dropMimeData(const QMimeData *data, Qt::DropAction acti else { - if(row == -1) + if (row == -1) { root.deleteBookmark(bookmark); root.addBookmark(bookmark); diff --git a/src/bookmarks/bookmarkstreemodel.h b/src/bookmarks/bookmarkstreemodel.h index b312ab2d..2cb78770 100644 --- a/src/bookmarks/bookmarkstreemodel.h +++ b/src/bookmarks/bookmarkstreemodel.h @@ -43,10 +43,10 @@ class BtmItem public: BtmItem(const KBookmark &bm); ~BtmItem(); - QVariant data( int role = Qt::DisplayRole ) const; + QVariant data(int role = Qt::DisplayRole) const; int row() const; int childCount() const; - BtmItem* child( int n ); + BtmItem* child(int n); BtmItem* parent() const; void appendChild(BtmItem *child); void clear(); @@ -78,10 +78,10 @@ public: virtual QModelIndex parent(const QModelIndex &index) const; virtual QVariant data(const QModelIndex &index, int role) const; - virtual QStringList mimeTypes () const; + virtual QStringList mimeTypes() const; virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent); - virtual Qt::DropActions supportedDropActions () const; - virtual QMimeData *mimeData( const QModelIndexList & indexes ) const; + virtual Qt::DropActions supportedDropActions() const; + virtual QMimeData *mimeData(const QModelIndexList & indexes) const; private slots: void bookmarksChanged(); @@ -96,7 +96,7 @@ private: void resetModel(); void setRoot(KBookmarkGroup bmg); - void populate( BtmItem *node, KBookmarkGroup bmg); + void populate(BtmItem *node, KBookmarkGroup bmg); KBookmark bookmarkForIndex(const QModelIndex index) const; }; |