Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define codestyle #472

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
BasedOnStyle: WebKit
Language: Cpp
AlignAfterOpenBracket: Align
AllowShortEnumsOnASingleLine: false
BreakInheritanceList: AfterColon
BreakConstructorInitializers: AfterColon
SpaceBeforeCtorInitializerColon: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
AllowAllConstructorInitializersOnNextLine: false
SpaceBeforeInheritanceColon: false
PointerAlignment: Left
ReflowComments: true
FixNamespaceComments: true
SortIncludes: true
SortUsingDeclarations: true
IncludeBlocks: Regroup
# regular expressions are matched against the filename of an include (including the <> or “”) in order:
# topmost: main header file (the one that has the same name as .cpp-file) and ui_XXX.h, if exists
# second group: local header files (i.e. "something.h")
# third group: external header files (i.e. <smth/other.h>)
# fourth group: Qt toolkit headers (actually, anything that starts with a 'Q')
# last group: all other external header files
# headers in all groups are sorted by name
IncludeCategories:
- Regex: '"ui_.*'
Priority: 0
- Regex: '^".*'
Priority: 1
- Regex: '^<Qt.*'
Priority: 3
- Regex: '^<.*/.*\.h>'
Priority: 2
- Regex: '^<Q.*'
Priority: 3
- Regex: '^<.*'
Priority: 4
ColumnLimit: 100
TabWidth: 4
UseTab: Never
MaxEmptyLinesToKeep: 1
13 changes: 13 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@ env:
BUILD_TYPE: Release

jobs:
check-code-style:
runs-on: ubuntu-22.04
name: "Check code style"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Perform check
run: ./tools/check_code_style.sh

build:
runs-on: ubuntu-${{ matrix.ubuntu_version }}
name: Ubuntu-${{ matrix.ubuntu_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
needs: check-code-style
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -55,6 +65,7 @@ jobs:
MSVC:
name: windows-${{ matrix.win_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
runs-on: windows-${{ matrix.win_version }}
needs: check-code-style
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -96,6 +107,7 @@ jobs:
MinGW-w64:
runs-on: windows-2022
name: msys2-${{ matrix.msystem }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
needs: check-code-style
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -165,6 +177,7 @@ jobs:
macos:
runs-on: macos-${{ matrix.macos_version }}
name: macos-${{ matrix.macos_version }}-Qt-${{ matrix.qt_version }}-static-${{ matrix.static }}
needs: check-code-style
strategy:
fail-fast: false
matrix:
Expand Down
90 changes: 49 additions & 41 deletions console/main.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#include "../limereport/version.h"

#include <QApplication>
#include <QUuid>
#include <LimeReport>
#include <iostream>
#include <QCommandLineParser>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QCommandLineParser>
#include "../limereport/version.h"
#include <QUuid>

#include <LimeReport>
#include <iostream>

#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
#include <fcntl.h>
#include <io.h>
#endif

int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
QApplication::setApplicationVersion(LIMEREPORT_VERSION_STR);
Expand All @@ -23,63 +25,69 @@ int main(int argc, char *argv[])
QCommandLineParser parser;
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption sourceOption(QStringList() << "s" << "source",
QCoreApplication::translate("main", "Limereport pattern file name"),
QCoreApplication::translate("main", "source"));
QCommandLineOption sourceOption(
QStringList() << "s"
<< "source",
QCoreApplication::translate("main", "Limereport pattern file name"),
QCoreApplication::translate("main", "source"));
parser.addOption(sourceOption);
QCommandLineOption destinationOption(QStringList() << "d" << "destination",
QCoreApplication::translate("main", "Output file name"),
QCoreApplication::translate("main", "destination"));
QCommandLineOption destinationOption(QStringList() << "d"
<< "destination",
QCoreApplication::translate("main", "Output file name"),
QCoreApplication::translate("main", "destination"));
parser.addOption(destinationOption);
QCommandLineOption variablesOption(QStringList() << "p" << "param",
QCoreApplication::translate("main", "Report parameter (can be more than one)"),
QCoreApplication::translate("main", "param_name=param_value"));
QCommandLineOption variablesOption(
QStringList() << "p"
<< "param",
QCoreApplication::translate("main", "Report parameter (can be more than one)"),
QCoreApplication::translate("main", "param_name=param_value"));
parser.addOption(variablesOption);
parser.process(a);

LimeReport::ReportEngine report;

if (parser.value(sourceOption).isEmpty()){
std::cerr<<"Error! Report file is not specified !! \n";
if (parser.value(sourceOption).isEmpty()) {
std::cerr << "Error! Report file is not specified !! \n";
return 1;
}

if (!report.loadFromFile(parser.value(sourceOption))){
std::cerr<<"Error! Report file \""+parser.value(sourceOption).toStdString()+"\" not found \n";
if (!report.loadFromFile(parser.value(sourceOption))) {
std::cerr << "Error! Report file \"" + parser.value(sourceOption).toStdString()
+ "\" not found \n";
return 1;
}

if (!parser.values(variablesOption).isEmpty()){
foreach(QString var, parser.values(variablesOption)){
if (!parser.values(variablesOption).isEmpty()) {
foreach (QString var, parser.values(variablesOption)) {
QStringList varItem = var.split("=");
if (varItem.size() == 2)
report.dataManager()->setReportVariable(varItem.at(0),varItem.at(1));
report.dataManager()->setReportVariable(varItem.at(0), varItem.at(1));
}
}

if (parser.value(destinationOption).isEmpty()){
if (parser.value(destinationOption).isEmpty()) {
report.printToPDF(QFileInfo(parser.value(sourceOption)).baseName());
} else {
report.printToPDF(parser.value(destinationOption));
}
#else
std::cerr<<"This demo intended for Qt 5.2 and higher\n";
std::cerr << "This demo intended for Qt 5.2 and higher\n";
#endif
// QUuid uid = QUuid::createUuid();
// QString uidStr = uid.toString()+".pdf";
// report.printToPDF(uidStr);
// QFile in(uidStr);
// QFile out;
// out.open(stdout, QFile::WriteOnly);
// in.open(QIODevice::ReadOnly);
//#ifdef _WIN32
// _setmode(fileno(stdout),O_BINARY);
//#endif
// QByteArray buffer = in.readAll();
// fwrite(buffer,1,buffer.size(),stdout);
// in.close();
// in.remove();
// QUuid uid = QUuid::createUuid();
// QString uidStr = uid.toString()+".pdf";
// report.printToPDF(uidStr);
// QFile in(uidStr);
// QFile out;
// out.open(stdout, QFile::WriteOnly);
// in.open(QIODevice::ReadOnly);
//#ifdef _WIN32
// _setmode(fileno(stdout),O_BINARY);
//#endif
// QByteArray buffer = in.readAll();
// fwrite(buffer,1,buffer.size(),stdout);
// in.close();
// in.remove();

return 0;
//return a.exec();
// return a.exec();
}
4 changes: 2 additions & 2 deletions demo_r1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
* GNU General Public License for more details. *
****************************************************************************/
#include "mainwindow.h"
#include <QApplication>

#include <QApplication>

int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
MainWindow w;
Expand Down
Loading