[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kexi/koproperty2/koproperty/test
From: Jaroslaw Staniek <js () iidea ! pl>
Date: 2009-03-25 10:49:27
Message-ID: 1237978167.414331.27832.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 944240 by staniek:
KoProperty
- clean up the test code
M +2 -9 main.cpp
M +45 -45 test.cpp
M +7 -11 test.h
--- trunk/koffice/kexi/koproperty2/koproperty/test/main.cpp #944239:944240
@@ -40,17 +40,10 @@
options.add("property <name>", ki18n("Display only specified property\n(useful \
when we want to focus on testing a single property editor)")); \
KCmdLineArgs::addCmdLineOptions(options); KApplication app;
- Test *mainWin = 0;
- if (app.isSessionRestored()) {
- RESTORE(Test);
- } else {
- // no session.. just start up normally
- mainWin = new Test();
- mainWin->show();
- }
+ TestWindow test;
+ test.show();
- // mainWin has WDestructiveClose flag by default, so it will delete itself.
return app.exec();
}
--- trunk/koffice/kexi/koproperty2/koproperty/test/test.cpp #944239:944240
@@ -1,6 +1,6 @@
/* This file is part of the KDE project
Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
- Copyright (C) 2008 Jarosław Staniek <staniek@kde.org>
+ Copyright (C) 2008-2009 Jarosław Staniek <staniek@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -23,23 +23,25 @@
#include "koproperty/Property.h"
#include "koproperty/EditorView.h"
-#include <kmainwindow.h>
-#include <klocale.h>
-#include <kdebug.h>
-#include <kcmdlineargs.h>
-#include <kiconloader.h>
+#include <KLocale>
+#include <KDebug>
+#include <KCmdLineArgs>
+#include <KIconLoader>
+#include <QDate>
+#include <QDateTime>
#include <QPixmap>
#include <QStringList>
-#include <q3datetimeedit.h>
#include <QCursor>
#include <QApplication>
#include <QDesktopWidget>
+#include <QVBoxLayout>
using namespace KoProperty;
-Test::Test()
- : KXmlGuiWindow()
+TestWindow::TestWindow()
+ : QWidget()
+ , m_set(this, "test")
{
setObjectName("koproperty_test");
setWindowIcon(DesktopIcon("document-properties"));
@@ -49,47 +51,41 @@
const bool readOnly = args->isSet("ro");
const QString singleProperty = args->getOption("property");
-// 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);
+ m_set.setReadOnly(readOnly);
QByteArray group;
if (!flat) {
group = "SimpleGroup";
- m_set->setGroupDescription(group, "Simple Group");
+ m_set.setGroupDescription(group, "Simple Group");
}
if (singleProperty.isEmpty() || singleProperty=="Name") {
- m_set->addProperty(new Property("Name", "Name"), group);
- (*m_set)["Name"].setAutoSync(1);
+ m_set.addProperty(new Property("Name", "Name"), group);
+ m_set["Name"].setAutoSync(1);
}
if (singleProperty.isEmpty() || singleProperty=="Int") {
- m_set->addProperty(new Property("Int", 2, "Int"), group);
+ m_set.addProperty(new Property("Int", 2, "Int"), group);
}
if (singleProperty.isEmpty() || singleProperty=="Double") {
- m_set->addProperty(new Property("Double", 3.1415, "Double"), group);
+ m_set.addProperty(new Property("Double", 3.1415, "Double"), group);
}
if (singleProperty.isEmpty() || singleProperty=="Bool") {
- m_set->addProperty(new Property("Bool", QVariant(true), "Bool"), group);
+ m_set.addProperty(new Property("Bool", QVariant(true), "Bool"), group);
}
if (singleProperty.isEmpty() || singleProperty=="3-State") {
- m_set->addProperty(p = new Property("3-State", QVariant(), "3 States", "", \
Bool), group); + m_set.addProperty(p = new Property("3-State", QVariant(), "3 \
States", "", Bool), group); p->setOption("3State", true);
}
if (singleProperty.isEmpty() || singleProperty=="Date") {
- m_set->addProperty(p = new Property("Date", QDate::currentDate(), "Date"), \
group); + m_set.addProperty(p = new Property("Date", QDate::currentDate(), \
"Date"), group); p->setIcon("date");
}
if (singleProperty.isEmpty() || singleProperty=="Time") {
- m_set->addProperty(new Property("Time", QTime::currentTime(), "Time"), \
group); + m_set.addProperty(new Property("Time", QTime::currentTime(), \
"Time"), group); }
if (singleProperty.isEmpty() || singleProperty=="DateTime") {
- m_set->addProperty(new Property("DateTime", QDateTime::currentDateTime(), \
"Date/Time"), group); + m_set.addProperty(new Property("DateTime", \
QDateTime::currentDateTime(), "Date/Time"), group); }
QStringList name_list; //strings
@@ -97,7 +93,7 @@
if (singleProperty.isEmpty() || singleProperty=="List") {
QStringList list;//keys
list << "myitem" << "otheritem" << "3rditem";
- m_set->addProperty(new Property("List", list, name_list, "otheritem", \
"List"), group); + m_set.addProperty(new Property("List", list, name_list, \
"otheritem", "List"), group); }
if (singleProperty.isEmpty() || singleProperty=="List2") {
@@ -107,67 +103,71 @@
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);
+ m_set.addProperty(new Property("List2", listData, 3, "List 2"), group);
}
// Complex
if (!flat) {
group = "ComplexGroup";
- m_set->setGroupDescription(group, "Complex Group");
+ m_set.setGroupDescription(group, "Complex Group");
}
if (singleProperty.isEmpty() || singleProperty=="Rect") {
- m_set->addProperty(new Property("Rect", QRect(5,11,100,200), "Rect"), \
group); + m_set.addProperty(new Property("Rect", QRect(5,11,100,200), "Rect"), \
group); }
if (singleProperty.isEmpty() || singleProperty=="Point") {
- m_set->addProperty(new Property("Point", QPoint(3, 4), "Point"), group);
+ m_set.addProperty(new Property("Point", QPoint(3, 4), "Point"), group);
}
if (singleProperty.isEmpty() || singleProperty=="Size") {
- m_set->addProperty(new Property("Size", QSize(10, 20), "Size"), group);
+ m_set.addProperty(new Property("Size", QSize(10, 20), "Size"), group);
}
// Appearance
if (!flat) {
group = "Appearance Group";
- m_set->setGroupDescription(group, "Appearance Group");
- m_set->setGroupIcon(group, "appearance");
+ m_set.setGroupDescription(group, "Appearance Group");
+ m_set.setGroupIcon(group, "appearance");
}
if (singleProperty.isEmpty() || singleProperty=="Color") {
- m_set->addProperty(new Property("Color", palette().color(QPalette::Active, \
QPalette::Background), "Color"), group); + m_set.addProperty(new \
Property("Color", palette().color(QPalette::Active, QPalette::Background), "Color"), \
group); }
if (singleProperty.isEmpty() || singleProperty=="Pixmap") {
QPixmap pm(DesktopIcon("network-wired"));
- m_set->addProperty(p = new Property("Pixmap", pm, "Pixmap"), group);
+ m_set.addProperty(p = new Property("Pixmap", pm, "Pixmap"), group);
p->setIcon("kpaint");
}
if (singleProperty.isEmpty() || singleProperty=="Font") {
QFont myFont("Times", 12);
- m_set->addProperty(p = new Property("Font", myFont, "Font"), group);
+ m_set.addProperty(p = new Property("Font", myFont, "Font"), group);
p->setIcon("fonts");
}
if (singleProperty.isEmpty() || singleProperty=="Cursor") {
- m_set->addProperty(new Property("Cursor", QCursor(Qt::WaitCursor), \
"Cursor"), group); + m_set.addProperty(new Property("Cursor", \
QCursor(Qt::WaitCursor), "Cursor"), group); }
if (singleProperty.isEmpty() || singleProperty=="LineStyle") {
- m_set->addProperty(new Property("LineStyle", 3, "Line Style", "", \
LineStyle), group); + m_set.addProperty(new Property("LineStyle", 3, "Line \
Style", "", LineStyle), group); }
if (singleProperty.isEmpty() || singleProperty=="SizePolicy") {
- m_set->addProperty(new Property("SizePolicy", sizePolicy(), "Size Policy"), \
group); + QSizePolicy sp(sizePolicy());
+ sp.setHorizontalStretch(1);
+ sp.setVerticalStretch(2);
+ m_set.addProperty(new Property("SizePolicy", sp, "Size Policy"), group);
}
if (singleProperty.isEmpty() || singleProperty=="Invisible") {
- m_set->addProperty(p = new Property("Invisible", "I am invisible", \
"Invisible"), group); + m_set.addProperty(p = new Property("Invisible", "I am \
invisible", "Invisible"), group); p->setVisible(false);
}
-// kDebug(30007) << m_set->groupNames();
+// kDebug(30007) << m_set.groupNames();
+ QVBoxLayout *lyr = new QVBoxLayout(this);
EditorView *editorView = new EditorView(this);
- editorView->changeSet(m_set);
+ lyr->addWidget(editorView);
+ editorView->changeSet(&m_set);
//crashes.. why?: editorView->expandAll();
- setCentralWidget(editorView);
resize(400, qApp->desktop()->height() - 200);
editorView->setFocus();
}
-Test::~Test()
+TestWindow::~TestWindow()
{
}
--- trunk/koffice/kexi/koproperty2/koproperty/test/test.h #944239:944240
@@ -1,5 +1,6 @@
/* This file is part of the KDE project
Copyright (C) 2004-2005 Cedric Pasteur <cedric.pasteur@free.fr>
+ Copyright (C) 2008-2009 Jarosław Staniek <staniek@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -20,30 +21,25 @@
#ifndef TEST_H
#define TEST_H
-#include <kxmlguiwindow.h>
+#include <QWidget>
#include "koproperty/Set.h"
-namespace KoProperty
-{
-class Editor;
-}
-
/*!
* @internal
- * @short KoProperty test appliation main window
+ * @short KoProperty test application main window
* @author Cedric Pasteur <cedric.pasteur@free.fr>
* @version 0.1
*/
-class Test : public KXmlGuiWindow
+class TestWindow : public QWidget
{
Q_OBJECT
public:
- Test();
- virtual ~Test();
+ TestWindow();
+ virtual ~TestWindow();
private:
- KoProperty::Set *m_set;
+ KoProperty::Set m_set;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic