Created
April 30, 2009 06:46
-
-
Save torarnv/104312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit bc9fc46f05064f605a356af974caa06cb6ed7219 | |
Author: Tor Arne Vestbø <tor.arne.vestbo@nokia.com> | |
Date: Wed Apr 29 12:18:21 2009 +0200 | |
Add isEmpty() method to QWebElementCollection | |
diff --git a/WebKit/qt/Api/qwebelement.cpp b/WebKit/qt/Api/qwebelement.cpp | |
index e916076..361a2a4 100644 | |
--- a/WebKit/qt/Api/qwebelement.cpp | |
+++ b/WebKit/qt/Api/qwebelement.cpp | |
@@ -1407,6 +1407,17 @@ void QWebElementCollection::append(const QWebElement &element) | |
} | |
/*! | |
+ Returns true if the collection does not contain any elements; false otherwise. | |
+*/ | |
+bool QWebElementCollection::isEmpty() const | |
+{ | |
+ if (!d) | |
+ return true; | |
+ | |
+ return d->m_result->length() == 0; | |
+} | |
+ | |
+/*! | |
Returns the number of elements in the collection. | |
*/ | |
int QWebElementCollection::count() const | |
diff --git a/WebKit/qt/Api/qwebelement.h b/WebKit/qt/Api/qwebelement.h | |
index 844334e..7c5c45a 100644 | |
--- a/WebKit/qt/Api/qwebelement.h | |
+++ b/WebKit/qt/Api/qwebelement.h | |
@@ -162,6 +162,7 @@ public: | |
void append(const QWebElementCollection &collection); | |
void append(const QWebElement &element); | |
+ bool isEmpty() const; | |
int count() const; | |
QWebElement at(int i) const; | |
diff --git a/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp | |
index c10faa5..2eea25d 100644 | |
--- a/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp | |
+++ b/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp | |
@@ -144,6 +144,11 @@ void tst_QWebElement::simpleCollection() | |
QCOMPARE(list.count(), 2); | |
QCOMPARE(list.at(0).toPlainText(), QString("first para")); | |
QCOMPARE(list.at(1).toPlainText(), QString("second para")); | |
+ | |
+ QWebElementCollection empty; | |
+ QVERIFY(empty.isEmpty()); | |
+ empty.append(paras); | |
+ QVERIFY(!empty.isEmpty()); | |
} | |
void tst_QWebElement::attributes() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment