File indexing completed on 2023-05-30 10:41:19

0001 /*************************************************************************************
0002  *  Copyright (C) 2010 by Aleix Pol <aleixpol@kde.org>                               *
0003  *                                                                                   *
0004  *  This program is free software; you can redistribute it and/or                    *
0005  *  modify it under the terms of the GNU General Public License                      *
0006  *  as published by the Free Software Foundation; either version 2                   *
0007  *  of the License, or (at your option) any later version.                           *
0008  *                                                                                   *
0009  *  This program is distributed in the hope that it will be useful,                  *
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0012  *  GNU General Public License for more details.                                     *
0013  *                                                                                   *
0014  *  You should have received a copy of the GNU General Public License                *
0015  *  along with this program; if not, write to the Free Software                      *
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0017  *************************************************************************************/
0018 
0019 #include <analitzagui/operatorsmodel.h>
0020 #include <QApplication>
0021 #include <QStringList>
0022 #include <QFile>
0023 #include <QTextStream>
0024 
0025 int main(int argc, char** argv)
0026 {
0027     QApplication app(argc, argv);
0028     OperatorsModel m;
0029     
0030     QFile f(app.arguments().constLast());
0031     bool fileopened = f.open(QFile::WriteOnly);
0032     Q_ASSERT(fileopened);
0033     
0034     QTextStream str(&f);
0035 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0036     str.setCodec("UTF-8");
0037 #endif
0038     
0039     str << "<!-- this file is autogenerated, if any change has to be done, please "
0040                 "fix kdeedu/kalgebra/utils/main.cpp and its dependencies. "
0041                 "Thank you, Aleix Pol -->";
0042     str << "<chapter id='commands'>\n"
0043                 "<title>Commands supported by KAlgebra</title>\n";
0044     
0045     int rows = m.rowCount(), cols = m.columnCount();
0046     QStringList colHeaders;
0047     for(int i=0; i<cols; i++)
0048         colHeaders += m.headerData(i, Qt::Horizontal).toString();
0049     
0050     for(int i=0; i<rows; i++) {
0051         QString id = m.index(i,0).data().toString();
0052         str << "\t<sect1 id='" << id << "'><title>" << id << "</title><itemizedlist>\n";
0053         for(int c=0; c<cols; c++)
0054             str << QStringLiteral("\t\t<listitem><para>%1: %2</para></listitem>").arg(colHeaders[c], m.index(i,c).data().toString().toHtmlEscaped()) << '\n';
0055         
0056         str << "\t</itemizedlist></sect1>\n";
0057     }
0058     str << "</chapter>\n";
0059     
0060     return 0;
0061 }