F:/KPlato/koffice/libs/koproperty/test/test.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include <kmainwindow.h>
00021 #include <klocale.h>
00022 #include <kdebug.h>
00023 #include <kcmdlineargs.h>
00024 #include <kiconloader.h>
00025 
00026 #include <QPixmap>
00027 #include <QStringList>
00028 #include <q3datetimeedit.h>
00029 #include <QCursor>
00030 #include <QApplication>
00031 #include <QDesktopWidget>
00032 
00033 #include <property.h>
00034 #include <editor.h>
00035 
00036 #include "test.h"
00037 
00038 using namespace KoProperty;
00039 
00040 Test::Test()
00041  : KMainWindow(0,"koproperty_test")
00042 {
00043         KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00044         const bool flat = args->isSet("flat");
00045         const bool readOnly = args->isSet("ro");
00046 
00047 //      setXMLFile("testui.rc");
00048         QFont f;
00049         f.setPixelSize(f.pixelSize()*2/3);
00050         setFont(f);
00051 
00052 /*  First, create the Set which will hold the properties.  */
00053         Property *p = 0;
00054         m_set = new Set(this, "test");
00055         m_set->setReadOnly(readOnly);
00056         QByteArray group;
00057         if (!flat) {
00058                 group = "SimpleGroup";
00059                 m_set->setGroupDescription(group, "Simple Group");
00060         }
00061         m_set->addProperty(new Property("Name", "Name"), group);
00062         (*m_set)["Name"].setAutoSync(1);
00063         
00064         m_set->addProperty(new Property("Int", 2, "Int"), group);
00065         m_set->addProperty(new Property("Double", 3.1415,"Double"), group);
00066         m_set->addProperty(new Property("Bool", QVariant(true), "Bool"), group);
00067         m_set->addProperty(p = new Property("3 States", QVariant(), "3 States", "", Boolean), group);
00068         p->setOption("3rdState", "None");
00069         m_set->addProperty(p = new Property("Date", QDate::currentDate(),"Date"), group);
00070         p->setIcon("date");
00071         m_set->addProperty(new Property("Time", QTime::currentTime(),"Time"), group);
00072         m_set->addProperty(new Property("DateTime", QDateTime::currentDateTime(),"Date/Time"), group);
00073 
00074         QStringList list;//keys
00075         list << "myitem" << "otheritem" << "3rditem";
00076         QStringList name_list; //strings
00077         name_list << "My Item" << "Other Item" << "Third Item";
00078         m_set->addProperty(new Property("List", list, name_list, "otheritem", "List"), group);
00079 
00080         // A valueFromList property matching strings with ints (could be any type supported by QVariant)
00081         QList<QVariant> keys;
00082         keys.append(1);
00083         keys.append(2);
00084         keys.append(3);
00085         Property::ListData *listData = new Property::ListData(keys, name_list);
00086         m_set->addProperty(new Property("List2", listData, 3, "List 2"), group);
00087 
00088 //  Complex
00089         if (!flat) {
00090                 group = "ComplexGroup";
00091                 m_set->setGroupDescription(group, "Complex Group");
00092         }
00093         m_set->addProperty(new Property("Rect", this->geometry(),"Rect"), group);
00094         m_set->addProperty(new Property("Point", QPoint(3,4), "Point"), group);
00095         m_set->addProperty(new Property("Size", QPoint(3,4), "Size"), group);
00096 
00097 //  Appearance
00098         if (!flat) {
00099                 group = "Appearance Group";
00100                 m_set->setGroupDescription(group, "Appearance Group");
00101                 m_set->setGroupIcon(group, "appearance");
00102         }
00103         m_set->addProperty(new Property("Color", palette().color(QPalette::Active, QPalette::Background),"Color"), group);
00104         QPixmap pm(DesktopIcon("network"));
00105         m_set->addProperty(p = new Property("Pixmap", pm,"Pixmap"), group);
00106         p->setIcon("kpaint");
00107         m_set->addProperty(p = new Property("Font", this->font(),"Font"), group);
00108         p->setIcon("fonts");
00109         m_set->addProperty(new Property("Cursor", QCursor(Qt::WaitCursor),"Cursor"), group);
00110         m_set->addProperty(new Property("LineStyle", 3, "Line Style", "", LineStyle), group);
00111         m_set->addProperty(new Property("SizePolicy", sizePolicy(), "Size Policy"), group);
00112 
00113 //      kDebug() << m_set->groupNames() << endl;
00114 
00115         Editor *edit = new Editor(this,true/*autosync*/);
00116         setCentralWidget(edit);
00117         edit->changeSet(m_set);
00118         resize(400,qApp->desktop()->height()-200);
00119         move(x(),5);
00120         edit->setFocus();
00121 }
00122 
00123 Test::~Test()
00124 {
00125 }
00126 
00127 #include "test.moc"

Généré le Wed Nov 22 23:41:07 2006 pour KPlato par  doxygen 1.5.1-p1