initial port for Cevo game in C++ (libs)
This commit is contained in:
commit
8436242032
375 files changed
+46282
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class QTreeWidget;
|
||||
|
||||
namespace Cevo {
|
||||
|
||||
// Equivalent of Table.pas's TTableFormat/TTableFormats.
|
||||
enum class TableFormat { Excel, Plain, Csv, Html, ListView, MediaWiki, Xml, Json };
|
||||
|
||||
QString tableFormatText(TableFormat format);
|
||||
QString tableFormatExt(TableFormat format);
|
||||
|
||||
// Equivalent of Table.pas's TRow.
|
||||
struct Row {
|
||||
QStringList cells;
|
||||
void addCell(const QString &text) { cells.append(text); }
|
||||
};
|
||||
|
||||
// Equivalent of Table.pas's TTable: a generic string table with multi-format
|
||||
// export/import. JSON (QJsonDocument) and XML (QDomDocument) use Qt's own
|
||||
// parsers/serializers instead of the original's hand-rolled, line-based
|
||||
// ones (the original's JSON "parser" assumes exactly one "key": "value" per
|
||||
// line and no nesting; its HTML/JSON output also did not escape cell
|
||||
// content at all, which is fixed here).
|
||||
class Table {
|
||||
public:
|
||||
QString title;
|
||||
QStringList columns;
|
||||
std::vector<std::unique_ptr<Row>> rows;
|
||||
bool firstRowIsHeader = false;
|
||||
|
||||
void clear();
|
||||
Row &addRow();
|
||||
|
||||
QString outputTabs() const;
|
||||
QString outputPlain() const;
|
||||
QString outputCsv() const;
|
||||
QString outputXml() const;
|
||||
QString outputHtml() const;
|
||||
QString outputMediaWiki() const;
|
||||
QString outputJson() const;
|
||||
void populateTreeWidget(QTreeWidget *tree) const;
|
||||
QString output(TableFormat format) const;
|
||||
|
||||
void setInputCsv(const QString &text);
|
||||
void setInputMediaWiki(const QString &text);
|
||||
void setInputJson(const QString &text);
|
||||
void setInputXml(const QString &text);
|
||||
void setInput(TableFormat format, const QString &text);
|
||||
|
||||
static QList<TableFormat> inputFormats();
|
||||
};
|
||||
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user