From fc9a06849a7d85dac87d1a42a3c328a1bc07ff57 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Fri, 2 Dec 2011 22:53:27 +0100 Subject: =?UTF-8?q?GCI=20Task=20:=20Add=20some=20actions=20to=20forget=20h?= =?UTF-8?q?istory=20entries=20in=20the=20panel=20Patch=20by=20H=C3=BCseyin?= =?UTF-8?q?=20Zengin.=20Thanks=20!=20REVIEW:=20103255?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/history/historypanel.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++ src/history/historypanel.h | 4 +++ 2 files changed, 65 insertions(+) (limited to 'src/history') diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp index 8ba963e7..45e57312 100644 --- a/src/history/historypanel.cpp +++ b/src/history/historypanel.cpp @@ -83,6 +83,14 @@ void HistoryPanel::contextMenuItem(const QPoint &pos) connect(action, SIGNAL(triggered()), panelTreeView(), SLOT(copyToClipboard())); menu.addAction(action); + action = new KAction(KIcon("edit-clear"), i18n("Remove Entry"), this); + connect(action,SIGNAL(triggered()),this,SLOT(deleteEntry())); + menu.addAction(action); + + action = new KAction(KIcon("edit-clear"), i18n("Remove all occurences"), this); + connect(action,SIGNAL(triggered()),this,SLOT(forgetSite())); + menu.addAction(action); + menu.exec(panelTreeView()->mapToGlobal(pos)); } @@ -96,6 +104,10 @@ void HistoryPanel::contextMenuGroup(const QPoint &pos) connect(action, SIGNAL(triggered()), this, SLOT(openAll())); menu.addAction(action); + action = new KAction(KIcon("edit-clear"), i18n("Remove Folder"), this); + connect(action, SIGNAL(triggered()), this, SLOT(deleteGroup())); + menu.addAction(action); + menu.exec(panelTreeView()->mapToGlobal(pos)); } @@ -131,6 +143,21 @@ void HistoryPanel::openAll() emit openUrl(allChild.at(i).url(), Rekonq::NewTab); } +void HistoryPanel::deleteGroup() +{ + QModelIndex index = panelTreeView()->currentIndex(); + if (!index.isValid()) + return; + + //Getting all URLs of sub items. + QList allChild; + for (int i = 0; i < index.model()->rowCount(index); i++) + allChild << qVariantValue(index.child(i, 0).data(Qt::UserRole)); + + for (int i = 0; i < allChild.length(); i++) + rApp->historyManager()->removeHistoryEntry(allChild.at(i)); + +} void HistoryPanel::setup() { @@ -142,6 +169,40 @@ void HistoryPanel::setup() panelTreeView()->expand(proxy->index(0, 0)); } +void HistoryPanel::deleteEntry() +{ + QModelIndex index = panelTreeView()->currentIndex(); + if(!index.isValid()) + return; + removedFolderIndex=index.parent().row(); + + rApp->historyManager()->removeHistoryEntry(qVariantValue< KUrl >(index.data(Qt::UserRole))); + + QModelIndex expandItem = panelTreeView()->model()->index(removedFolderIndex, 0); + if (expandItem.isValid()) + panelTreeView()->expand(expandItem); +} + +void HistoryPanel::forgetSite() +{ + QModelIndex index = panelTreeView()->currentIndex(); + if(!index.isValid()) + return; + removedFolderIndex=index.row(); + + QString site = qVariantValue< KUrl >(index.data(Qt::UserRole)).host(); + QList toRemove = rApp->historyManager()->find(site); + for(int i = 0; i < toRemove.length(); i++) + { + rApp->historyManager()->removeHistoryEntry(KUrl(toRemove.at(i).url)); + } + + QModelIndex expandItem = panelTreeView()->model()->index(removedFolderIndex, 0); + if (expandItem.isValid()) + panelTreeView()->expand(expandItem); +} + + QAbstractItemModel* HistoryPanel::model() { diff --git a/src/history/historypanel.h b/src/history/historypanel.h index 5ca4fff0..f78ec5e1 100644 --- a/src/history/historypanel.h +++ b/src/history/historypanel.h @@ -50,10 +50,14 @@ private Q_SLOTS: virtual void contextMenuEmpty(const QPoint &pos); void openAll(); + void deleteEntry(); + void deleteGroup(); + void forgetSite(); private: virtual void setup(); virtual QAbstractItemModel* model(); + int removedFolderIndex; }; #endif // HISTORYPANEL_H -- cgit v1.2.1