[Ktutorial-commits] SF.net SVN: ktutorial:[111] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
|
From: <dan...@us...> - 2010-03-05 23:48:53
|
Revision: 111
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=111&view=rev
Author: danxuliu
Date: 2010-03-05 23:48:40 +0000 (Fri, 05 Mar 2010)
Log Message:
-----------
Add TextTreeItem class, that represents a plain string in a TreeModel.
Modified Paths:
--------------
trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt
trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt
Added Paths:
-----------
trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.cpp
trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.h
trunk/ktutorial/ktutorial-editor/tests/unit/view/TextTreeItemTest.cpp
Modified: trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2010-03-05 23:35:28 UTC (rev 110)
+++ trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2010-03-05 23:48:40 UTC (rev 111)
@@ -1,6 +1,7 @@
include_directories(${KDE4_INCLUDES})
set(ktutorial_editor_view_SRCS
+ TextTreeItem.cpp
TreeItem.cpp
TreeModel.cpp
)
Added: trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.cpp (rev 0)
+++ trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.cpp 2010-03-05 23:48:40 UTC (rev 111)
@@ -0,0 +1,30 @@
+/***************************************************************************
+ * Copyright (C) 2010 by Daniel Calviño Sánchez *
+ * dan...@gm... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#include "TextTreeItem.h"
+
+TextTreeItem::TextTreeItem(TreeItem* parent): TreeItem(parent) {
+}
+
+QString TextTreeItem::text() const {
+ return mText;
+}
+
+void TextTreeItem::setText(const QString& text) {
+ mText = text;
+}
Property changes on: trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.cpp
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.h
===================================================================
--- trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.h (rev 0)
+++ trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.h 2010-03-05 23:48:40 UTC (rev 111)
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * Copyright (C) 2010 by Daniel Calviño Sánchez *
+ * dan...@gm... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#ifndef TEXTTREEITEM_H
+#define TEXTTREEITEM_H
+
+#include "TreeItem.h"
+
+/**
+ * A simple TreeItem that represents a plain string.
+ */
+class TextTreeItem: public TreeItem {
+public:
+
+ /**
+ * Creates a new TextTreeItem with the given parent.
+ *
+ * @param parent The parent TreeItem.
+ */
+ explicit TextTreeItem(TreeItem* parent = 0);
+
+ /**
+ * The text to be shown for this node of the tree,
+ *
+ * @return The text for this TreeItem.
+ */
+ virtual QString text() const;
+
+ /**
+ * Sets the text of this TextTreeItem.
+ *
+ * @param text The text to set.
+ */
+ void setText(const QString& text);
+
+private:
+
+ /**
+ * The text to show.
+ */
+ QString mText;
+
+};
+
+#endif
Property changes on: trunk/ktutorial/ktutorial-editor/src/view/TextTreeItem.h
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt
===================================================================
--- trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-03-05 23:35:28 UTC (rev 110)
+++ trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-03-05 23:48:40 UTC (rev 111)
@@ -16,7 +16,7 @@
ENDFOREACH(_className)
ENDMACRO(UNIT_TESTS)
-unit_tests(TreeItem TreeModel)
+unit_tests(TextTreeItem TreeItem TreeModel)
MACRO(MEM_TESTS)
FOREACH(_testname ${ARGN})
@@ -24,4 +24,4 @@
ENDFOREACH(_testname)
ENDMACRO(MEM_TESTS)
-mem_tests(TreeItem TreeModel)
+mem_tests(TextTreeItem TreeItem TreeModel)
Added: trunk/ktutorial/ktutorial-editor/tests/unit/view/TextTreeItemTest.cpp
===================================================================
--- trunk/ktutorial/ktutorial-editor/tests/unit/view/TextTreeItemTest.cpp (rev 0)
+++ trunk/ktutorial/ktutorial-editor/tests/unit/view/TextTreeItemTest.cpp 2010-03-05 23:48:40 UTC (rev 111)
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (C) 2010 by Daniel Calviño Sánchez *
+ * dan...@gm... *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * 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 *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+
+#include <QtTest>
+
+#include "TextTreeItem.h"
+
+class TextTreeItemTest: public QObject {
+Q_OBJECT
+
+private slots:
+
+ void testConstructor();
+
+ void testSetText();
+
+};
+
+void TextTreeItemTest::testConstructor() {
+ TextTreeItem parent;
+ TextTreeItem treeItem(&parent);
+
+ QCOMPARE(parent.parent(), (TreeItem*)0);
+ QCOMPARE(treeItem.parent(), &parent);
+}
+
+void TextTreeItemTest::testSetText() {
+ TextTreeItem item;
+ item.setText("Hello world");
+
+ QCOMPARE(item.text(), QString("Hello world"));
+}
+
+QTEST_MAIN(TextTreeItemTest)
+
+#include "TextTreeItemTest.moc"
Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/view/TextTreeItemTest.cpp
___________________________________________________________________
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|