Skip to content

Commit 4c472b1

Browse files
author
Allen Winter
committed
Add wasn demo
1 parent 6120f2b commit 4c472b1

File tree

16 files changed

+108
-75
lines changed

16 files changed

+108
-75
lines changed

README-WASM.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# KDReports with WebAssembly
2+
3+
## Demo
4+
5+
A demo is available at <https://demos.kdab.com/wasm/kdreports>.
6+
7+
## Build tips for KDReports
8+
9+
- Visit <https://doc.qt.io/qt-5/wasm.html> if you haven't yet
10+
11+
- Open a terminal suitable for WASM development (with the correct Qt and toolchain in PATH, etc)
12+
13+
- KDReports can be built with:
14+
15+
```bash
16+
cmake \
17+
-DCMAKE_TOOLCHAIN_FILE=/usr/local/emsdk-1.39.8/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
18+
-DCMAKE_FIND_ROOT_PATH=~/Qt/5.15.1/wasm_32/ -DCMAKE_BUILD_TYPE=Release`
19+
(Adapt the paths to your own situation)
20+
```
21+
22+
## Builds tips for your own app ==
23+
24+
- Link to KDReports (libkdreports.a, or similar)

README-bindings.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@ and adjust to the PYTHONPATH accordingly, as necessary.
104104
copy "C:\Program Files\llvm\bin\libclang.dll" libclang.dll
105105
(Python3 installation in C:\Python37 and llvm in c:\Program Files\llvm. adjust as needed)
106106
```
107-

docs/CHANGES_2_2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ What is new in KD Reports 2.2
44
General:
55
--------
66
* buildsystem - increase CMake min version to 3.12.0
7+
* Add WebAssembly demo-example
78

89
Bugfixes:
910
-------------

examples/DemoWasm/CMakeLists.txt

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
##
2-
## This file is part of the KD Reports library.
3-
##
4-
## SPDX-FileCopyrightText: 2015-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5-
##
6-
## SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDReports OR LicenseRef-KDAB-KDReports-US
7-
##
8-
## Licensees holding valid commercial KD Reports licenses may use this file in
9-
## accordance with the KD Reports Commercial License Agreement provided with
10-
## the Software.
11-
##
12-
## Contact info@kdab.com if any conditions of this licensing are not clear to you.
13-
##
2+
# This file is part of the KD Reports library.
3+
#
4+
# SPDX-FileCopyrightText: 2015-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5+
#
6+
# SPDX-License-Identifier: MIT
7+
#
148

