~ubuntu-branches/ubuntu/trusty/kalgebra/trusty-updates

« back to all changes in this revision

Viewing changes to utils/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Philip Muškovac
  • Date: 2011-07-08 20:10:34 UTC
  • Revision ID: james.westby@ubuntu.com-20110708201034-0cqpagx7uz4pu82n
Tags: upstream-4.6.90+repack1
Import upstream version 4.6.90+repack1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*************************************************************************************
 
2
 *  Copyright (C) 2010 by Aleix Pol <aleixpol@kde.org>                               *
 
3
 *                                                                                   *
 
4
 *  This program is free software; you can redistribute it and/or                    *
 
5
 *  modify it under the terms of the GNU General Public License                      *
 
6
 *  as published by the Free Software Foundation; either version 2                   *
 
7
 *  of the License, or (at your option) any later version.                           *
 
8
 *                                                                                   *
 
9
 *  This program is distributed in the hope that it will be useful,                  *
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
 
12
 *  GNU General Public License for more details.                                     *
 
13
 *                                                                                   *
 
14
 *  You should have received a copy of the GNU General Public License                *
 
15
 *  along with this program; if not, write to the Free Software                      *
 
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
 
17
 *************************************************************************************/
 
18
 
 
19
#include <analitzagui/operatorsmodel.h>
 
20
#include <QApplication>
 
21
#include <QStringList>
 
22
#include <QFile>
 
23
#include <QTextDocument>
 
24
#include <QtCore/QTextStream>
 
25
 
 
26
int main(int argc, char** argv)
 
27
{
 
28
        QApplication app(argc, argv);
 
29
        OperatorsModel m;
 
30
        
 
31
        QFile f(app.arguments().last());
 
32
        bool fileopened = f.open(QFile::WriteOnly);
 
33
        Q_ASSERT(fileopened);
 
34
        
 
35
        QTextStream str(&f);
 
36
        
 
37
        str << "<!-- this file is autogenerated, if any change has to be done, please "
 
38
                                "fix kdeedu/kalgebra/utils/main.cpp and its dependencies. "
 
39
                                "Thank you, Aleix Pol -->";
 
40
        str << "<chapter id='commands'>\n"
 
41
                                "<title>Commands supported by KAlgebra</title>\n";
 
42
        
 
43
        int rows = m.rowCount(), cols = m.columnCount();
 
44
        QStringList colHeaders;
 
45
        for(int i=0; i<cols; i++)
 
46
                colHeaders += m.headerData(i, Qt::Horizontal).toString();
 
47
        
 
48
        for(int i=0; i<rows; i++) {
 
49
                QString id = m.index(i,0).data().toString();
 
50
                str << "\t<sect1 id='" << id << "'><title>" << id << "</title><itemizedlist>\n";
 
51
                for(int c=0; c<cols; c++)
 
52
                        str << qPrintable(QString("\t\t<listitem><para>%1: %2</para></listitem>").arg(colHeaders[c]).arg(Qt::escape(m.index(i,c).data().toString()))) << '\n';
 
53
                
 
54
                str << "\t</itemizedlist></sect1>\n";
 
55
        }
 
56
        str << "</chapter>\n";
 
57
        
 
58
        return 0;
 
59
}