Mercurial > clickerconvert
diff src/converter.h @ 3:8b4c49c92451
Add initial implementation that handles choices
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 22 Mar 2016 10:39:19 +0100 |
parents | |
children | a10425e7ef98 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/converter.h Tue Mar 22 10:39:19 2016 +0100 @@ -0,0 +1,81 @@ +#ifndef CONVERTER_H +#define CONVERTER_H +/* Copyright (C) 2016 by ETH Zürich + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU GPL (v>=2) + * and comes with ABSOLUTELY NO WARRANTY! + * See LICENSE.txt for details. + */ + +#include <QThread> +#include <QString> +#include <QStringList> +#include <QTextStream> +#include <QFile> + +#include "xlsxformat.h" + +/** @file Declaration of the Converter class. + */ + +/** + * @enum ConvertFormat + * @brief Possible output format values. + */ +enum ConvertFormat { + /*! XLSX (default). */ + Format_XLSX, + /*! PDF */ + Format_PDF +}; + +/** @brief Base class of Convert operations. + * + * Set up an instance of this using the ctor and according setters and + * start it. + */ +class Converter : public QThread +{ + Q_OBJECT + +public: + /** Construct a new Converter object. + * + * If input is empty stdin is used. If output + * is empty stdout is used. + * + * @param input input filename. + * @param output output filename. + * @param format the format of this. + */ + Converter(const QString &input, const QString &output, + ConvertFormat fmt = Format_XLSX, + const QString &title = QString()); + + /** Check for errors + * + * @returns Empty stringlist on success. Translated errors otherwise.*/ + const QStringList & errors() {return mErrors;} + +protected: + void convertToXSLX(QTextStream &instream, QFile &output); + void run(); + + QString mInput, mOutput; + ConvertFormat mFmt; + QStringList mErrors; + QString mTitle; + + QXlsx::Format mTitleFmt, + mQuestionFmt, + mAnswerChoiceFmt, + mAnswerTextFmt, + mFreeTextFmt, + mChoiceTextFmt, + mChoiceBarFmt, + mChoiceBarInactiveFmt, + mChoiceVotesFmt; +}; + +#endif // CONVERTER_H