159
set(DEMO_SOURCES
1610
kdreports.qrc
@@ -29,13 +23,15 @@ qt_add_executable(demo-wasm ${DEMO_SOURCES})
2923

3024
# Output wasm file to same location as .html
3125
# file created by qt_add_executable
32-
set_target_properties(demo-wasm PROPERTIES
33-
RUNTIME_OUTPUT_DIRECTORY_DEBUG ""
34-
RUNTIME_OUTPUT_DIRECTORY_RELEASE ""
35-
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ""
36-
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ""
26+
set_target_properties(
27+
demo-wasm
28+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ""
29+
RUNTIME_OUTPUT_DIRECTORY_RELEASE ""
30+
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ""
31+
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ""
3732
)
3833

3934
target_link_libraries(
40-
demo-wasm PUBLIC ${QT_LIBRARIES} kdreports
35+
demo-wasm
36+
PUBLIC ${QT_LIBRARIES} kdreports
4137
)

examples/DemoWasm/ResultModel.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22
**
33
** This file is part of the KD Reports library.
44
**
5-
** SPDX-FileCopyrightText: 2007-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5+
** SPDX-FileCopyrightText: 2007-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
66
**
7-
** SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDReports OR LicenseRef-KDAB-KDReports-US
8-
**
9-
** Licensees holding valid commercial KD Reports licenses may use this file in
10-
** accordance with the KD Reports Commercial License Agreement provided with
11-
** the Software.
12-
**
13-
** Contact info@kdab.com if any conditions of this licensing are not clear to you.
7+
** SPDX-License-Identifier: MIT
148
**
159
****************************************************************************/
1610

examples/DemoWasm/ResultModel.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22
**
33
** This file is part of the KD Reports library.
44
**
5-
** SPDX-FileCopyrightText: 2007-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5+
** SPDX-FileCopyrightText: 2007-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
66
**
7-
** SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDReports OR LicenseRef-KDAB-KDReports-US
8-
**
9-
** Licensees holding valid commercial KD Reports licenses may use this file in
10-
** accordance with the KD Reports Commercial License Agreement provided with
11-
** the Software.
12-
**
13-
** Contact info@kdab.com if any conditions of this licensing are not clear to you.
7+
** SPDX-License-Identifier: MIT
148
**
159
****************************************************************************/
1610

@@ -52,7 +46,10 @@ class ResultModel : public QAbstractTableModel
5246
list << _param << _error << QString("hidden");
5347
merged = true;
5448
}
55-
Data() { merged = false; }
49+
Data()
50+
{
51+
merged = false;
52+
}
5653

5754
QStringList list;
5855
bool merged;

examples/DemoWasm/TableModel.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22
**
33
** This file is part of the KD Reports library.
44
**
5-
** SPDX-FileCopyrightText: 2007-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5+
** SPDX-FileCopyrightText: 2007-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
66
**
7-
** SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDReports OR LicenseRef-KDAB-KDReports-US
8-
**
9-
** Licensees holding valid commercial KD Reports licenses may use this file in
10-
** accordance with the KD Reports Commercial License Agreement provided with
11-
** the Software.
12-
**
13-
** Contact info@kdab.com if any conditions of this licensing are not clear to you.
7+
** SPDX-License-Identifier: MIT
148
**
159
****************************************************************************/
1610

@@ -31,7 +25,9 @@ TableModel::TableModel(QObject *parent)
3125
{
3226
}
3327

34-
TableModel::~TableModel() { }
28+
TableModel::~TableModel()
29+
{
30+
}
3531

3632
int TableModel::rowCount(const QModelIndex &) const
3733
{

examples/DemoWasm/TableModel.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22
**
33
** This file is part of the KD Reports library.
44
**
5-
** SPDX-FileCopyrightText: 2007-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5+
** SPDX-FileCopyrightText: 2007-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
66
**
7-
** SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDReports OR LicenseRef-KDAB-KDReports-US
8-
**
9-
** Licensees holding valid commercial KD Reports licenses may use this file in
10-
** accordance with the KD Reports Commercial License Agreement provided with
11-
** the Software.
12-
**
13-
** Contact info@kdab.com if any conditions of this licensing are not clear to you.
7+
** SPDX-License-Identifier: MIT
148
**
159
****************************************************************************/
1610

@@ -78,16 +72,25 @@ class TESTTOOLS_EXPORT TableModel : public QAbstractTableModel
7872
/**
7973
* Set to false if the data has no horizontal header
8074
*/
81-
void setDataHasHorizontalHeaders(bool value) { m_dataHasHorizontalHeaders = value; }
75+
void setDataHasHorizontalHeaders(bool value)
76+
{
77+
m_dataHasHorizontalHeaders = value;
78+
}
8279
/**
8380
* Set to false if the data has no vertical header
8481
*/
85-
void setDataHasVerticalHeaders(bool value) { m_dataHasVerticalHeaders = value; }
82+
void setDataHasVerticalHeaders(bool value)
83+
{
84+
m_dataHasVerticalHeaders = value;
85+
}
8686
/**
8787
* setSupplyHeaderData(false) allows to prevent the model from supplying header data,
8888
* even if parsing found any
8989
*/
90-
void setSupplyHeaderData(bool value) { m_supplyHeaderData = value; }
90+
void setSupplyHeaderData(bool value)
91+
{
92+
m_supplyHeaderData = value;
93+
}
9194

9295
private:
9396
// the vector of rows:

examples/DemoWasm/kdreportswindow.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/****************************************************************************
2+
**
3+
** This file is part of the KD Reports library.
4+
**
5+
** SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6+
**
7+
** SPDX-License-Identifier: MIT
8+
**
9+
****************************************************************************/
10+
111
#include "kdreportswindow.h"
212
#include "ui_kdreportswindow.h"
313

@@ -384,10 +394,10 @@ void KDReportsWindow::priceListXml()
384394
// not only as complete (generated) reports.
385395
report->associateTextValue("title_element", "Price list example");
386396
report->associateTextValue("company_address",
387-
QString::fromUtf8("Klarälvdalens Datakonsult AB\n"
388-
"Rysktorp\n"
389-
"SE-68392 Hagfors\n"
390-
"Sweden"));
397+
QString::fromUtf8("Klarälvdalens Datakonsult AB\n"
398+
"Rysktorp\n"
399+
"SE-68392 Hagfors\n"
400+
"Sweden"));
391401
// Note how id="table1_title" is used twice in the xml, both places get the right value
392402
report->associateTextValue("table1_title", "Network Peripherals");
393403
report->associateTextValue("table2_title", "Printer Cartridges");

examples/DemoWasm/kdreportswindow.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1+
/****************************************************************************
2+
**
3+
** This file is part of the KD Reports library.
4+
**
5+
** SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6+
**
7+
** SPDX-License-Identifier: MIT
8+
**
9+
****************************************************************************/
10+
111
#ifndef KDREPORTSWINDOW_H
212
#define KDREPORTSWINDOW_H
313

414
#include <QMainWindow>
515

616
QT_BEGIN_NAMESPACE
7-
namespace Ui { class KDReportsWindow; }
17+
namespace Ui {
18+
class KDReportsWindow;
19+
}
820
QT_END_NAMESPACE
921

1022
class KDReportsWindow : public QMainWindow

0 commit comments

Comments
 (0)