2
* optionstest.cpp - Test class for OptionsTree
3
* Copyright (C) 2006 Kevin Smith
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include <QKeySequence>
23
#include "optionstree.h"
25
int main (int argc, char const* argv[])
29
l << QVariant(QString("item1")) << qVariantFromValue(QKeySequence("CTRL+L"));
31
sl << "String 1" << "String 2";
33
tree.setOption("paris",QVariant(QString("sirap")));
34
tree.setOption("Benvolio",QVariant(QString("Benvolio")));
35
tree.setOption("Benvolio",QVariant(QString("Not benvolio!!")));
36
tree.setOption("capulet.Juliet",QVariant(QString("girly")));
37
tree.setOption("verona.montague.romeo",QVariant(QString("poisoned")));
38
tree.setOption("capulet.Nursey",QVariant(QString("matchmaker")));
39
//should fail, values can't have subnodes
40
tree.setOption("capulet.Juliet.dead",QVariant(true));
41
tree.setOption("verona.city",QVariant(true));
42
tree.setOption("verona.lovers",QVariant(2));
43
tree.setOption("verona.size",QVariant(QSize(210,295)));
44
tree.setOption("verona.stuff",l);
45
tree.setOption("verona.stringstuff",sl);
46
tree.setComment("verona","Fair city");
47
tree.setComment("paris","Bloke or city?");
48
tree.setComment("verona.montague.romeo","Watch what this one drinks");
50
foreach(QString name, tree.allOptionNames())
52
qWarning(qPrintable(name));
53
qWarning(qPrintable(tree.getOption(name).toString()));
56
tree.saveOptions("options.xml","OptionsTest","http://psi-im.org/optionstest","0.1");
59
tree2.loadOptions("options.xml","OptionsTest","http://psi-im.org/optionstest","0.1");
60
foreach(QString name, tree2.allOptionNames())
62
qWarning(qPrintable(name));
63
qWarning(qPrintable(tree2.getOption(name).toString()));
65
tree2.saveOptions("options2.xml","OptionsTest","http://psi-im.org/optionstest","0.1");
68
tree3.loadOptions("options.xml","OptionsTest","http://psi-im.org/optionstest","0.1");
69
tree3.saveOptions("options3.xml","OptionsTest","http://psi-im.org/optionstest","0.1");