summaryrefslogtreecommitdiffstats
path: root/lib/koproperty/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/koproperty/test')
-rw-r--r--lib/koproperty/test/Makefile.am17
-rw-r--r--lib/koproperty/test/main.cpp68
-rw-r--r--lib/koproperty/test/test.cpp126
-rw-r--r--lib/koproperty/test/test.h47
4 files changed, 258 insertions, 0 deletions
diff --git a/lib/koproperty/test/Makefile.am b/lib/koproperty/test/Makefile.am
new file mode 100644
index 00000000..2bcf7993
--- /dev/null
+++ b/lib/koproperty/test/Makefile.am
@@ -0,0 +1,17 @@
+noinst_HEADERS = test.h
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+noinst_PROGRAMS = propertytest
+
+propertytest_SOURCES = main.cpp test.cpp
+propertytest_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+propertytest_LDADD = $(LIB_KOPROPERTY)
+
+# this is where the shell's XML-GUI resource file goes
+#shellrcdir = $(kde_datadir)/test
+#shellrc_DATA = testui.rc
+
+INCLUDES= $(KOPROPERTY_INCLUDES) $(KOFFICE_INCLUDES) $(all_includes)
+
diff --git a/lib/koproperty/test/main.cpp b/lib/koproperty/test/main.cpp
new file mode 100644
index 00000000..83370cfd
--- /dev/null
+++ b/lib/koproperty/test/main.cpp
@@ -0,0 +1,68 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include "test.h"
+#include <kapplication.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+
+static const char description[] = "A test application for the KoProperty library";
+
+static const char version[] = "0.2";
+
+static KCmdLineOptions options[] =
+{
+ { "flat", "Flat display: don't display groups\n(useful for testing)", 0 },
+ { "ro", "Set all properties as read-only:\n(useful for testing read-only mode)", 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char **argv)
+{
+ KAboutData about("proptest", "KoProperty Test", version, description,
+ KAboutData::License_GPL, "(C) 2005 Cedric Pasteur", 0, 0, "cedric.pasteur@free.fr");
+ about.addAuthor( "Cedric Pasteur", 0, "cedric.pasteur@free.fr" );
+ KCmdLineArgs::init(argc, argv, &about);
+ KCmdLineArgs::addCmdLineOptions( options );
+ KApplication app;
+ Test *mainWin = 0;
+
+ if (app.isRestored())
+ {
+ RESTORE(Test);
+ }
+ else
+ {
+ // no session.. just start up normally
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ /// @todo do something with the command line args here
+
+ mainWin = new Test();
+ app.setMainWidget( mainWin );
+ mainWin->show();
+
+ args->clear();
+ }
+
+ // mainWin has WDestructiveClose flag by default, so it will delete itself.
+ return app.exec();
+}
+
diff --git a/lib/koproperty/test/test.cpp b/lib/koproperty/test/test.cpp
new file mode 100644
index 00000000..2c7c7561
--- /dev/null
+++ b/lib/koproperty/test/test.cpp
@@ -0,0 +1,126 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#include <kmainwindow.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kcmdlineargs.h>
+#include <kiconloader.h>
+
+#include <qpixmap.h>
+#include <qstringlist.h>
+#include <qdatetimeedit.h>
+#include <qcursor.h>
+#include <qapplication.h>
+
+#include <koproperty/property.h>
+#include <koproperty/editor.h>
+
+#include "test.h"
+
+using namespace KoProperty;
+
+Test::Test()
+ : KMainWindow(0,"koproperty_test")
+{
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ const bool flat = args->isSet("flat");
+ const bool readOnly = args->isSet("ro");
+
+// setXMLFile("testui.rc");
+ QFont f;
+ f.setPixelSize(f.pixelSize()*2/3);
+ setFont(f);
+
+/* First, create the Set which will hold the properties. */
+ Property *p = 0;
+ m_set = new Set(this, "test");
+ m_set->setReadOnly(readOnly);
+ QCString group;
+ if (!flat) {
+ group = "SimpleGroup";
+ m_set->setGroupDescription(group, "Simple Group");
+ }
+ m_set->addProperty(new Property("Name", "Name"), group);
+ (*m_set)["Name"].setAutoSync(1);
+
+ m_set->addProperty(new Property("Int", 2, "Int"), group);
+ m_set->addProperty(new Property("Double", 3.1415,"Double"), group);
+ m_set->addProperty(new Property("Bool", QVariant(true, 4), "Bool"), group);
+ m_set->addProperty(p = new Property("3 States", QVariant(), "3 States", "", Boolean), group);
+ p->setOption("3rdState", "None");
+ m_set->addProperty(p = new Property("Date", QDate::currentDate(),"Date"), group);
+ p->setIcon("date");
+ m_set->addProperty(new Property("Time", QTime::currentTime(),"Time"), group);
+ m_set->addProperty(new Property("DateTime", QDateTime::currentDateTime(),"Date/Time"), group);
+
+ QStringList list;//keys
+ list << "myitem" << "otheritem" << "3rditem";
+ QStringList name_list; //strings
+ name_list << "My Item" << "Other Item" << "Third Item";
+ m_set->addProperty(new Property("List", list, name_list, "otheritem", "List"), group);
+
+ // A valueFromList property matching strings with ints (could be any type supported by QVariant)
+ QValueList<QVariant> keys;
+ keys.append(1);
+ keys.append(2);
+ keys.append(3);
+ Property::ListData *listData = new Property::ListData(keys, name_list);
+ m_set->addProperty(new Property("List2", listData, 3, "List 2"), group);
+
+// Complex
+ if (!flat) {
+ group = "ComplexGroup";
+ m_set->setGroupDescription(group, "Complex Group");
+ }
+ m_set->addProperty(new Property("Rect", this->geometry(),"Rect"), group);
+ m_set->addProperty(new Property("Point", QPoint(3,4), "Point"), group);
+ m_set->addProperty(new Property("Size", QPoint(3,4), "Size"), group);
+
+// Appearance
+ if (!flat) {
+ group = "Appearance Group";
+ m_set->setGroupDescription(group, "Appearance Group");
+ m_set->setGroupIcon(group, "appearance");
+ }
+ m_set->addProperty(new Property("Color", this->paletteBackgroundColor(),"Color"), group);
+ QPixmap pm(DesktopIcon("network"));
+ m_set->addProperty(p = new Property("Pixmap", pm,"Pixmap"), group);
+ p->setIcon("kpaint");
+ m_set->addProperty(p = new Property("Font", this->font(),"Font"), group);
+ p->setIcon("fonts");
+ m_set->addProperty(new Property("Cursor", QCursor(Qt::WaitCursor),"Cursor"), group);
+ m_set->addProperty(new Property("LineStyle", 3, "Line Style", "", LineStyle), group);
+ m_set->addProperty(new Property("SizePolicy", sizePolicy(), "Size Policy"), group);
+
+// kdDebug() << m_set->groupNames() << endl;
+
+ Editor *edit = new Editor(this,true/*autosync*/);
+ setCentralWidget(edit);
+ edit->changeSet(m_set);
+ resize(400,qApp->desktop()->height()-200);
+ move(x(),5);
+ edit->setFocus();
+}
+
+Test::~Test()
+{
+}
+
+#include "test.moc"
diff --git a/lib/koproperty/test/test.h b/lib/koproperty/test/test.h
new file mode 100644
index 00000000..cef6e97a
--- /dev/null
+++ b/lib/koproperty/test/test.h
@@ -0,0 +1,47 @@
+/* This file is part of the KDE project
+ Copyright (C) 2004-2005 Cedric Pasteur <cedric.pasteur@free.fr>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+#ifndef TEST_H
+#define TEST_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <kmainwindow.h>
+
+#include <koproperty/set.h>
+
+/*!
+ * @short KoProperty test appliation main window
+ * @author Cedric Pasteur <cedric.pasteur@free.fr>
+ * @version 0.1
+ */
+class Test : public KMainWindow
+{
+ Q_OBJECT
+ public:
+ Test();
+ virtual ~Test();
+
+ private:
+ KoProperty::Set *m_set;
+};
+
+#endif