Issue #334, try 2.

Changed spaces, some minor stuffs like [[noreturn]].
Removed added by error clang settings.

--HG--
branch : develop
This commit is contained in:
Alex 2015-08-25 22:27:21 +03:00
parent 799d5d1dc2
commit dc95ae30e9
10 changed files with 78 additions and 40 deletions

View File

@ -14,6 +14,7 @@ SOURCES += \
$$PWD/version.cpp \ $$PWD/version.cpp \
$$PWD/mainwindowsnogui.cpp $$PWD/mainwindowsnogui.cpp
# Some header files # Some header files
HEADERS += \ HEADERS += \
$$PWD/mainwindow.h \ $$PWD/mainwindow.h \

View File

@ -108,8 +108,6 @@ CONFIG(debug, debug|release){
# -isystem key works only for headers. In some cases it's not enough. But we can't delete this warnings and # -isystem key works only for headers. In some cases it's not enough. But we can't delete this warnings and
# want them in global list. Compromise decision delete them from local list. # want them in global list. Compromise decision delete them from local list.
QMAKE_CXXFLAGS -= \ QMAKE_CXXFLAGS -= \
-Wuninitialized \
-Winit-self \
-Wmissing-prototypes \ -Wmissing-prototypes \
-Wundefined-reinterpret-cast -Wundefined-reinterpret-cast
} }

View File

@ -597,11 +597,13 @@ void VApplication::InitTrVars()
{ {
trVars = new VTranslateVars(Settings()); trVars = new VTranslateVars(Settings());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VApplication::CheckGUI() bool VApplication::CheckGUI()
{ {
return (VCommandLine::instance != nullptr) && VCommandLine::instance->IsGuiEnabled(); return (VCommandLine::instance != nullptr) && VCommandLine::instance->IsGuiEnabled();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
const VCommandLinePtr VApplication::CommandLine() const const VCommandLinePtr VApplication::CommandLine() const
{ {

View File

@ -29,7 +29,7 @@ const static auto OPTION_SHIFTUNITS = QStringLiteral("layounits");
const static auto OPTION_GAPWIDTH = QStringLiteral("gapwidth"); const static auto OPTION_GAPWIDTH = QStringLiteral("gapwidth");
const static auto OPTION_GROUPPING = QStringLiteral("groups"); const static auto OPTION_GROUPPING = QStringLiteral("groups");
#define tr(A) QCoreApplication::translate("VCommandLine",(A)) #define tr(A) QCoreApplication::translate("VCommandLine", (A))
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
//such a tricky initialization is used, because it uses static functions which relay on static variables and order of initialization is not defined between compiled units. //such a tricky initialization is used, because it uses static functions which relay on static variables and order of initialization is not defined between compiled units.
@ -37,39 +37,73 @@ const static auto OPTION_GROUPPING = QStringLiteral("groups");
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
VCommandLine::VCommandLine() : parser() VCommandLine::VCommandLine() : parser()
, optionsUsed ({ , optionsUsed ({
QCommandLineOption(OPTION_OUTFILE, tr("Path to output exported layout file. Use it to enable console export mode."), OPTION_OUTFILE), //keep in mind order here - that is how user will see it, so group-up for usability
//===================================================================================
QCommandLineOption(OPTION_MEASUREFILE, tr("Path to custom measure file (export mode)."), OPTION_MEASUREFILE), QCommandLineOption(OPTION_OUTFILE,
tr("Path to output exported layout file. Use it to enable console export mode."),
OPTION_OUTFILE),
QCommandLineOption(OPTION_EXP2FORMAT, tr("Number corresponding to output format (default = 0, export mode): ") + QCommandLineOption(OPTION_MEASUREFILE,
tr("Path to custom measure file (export mode)."),
OPTION_MEASUREFILE),
QCommandLineOption(OPTION_EXP2FORMAT,
tr("Number corresponding to output format (default = 0, export mode): ") +
DialogSaveLayout::MakeHelpFormatList(), OPTION_EXP2FORMAT, "0"), DialogSaveLayout::MakeHelpFormatList(), OPTION_EXP2FORMAT, "0"),
QCommandLineOption(OPTION_PAGETEMPLATE, tr("Number corresponding to page template (default = 0, export mode): ")+ //===================================================================================
QCommandLineOption(OPTION_PAGETEMPLATE,
tr("Number corresponding to page template (default = 0, export mode): ")+
DialogLayoutSettings::MakeHelpTemplateList(), OPTION_PAGETEMPLATE, "0"), DialogLayoutSettings::MakeHelpTemplateList(), OPTION_PAGETEMPLATE, "0"),
QCommandLineOption(OPTION_PAGEW, tr("Page width in current units like 12.0 (cannot be used with \"")+OPTION_PAGETEMPLATE+tr("\", export mode)."), OPTION_PAGEW), QCommandLineOption(OPTION_PAGEW,
tr("Page width in current units like 12.0 (cannot be used with \"")
+OPTION_PAGETEMPLATE+tr("\", export mode)."), OPTION_PAGEW),
QCommandLineOption(OPTION_PAGEH, tr("Page height in current units like 12.0 (cannot be used with \"")+OPTION_PAGETEMPLATE+tr("\", export mode)."), OPTION_PAGEH), QCommandLineOption(OPTION_PAGEH,
tr("Page height in current units like 12.0 (cannot be used with \"")
+OPTION_PAGETEMPLATE+tr("\", export mode)."), OPTION_PAGEH),
QCommandLineOption(OPTION_PAGEUNITS, tr("Page height/width measure units (cannot be used with \"")+ QCommandLineOption(OPTION_PAGEUNITS,
OPTION_PAGETEMPLATE+tr("\", export mode): ") + VDomDocument::UnitsHelpString(), OPTION_PAGEUNITS), tr("Page height/width measure units (cannot be used with \"")+
OPTION_PAGETEMPLATE+tr("\", export mode): ") + VDomDocument::UnitsHelpString(),
OPTION_PAGEUNITS),
QCommandLineOption(OPTION_ROTATE, tr("Rotation in degrees (one of predefined). Default (or 0) is no-rotate (export mode)."), OPTION_ROTATE), //===================================================================================
QCommandLineOption(OPTION_CROP, tr("Auto crop unused length (export mode).")), QCommandLineOption(OPTION_ROTATE,
tr("Rotation in degrees (one of predefined). Default (or 0) is no-rotate (export mode)."),
OPTION_ROTATE),
QCommandLineOption(OPTION_UNITE, tr("Unite pages if possible (export mode).")), QCommandLineOption(OPTION_CROP,
tr("Auto crop unused length (export mode).")),
QCommandLineOption(OPTION_SAVELENGTH, tr("Save length of the sheet if set. (export mode).")), QCommandLineOption(OPTION_UNITE,
tr("Unite pages if possible (export mode).")),
QCommandLineOption(OPTION_SHIFTUNITS, tr("Layout units (as paper's one except px, export mode)."), OPTION_SHIFTUNITS), //===================================================================================
QCommandLineOption(OPTION_SHIFTLENGTH, tr("Shift layout length measured in layout units (export mode)."), OPTION_SHIFTLENGTH), QCommandLineOption(OPTION_SAVELENGTH,
tr("Save length of the sheet if set. (export mode).")),
QCommandLineOption(OPTION_GAPWIDTH, tr("Gap width x2, measured in layout units. (export mode)."), OPTION_GAPWIDTH), QCommandLineOption(OPTION_SHIFTUNITS,
tr("Layout units (as paper's one except px, export mode)."),
OPTION_SHIFTUNITS),
QCommandLineOption(OPTION_GROUPPING, tr("Sets layout groupping (export mode): ") + DialogLayoutSettings::MakeGroupsHelp(), OPTION_GROUPPING, "2"), QCommandLineOption(OPTION_SHIFTLENGTH,
tr("Shift layout length measured in layout units (export mode)."),
OPTION_SHIFTLENGTH),
QCommandLineOption(OPTION_GAPWIDTH,
tr("Gap width x2, measured in layout units. (export mode)."),
OPTION_GAPWIDTH),
QCommandLineOption(OPTION_GROUPPING,
tr("Sets layout groupping (export mode): ")
+ DialogLayoutSettings::MakeGroupsHelp(), OPTION_GROUPPING, "2"),
}), }),
isGuiEnabled(false) isGuiEnabled(false)
{ {
@ -83,17 +117,20 @@ VCommandLine::VCommandLine() : parser()
parser.addOption(o); parser.addOption(o);
} }
} }
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
int VCommandLine::Lo2Px(const QString &src, const DialogLayoutSettings &converter) int VCommandLine::Lo2Px(const QString &src, const DialogLayoutSettings &converter)
{ {
//that is dirty-dirty hack ...eventually number is converted float <--> int 3 or 4 times including inside dialog ... that will loose precision for sure //that is dirty-dirty hack ...eventually number is converted float <--> int 3 or 4 times including inside dialog ... that will loose precision for sure
return converter.LayoutToPixels(src.toFloat()); return converter.LayoutToPixels(src.toFloat());
} }
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
int VCommandLine::Pg2Px(const QString& src, const DialogLayoutSettings& converter) int VCommandLine::Pg2Px(const QString& src, const DialogLayoutSettings& converter)
{ {
return converter.PageToPixels(src.toFloat()); return converter.PageToPixels(src.toFloat());
} }
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
{ {
@ -194,8 +231,8 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
return res; return res;
} }
//------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------
VCommandLinePtr VCommandLine::Get(const QCoreApplication& app) VCommandLinePtr VCommandLine::Get(const QCoreApplication& app)
{ {
if (instance == nullptr) if (instance == nullptr)
@ -209,12 +246,14 @@ VCommandLinePtr VCommandLine::Get(const QCoreApplication& app)
return instance; return instance;
} }
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
NORET_ATTR void VCommandLine::Error(const QString &text) const NORET_ATTR void VCommandLine::Error(const QString &text) const
{ {
qStdErr() << text << "\n"; qStdErr() << text << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(FAILED_HELP_SHOWN_STATUS); const_cast<VCommandLine*>(this)->parser.showHelp(FAILED_HELP_SHOWN_STATUS);
} }
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
void VCommandLine::Reset() void VCommandLine::Reset()
{ {
@ -231,6 +270,7 @@ bool VCommandLine::IsExportEnabled() const
} }
return r; return r;
} }
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
DialogLayoutSettings::PaperSizeTemplate VCommandLine::OptPaperSize() const DialogLayoutSettings::PaperSizeTemplate VCommandLine::OptPaperSize() const
{ {
@ -253,6 +293,7 @@ int VCommandLine::OptRotation() const
return rotate; return rotate;
} }
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
Cases VCommandLine::OptGroup() const Cases VCommandLine::OptGroup() const
{ {
@ -263,8 +304,8 @@ Cases VCommandLine::OptGroup() const
} }
return static_cast<Cases>(r); return static_cast<Cases>(r);
} }
//------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------
QString VCommandLine::OptMeasurePath() const QString VCommandLine::OptMeasurePath() const
{ {
QString measure; QString measure;
@ -279,7 +320,6 @@ QString VCommandLine::OptMeasurePath() const
} }
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
QString VCommandLine::OptExportPath() const QString VCommandLine::OptExportPath() const
{ {
QString path; QString path;
@ -290,8 +330,8 @@ QString VCommandLine::OptExportPath() const
return path; return path;
} }
//------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------
int VCommandLine::OptExportType() const int VCommandLine::OptExportType() const
{ {
int r = 0; int r = 0;
@ -303,11 +343,11 @@ int VCommandLine::OptExportType() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VCommandLine::OptInputFileNames() const QStringList VCommandLine::OptInputFileNames() const
{ {
return parser.positionalArguments(); return parser.positionalArguments();
} }
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
bool VCommandLine::IsGuiEnabled() const bool VCommandLine::IsGuiEnabled() const
{ {

View File

@ -11,11 +11,10 @@ constexpr auto GENERAL_ERROR_STATUS = 255;
constexpr auto INVALID_PARAMS_STATUS = 254; constexpr auto INVALID_PARAMS_STATUS = 254;
constexpr auto FAILED_TO_GEN_LAYOUT_STATUS = 253; constexpr auto FAILED_TO_GEN_LAYOUT_STATUS = 253;
constexpr auto FAILED_HELP_SHOWN_STATUS = 250; constexpr auto FAILED_HELP_SHOWN_STATUS = 250;
constexpr auto FAILED_GEN_BASE_STATUS = 240;
//making QtCReator happy....[[noreturn]] is part of C++11 standard #define NORET_ATTR Q_NORETURN
//http://en.cppreference.com/w/cpp/language/attributes
#define NORET_ATTR [[noreturn]]
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
inline QTextStream& qStdErr() inline QTextStream& qStdErr()

View File

@ -269,6 +269,7 @@ void DialogLayoutSettings::SetUnitePages(bool save)
{ {
ui->checkBoxUnitePages->setChecked(save); ui->checkBoxUnitePages->setChecked(save);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::TemplateSelected() void DialogLayoutSettings::TemplateSelected()
{ {
@ -304,6 +305,7 @@ bool DialogLayoutSettings::SelectPaperUnit(const QString& units)
} }
return indexUnit != -1; return indexUnit != -1;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::SelectLayoutUnit(const QString &units) bool DialogLayoutSettings::SelectLayoutUnit(const QString &units)
{ {
@ -314,16 +316,19 @@ bool DialogLayoutSettings::SelectLayoutUnit(const QString &units)
} }
return indexUnit != -1; return indexUnit != -1;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int DialogLayoutSettings::LayoutToPixels(qreal value) const int DialogLayoutSettings::LayoutToPixels(qreal value) const
{ {
return static_cast<quint32>(qFloor(UnitConvertor(value, LayoutUnit(), Unit::Px))); return static_cast<quint32>(qFloor(UnitConvertor(value, LayoutUnit(), Unit::Px)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int DialogLayoutSettings::PageToPixels(qreal value) const int DialogLayoutSettings::PageToPixels(qreal value) const
{ {
return static_cast<quint32>(qFloor(UnitConvertor(value, PaperUnit(), Unit::Px))); return static_cast<quint32>(qFloor(UnitConvertor(value, PaperUnit(), Unit::Px)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogLayoutSettings::MakeGroupsHelp() QString DialogLayoutSettings::MakeGroupsHelp()
{ {
@ -366,8 +371,8 @@ void DialogLayoutSettings::PaperSizeChanged()
Label(); Label();
} }
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate& id) bool DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate& id)
{ {
int index = ui->comboBoxTemplates->findData(static_cast<VIndexType>(id)); int index = ui->comboBoxTemplates->findData(static_cast<VIndexType>(id));
@ -378,8 +383,8 @@ bool DialogLayoutSettings::SelectTemplate(const PaperSizeTemplate& id)
return (index > -1); return (index > -1);
} }
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::Swap(bool checked) void DialogLayoutSettings::Swap(bool checked)
{ {
if (checked) if (checked)
@ -481,8 +486,8 @@ void DialogLayoutSettings::InitTemplates()
} }
ui->comboBoxTemplates->setCurrentIndex(-1); ui->comboBoxTemplates->setCurrentIndex(-1);
} }
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
QString DialogLayoutSettings::MakeHelpTemplateList() QString DialogLayoutSettings::MakeHelpTemplateList()
{ {
QString out = "\n"; QString out = "\n";

View File

@ -756,12 +756,6 @@ void MainWindow::ToolTrueDarts(bool checked)
&MainWindow::ClosedDialogWithApply<VToolTrueDarts>, &MainWindow::ClosedDialogWithApply<VToolTrueDarts>,
&MainWindow::ApplyDialog<VToolTrueDarts>); &MainWindow::ApplyDialog<VToolTrueDarts>);
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::ToolRotate(bool checked)
{
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -1080,7 +1074,6 @@ void MainWindow::InitToolButtons()
connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength); connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength);
connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts); connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts);
//connect(ui->toolButtonRotate, &QToolButton::clicked, this, &MainWindow::ToolRotate);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -125,7 +125,6 @@ public slots:
void ToolPointFromArcAndTangent(bool checked); void ToolPointFromArcAndTangent(bool checked);
void ToolArcWithLength(bool checked); void ToolArcWithLength(bool checked);
void ToolTrueDarts(bool checked); void ToolTrueDarts(bool checked);
void ToolRotate(bool checked);
void ClosedDialogDetail(int result); void ClosedDialogDetail(int result);
void ClosedDialogUnionDetails(int result); void ClosedDialogUnionDetails(int result);

View File

@ -161,7 +161,8 @@ void MainWindowsNoGUI::ErrorConsoleMode(const LayoutErrors &state)
default: default:
break; break;
} }
AppAbort(text, FAILED_TO_GEN_LAYOUT_STATUS); //just added different return status in console mode
AppAbort(text, FAILED_GEN_BASE_STATUS + static_cast<int>(state));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -87,7 +87,7 @@ enum class Tool : unsigned char
enum class Vis : unsigned char enum class Vis : unsigned char
{ {
ControlPointSpline = static_cast<Vis>(Tool::LAST_ONE_DO_NOT_USE), //38,// increase this value if need more positions in Tool enum ControlPointSpline = static_cast<Vis>(Tool::LAST_ONE_DO_NOT_USE),
GraphicsSimpleTextItem, GraphicsSimpleTextItem,
SimpleSplinePath, SimpleSplinePath,
SimplePoint, SimplePoint,