add a clear() method to QWebPageHistory.
authorlars <lars@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2007 13:57:39 +0000 (13:57 +0000)
committerlars <lars@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2007 13:57:39 +0000 (13:57 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@26158 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebpagehistory.cpp
WebKit/qt/Api/qwebpagehistory.h
WebKit/qt/ChangeLog

index 191dc1f4dadc3d0c52b3169991401a9f4ef56d54..ff7d58d6bdbe07dce8871514a18c62f6361396fe 100644 (file)
@@ -84,14 +84,6 @@ QWebPageHistory::QWebPageHistory(QWebPageHistoryPrivate *priv)
     d = priv;
 }
 
-QWebHistoryItem QWebPageHistory::itemAtIndex(int i) const
-{
-    WebCore::HistoryItem *item = d->lst->itemAtIndex(i);
-
-    QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(item);
-    return QWebHistoryItem(priv);
-}
-
 QWebPageHistory::QWebPageHistory(const QWebPageHistory &other)
 {
     d = other.d;
@@ -107,6 +99,16 @@ QWebPageHistory::~QWebPageHistory()
 {
 }
 
+void QWebPageHistory::clear()
+{
+    RefPtr<WebCore::HistoryItem> current = d->lst->currentItem();
+    int capacity = d->lst->capacity();
+    d->lst->setCapacity(0);    
+    d->lst->setCapacity(capacity);
+    d->lst->addItem(current.get());
+    d->lst->goToItem(current.get());
+}
+
 QList<QWebHistoryItem> QWebPageHistory::items() const
 {
     const WebCore::HistoryItemVector &items = d->lst->entries();
@@ -191,3 +193,11 @@ QWebHistoryItem QWebPageHistory::forwardItem() const
     return QWebHistoryItem(priv);
 }
 
+QWebHistoryItem QWebPageHistory::itemAtIndex(int i) const
+{
+    WebCore::HistoryItem *item = d->lst->itemAtIndex(i);
+
+    QWebHistoryItemPrivate *priv = new QWebHistoryItemPrivate(item);
+    return QWebHistoryItem(priv);
+}
+
index 132f6196a423c9bf2fc4a29391301b961dbb8629..d92366b386aa7806bc6c4c497ce9187463fcbb34 100644 (file)
@@ -124,6 +124,8 @@ public:
     QWebPageHistory(const QWebPageHistory &other);
     QWebPageHistory &operator=(const QWebPageHistory &other);
     ~QWebPageHistory();
+
+    void clear();
     
     QList<QWebHistoryItem> items() const;
     QList<QWebHistoryItem> backItems(int maxItems) const;
index 56a95706c73d611c90bad131abe4f76aadafb61c..5c0a71975f7e99c72a413dfc46566fd9c8ef3356 100644 (file)
@@ -1,3 +1,14 @@
+2007-10-09  Lars Knoll  <lars@trolltech.com>
+
+        Reviewed by Simon.
+
+        add a clear() method to QWebPageHistory.
+
+        * Api/qwebpagehistory.cpp:
+        (QWebPageHistory::clear):
+        (QWebPageHistory::itemAtIndex):
+        * Api/qwebpagehistory.h:
+
 2007-10-05  Lars Knoll  <lars@trolltech.com>
 
         add proper error messages to the FrameLoaderClient.