diff options
-rw-r--r-- | src/history/historypanel.cpp | 61 | ||||
-rw-r--r-- | src/history/historypanel.h | 4 |
2 files changed, 65 insertions, 0 deletions
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<KUrl> allChild; + for (int i = 0; i < index.model()->rowCount(index); i++) + allChild << qVariantValue<KUrl>(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<HistoryItem> 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 |