~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to src/tools/optionstree/optionstest/optionstest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-04-14 18:57:30 UTC
  • mfrom: (2.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080414185730-528re3zp0m2hdlhi
Tags: 0.11-8
* added CONFIG -= link_prl to .pro files and removed dependencies
  which are made unnecessary by this change
* Fix segfault when closing last chat tab with qt4.4
  (This is from upstream svn, rev. 1101) (Closes: Bug#476122)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * optionstest.cpp - Test class for OptionsTree
 
3
 * Copyright (C) 2006  Kevin Smith
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 *
 
19
 */
 
20
 
 
21
#include <QtCore>
 
22
#include <QKeySequence>
 
23
#include "optionstree.h"
 
24
 
 
25
int main (int argc, char const* argv[])
 
26
{
 
27
        OptionsTree tree;
 
28
        QVariantList l;
 
29
        l << QVariant(QString("item1")) << qVariantFromValue(QKeySequence("CTRL+L"));
 
30
        QStringList sl;
 
31
        sl << "String 1" << "String 2";
 
32
        
 
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");
 
49
        
 
50
        foreach(QString name, tree.allOptionNames())
 
51
        {
 
52
                qWarning(qPrintable(name));
 
53
                qWarning(qPrintable(tree.getOption(name).toString()));
 
54
        }
 
55
        
 
56
        tree.saveOptions("options.xml","OptionsTest","http://psi-im.org/optionstest","0.1");
 
57
        
 
58
        OptionsTree tree2;
 
59
        tree2.loadOptions("options.xml","OptionsTest","http://psi-im.org/optionstest","0.1");
 
60
        foreach(QString name, tree2.allOptionNames())
 
61
        {
 
62
                qWarning(qPrintable(name));
 
63
                qWarning(qPrintable(tree2.getOption(name).toString()));
 
64
        }
 
65
        tree2.saveOptions("options2.xml","OptionsTest","http://psi-im.org/optionstest","0.1");
 
66
        
 
67
        OptionsTree tree3;
 
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");
 
70
        return 0;
 
71
}