Thrown away code for support Qt < 5.2.
--HG-- branch : develop
This commit is contained in:
parent
2dcfe1c84b
commit
7e064f80c5
|
@ -58,11 +58,11 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare
|
|||
connect(ui->systemCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this]()
|
||||
{
|
||||
m_systemChanged = true;
|
||||
QString text = qApp->TrVars()->PMSystemAuthor(CURRENT_DATA(ui->systemCombo).toString());
|
||||
QString text = qApp->TrVars()->PMSystemAuthor(ui->systemCombo->currentData().toString());
|
||||
ui->systemAuthorValueLabel->setText(text);
|
||||
ui->systemAuthorValueLabel->setToolTip(text);
|
||||
|
||||
text = qApp->TrVars()->PMSystemBook(CURRENT_DATA(ui->systemCombo).toString());
|
||||
text = qApp->TrVars()->PMSystemBook(ui->systemCombo->currentData().toString());
|
||||
ui->systemBookValueLabel->setPlainText(text);
|
||||
});
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ DialogAboutTape::DialogAboutTape(QWidget *parent)
|
|||
//mApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||
|
||||
RetranslateUi();
|
||||
connect(ui->pushButton_Web_Site, &QPushButton::clicked, RECEIVER(this)[this]()
|
||||
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false)
|
||||
{
|
||||
|
|
|
@ -80,13 +80,13 @@ DialogNewMeasurements::~DialogNewMeasurements()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MeasurementsType DialogNewMeasurements::Type() const
|
||||
{
|
||||
return static_cast<MeasurementsType>(CURRENT_DATA(ui->comboBoxMType).toInt());
|
||||
return static_cast<MeasurementsType>(ui->comboBoxMType->currentData().toInt());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
Unit DialogNewMeasurements::MUnit() const
|
||||
{
|
||||
return static_cast<Unit>(CURRENT_DATA(ui->comboBoxUnit).toInt());
|
||||
return static_cast<Unit>(ui->comboBoxUnit->currentData().toInt());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -109,7 +109,7 @@ void DialogNewMeasurements::changeEvent(QEvent *event)
|
|||
// retranslate designer form (single inheritance approach)
|
||||
ui->retranslateUi(this);
|
||||
InitMTypes();
|
||||
InitUnits(static_cast<MeasurementsType>(CURRENT_DATA(ui->comboBoxMType).toInt()));
|
||||
InitUnits(static_cast<MeasurementsType>(ui->comboBoxMType->currentData().toInt()));
|
||||
}
|
||||
|
||||
// remember to call base class implementation
|
||||
|
@ -177,7 +177,7 @@ void DialogNewMeasurements::InitMTypes()
|
|||
int val = static_cast<int>(MeasurementsType::Unknown);
|
||||
if (ui->comboBoxMType->currentIndex() != -1)
|
||||
{
|
||||
val = CURRENT_DATA(ui->comboBoxMType).toInt();
|
||||
val = ui->comboBoxMType->currentData().toInt();
|
||||
}
|
||||
|
||||
ui->comboBoxMType->blockSignals(true);
|
||||
|
@ -215,7 +215,7 @@ void DialogNewMeasurements::InitUnits(const MeasurementsType &type)
|
|||
int val = static_cast<int>(Unit::Cm);
|
||||
if (ui->comboBoxUnit->currentIndex() != -1)
|
||||
{
|
||||
val = CURRENT_DATA(ui->comboBoxUnit).toInt();
|
||||
val = ui->comboBoxUnit->currentData().toInt();
|
||||
}
|
||||
|
||||
ui->comboBoxUnit->blockSignals(true);
|
||||
|
|
|
@ -60,11 +60,7 @@ Q_LOGGING_CATEGORY(mApp, "m.application")
|
|||
|
||||
QT_WARNING_POP
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
# include "../vmisc/backport/qcommandlineparser.h"
|
||||
#else
|
||||
#include <QCommandLineParser>
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
|
|
|
@ -104,14 +104,12 @@ TMainWindow::TMainWindow(QWidget *parent)
|
|||
|
||||
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditFind->setClearButtonEnabled(true);
|
||||
ui->lineEditName->setClearButtonEnabled(true);
|
||||
ui->lineEditFullName->setClearButtonEnabled(true);
|
||||
ui->lineEditGivenName->setClearButtonEnabled(true);
|
||||
ui->lineEditFamilyName->setClearButtonEnabled(true);
|
||||
ui->lineEditEmail->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditFind->installEventFilter(this);
|
||||
ui->plainTextEditFormula->installEventFilter(this);
|
||||
|
@ -142,13 +140,7 @@ TMainWindow::TMainWindow(QWidget *parent)
|
|||
QMenu *menu = new QMenu(this);
|
||||
connect(menu, &QMenu::aboutToShow, this, &TMainWindow::AboutToShowDockMenu);
|
||||
AboutToShowDockMenu();
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
menu->setAsDockMenu();
|
||||
#else
|
||||
extern void qt_mac_set_dock_menu(QMenu *);
|
||||
qt_mac_set_dock_menu(menu);
|
||||
#endif
|
||||
#endif //defined(Q_OS_MAC)
|
||||
}
|
||||
|
||||
|
@ -1901,7 +1893,7 @@ void TMainWindow::SetupMenu()
|
|||
ui->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
|
||||
|
||||
connect(ui->actionExportToCSV, &QAction::triggered, this, &TMainWindow::ExportToCSV);
|
||||
connect(ui->actionReadOnly, &QAction::triggered, RECEIVER(this)[this](bool ro)
|
||||
connect(ui->actionReadOnly, &QAction::triggered, this, [this](bool ro)
|
||||
{
|
||||
if (not mIsReadOnly)
|
||||
{
|
||||
|
@ -1924,7 +1916,7 @@ void TMainWindow::SetupMenu()
|
|||
{
|
||||
QAction *action = new QAction(this);
|
||||
recentFileActs[i] = action;
|
||||
connect(action, &QAction::triggered, RECEIVER(this)[action, this]()
|
||||
connect(action, &QAction::triggered, this, [action, this]()
|
||||
{
|
||||
if (action != nullptr)
|
||||
{
|
||||
|
@ -1965,11 +1957,11 @@ void TMainWindow::SetupMenu()
|
|||
AboutToShowWindowMenu();
|
||||
|
||||
// Help
|
||||
connect(ui->actionAboutQt, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionAboutQt, &QAction::triggered, this, [this]()
|
||||
{
|
||||
QMessageBox::aboutQt(this, tr("About Qt"));
|
||||
});
|
||||
connect(ui->actionAboutTape, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionAboutTape, &QAction::triggered, this, [this]()
|
||||
{
|
||||
DialogAboutTape *aboutDialog = new DialogAboutTape(this);
|
||||
aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
@ -2118,11 +2110,11 @@ void TMainWindow::InitWindow()
|
|||
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, [this] (){search->FindPrevious();});
|
||||
connect(ui->toolButtonFindNext, &QToolButton::clicked, [this] (){search->FindNext();});
|
||||
|
||||
connect(search.data(), &VTableSearch::HasResult, RECEIVER(this)[this] (bool state)
|
||||
connect(search.data(), &VTableSearch::HasResult, this, [this] (bool state)
|
||||
{
|
||||
ui->toolButtonFindPrevious->setEnabled(state);
|
||||
});
|
||||
connect(search.data(), &VTableSearch::HasResult, RECEIVER(this)[this] (bool state)
|
||||
connect(search.data(), &VTableSearch::HasResult, this, [this] (bool state)
|
||||
{
|
||||
ui->toolButtonFindNext->setEnabled(state);
|
||||
});
|
||||
|
@ -2149,7 +2141,7 @@ void TMainWindow::InitWindow()
|
|||
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveMDescription);
|
||||
connect(ui->lineEditFullName, &QLineEdit::textEdited, this, &TMainWindow::SaveMFullName);
|
||||
|
||||
connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, RECEIVER(this)[this]()
|
||||
connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
ShowInGraphicalShell(curFile);
|
||||
});
|
||||
|
@ -2949,7 +2941,7 @@ void TMainWindow::CreateWindowMenu(QMenu *menu)
|
|||
SCASSERT(menu != nullptr)
|
||||
|
||||
QAction *action = menu->addAction(tr("&New Window"));
|
||||
connect(action, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(action, &QAction::triggered, this, [this]()
|
||||
{
|
||||
qApp->NewMainWindow();
|
||||
qApp->MainWindow()->activateWindow();
|
||||
|
@ -2983,7 +2975,6 @@ void TMainWindow::CreateWindowMenu(QMenu *menu)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool TMainWindow::IgnoreLocking(int error, const QString &path)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
QMessageBox::StandardButton answer = QMessageBox::Abort;
|
||||
if (not qApp->IsTestMode())
|
||||
{
|
||||
|
@ -3045,11 +3036,6 @@ bool TMainWindow::IgnoreLocking(int error, const QString &path)
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
Q_UNUSED(error)
|
||||
Q_UNUSED(path)
|
||||
return true;// On older Qt lock assumed always taken. Allow user to ignore warning.
|
||||
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -33,16 +33,11 @@
|
|||
#include <vector>
|
||||
#include <QTextStream>
|
||||
#include <QCoreApplication>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
#include "../dialogs/dialoglayoutsettings.h"
|
||||
#include "../vmisc/vsysexits.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
# include "../vmisc/backport/qcommandlineparser.h"
|
||||
#else
|
||||
# include <QCommandLineParser>
|
||||
#endif
|
||||
|
||||
class VCommandLine;
|
||||
typedef std::shared_ptr<VCommandLine> VCommandLinePtr;
|
||||
typedef QList<QCommandLineOption *> VCommandLineOptions;
|
||||
|
|
|
@ -83,11 +83,11 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
|
|||
connect(ui->systemCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this]()
|
||||
{
|
||||
m_systemChanged = true;
|
||||
QString text = qApp->TrVars()->PMSystemAuthor(CURRENT_DATA(ui->systemCombo).toString());
|
||||
QString text = qApp->TrVars()->PMSystemAuthor(ui->systemCombo->currentData().toString());
|
||||
ui->systemAuthorValueLabel->setText(text);
|
||||
ui->systemAuthorValueLabel->setToolTip(text);
|
||||
|
||||
text = qApp->TrVars()->PMSystemBook(CURRENT_DATA(ui->systemCombo).toString());
|
||||
text = qApp->TrVars()->PMSystemBook(ui->systemCombo->currentData().toString());
|
||||
ui->systemBookValueLabel->setPlainText(text);
|
||||
});
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) :
|
|||
|
||||
|
||||
ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR));
|
||||
connect(ui->pushButton_Web_Site, &QPushButton::clicked, RECEIVER(this)[this]()
|
||||
connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent)
|
|||
FillTable();
|
||||
InitialTable();
|
||||
connect(ui->tableWidget, &QTableWidget::cellClicked, this, &DialogHistory::cellClicked);
|
||||
connect(this, &DialogHistory::ShowHistoryTool, RECEIVER(doc)[doc](quint32 id, bool enable)
|
||||
connect(this, &DialogHistory::ShowHistoryTool, doc, [doc](quint32 id, bool enable)
|
||||
{
|
||||
emit doc->ShowTool(id, enable);
|
||||
});
|
||||
|
|
|
@ -63,10 +63,8 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditName->setClearButtonEnabled(true);
|
||||
ui->lineEditFind->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditFind->installEventFilter(this);
|
||||
|
||||
|
@ -108,15 +106,15 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
connect(ui->lineEditName, &QLineEdit::textEdited, this, &DialogIncrements::SaveIncrName);
|
||||
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &DialogIncrements::SaveIncrDescription);
|
||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogIncrements::SaveIncrFormula);
|
||||
connect(ui->lineEditFind, &QLineEdit::textEdited, RECEIVER(this)[this](const QString &term){search->Find(term);});
|
||||
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, RECEIVER(this)[this](){search->FindPrevious();});
|
||||
connect(ui->toolButtonFindNext, &QToolButton::clicked, RECEIVER(this)[this](){search->FindNext();});
|
||||
connect(ui->lineEditFind, &QLineEdit::textEdited, this, [this](const QString &term){search->Find(term);});
|
||||
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, this, [this](){search->FindPrevious();});
|
||||
connect(ui->toolButtonFindNext, &QToolButton::clicked, this, [this](){search->FindNext();});
|
||||
|
||||
connect(search.data(), &VTableSearch::HasResult, RECEIVER(this)[this] (bool state)
|
||||
connect(search.data(), &VTableSearch::HasResult, this, [this] (bool state)
|
||||
{
|
||||
ui->toolButtonFindPrevious->setEnabled(state);
|
||||
});
|
||||
connect(search.data(), &VTableSearch::HasResult, RECEIVER(this)[this] (bool state)
|
||||
connect(search.data(), &VTableSearch::HasResult, this, [this] (bool state)
|
||||
{
|
||||
ui->toolButtonFindNext->setEnabled(state);
|
||||
});
|
||||
|
|
|
@ -55,7 +55,7 @@ DialogLayoutProgress::DialogLayoutProgress(int count, QWidget *parent)
|
|||
|
||||
QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||
SCASSERT(bCancel != nullptr)
|
||||
connect(bCancel, &QPushButton::clicked, RECEIVER(this)[this](){emit Abort();});
|
||||
connect(bCancel, &QPushButton::clicked, this, [this](){emit Abort();});
|
||||
setModal(true);
|
||||
|
||||
this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
|
||||
|
|
|
@ -824,7 +824,7 @@ QString DialogLayoutSettings::MakeHelpTemplateList()
|
|||
QSizeF DialogLayoutSettings::Template()
|
||||
{
|
||||
PaperSizeTemplate temp;
|
||||
temp = static_cast<PaperSizeTemplate>(CURRENT_DATA(ui->comboBoxTemplates).toInt());
|
||||
temp = static_cast<PaperSizeTemplate>(ui->comboBoxTemplates->currentData().toInt());
|
||||
|
||||
switch (temp)
|
||||
{
|
||||
|
@ -976,13 +976,13 @@ QMarginsF DialogLayoutSettings::GetDefPrinterFields() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
Unit DialogLayoutSettings::PaperUnit() const
|
||||
{
|
||||
return VDomDocument::StrToUnits(CURRENT_DATA(ui->comboBoxPaperSizeUnit).toString());
|
||||
return VDomDocument::StrToUnits(ui->comboBoxPaperSizeUnit->currentData().toString());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
Unit DialogLayoutSettings::LayoutUnit() const
|
||||
{
|
||||
return VDomDocument::StrToUnits(CURRENT_DATA(ui->comboBoxLayoutUnit).toString());
|
||||
return VDomDocument::StrToUnits(ui->comboBoxLayoutUnit->currentData().toString());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -45,9 +45,7 @@ DialogNewPattern::DialogNewPattern(VContainer *data, const QString &patternPiece
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditName->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||
|
||||
|
|
|
@ -67,9 +67,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditAuthor->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
SCASSERT(doc != nullptr)
|
||||
|
||||
|
@ -89,7 +87,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
|
|||
}
|
||||
ui->lineEditPathToFile->setCursorPosition(0);
|
||||
|
||||
connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, RECEIVER(this)[this]()
|
||||
connect(ui->pushButtonShowInExplorer, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
ShowInGraphicalShell(m_filePath);
|
||||
});
|
||||
|
@ -140,7 +138,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
|
|||
const QString size = QString().setNum(doc->GetDefCustomSize());
|
||||
SetDefaultSize(size);
|
||||
|
||||
connect(ui->radioButtonDefFromP, &QRadioButton::toggled, RECEIVER(this)[this]()
|
||||
connect(ui->radioButtonDefFromP, &QRadioButton::toggled, this, [this]()
|
||||
{
|
||||
ui->comboBoxHeight->setEnabled(ui->radioButtonDefFromP->isChecked());
|
||||
ui->comboBoxSize->setEnabled(ui->radioButtonDefFromP->isChecked());
|
||||
|
@ -148,20 +146,20 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
|
|||
|
||||
auto DefValueChanged = [this](){defaultChanged = true;};
|
||||
|
||||
connect(ui->radioButtonDefFromP, &QRadioButton::toggled, RECEIVER(this)DefValueChanged);
|
||||
connect(ui->radioButtonDefFromP, &QRadioButton::toggled, this, DefValueChanged);
|
||||
|
||||
ui->radioButtonDefFromP->setChecked(doc->IsDefCustom());
|
||||
|
||||
connect(ui->comboBoxHeight, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
RECEIVER(this)DefValueChanged);
|
||||
this, DefValueChanged);
|
||||
connect(ui->comboBoxSize, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
RECEIVER(this)DefValueChanged);
|
||||
this, DefValueChanged);
|
||||
|
||||
const bool readOnly = doc->IsReadOnly();
|
||||
ui->checkBoxPatternReadOnly->setChecked(readOnly);
|
||||
if (not readOnly)
|
||||
{
|
||||
connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, RECEIVER(this)[this](){securityChanged = true;});
|
||||
connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, this, [this](){securityChanged = true;});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -736,7 +734,7 @@ void DialogPatternProperties::InitImage()
|
|||
{
|
||||
ui->imageLabel->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->imageLabel->setScaledContents(true);
|
||||
connect(ui->imageLabel, &QWidget::customContextMenuRequested, RECEIVER(this)[this]()
|
||||
connect(ui->imageLabel, &QWidget::customContextMenuRequested, this, [this]()
|
||||
{
|
||||
QMenu menu(this);
|
||||
menu.addAction(deleteAction);
|
||||
|
@ -752,7 +750,7 @@ void DialogPatternProperties::InitImage()
|
|||
saveImageAction = new QAction(tr("Save image to file"), this);
|
||||
showImageAction = new QAction(tr("Show image"), this);
|
||||
|
||||
connect(deleteAction, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(deleteAction, &QAction::triggered, this, [this]()
|
||||
{
|
||||
doc->DeleteImage();
|
||||
ui->imageLabel->setText(tr("Change image"));
|
||||
|
@ -763,7 +761,7 @@ void DialogPatternProperties::InitImage()
|
|||
|
||||
connect(changeImageAction, &QAction::triggered, this, &DialogPatternProperties::ChangeImage);
|
||||
connect(saveImageAction, &QAction::triggered, this, &DialogPatternProperties::SaveImage);
|
||||
connect(showImageAction, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(showImageAction, &QAction::triggered, this, [this]()
|
||||
{
|
||||
QLabel *label = new QLabel(this, Qt::Window);
|
||||
const QImage image = GetImage();
|
||||
|
|
|
@ -51,10 +51,8 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditPath->setClearButtonEnabled(true);
|
||||
ui->lineEditFileName->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||
|
||||
|
@ -62,11 +60,7 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
|
|||
SCASSERT(bOk != nullptr)
|
||||
bOk->setEnabled(false);
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5, 1, 0)
|
||||
ui->lineEditFileName->setValidator( new QRegularExpressionValidator(QRegularExpression(baseFilenameRegExp), this));
|
||||
#else
|
||||
ui->lineEditFileName->setValidator( new QRegExpValidator(QRegExp(baseFilenameRegExp), this));
|
||||
#endif
|
||||
|
||||
const QString mask = fileName+QLatin1String("_");
|
||||
if (VApplication::IsGUIMode())
|
||||
|
@ -97,10 +91,10 @@ DialogSaveLayout::DialogSaveLayout(int count, const QString &fileName, QWidget *
|
|||
ui->labelExample->setText(tr("Example:") + FileName() + QLatin1String("1") + Format());
|
||||
};
|
||||
|
||||
connect(ui->lineEditFileName, &QLineEdit::textChanged, RECEIVER(this)ShowExample);
|
||||
connect(ui->lineEditFileName, &QLineEdit::textChanged, this, ShowExample);
|
||||
connect(ui->comboBoxFormat, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
RECEIVER(this)ShowExample);
|
||||
connect(ui->pushButtonBrowse, &QPushButton::clicked, RECEIVER(this)[this]()
|
||||
this, ShowExample);
|
||||
connect(ui->pushButtonBrowse, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
const QString dirPath = qApp->ValentinaSettings()->GetPathLayout();
|
||||
bool usedNotExistedDir = false;
|
||||
|
@ -208,7 +202,7 @@ QString DialogSaveLayout::FileName() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogSaveLayout::Format() const
|
||||
{
|
||||
return CURRENT_DATA(ui->comboBoxFormat).toString();
|
||||
return ui->comboBoxFormat->currentData().toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -143,7 +143,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternChangesWereSaved);
|
||||
connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile);
|
||||
connect(doc, &VPattern::SetEnabledGUI, this, &MainWindow::SetEnabledGUI);
|
||||
connect(doc, &VPattern::CheckLayout, RECEIVER(this)[this]()
|
||||
connect(doc, &VPattern::CheckLayout, this, [this]()
|
||||
{
|
||||
if (pattern->DataPieces()->count() == 0)
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->dockWidgetLayoutPages->setVisible(false);
|
||||
|
||||
connect(watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged);
|
||||
connect(qApp, &QApplication::focusChanged, RECEIVER(this)[this](QWidget *old, QWidget *now)
|
||||
connect(qApp, &QApplication::focusChanged, this, [this](QWidget *old, QWidget *now)
|
||||
{
|
||||
if (old == nullptr && isAncestorOf(now) == true)
|
||||
{// focus IN
|
||||
|
@ -232,12 +232,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
actionPreferences->setMenuRole(QAction::NoRole);
|
||||
connect(actionPreferences, &QAction::triggered, this, &MainWindow::Preferences);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
menu->setAsDockMenu();
|
||||
#else
|
||||
extern void qt_mac_set_dock_menu(QMenu *);
|
||||
qt_mac_set_dock_menu(menu);
|
||||
#endif
|
||||
#endif //defined(Q_OS_MAC)
|
||||
}
|
||||
|
||||
|
@ -362,7 +357,7 @@ void MainWindow::InitScenes()
|
|||
sceneDetails->setTransform(ui->view->transform());
|
||||
|
||||
connect(ui->view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
|
||||
connect(ui->view, &VMainGraphicsView::MouseRelease, RECEIVER(this)[this](){EndVisualization(true);});
|
||||
connect(ui->view, &VMainGraphicsView::MouseRelease, this, [this](){EndVisualization(true);});
|
||||
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
policy.setHorizontalStretch(12);
|
||||
ui->view->setSizePolicy(policy);
|
||||
|
@ -1817,9 +1812,9 @@ void MainWindow::ToolBarDraws()
|
|||
comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
comboBoxDraws->setEnabled(false);
|
||||
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
RECEIVER(this)[this](int index){ChangePP(index);});
|
||||
this, [this](int index){ChangePP(index);});
|
||||
|
||||
connect(ui->actionOptionDraw, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionOptionDraw, &QAction::triggered, this, [this]()
|
||||
{
|
||||
const QString activDraw = doc->GetNameActivPP();
|
||||
const QString nameDraw = PatternPieceName(activDraw);
|
||||
|
@ -3776,14 +3771,14 @@ void MainWindow::AddDocks()
|
|||
//Add dock
|
||||
actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction();
|
||||
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetToolOptions);
|
||||
connect(ui->dockWidgetToolOptions, &QDockWidget::visibilityChanged, RECEIVER(this)[this](bool visible)
|
||||
connect(ui->dockWidgetToolOptions, &QDockWidget::visibilityChanged, this, [this](bool visible)
|
||||
{
|
||||
isDockToolOptionsVisible = visible;
|
||||
});
|
||||
|
||||
actionDockWidgetGroups = ui->dockWidgetGroups->toggleViewAction();
|
||||
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetGroups);
|
||||
connect(ui->dockWidgetGroups, &QDockWidget::visibilityChanged, RECEIVER(this)[this](bool visible)
|
||||
connect(ui->dockWidgetGroups, &QDockWidget::visibilityChanged, this, [this](bool visible)
|
||||
{
|
||||
isDockGroupsVisible = visible;
|
||||
});
|
||||
|
@ -3835,14 +3830,14 @@ void MainWindow::CreateActions()
|
|||
connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails);
|
||||
connect(ui->actionLayout, &QAction::triggered, this, &MainWindow::ActionLayout);
|
||||
|
||||
connect(ui->actionHistory, &QAction::triggered, RECEIVER(this)[this](bool checked)
|
||||
connect(ui->actionHistory, &QAction::triggered, this, [this](bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
dialogHistory = new DialogHistory(pattern, doc, this);
|
||||
dialogHistory->setWindowFlags(Qt::Window);
|
||||
connect(this, &MainWindow::RefreshHistory, dialogHistory.data(), &DialogHistory::UpdateHistory);
|
||||
connect(dialogHistory.data(), &DialogHistory::DialogClosed, RECEIVER(this)[this]()
|
||||
connect(dialogHistory.data(), &DialogHistory::DialogClosed, this, [this]()
|
||||
{
|
||||
ui->actionHistory->setChecked(false);
|
||||
delete dialogHistory;
|
||||
|
@ -3858,7 +3853,7 @@ void MainWindow::CreateActions()
|
|||
}
|
||||
});
|
||||
|
||||
connect(ui->actionNewDraw, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionNewDraw, &QAction::triggered, this, [this]()
|
||||
{
|
||||
qCDebug(vMainWindow, "New PP.");
|
||||
QString patternPieceName = tr("Pattern piece %1").arg(comboBoxDraws->count()+1);
|
||||
|
@ -3882,12 +3877,12 @@ void MainWindow::CreateActions()
|
|||
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::New);
|
||||
connect(ui->actionExportIncrementsToCSV, &QAction::triggered, this, &MainWindow::ExportToCSV);
|
||||
|
||||
connect(ui->actionTable, &QAction::triggered, RECEIVER(this)[this](bool checked)
|
||||
connect(ui->actionTable, &QAction::triggered, this, [this](bool checked)
|
||||
{
|
||||
if (checked)
|
||||
{
|
||||
dialogTable = new DialogIncrements(pattern, doc, this);
|
||||
connect(dialogTable.data(), &DialogIncrements::DialogClosed, RECEIVER(this)[this]()
|
||||
connect(dialogTable.data(), &DialogIncrements::DialogClosed, this, [this]()
|
||||
{
|
||||
ui->actionTable->setChecked(false);
|
||||
delete dialogTable;
|
||||
|
@ -3901,12 +3896,12 @@ void MainWindow::CreateActions()
|
|||
}
|
||||
});
|
||||
|
||||
connect(ui->actionAbout_Qt, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionAbout_Qt, &QAction::triggered, this, [this]()
|
||||
{
|
||||
QMessageBox::aboutQt(this, tr("About Qt"));
|
||||
});
|
||||
|
||||
connect(ui->actionAbout_Valentina, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionAbout_Valentina, &QAction::triggered, this, [this]()
|
||||
{
|
||||
DialogAboutApp *aboutDialog = new DialogAboutApp(this);
|
||||
aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
@ -3916,19 +3911,19 @@ void MainWindow::CreateActions()
|
|||
connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
|
||||
|
||||
connect(ui->actionPreferences, &QAction::triggered, this, &MainWindow::Preferences);
|
||||
connect(ui->actionReportBug, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionReportBug, &QAction::triggered, this, [this]()
|
||||
{
|
||||
qCDebug(vMainWindow, "Reporting bug");
|
||||
QDesktopServices::openUrl(QUrl(QStringLiteral("https://bitbucket.org/dismine/valentina/issues/new")));
|
||||
});
|
||||
|
||||
connect(ui->actionWiki, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionWiki, &QAction::triggered, this, [this]()
|
||||
{
|
||||
qCDebug(vMainWindow, "Showing online help");
|
||||
QDesktopServices::openUrl(QUrl(QStringLiteral("https://wiki.valentinaproject.org/wiki/Main_Page")));
|
||||
});
|
||||
|
||||
connect(ui->actionForum, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionForum, &QAction::triggered, this, [this]()
|
||||
{
|
||||
qCDebug(vMainWindow, "Opening forum");
|
||||
QDesktopServices::openUrl(QUrl(QStringLiteral("http://forum.valentina-project.org/")));
|
||||
|
@ -3936,10 +3931,10 @@ void MainWindow::CreateActions()
|
|||
|
||||
connect(ui->actionLast_tool, &QAction::triggered, this, &MainWindow::LastUsedTool);
|
||||
|
||||
connect(ui->actionPattern_properties, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionPattern_properties, &QAction::triggered, this, [this]()
|
||||
{
|
||||
DialogPatternProperties proper(curFile, doc, pattern, this);
|
||||
connect(&proper, &DialogPatternProperties::UpdateGradation, RECEIVER(this)[this]()
|
||||
connect(&proper, &DialogPatternProperties::UpdateGradation, this, [this]()
|
||||
{
|
||||
UpdateHeightsList(VMeasurement::ListHeights(doc->GetGradationHeights(), qApp->patternUnit()));
|
||||
UpdateSizesList(VMeasurement::ListSizes(doc->GetGradationSizes(), qApp->patternUnit()));
|
||||
|
@ -3948,7 +3943,7 @@ void MainWindow::CreateActions()
|
|||
});
|
||||
|
||||
ui->actionPattern_properties->setEnabled(false);
|
||||
connect(ui->actionClosePattern, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionClosePattern, &QAction::triggered, this, [this]()
|
||||
{
|
||||
if (MaybeSave())
|
||||
{
|
||||
|
@ -3957,7 +3952,7 @@ void MainWindow::CreateActions()
|
|||
}
|
||||
});
|
||||
|
||||
connect(ui->actionShowCurveDetails, &QAction::triggered, RECEIVER(this)[this](bool checked)
|
||||
connect(ui->actionShowCurveDetails, &QAction::triggered, this, [this](bool checked)
|
||||
{
|
||||
ui->view->itemClicked(nullptr);
|
||||
sceneDraw->EnableDetailsMode(checked);
|
||||
|
@ -3966,7 +3961,7 @@ void MainWindow::CreateActions()
|
|||
connect(ui->actionLoadIndividual, &QAction::triggered, this, &MainWindow::LoadIndividual);
|
||||
connect(ui->actionLoadStandard, &QAction::triggered, this, &MainWindow::LoadStandard);
|
||||
|
||||
connect(ui->actionOpenTape, &QAction::triggered, RECEIVER(this)[this]()
|
||||
connect(ui->actionOpenTape, &QAction::triggered, this, [this]()
|
||||
{
|
||||
const QString tape = qApp->TapeFilePath();
|
||||
const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath();
|
||||
|
@ -3994,7 +3989,7 @@ void MainWindow::CreateActions()
|
|||
QAction *action = new QAction(this);
|
||||
action->setVisible(false);
|
||||
recentFileActs[i] = action;
|
||||
connect(recentFileActs[i], &QAction::triggered, RECEIVER(this)[action, this]()
|
||||
connect(recentFileActs[i], &QAction::triggered, this, [action, this]()
|
||||
{
|
||||
if (action != nullptr)
|
||||
{
|
||||
|
@ -4244,7 +4239,6 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList MainWindow::GetUnlokedRestoreFileList() const
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
QStringList restoreFiles;
|
||||
//Take all files that need to be restored
|
||||
QStringList files = qApp->ValentinaSettings()->GetRestoreFileList();
|
||||
|
@ -4279,9 +4273,6 @@ QStringList MainWindow::GetUnlokedRestoreFileList() const
|
|||
qApp->ValentinaSettings()->SetRestoreFileList(filtered);
|
||||
}
|
||||
return restoreFiles;
|
||||
#else
|
||||
return qApp->ValentinaSettings()->GetRestoreFileList();
|
||||
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -4930,7 +4921,6 @@ void MainWindow::UpdateWindowTitle()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool MainWindow::IgnoreLocking(int error, const QString &path)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
QMessageBox::StandardButton answer = QMessageBox::Abort;
|
||||
if (VApplication::IsGUIMode())
|
||||
{
|
||||
|
@ -4993,11 +4983,6 @@ bool MainWindow::IgnoreLocking(int error, const QString &path)
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
Q_UNUSED(error)
|
||||
Q_UNUSED(path)
|
||||
return true;// On older Qt lock assumed always taken. Allow user to ignore warning.
|
||||
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -305,7 +305,7 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
|
|||
|
||||
m_reply = m_qnam.get(request);
|
||||
|
||||
connect(m_reply.data(), &QNetworkReply::readyRead, RECEIVER(this)[this]()
|
||||
connect(m_reply.data(), &QNetworkReply::readyRead, this, [this]()
|
||||
{
|
||||
// this slot gets called every time the QNetworkReply has new data.
|
||||
// We read all of its new data and write it into the file.
|
||||
|
@ -313,7 +313,7 @@ void FvUpdater::startDownloadFeed(const QUrl &url)
|
|||
// signal of the QNetworkReply
|
||||
m_xml.addData(m_reply->readAll());
|
||||
});
|
||||
connect(m_reply.data(), &QNetworkReply::downloadProgress, RECEIVER(this)[this](qint64 bytesRead, qint64 totalBytes)
|
||||
connect(m_reply.data(), &QNetworkReply::downloadProgress, this, [this](qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
Q_UNUSED(bytesRead)
|
||||
Q_UNUSED(totalBytes)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <qdom.h>
|
||||
#include <QSaveFile>
|
||||
|
||||
#include "../exception/vexceptionbadid.h"
|
||||
#include "../exception/vexceptionconversionerror.h"
|
||||
|
@ -39,12 +40,6 @@
|
|||
#include "../vmisc/logging.h"
|
||||
#include "../ifcdef.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
# include "../vmisc/backport/qsavefile.h"
|
||||
#else
|
||||
# include <QSaveFile>
|
||||
#endif
|
||||
|
||||
#include <QAbstractMessageHandler>
|
||||
#include <QByteArray>
|
||||
#include <QDomNodeList>
|
||||
|
|
|
@ -135,13 +135,11 @@ int VDxfPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
|
|||
case QPaintDevice::PdmDpiX:
|
||||
case QPaintDevice::PdmDpiY:
|
||||
return static_cast<int>(engine->getResolution());
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 2)
|
||||
case QPaintDevice::PdmDevicePixelRatio:
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||
case QPaintDevice::PdmDevicePixelRatioScaled:
|
||||
#endif
|
||||
return 1;
|
||||
#endif
|
||||
default:
|
||||
qWarning("VDxfPaintDevice::metric(), unhandled metric %d\n", metric);
|
||||
break;
|
||||
|
|
|
@ -275,11 +275,7 @@ QVector<QPointF> VArc::GetPoints() const
|
|||
QVector<QPointF> splPoints = spl.GetPoints();
|
||||
if (not splPoints.isEmpty() && i != sectionAngle.size() - 1)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
splPoints.remove(splPoints.size() - 1);
|
||||
#else
|
||||
splPoints.removeLast();
|
||||
#endif
|
||||
}
|
||||
|
||||
points << splPoints;
|
||||
|
|
|
@ -401,11 +401,7 @@ QVector<QPointF> VEllipticalArc::GetPoints() const
|
|||
|
||||
if (not splPoints.isEmpty() && i != sectionAngle.size() - 1)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
splPoints.remove(splPoints.size() - 1);
|
||||
#else
|
||||
splPoints.removeLast();
|
||||
#endif
|
||||
}
|
||||
points << splPoints;
|
||||
currentAngle += sectionAngle.at(i);
|
||||
|
|
|
@ -230,9 +230,7 @@ void VLayoutGenerator::Abort()
|
|||
{
|
||||
stopGeneration.store(true);
|
||||
state = LayoutErrors::ProcessStoped;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
QThreadPool::globalInstance()->clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -780,11 +780,7 @@ void VLayoutPiece::SetLayoutAllowancePoints()
|
|||
d->layoutAllowance = Equidistant(PrepareAllowance(GetSeamAllowancePoints()), d->layoutWidth);
|
||||
if (d->layoutAllowance.isEmpty() == false)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
d->layoutAllowance.remove(d->layoutAllowance.size() - 1);
|
||||
#else
|
||||
d->layoutAllowance.removeLast();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -792,11 +788,7 @@ void VLayoutPiece::SetLayoutAllowancePoints()
|
|||
d->layoutAllowance = Equidistant(PrepareAllowance(GetContourPoints()), d->layoutWidth);
|
||||
if (d->layoutAllowance.isEmpty() == false)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
d->layoutAllowance.remove(d->layoutAllowance.size() - 1);
|
||||
#else
|
||||
d->layoutAllowance.removeLast();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,307 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
|
||||
** Copyright (C) 2013 David Faure <faure@kde.org>
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcommandlineoption.h"
|
||||
|
||||
#include <QSet>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#include "../vmisc/diagnostic.h"
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
||||
|
||||
class QCommandLineOptionPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
inline QCommandLineOptionPrivate()
|
||||
{ }
|
||||
|
||||
void setNames(const QStringList &nameList);
|
||||
|
||||
//! The list of names used for this option.
|
||||
QStringList names;
|
||||
|
||||
//! The documentation name for the value, if one is expected
|
||||
//! Example: "-o <file>" means valueName == "file"
|
||||
QString valueName;
|
||||
|
||||
//! The description used for this option.
|
||||
QString description;
|
||||
|
||||
//! The list of default values used for this option.
|
||||
QStringList defaultValues;
|
||||
};
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
/*!
|
||||
\since 5.2
|
||||
\class QCommandLineOption
|
||||
\brief The QCommandLineOption class defines a possible command-line option.
|
||||
\inmodule QtCore
|
||||
\ingroup shared
|
||||
\ingroup tools
|
||||
|
||||
This class is used to describe an option on the command line. It allows
|
||||
different ways of defining the same option with multiple aliases possible.
|
||||
It is also used to describe how the option is used - it may be a flag (e.g. \c{-v})
|
||||
or take an argument (e.g. \c{-o file}).
|
||||
|
||||
Examples:
|
||||
\snippet code/src_corelib_tools_qcommandlineoption.cpp 0
|
||||
|
||||
\sa QCommandLineParser
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QCommandLineOption &QCommandLineOption::operator=(QCommandLineOption &&other)
|
||||
|
||||
Move-assigns \a other to this QCommandLineOption instance.
|
||||
|
||||
\since 5.2
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a command line option object with the given arguments.
|
||||
|
||||
The name of the option is set to \a name.
|
||||
The name can be either short or long. If the name is one character in
|
||||
length, it is considered a short name. Option names must not be empty,
|
||||
must not start with a dash or a slash character, must not contain a \c{=}
|
||||
and cannot be repeated.
|
||||
|
||||
The description is set to \a description. It is customary to add a "."
|
||||
at the end of the description.
|
||||
|
||||
In addition, the \a valueName can be set if the option expects a value.
|
||||
The default value for the option is set to \a defaultValue.
|
||||
|
||||
\sa setDescription(), setValueName(), setDefaultValues()
|
||||
*/
|
||||
QCommandLineOption::QCommandLineOption(const QString &name, const QString &description,
|
||||
const QString &valueName,
|
||||
const QString &defaultValue)
|
||||
: d(new QCommandLineOptionPrivate)
|
||||
{
|
||||
d->setNames(QStringList(name));
|
||||
setValueName(valueName);
|
||||
setDescription(description);
|
||||
setDefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a command line option object with the given arguments.
|
||||
|
||||
This overload allows to set multiple names for the option, for instance
|
||||
\c{o} and \c{output}.
|
||||
|
||||
The names of the option are set to \a names.
|
||||
The names can be either short or long. Any name in the list that is one
|
||||
character in length is a short name. Option names must not be empty,
|
||||
must not start with a dash or a slash character, must not contain a \c{=}
|
||||
and cannot be repeated.
|
||||
|
||||
The description is set to \a description. It is customary to add a "."
|
||||
at the end of the description.
|
||||
|
||||
In addition, the \a valueName can be set if the option expects a value.
|
||||
The default value for the option is set to \a defaultValue.
|
||||
|
||||
\sa setDescription(), setValueName(), setDefaultValues()
|
||||
*/
|
||||
QCommandLineOption::QCommandLineOption(const QStringList &names, const QString &description,
|
||||
const QString &valueName,
|
||||
const QString &defaultValue)
|
||||
: d(new QCommandLineOptionPrivate)
|
||||
{
|
||||
d->setNames(names);
|
||||
setValueName(valueName);
|
||||
setDescription(description);
|
||||
setDefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a QCommandLineOption object that is a copy of the QCommandLineOption
|
||||
object \a other.
|
||||
|
||||
\sa operator=()
|
||||
*/
|
||||
QCommandLineOption::QCommandLineOption(const QCommandLineOption &other)
|
||||
: d(other.d)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the command line option object.
|
||||
*/
|
||||
QCommandLineOption::~QCommandLineOption()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Makes a copy of the \a other object and assigns it to this QCommandLineOption
|
||||
object.
|
||||
*/
|
||||
QCommandLineOption &QCommandLineOption::operator=(const QCommandLineOption &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QCommandLineOption::swap(QCommandLineOption &other)
|
||||
|
||||
Swaps option \a other with this option. This operation is very
|
||||
fast and never fails.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the names set for this option.
|
||||
*/
|
||||
QStringList QCommandLineOption::names() const
|
||||
{
|
||||
return d->names;
|
||||
}
|
||||
|
||||
void QCommandLineOptionPrivate::setNames(const QStringList &nameList)
|
||||
{
|
||||
names.clear();
|
||||
if (nameList.isEmpty())
|
||||
qWarning("QCommandLineOption: Options must have at least one name");
|
||||
foreach (const QString &name, nameList) {
|
||||
if (name.isEmpty()) {
|
||||
qWarning("QCommandLineOption: Option names cannot be empty");
|
||||
} else {
|
||||
const QChar c = name.at(0);
|
||||
if (c == QLatin1Char('-'))
|
||||
qWarning("QCommandLineOption: Option names cannot start with a '-'");
|
||||
else if (c == QLatin1Char('/'))
|
||||
qWarning("QCommandLineOption: Option names cannot start with a '/'");
|
||||
else if (name.contains(QLatin1Char('=')))
|
||||
qWarning("QCommandLineOption: Option names cannot contain a '='");
|
||||
else
|
||||
names.append(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the name of the expected value, for the documentation, to \a valueName.
|
||||
|
||||
Options without a value assigned have a boolean-like behavior:
|
||||
either the user specifies --option or they don't.
|
||||
|
||||
Options with a value assigned need to set a name for the expected value,
|
||||
for the documentation of the option in the help output. An option with names \c{o} and \c{output},
|
||||
and a value name of \c{file} will appear as \c{-o, --output <file>}.
|
||||
|
||||
Call QCommandLineParser::argument() if you expect the option to be present
|
||||
only once, and QCommandLineParser::arguments() if you expect that option
|
||||
to be present multiple times.
|
||||
|
||||
\sa valueName()
|
||||
*/
|
||||
void QCommandLineOption::setValueName(const QString &valueName)
|
||||
{
|
||||
d->valueName = valueName;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the name of the expected value.
|
||||
|
||||
If empty, the option doesn't take a value.
|
||||
|
||||
\sa setValueName()
|
||||
*/
|
||||
QString QCommandLineOption::valueName() const
|
||||
{
|
||||
return d->valueName;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the description used for this option to \a description.
|
||||
|
||||
It is customary to add a "." at the end of the description.
|
||||
|
||||
The description is used by QCommandLineParser::showHelp().
|
||||
|
||||
\sa description()
|
||||
*/
|
||||
void QCommandLineOption::setDescription(const QString &description)
|
||||
{
|
||||
d->description = description;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the description set for this option.
|
||||
|
||||
\sa setDescription()
|
||||
*/
|
||||
QString QCommandLineOption::description() const
|
||||
{
|
||||
return d->description;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the default value used for this option to \a defaultValue.
|
||||
|
||||
The default value is used if the user of the application does not specify
|
||||
the option on the command line.
|
||||
|
||||
If \a defaultValue is empty, the option has no default values.
|
||||
|
||||
\sa defaultValues() setDefaultValues()
|
||||
*/
|
||||
void QCommandLineOption::setDefaultValue(const QString &defaultValue)
|
||||
{
|
||||
d->defaultValues.clear();
|
||||
if (!defaultValue.isEmpty())
|
||||
d->defaultValues << defaultValue;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the list of default values used for this option to \a defaultValues.
|
||||
|
||||
The default values are used if the user of the application does not specify
|
||||
the option on the command line.
|
||||
|
||||
\sa defaultValues() setDefaultValue()
|
||||
*/
|
||||
void QCommandLineOption::setDefaultValues(const QStringList &defaultValues)
|
||||
{
|
||||
d->defaultValues = defaultValues;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the default values set for this option.
|
||||
|
||||
\sa setDefaultValues()
|
||||
*/
|
||||
QStringList QCommandLineOption::defaultValues() const
|
||||
{
|
||||
return d->defaultValues;
|
||||
}
|
||||
|
||||
|
||||
#endif //QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
|
@ -1,81 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QCOMMANDLINEOPTION_H
|
||||
#define QCOMMANDLINEOPTION_H
|
||||
|
||||
#include <QStringList>
|
||||
#include <QSharedData>
|
||||
#include <QtGlobal>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#include "../vmisc/diagnostic.h"
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
||||
|
||||
class QCommandLineOptionPrivate;
|
||||
|
||||
class QCommandLineOption
|
||||
{
|
||||
public:
|
||||
explicit QCommandLineOption(const QString &name, const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString());
|
||||
explicit QCommandLineOption(const QStringList &names, const QString &description = QString(),
|
||||
const QString &valueName = QString(),
|
||||
const QString &defaultValue = QString());
|
||||
QCommandLineOption(const QCommandLineOption &other);
|
||||
|
||||
~QCommandLineOption();
|
||||
|
||||
QCommandLineOption &operator=(const QCommandLineOption &other);
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
inline QCommandLineOption &operator=(QCommandLineOption &&other)
|
||||
{ qSwap(d, other.d); return *this; }
|
||||
#endif
|
||||
|
||||
inline void swap(QCommandLineOption &other)
|
||||
{ qSwap(d, other.d); }
|
||||
|
||||
QStringList names() const;
|
||||
|
||||
void setValueName(const QString &name);
|
||||
QString valueName() const;
|
||||
|
||||
void setDescription(const QString &description);
|
||||
QString description() const;
|
||||
|
||||
void setDefaultValue(const QString &defaultValue);
|
||||
void setDefaultValues(const QStringList &defaultValues);
|
||||
QStringList defaultValues() const;
|
||||
|
||||
private:
|
||||
QSharedDataPointer<QCommandLineOptionPrivate> d;
|
||||
};
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
Q_DECLARE_SHARED(QCommandLineOption)
|
||||
|
||||
#endif //QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#endif // QCOMMANDLINEOPTION_H
|
|
@ -1,897 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
|
||||
** Copyright (C) 2013 David Faure <faure@kde.org>
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcommandlineparser.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QHash>
|
||||
#include <QVector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#include "../vmisc/diagnostic.h"
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
QT_WARNING_DISABLE_GCC("-Wsuggest-attribute=noreturn")
|
||||
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
||||
|
||||
typedef QHash<QString, int> NameHash_t;
|
||||
|
||||
class QCommandLineParserPrivate
|
||||
{
|
||||
public:
|
||||
inline QCommandLineParserPrivate()
|
||||
: singleDashWordOptionMode(QCommandLineParser::ParseAsCompactedShortOptions),
|
||||
builtinVersionOption(false),
|
||||
builtinHelpOption(false),
|
||||
needsParsing(true)
|
||||
{ }
|
||||
|
||||
bool parse(const QStringList &args);
|
||||
void checkParsed(const char *method);
|
||||
QStringList aliases(const QString &name) const;
|
||||
QString helpText() const;
|
||||
bool registerFoundOption(const QString &optionName);
|
||||
bool parseOptionValue(const QString &optionName, const QString &argument,
|
||||
QStringList::const_iterator *argumentIterator,
|
||||
QStringList::const_iterator argsEnd);
|
||||
|
||||
//! Error text set when parse() returns false
|
||||
QString errorText;
|
||||
|
||||
//! The command line options used for parsing
|
||||
QList<QCommandLineOption> commandLineOptionList;
|
||||
|
||||
//! Hash mapping option names to their offsets in commandLineOptionList and optionArgumentList.
|
||||
NameHash_t nameHash;
|
||||
|
||||
//! Option values found (only for options with a value)
|
||||
QHash<int, QStringList> optionValuesHash;
|
||||
|
||||
//! Names of options found on the command line.
|
||||
QStringList optionNames;
|
||||
|
||||
//! Arguments which did not belong to any option.
|
||||
QStringList positionalArgumentList;
|
||||
|
||||
//! Names of options which were unknown.
|
||||
QStringList unknownOptionNames;
|
||||
|
||||
//! Application description
|
||||
QString description;
|
||||
|
||||
//! Documentation for positional arguments
|
||||
struct PositionalArgumentDefinition
|
||||
{
|
||||
QString name;
|
||||
QString description;
|
||||
QString syntax;
|
||||
};
|
||||
QVector<PositionalArgumentDefinition> positionalArgumentDefinitions;
|
||||
|
||||
//! The parsing mode for "-abc"
|
||||
QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode;
|
||||
|
||||
//! Whether addVersionOption was called
|
||||
bool builtinVersionOption;
|
||||
|
||||
//! Whether addHelpOption was called
|
||||
bool builtinHelpOption;
|
||||
|
||||
//! True if parse() needs to be called
|
||||
bool needsParsing;
|
||||
};
|
||||
|
||||
QStringList QCommandLineParserPrivate::aliases(const QString &optionName) const
|
||||
{
|
||||
const NameHash_t::const_iterator it = nameHash.find(optionName);
|
||||
if (it == nameHash.end()) {
|
||||
qWarning("QCommandLineParser: option not defined: \"%s\"", qPrintable(optionName));
|
||||
return QStringList();
|
||||
}
|
||||
return commandLineOptionList.at(*it).names();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.2
|
||||
\class QCommandLineParser
|
||||
\inmodule QtCore
|
||||
\ingroup tools
|
||||
|
||||
\brief The QCommandLineParser class provides a means for handling the
|
||||
command line options.
|
||||
|
||||
QCoreApplication provides the command-line arguments as a simple list of strings.
|
||||
QCommandLineParser provides the ability to define a set of options, parse the
|
||||
command-line arguments, and store which options have actually been used, as
|
||||
well as option values.
|
||||
|
||||
Any argument that isn't an option (i.e. doesn't start with a \c{-}) is stored
|
||||
as a "positional argument".
|
||||
|
||||
The parser handles short names, long names, more than one name for the same
|
||||
option, and option values.
|
||||
|
||||
Options on the command line are recognized as starting with a single or
|
||||
double \c{-} character(s).
|
||||
The option \c{-} (single dash alone) is a special case, often meaning standard
|
||||
input, and not treated as an option. The parser will treat everything after the
|
||||
option \c{--} (double dash) as positional arguments.
|
||||
|
||||
Short options are single letters. The option \c{v} would be specified by
|
||||
passing \c{-v} on the command line. In the default parsing mode, short options
|
||||
can be written in a compact form, for instance \c{-abc} is equivalent to \c{-a -b -c}.
|
||||
The parsing mode for can be set to ParseAsLongOptions, in which case \c{-abc}
|
||||
will be parsed as the long option \c{abc}.
|
||||
|
||||
Long options are more than one letter long and cannot be compacted together.
|
||||
The long option \c{verbose} would be passed as \c{--verbose} or \c{-verbose}.
|
||||
|
||||
Passing values to options can be done using the assignment operator: \c{-v=value}
|
||||
\c{--verbose=value}, or a space: \c{-v value} \c{--verbose value}, i.e. the next
|
||||
argument is used as value (even if it starts with a \c{-}).
|
||||
|
||||
The parser does not support optional values - if an option is set to
|
||||
require a value, one must be present. If such an option is placed last
|
||||
and has no value, the option will be treated as if it had not been
|
||||
specified.
|
||||
|
||||
The parser does not automatically support negating or disabling long options
|
||||
by using the format \c{--disable-option} or \c{--no-option}. However, it is
|
||||
possible to handle this case explicitly by making an option with \c{no-option}
|
||||
as one of its names, and handling the option explicitly.
|
||||
|
||||
Example:
|
||||
\snippet code/src_corelib_tools_qcommandlineparser_main.cpp 0
|
||||
|
||||
Known limitation: the parsing of Qt options inside QCoreApplication and subclasses
|
||||
happens before QCommandLineParser exists, so it can't take it into account. This
|
||||
means any option value that looks like a builtin Qt option, will be treated by
|
||||
QCoreApplication as a builtin Qt option. Example: \c{--profile -reverse} will
|
||||
lead to QGuiApplication seeing the -reverse option set, and removing it from
|
||||
QCoreApplication::arguments() before QCommandLineParser defines the \c{profile}
|
||||
option and parses the command line.
|
||||
|
||||
\sa QCommandLineOption, QCoreApplication
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a command line parser object.
|
||||
*/
|
||||
QCommandLineParser::QCommandLineParser()
|
||||
: d(new QCommandLineParserPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the command line parser object.
|
||||
*/
|
||||
QCommandLineParser::~QCommandLineParser()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
\enum QCommandLineParser::SingleDashWordOptionMode
|
||||
|
||||
This enum describes the way the parser interprets command-line
|
||||
options that use a single dash followed by multiple letters, as as \c{-abc}.
|
||||
|
||||
\value ParseAsCompactedShortOptions \c{-abc} is interpreted as \c{-a -b -c},
|
||||
i.e. as three short options that have been compacted on the command-line,
|
||||
if none of the options take a value. If \c{a} takes a value, then it
|
||||
is interpreted as \c{-a bc}, i.e. the short option \c{a} followed by the value \c{bc}.
|
||||
This is typically used in tools that behave like compilers, in order
|
||||
to handle options such as \c{-DDEFINE=VALUE} or \c{-I/include/path}.
|
||||
This is the default parsing mode. New applications are recommended to
|
||||
use this mode.
|
||||
|
||||
\value ParseAsLongOptions \c{-abc} is interpreted as \c{--abc},
|
||||
i.e. as the long option named \c{abc}. This is how Qt's own tools
|
||||
(uic, rcc...) have always been parsing arguments. This mode should be
|
||||
used for preserving compatibility in applications that were parsing
|
||||
arguments in such a way.
|
||||
|
||||
\sa setSingleDashWordOptionMode()
|
||||
*/
|
||||
|
||||
/*!
|
||||
Sets the parsing mode to \a singleDashWordOptionMode.
|
||||
This must be called before process() or parse().
|
||||
*/
|
||||
void QCommandLineParser::setSingleDashWordOptionMode(QCommandLineParser::SingleDashWordOptionMode singleDashWordOptionMode)
|
||||
{
|
||||
d->singleDashWordOptionMode = singleDashWordOptionMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds the option \a option to look for while parsing.
|
||||
|
||||
Returns \c true if adding the option was successful; otherwise returns \c false.
|
||||
|
||||
Adding the option fails if there is no name attached to the option, or
|
||||
the option has a name that clashes with an option name added before.
|
||||
*/
|
||||
bool QCommandLineParser::addOption(const QCommandLineOption &option)
|
||||
{
|
||||
QStringList optionNames = option.names();
|
||||
|
||||
if (!optionNames.isEmpty()) {
|
||||
foreach (const QString &name, optionNames) {
|
||||
if (d->nameHash.contains(name))
|
||||
return false;
|
||||
}
|
||||
|
||||
d->commandLineOptionList.append(option);
|
||||
|
||||
const int offset = d->commandLineOptionList.size() - 1;
|
||||
foreach (const QString &name, optionNames)
|
||||
d->nameHash.insert(name, offset);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds the \c{-v} / \c{--version} option, which displays the version string of the application.
|
||||
|
||||
This option is handled automatically by QCommandLineParser.
|
||||
|
||||
You can set the actual version string by using QCoreApplication::setApplicationVersion().
|
||||
|
||||
Returns the option instance, which can be used to call isSet().
|
||||
*/
|
||||
QCommandLineOption QCommandLineParser::addVersionOption()
|
||||
{
|
||||
d->builtinVersionOption = true;
|
||||
QCommandLineOption opt(QStringList() << QStringLiteral("v") << QStringLiteral("version"), tr("Displays version information."));
|
||||
addOption(opt);
|
||||
return opt;
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds the help option (\c{-h}, \c{--help} and \c{-?} on Windows)
|
||||
This option is handled automatically by QCommandLineParser.
|
||||
|
||||
Remember to use setApplicationDescription to set the application description,
|
||||
which will be displayed when this option is used.
|
||||
|
||||
Example:
|
||||
\snippet code/src_corelib_tools_qcommandlineparser_main.cpp 0
|
||||
|
||||
Returns the option instance, which can be used to call isSet().
|
||||
*/
|
||||
QCommandLineOption QCommandLineParser::addHelpOption()
|
||||
{
|
||||
d->builtinHelpOption = true;
|
||||
QCommandLineOption opt(QStringList()
|
||||
#ifdef Q_OS_WIN
|
||||
<< QStringLiteral("?")
|
||||
#endif
|
||||
<< QStringLiteral("h")
|
||||
<< QStringLiteral("help"), tr("Displays this help."));
|
||||
addOption(opt);
|
||||
return opt;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the application \a description shown by helpText().
|
||||
*/
|
||||
void QCommandLineParser::setApplicationDescription(const QString &description)
|
||||
{
|
||||
d->description = description;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the application description set in setApplicationDescription().
|
||||
*/
|
||||
QString QCommandLineParser::applicationDescription() const
|
||||
{
|
||||
return d->description;
|
||||
}
|
||||
|
||||
/*!
|
||||
Defines an additional argument to the application, for the benefit of the help text.
|
||||
|
||||
The argument \a name and \a description will appear under the \c{Arguments:} section
|
||||
of the help. If \a syntax is specified, it will be appended to the Usage line, otherwise
|
||||
the \a name will be appended.
|
||||
|
||||
Example:
|
||||
\snippet code/src_corelib_tools_qcommandlineparser.cpp 2
|
||||
|
||||
\sa addHelpOption(), helpText()
|
||||
*/
|
||||
void QCommandLineParser::addPositionalArgument(const QString &name, const QString &description, const QString &syntax)
|
||||
{
|
||||
QCommandLineParserPrivate::PositionalArgumentDefinition arg;
|
||||
arg.name = name;
|
||||
arg.description = description;
|
||||
arg.syntax = syntax.isEmpty() ? name : syntax;
|
||||
d->positionalArgumentDefinitions.append(arg);
|
||||
}
|
||||
|
||||
/*!
|
||||
Clears the definitions of additional arguments from the help text.
|
||||
|
||||
This is only needed for the special case of tools which support multiple commands
|
||||
with different options. Once the actual command has been identified, the options
|
||||
for this command can be defined, and the help text for the command can be adjusted
|
||||
accordingly.
|
||||
|
||||
Example:
|
||||
\snippet code/src_corelib_tools_qcommandlineparser.cpp 3
|
||||
*/
|
||||
void QCommandLineParser::clearPositionalArguments()
|
||||
{
|
||||
d->positionalArgumentDefinitions.clear();
|
||||
}
|
||||
|
||||
/*!
|
||||
Parses the command line \a arguments.
|
||||
|
||||
Most programs don't need to call this, a simple call to process() is enough.
|
||||
|
||||
parse() is more low-level, and only does the parsing. The application will have to
|
||||
take care of the error handling, using errorText() if parse() returns \c false.
|
||||
This can be useful for instance to show a graphical error message in graphical programs.
|
||||
|
||||
Calling parse() instead of process() can also be useful in order to ignore unknown
|
||||
options temporarily, because more option definitions will be provided later on
|
||||
(depending on one of the arguments), before calling process().
|
||||
|
||||
Don't forget that \a arguments must start with the name of the executable (ignored, though).
|
||||
|
||||
Returns \c false in case of a parse error (unknown option or missing value); returns \c true otherwise.
|
||||
|
||||
\sa process()
|
||||
*/
|
||||
bool QCommandLineParser::parse(const QStringList &arguments)
|
||||
{
|
||||
return d->parse(arguments);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a translated error text for the user.
|
||||
This should only be called when parse() returns \c false.
|
||||
*/
|
||||
QString QCommandLineParser::errorText() const
|
||||
{
|
||||
if (!d->errorText.isEmpty())
|
||||
return d->errorText;
|
||||
if (d->unknownOptionNames.count() == 1)
|
||||
return tr("Unknown option '%1'.").arg(d->unknownOptionNames.first());
|
||||
if (d->unknownOptionNames.count() > 1)
|
||||
return tr("Unknown options: %1.").arg(d->unknownOptionNames.join(QStringLiteral(", ")));
|
||||
return QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
Processes the command line \a arguments.
|
||||
|
||||
In addition to parsing the options (like parse()), this function also handles the builtin
|
||||
options and handles errors.
|
||||
|
||||
The builtin options are \c{--version} if addVersionOption was called and \c{--help} if addHelpOption was called.
|
||||
|
||||
When invoking one of these options, or when an error happens (for instance an unknown option was
|
||||
passed), the current process will then stop, using the exit() function.
|
||||
|
||||
\sa QCoreApplication::arguments(), parse()
|
||||
*/
|
||||
void QCommandLineParser::process(const QStringList &arguments)
|
||||
{
|
||||
if (!d->parse(arguments)) {
|
||||
fprintf(stderr, "%s\n", qPrintable(errorText()));
|
||||
::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (d->builtinVersionOption && isSet(QStringLiteral("version"))) {
|
||||
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion()));
|
||||
::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (d->builtinHelpOption && isSet(QStringLiteral("help")))
|
||||
showHelp(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
|
||||
The command line is obtained from the QCoreApplication instance \a app.
|
||||
*/
|
||||
void QCommandLineParser::process(const QCoreApplication &app)
|
||||
{
|
||||
// QCoreApplication::arguments() is static, but the app instance must exist so we require it as parameter
|
||||
Q_UNUSED(app)
|
||||
process(QCoreApplication::arguments());
|
||||
}
|
||||
|
||||
void QCommandLineParserPrivate::checkParsed(const char *method)
|
||||
{
|
||||
if (needsParsing)
|
||||
qWarning("QCommandLineParser: call process() or parse() before %s", method);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
Looks up the option \a optionName (found on the command line) and register it as found.
|
||||
Returns \c true on success.
|
||||
*/
|
||||
bool QCommandLineParserPrivate::registerFoundOption(const QString &optionName)
|
||||
{
|
||||
if (nameHash.contains(optionName)) {
|
||||
optionNames.append(optionName);
|
||||
return true;
|
||||
} else {
|
||||
unknownOptionNames.append(optionName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\brief Parse the value for a given option, if it was defined to expect one.
|
||||
|
||||
The value is taken from the next argument, or after the equal sign in \a argument.
|
||||
|
||||
\param optionName the short option name
|
||||
\param argument the argument from the command line currently parsed. Only used for -k=value parsing.
|
||||
\param argumentIterator iterator to the currently parsed argument. Incremented if the next argument contains the value.
|
||||
\param argsEnd args.end(), to check if ++argumentIterator goes out of bounds
|
||||
Returns \c true on success.
|
||||
*/
|
||||
bool QCommandLineParserPrivate::parseOptionValue(const QString &optionName, const QString &argument,
|
||||
QStringList::const_iterator *argumentIterator, QStringList::const_iterator argsEnd)
|
||||
{
|
||||
const QLatin1Char assignChar('=');
|
||||
const NameHash_t::const_iterator nameHashIt = nameHash.constFind(optionName);
|
||||
if (nameHashIt != nameHash.constEnd()) {
|
||||
const int assignPos = argument.indexOf(assignChar);
|
||||
const NameHash_t::mapped_type optionOffset = *nameHashIt;
|
||||
const bool withValue = !commandLineOptionList.at(optionOffset).valueName().isEmpty();
|
||||
if (withValue) {
|
||||
if (assignPos == -1) {
|
||||
++(*argumentIterator);
|
||||
if (*argumentIterator == argsEnd) {
|
||||
errorText = QCommandLineParser::tr("Missing value after '%1'.").arg(argument);
|
||||
return false;
|
||||
}
|
||||
optionValuesHash[optionOffset].append(*(*argumentIterator));
|
||||
} else {
|
||||
optionValuesHash[optionOffset].append(argument.mid(assignPos + 1));
|
||||
}
|
||||
} else {
|
||||
if (assignPos != -1) {
|
||||
errorText = QCommandLineParser::tr("Unexpected value after '%1'.").arg(argument.left(assignPos));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
Parse the list of arguments \a args, and fills in
|
||||
optionNames, optionValuesHash, unknownOptionNames, positionalArguments, and errorText.
|
||||
|
||||
Any results from a previous parse operation are removed.
|
||||
|
||||
The parser will not look for further options once it encounters the option
|
||||
\c{--}; this does not include when \c{--} follows an option that requires a value.
|
||||
*/
|
||||
bool QCommandLineParserPrivate::parse(const QStringList &args)
|
||||
{
|
||||
needsParsing = false;
|
||||
bool error = false;
|
||||
|
||||
const QString doubleDashString(QStringLiteral("--"));
|
||||
const QLatin1Char dashChar('-');
|
||||
const QLatin1Char assignChar('=');
|
||||
|
||||
bool doubleDashFound = false;
|
||||
errorText.clear();
|
||||
positionalArgumentList.clear();
|
||||
optionNames.clear();
|
||||
unknownOptionNames.clear();
|
||||
optionValuesHash.clear();
|
||||
|
||||
if (args.isEmpty()) {
|
||||
qWarning("QCommandLineParser: argument list cannot be empty, it should contain at least the executable name");
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList::const_iterator argumentIterator = args.begin();
|
||||
++argumentIterator; // skip executable name
|
||||
|
||||
for (; argumentIterator != args.end() ; ++argumentIterator) {
|
||||
QString argument = *argumentIterator;
|
||||
|
||||
if (doubleDashFound) {
|
||||
positionalArgumentList.append(argument);
|
||||
} else if (argument.startsWith(doubleDashString)) {
|
||||
if (argument.length() > 2) {
|
||||
QString optionName = argument.mid(2).section(assignChar, 0, 0);
|
||||
if (registerFoundOption(optionName)) {
|
||||
if (!parseOptionValue(optionName, argument, &argumentIterator, args.end()))
|
||||
error = true;
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
} else {
|
||||
doubleDashFound = true;
|
||||
}
|
||||
} else if (argument.startsWith(dashChar)) {
|
||||
if (argument.size() == 1) { // single dash ("stdin")
|
||||
positionalArgumentList.append(argument);
|
||||
continue;
|
||||
}
|
||||
switch (singleDashWordOptionMode) {
|
||||
case QCommandLineParser::ParseAsCompactedShortOptions:
|
||||
{
|
||||
QString optionName;
|
||||
bool valueFound = false;
|
||||
for (int pos = 1 ; pos < argument.size(); ++pos) {
|
||||
optionName = argument.mid(pos, 1);
|
||||
if (!registerFoundOption(optionName)) {
|
||||
error = true;
|
||||
} else {
|
||||
const NameHash_t::const_iterator nameHashIt = nameHash.constFind(optionName);
|
||||
Q_ASSERT(nameHashIt != nameHash.constEnd()); // checked by registerFoundOption
|
||||
const NameHash_t::mapped_type optionOffset = *nameHashIt;
|
||||
const bool withValue = !commandLineOptionList.at(optionOffset).valueName().isEmpty();
|
||||
if (withValue) {
|
||||
if (pos + 1 < argument.size()) {
|
||||
if (argument.at(pos + 1) == assignChar)
|
||||
++pos;
|
||||
optionValuesHash[optionOffset].append(argument.mid(pos + 1));
|
||||
valueFound = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (pos + 1 < argument.size() && argument.at(pos + 1) == assignChar)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valueFound && !parseOptionValue(optionName, argument, &argumentIterator, args.end()))
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
case QCommandLineParser::ParseAsLongOptions:
|
||||
{
|
||||
const QString optionName = argument.mid(1).section(assignChar, 0, 0);
|
||||
if (registerFoundOption(optionName)) {
|
||||
if (!parseOptionValue(optionName, argument, &argumentIterator, args.end()))
|
||||
error = true;
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
positionalArgumentList.append(argument);
|
||||
}
|
||||
if (argumentIterator == args.end())
|
||||
break;
|
||||
}
|
||||
return !error;
|
||||
}
|
||||
|
||||
/*!
|
||||
Checks whether the option \a name was passed to the application.
|
||||
|
||||
Returns \c true if the option \a name was set, false otherwise.
|
||||
|
||||
The name provided can be any long or short name of any option that was
|
||||
added with \c addOption(). All the options names are treated as being
|
||||
equivalent. If the name is not recognized or that option was not present,
|
||||
false is returned.
|
||||
|
||||
Example:
|
||||
\snippet code/src_corelib_tools_qcommandlineparser.cpp 0
|
||||
*/
|
||||
|
||||
bool QCommandLineParser::isSet(const QString &name) const
|
||||
{
|
||||
d->checkParsed("isSet");
|
||||
if (d->optionNames.contains(name))
|
||||
return true;
|
||||
const QStringList aliases = d->aliases(name);
|
||||
foreach (const QString &optionName, d->optionNames) {
|
||||
if (aliases.contains(optionName))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the option value found for the given option name \a optionName, or
|
||||
an empty string if not found.
|
||||
|
||||
The name provided can be any long or short name of any option that was
|
||||
added with \c addOption(). All the option names are treated as being
|
||||
equivalent. If the name is not recognized or that option was not present, an
|
||||
empty string is returned.
|
||||
|
||||
For options found by the parser, the last value found for
|
||||
that option is returned. If the option wasn't specified on the command line,
|
||||
the default value is returned.
|
||||
|
||||
An empty string is returned if the option does not take a value.
|
||||
|
||||
\sa values(), QCommandLineOption::setDefaultValue(), QCommandLineOption::setDefaultValues()
|
||||
*/
|
||||
|
||||
QString QCommandLineParser::value(const QString &optionName) const
|
||||
{
|
||||
d->checkParsed("value");
|
||||
const QStringList valueList = values(optionName);
|
||||
|
||||
if (!valueList.isEmpty())
|
||||
return valueList.last();
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of option values found for the given option name \a
|
||||
optionName, or an empty list if not found.
|
||||
|
||||
The name provided can be any long or short name of any option that was
|
||||
added with \c addOption(). All the options names are treated as being
|
||||
equivalent. If the name is not recognized or that option was not present, an
|
||||
empty list is returned.
|
||||
|
||||
For options found by the parser, the list will contain an entry for
|
||||
each time the option was encountered by the parser. If the option wasn't
|
||||
specified on the command line, the default values are returned.
|
||||
|
||||
An empty list is returned if the option does not take a value.
|
||||
|
||||
\sa value(), QCommandLineOption::setDefaultValue(), QCommandLineOption::setDefaultValues()
|
||||
*/
|
||||
|
||||
QStringList QCommandLineParser::values(const QString &optionName) const
|
||||
{
|
||||
d->checkParsed("values");
|
||||
const NameHash_t::const_iterator it = d->nameHash.find(optionName);
|
||||
if (it != d->nameHash.end()) {
|
||||
const int optionOffset = *it;
|
||||
QStringList values = d->optionValuesHash.value(optionOffset);
|
||||
if (values.isEmpty())
|
||||
values = d->commandLineOptionList.at(optionOffset).defaultValues();
|
||||
return values;
|
||||
}
|
||||
|
||||
qWarning("QCommandLineParser: option not defined: \"%s\"", qPrintable(optionName));
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Checks whether the \a option was passed to the application.
|
||||
|
||||
Returns \c true if the \a option was set, false otherwise.
|
||||
|
||||
This is the recommended way to check for options with no values.
|
||||
|
||||
Example:
|
||||
\snippet code/src_corelib_tools_qcommandlineparser.cpp 1
|
||||
*/
|
||||
bool QCommandLineParser::isSet(const QCommandLineOption &option) const
|
||||
{
|
||||
return isSet(option.names().first());
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Returns the option value found for the given \a option, or
|
||||
an empty string if not found.
|
||||
|
||||
For options found by the parser, the last value found for
|
||||
that option is returned. If the option wasn't specified on the command line,
|
||||
the default value is returned.
|
||||
|
||||
An empty string is returned if the option does not take a value.
|
||||
|
||||
\sa values(), QCommandLineOption::setDefaultValue(), QCommandLineOption::setDefaultValues()
|
||||
*/
|
||||
QString QCommandLineParser::value(const QCommandLineOption &option) const
|
||||
{
|
||||
return value(option.names().first());
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Returns a list of option values found for the given \a option,
|
||||
or an empty list if not found.
|
||||
|
||||
For options found by the parser, the list will contain an entry for
|
||||
each time the option was encountered by the parser. If the option wasn't
|
||||
specified on the command line, the default values are returned.
|
||||
|
||||
An empty list is returned if the option does not take a value.
|
||||
|
||||
\sa value(), QCommandLineOption::setDefaultValue(), QCommandLineOption::setDefaultValues()
|
||||
*/
|
||||
QStringList QCommandLineParser::values(const QCommandLineOption &option) const
|
||||
{
|
||||
return values(option.names().first());
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of positional arguments.
|
||||
|
||||
These are all of the arguments that were not recognized as part of an
|
||||
option.
|
||||
*/
|
||||
|
||||
QStringList QCommandLineParser::positionalArguments() const
|
||||
{
|
||||
d->checkParsed("positionalArguments");
|
||||
return d->positionalArgumentList;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of option names that were found.
|
||||
|
||||
This returns a list of all the recognized option names found by the
|
||||
parser, in the order in which they were found. For any long options
|
||||
that were in the form {--option=value}, the value part will have been
|
||||
dropped.
|
||||
|
||||
The names in this list do not include the preceding dash characters.
|
||||
Names may appear more than once in this list if they were encountered
|
||||
more than once by the parser.
|
||||
|
||||
Any entry in the list can be used with \c value() or with
|
||||
\c values() to get any relevant option values.
|
||||
*/
|
||||
|
||||
QStringList QCommandLineParser::optionNames() const
|
||||
{
|
||||
d->checkParsed("optionNames");
|
||||
return d->optionNames;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of unknown option names.
|
||||
|
||||
This list will include both long an short name options that were not
|
||||
recognized. For any long options that were in the form {--option=value},
|
||||
the value part will have been dropped and only the long name is added.
|
||||
|
||||
The names in this list do not include the preceding dash characters.
|
||||
Names may appear more than once in this list if they were encountered
|
||||
more than once by the parser.
|
||||
|
||||
\sa optionNames()
|
||||
*/
|
||||
|
||||
QStringList QCommandLineParser::unknownOptionNames() const
|
||||
{
|
||||
d->checkParsed("unknownOptionNames");
|
||||
return d->unknownOptionNames;
|
||||
}
|
||||
|
||||
/*!
|
||||
Displays the help information, and exits the application.
|
||||
This is automatically triggered by the --help option, but can also
|
||||
be used to display the help when the user is not invoking the
|
||||
application correctly.
|
||||
The exit code is set to \a exitCode. It should be set to 0 if the
|
||||
user requested to see the help, and to any other value in case of
|
||||
an error.
|
||||
|
||||
\sa helpText()
|
||||
*/
|
||||
Q_NORETURN void QCommandLineParser::showHelp(int exitCode)
|
||||
{
|
||||
fprintf(stdout, "%s", qPrintable(d->helpText()));
|
||||
::exit(exitCode);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a string containing the complete help information.
|
||||
|
||||
\sa showHelp()
|
||||
*/
|
||||
QString QCommandLineParser::helpText() const
|
||||
{
|
||||
return d->helpText();
|
||||
}
|
||||
|
||||
static QString wrapText(const QString &names, int longestOptionNameString, const QString &description)
|
||||
{
|
||||
const QLatin1Char nl('\n');
|
||||
QString text = QStringLiteral(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' ');
|
||||
const int leftColumnWidth = text.length();
|
||||
const int rightColumnWidth = 79 - leftColumnWidth;
|
||||
text += description.left(rightColumnWidth) + nl;
|
||||
for (int n = rightColumnWidth; n < description.length(); n += rightColumnWidth)
|
||||
text += QStringLiteral(" ").repeated(leftColumnWidth) + description.mid(n, rightColumnWidth) + nl;
|
||||
return text;
|
||||
}
|
||||
|
||||
QString QCommandLineParserPrivate::helpText() const
|
||||
{
|
||||
const QLatin1Char nl('\n');
|
||||
QString text;
|
||||
const QString exeName = QCoreApplication::instance()->arguments().first();
|
||||
QString usage = exeName;
|
||||
if (!commandLineOptionList.isEmpty()) {
|
||||
usage += QLatin1Char(' ');
|
||||
usage += QCommandLineParser::tr("[options]");
|
||||
}
|
||||
foreach (const PositionalArgumentDefinition &arg, positionalArgumentDefinitions) {
|
||||
usage += QLatin1Char(' ');
|
||||
usage += arg.syntax;
|
||||
}
|
||||
text += QCommandLineParser::tr("Usage: %1").arg(usage) + nl;
|
||||
if (!description.isEmpty())
|
||||
text += description + nl;
|
||||
text += nl;
|
||||
if (!commandLineOptionList.isEmpty())
|
||||
text += QCommandLineParser::tr("Options:") + nl;
|
||||
QStringList optionNameList;
|
||||
int longestOptionNameString = 0;
|
||||
foreach (const QCommandLineOption &option, commandLineOptionList) {
|
||||
QStringList optionNames;
|
||||
foreach (const QString &optionName, option.names()) {
|
||||
if (optionName.length() == 1)
|
||||
optionNames.append(QLatin1Char('-') + optionName);
|
||||
else
|
||||
optionNames.append(QStringLiteral("--") + optionName);
|
||||
}
|
||||
QString optionNamesString = optionNames.join(QStringLiteral(", "));
|
||||
if (!option.valueName().isEmpty())
|
||||
optionNamesString += QStringLiteral(" <") + option.valueName() + QLatin1Char('>');
|
||||
optionNameList.append(optionNamesString);
|
||||
longestOptionNameString = qMax(longestOptionNameString, optionNamesString.length());
|
||||
}
|
||||
++longestOptionNameString;
|
||||
for (int i = 0; i < commandLineOptionList.count(); ++i) {
|
||||
const QCommandLineOption &option = commandLineOptionList.at(i);
|
||||
text += wrapText(optionNameList.at(i), longestOptionNameString, option.description());
|
||||
}
|
||||
if (!positionalArgumentDefinitions.isEmpty()) {
|
||||
if (!commandLineOptionList.isEmpty())
|
||||
text += nl;
|
||||
text += QCommandLineParser::tr("Arguments:") + nl;
|
||||
foreach (const PositionalArgumentDefinition &arg, positionalArgumentDefinitions) {
|
||||
text += wrapText(arg.name, longestOptionNameString, arg.description);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
#endif //QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
|
@ -1,91 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QCOMMANDLINEPARSER_H
|
||||
#define QCOMMANDLINEPARSER_H
|
||||
|
||||
#include <QStringList>
|
||||
#include <QCoreApplication>
|
||||
#include "qcommandlineoption.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
class QCommandLineParserPrivate;
|
||||
class QCoreApplication;
|
||||
|
||||
#include "../vmisc/diagnostic.h"
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
||||
|
||||
class QCommandLineParser
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QCommandLineParser)
|
||||
public:
|
||||
QCommandLineParser();
|
||||
~QCommandLineParser();
|
||||
|
||||
enum SingleDashWordOptionMode {
|
||||
ParseAsCompactedShortOptions,
|
||||
ParseAsLongOptions
|
||||
};
|
||||
void setSingleDashWordOptionMode(SingleDashWordOptionMode parsingMode);
|
||||
|
||||
bool addOption(const QCommandLineOption &commandLineOption);
|
||||
|
||||
QCommandLineOption addVersionOption();
|
||||
QCommandLineOption addHelpOption();
|
||||
void setApplicationDescription(const QString &description);
|
||||
QString applicationDescription() const;
|
||||
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax = QString());
|
||||
void clearPositionalArguments();
|
||||
|
||||
void process(const QStringList &arguments);
|
||||
void process(const QCoreApplication &app);
|
||||
|
||||
bool parse(const QStringList &arguments);
|
||||
QString errorText() const;
|
||||
|
||||
bool isSet(const QString &name) const;
|
||||
QString value(const QString &name) const;
|
||||
QStringList values(const QString &name) const;
|
||||
|
||||
bool isSet(const QCommandLineOption &option) const;
|
||||
QString value(const QCommandLineOption &option) const;
|
||||
QStringList values(const QCommandLineOption &option) const;
|
||||
|
||||
QStringList positionalArguments() const;
|
||||
QStringList optionNames() const;
|
||||
QStringList unknownOptionNames() const;
|
||||
|
||||
Q_NORETURN void showHelp(int exitCode = 0);
|
||||
QString helpText() const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QCommandLineParser)
|
||||
|
||||
QCommandLineParserPrivate * const d;
|
||||
};
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
#endif //QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#endif // QCOMMANDLINEPARSER_H
|
|
@ -33,9 +33,7 @@
|
|||
|
||||
#include "qmarginsf.h"
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
#include <QDebugStateSaver>
|
||||
#endif
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||
#include <QDataStream>
|
||||
|
@ -368,9 +366,7 @@ QDataStream &operator>>(QDataStream &s, QMarginsF &m)
|
|||
#ifndef QT_NO_DEBUG_STREAM
|
||||
QDebug operator<<(QDebug dbg, const QMarginsF &m)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
QDebugStateSaver saver(dbg);
|
||||
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
dbg.nospace();
|
||||
dbg << "QMarginsF" << '(';
|
||||
dbg << m.left() << ", " << m.top() << ", " << m.right() << ", " << m.bottom();
|
||||
|
|
|
@ -48,22 +48,6 @@ template <class T> class QSharedPointer;
|
|||
#include <ciso646>
|
||||
#endif /* Q_CC_MSVC */
|
||||
|
||||
//There is no automatic disconnection when the 'receiver' is destroyed because it's a functor with no QObject. However,
|
||||
//since 5.2 there is an overload which adds a "context object". When that object is destroyed, the connection is broken
|
||||
//(the context is also used for the thread affinity: the lambda will be called in the thread of the event loop of the
|
||||
// object used as context).
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
#define RECEIVER(obj) (obj),
|
||||
#else
|
||||
#define RECEIVER(obj)
|
||||
#endif
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
#define CURRENT_DATA(box) box->itemData(box->currentIndex())
|
||||
#else
|
||||
#define CURRENT_DATA(box) box->currentData()
|
||||
#endif
|
||||
|
||||
class QComboBox;
|
||||
class QMarginsF;
|
||||
class VTranslateMeasurements;
|
||||
|
|
|
@ -81,7 +81,7 @@ bool DialogExportToCSV::WithHeader() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int DialogExportToCSV::SelectedMib() const
|
||||
{
|
||||
return CURRENT_DATA(ui->comboBoxCodec).toInt();
|
||||
return ui->comboBoxCodec->currentData().toInt();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -24,61 +24,6 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
//
|
||||
// Qt < 5.2 didn't feature categorized logging:
|
||||
// Just enable qCWarning, qCCritical, but disable qCDebug
|
||||
//
|
||||
class QLoggingCategory
|
||||
{
|
||||
Q_DISABLE_COPY(QLoggingCategory)
|
||||
public:
|
||||
explicit QLoggingCategory(const char *category) : name(category) {}
|
||||
~QLoggingCategory() {}
|
||||
|
||||
bool isDebugEnabled() const { return false; }
|
||||
bool isWarningEnabled() const { return true; }
|
||||
bool isCriticalEnabled() const { return true; }
|
||||
|
||||
const char *categoryName() const { return name; }
|
||||
|
||||
QLoggingCategory &operator()() { return *this; }
|
||||
|
||||
private:
|
||||
const char *name;
|
||||
};
|
||||
|
||||
#define Q_DECLARE_LOGGING_CATEGORY(name) \
|
||||
extern QLoggingCategory &name();
|
||||
|
||||
// relies on QLoggingCategory(QString) being thread safe!
|
||||
#define Q_LOGGING_CATEGORY(name, string) \
|
||||
QLoggingCategory &name() \
|
||||
{ \
|
||||
static QLoggingCategory category(string); \
|
||||
return category; \
|
||||
}
|
||||
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
|
||||
|
||||
//
|
||||
// Qt 5.0, 5.1 do have already support for categories in QMessageLogger
|
||||
//
|
||||
|
||||
#define qCDebug(category, ...) \
|
||||
for (bool q_category_enabled = category().isDebugEnabled(); q_category_enabled; q_category_enabled = false) \
|
||||
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).debug(__VA_ARGS__)
|
||||
#define qCWarning(category, ...) \
|
||||
for (bool q_category_enabled = category().isWarningEnabled(); q_category_enabled; q_category_enabled = false) \
|
||||
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).warning(__VA_ARGS__)
|
||||
#define qCCritical(category, ...) \
|
||||
for (bool q_category_enabled = category().isCriticalEnabled(); q_category_enabled; q_category_enabled = false) \
|
||||
QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, category().categoryName()).critical(__VA_ARGS__)
|
||||
# endif // QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
|
||||
|
||||
#else // QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||
|
@ -101,6 +46,4 @@ private:
|
|||
|
||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||
|
||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#endif // LOGGING_H
|
||||
|
|
|
@ -59,25 +59,15 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
|
|||
doc(nullptr),
|
||||
openingPattern(false)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
QString rules;
|
||||
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
// Qt < 5.2 didn't feature categorized logging
|
||||
// Do nothing
|
||||
#else
|
||||
|
||||
// In Qt 5.2 need manualy enable debug information for categories. This work
|
||||
// because Qt doesn't provide debug information for categories itself. And in this
|
||||
// case will show our messages. Another situation with Qt 5.3 that has many debug
|
||||
// messages itself. We don't need this information and can turn on later if need.
|
||||
// But here Qt already show our debug messages without enabling.
|
||||
rules += QLatin1String("*.debug=true\n");
|
||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 1)
|
||||
|
@ -91,12 +81,10 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
|
|||
#endif //defined(V_NO_ASSERT)
|
||||
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 4, 1)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
if (not rules.isEmpty())
|
||||
{
|
||||
QLoggingCategory::setFilterRules(rules);
|
||||
}
|
||||
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||
// Enable support for HiDPI bitmap resources
|
||||
|
@ -115,7 +103,7 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
|
|||
setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
|
||||
connect(this, &QApplication::aboutToQuit, RECEIVER(this)[this]()
|
||||
connect(this, &QApplication::aboutToQuit, this, [this]()
|
||||
{
|
||||
// If try to use the method QApplication::exit program can't sync settings and show warning about QApplication
|
||||
// instance. Solution is to call sync() before quit.
|
||||
|
|
|
@ -36,17 +36,11 @@
|
|||
|
||||
#include "../vmisc/diagnostic.h"
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
#include <QFileInfo>
|
||||
#include <QLockFile>
|
||||
#if defined(Q_OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#define PEDANT_COMPILER ,lock(nullptr)
|
||||
#else
|
||||
#define PEDANT_COMPILER
|
||||
#pragma message("To have lock-file support you must use Qt 5.1+. Expect collissions when run 2 copies of the program.")
|
||||
#endif
|
||||
|
||||
/*@brief
|
||||
* This class creates Guarded object if and only if lock file taken. It keeps shared_ptr to object and lock-file.
|
||||
|
@ -78,10 +72,7 @@ private:
|
|||
std::shared_ptr<Guarded> holder;
|
||||
int lockError;
|
||||
QString lockFile;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
std::shared_ptr<QLockFile> lock;
|
||||
#endif
|
||||
|
||||
// cppcheck-suppress functionStatic
|
||||
bool TryLock(const QString &lockName, int stale, int timeout);
|
||||
|
@ -90,7 +81,7 @@ private:
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename Guarded>
|
||||
VLockGuard<Guarded>::VLockGuard(const QString &lockName, int stale, int timeout)
|
||||
: holder(nullptr), lockError(0), lockFile() PEDANT_COMPILER
|
||||
: holder(nullptr), lockError(0), lockFile(), lock(nullptr)
|
||||
{
|
||||
if (TryLock(lockName, stale, timeout))
|
||||
{
|
||||
|
@ -103,7 +94,7 @@ VLockGuard<Guarded>::VLockGuard(const QString &lockName, int stale, int timeout)
|
|||
//object
|
||||
template <typename Guarded> template <typename Alloc>
|
||||
VLockGuard<Guarded>::VLockGuard(const QString& lockName, Alloc a, int stale, int timeout)
|
||||
: holder(nullptr), lockError(0), lockFile() PEDANT_COMPILER
|
||||
: holder(nullptr), lockError(0), lockFile(), lock(nullptr)
|
||||
{
|
||||
if (TryLock(lockName, stale, timeout))
|
||||
{
|
||||
|
@ -114,7 +105,7 @@ VLockGuard<Guarded>::VLockGuard(const QString& lockName, Alloc a, int stale, int
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename Guarded> template <typename Alloc, typename Delete>
|
||||
VLockGuard<Guarded>::VLockGuard(const QString& lockName, Alloc a, Delete d, int stale, int timeout)
|
||||
: holder(nullptr), lockError(0), lockFile() PEDANT_COMPILER
|
||||
: holder(nullptr), lockError(0), lockFile(), lock(nullptr)
|
||||
{
|
||||
if (TryLock(lockName, stale, timeout))
|
||||
{
|
||||
|
@ -156,8 +147,6 @@ bool VLockGuard<Guarded>::TryLock(const QString &lockName, int stale, int timeou
|
|||
{
|
||||
bool res = true;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
|
||||
lockFile = lockName + QLatin1String(".lock");
|
||||
#if defined(Q_OS_UNIX)
|
||||
QFileInfo info(lockFile);
|
||||
|
@ -188,16 +177,9 @@ bool VLockGuard<Guarded>::TryLock(const QString &lockName, int stale, int timeou
|
|||
SetFileAttributesW(lockFile.toStdWString().c_str(), FILE_ATTRIBUTE_HIDDEN);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(lockName)
|
||||
Q_UNUSED(stale)
|
||||
Q_UNUSED(timeout)
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
#undef PEDANT_COMPILER
|
||||
|
||||
//use pointer and function below to persistent things like class-member, because lock is taken by constructor
|
||||
//helper functions allow to write shorter creating and setting new lock-pointer
|
||||
|
||||
|
|
|
@ -21,32 +21,7 @@
|
|||
#ifndef VMATH_H
|
||||
#define VMATH_H
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
#include <QtMath>
|
||||
#else
|
||||
#include "qmath.h"
|
||||
|
||||
Q_DECL_CONSTEXPR inline float qDegreesToRadians(float degrees)
|
||||
{
|
||||
return degrees * float(M_PI/180);
|
||||
}
|
||||
|
||||
Q_DECL_CONSTEXPR inline double qDegreesToRadians(double degrees)
|
||||
{
|
||||
return degrees * (M_PI / 180);
|
||||
}
|
||||
|
||||
Q_DECL_CONSTEXPR inline float qRadiansToDegrees(float radians)
|
||||
{
|
||||
return radians * float(180/M_PI);
|
||||
}
|
||||
|
||||
Q_DECL_CONSTEXPR inline double qRadiansToDegrees(double radians)
|
||||
{
|
||||
return radians * (180 / M_PI);
|
||||
}
|
||||
|
||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
|
||||
#ifndef M_2PI
|
||||
#define M_2PI (6.28318530717958647692) /* 2*pi */
|
||||
|
|
|
@ -42,15 +42,6 @@ HEADERS += \
|
|||
# 5.2.0, 5.2.1
|
||||
# 5.3.0, 5.3.1, 5.3.2
|
||||
|
||||
contains(QT_VERSION, ^5\\.[0-1]\\.[0-2]$) { # Since Qt 5.2.0
|
||||
HEADERS += \
|
||||
$$PWD/backport/qcommandlineoption.h \
|
||||
$$PWD/backport/qcommandlineparser.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/backport/qcommandlineoption.cpp \
|
||||
$$PWD/backport/qcommandlineparser.cpp
|
||||
}
|
||||
|
||||
contains(QT_VERSION, ^5\\.[0-2]\\.[0-2]$) { # Since Qt 5.3.0
|
||||
HEADERS += \
|
||||
|
|
|
@ -156,13 +156,11 @@ int VObjPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
|
|||
case QPaintDevice::PdmPhysicalDpiX:
|
||||
case QPaintDevice::PdmPhysicalDpiY:
|
||||
return engine->getResolution();
|
||||
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 2)
|
||||
case QPaintDevice::PdmDevicePixelRatio:
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||
case QPaintDevice::PdmDevicePixelRatioScaled:
|
||||
#endif
|
||||
return 1;
|
||||
#endif
|
||||
default:
|
||||
qWarning("VObjPaintDevice::metric(), unhandled metric %d\n", metric);
|
||||
break;
|
||||
|
|
|
@ -57,9 +57,7 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV
|
|||
tmpEditor->setLocale(parent->locale());
|
||||
tmpEditor->setReadOnly(readOnly);
|
||||
tmpEditor->installEventFilter(this);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
tmpEditor->setClearButtonEnabled(clearButton);
|
||||
#endif
|
||||
tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
tmpEditor->setText(d_ptr->VariantValue.toString());
|
||||
|
||||
|
|
|
@ -82,10 +82,8 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
|
|||
InitFormulaUI(ui);
|
||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||
ui->plainTextEditFormula->installEventFilter(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->filterFormulaInputs->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
connect(ui->filterFormulaInputs, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FilterVariablesEdited);
|
||||
|
||||
InitOkCancel(ui);
|
||||
|
@ -412,31 +410,31 @@ void DialogEditWrongFormula::InitVariables()
|
|||
auto ClearFilterFormulaInputs = [this] () { ui->filterFormulaInputs->clear(); };
|
||||
|
||||
connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, &DialogEditWrongFormula::Measurements);
|
||||
connect(ui->radioButtonStandardTable, &QRadioButton::clicked, RECEIVER(this)ClearFilterFormulaInputs);
|
||||
connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
|
||||
|
||||
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogEditWrongFormula::Increments);
|
||||
connect(ui->radioButtonIncrements, &QRadioButton::clicked, RECEIVER(this)ClearFilterFormulaInputs);
|
||||
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
|
||||
|
||||
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogEditWrongFormula::LengthLines);
|
||||
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, RECEIVER(this)ClearFilterFormulaInputs);
|
||||
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
|
||||
|
||||
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogEditWrongFormula::LengthCurves);
|
||||
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, RECEIVER(this)ClearFilterFormulaInputs);
|
||||
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
|
||||
|
||||
connect(ui->radioButtonAngleLine, &QRadioButton::clicked, this, &DialogEditWrongFormula::AngleLines);
|
||||
connect(ui->radioButtonAngleLine, &QRadioButton::clicked, RECEIVER(this)ClearFilterFormulaInputs);
|
||||
connect(ui->radioButtonAngleLine, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
|
||||
|
||||
connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, &DialogEditWrongFormula::RadiusArcs);
|
||||
connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, RECEIVER(this)ClearFilterFormulaInputs);
|
||||
connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
|
||||
|
||||
connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, &DialogEditWrongFormula::AnglesCurves);
|
||||
connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, RECEIVER(this)ClearFilterFormulaInputs);
|
||||
connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
|
||||
|
||||
connect(ui->radioButtonCLength, &QRadioButton::clicked, this, &DialogEditWrongFormula::CurvesCLength);
|
||||
connect(ui->radioButtonCLength, &QRadioButton::clicked, RECEIVER(this)ClearFilterFormulaInputs);
|
||||
connect(ui->radioButtonCLength, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
|
||||
|
||||
connect(ui->radioButtonFunctions, &QRadioButton::clicked, this, &DialogEditWrongFormula::Functions);
|
||||
connect(ui->radioButtonFunctions, &QRadioButton::clicked, RECEIVER(this)ClearFilterFormulaInputs);
|
||||
connect(ui->radioButtonFunctions, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
|
||||
|
||||
connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogEditWrongFormula::Measurements);
|
||||
}
|
||||
|
|
|
@ -52,13 +52,13 @@ DialogUndo::DialogUndo(QWidget *parent)
|
|||
}
|
||||
else
|
||||
{
|
||||
connect(ui->pushButtonUndo, &QPushButton::clicked, RECEIVER(this)[this]()
|
||||
connect(ui->pushButtonUndo, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
result = UndoButton::Undo;
|
||||
accept();
|
||||
});
|
||||
}
|
||||
connect(ui->pushButtonFix, &QPushButton::clicked, RECEIVER(this)[this]()
|
||||
connect(ui->pushButtonFix, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
result = UndoButton::Fix;
|
||||
accept();
|
||||
|
|
|
@ -67,9 +67,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -60,9 +60,7 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -63,9 +63,7 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -56,9 +56,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -56,9 +56,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -56,9 +56,7 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -72,9 +72,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -62,9 +62,7 @@ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidge
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
labelEditNamePoint = ui->labelEditNamePoint;
|
||||
|
|
|
@ -215,7 +215,7 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type)
|
|||
*/
|
||||
quint32 DialogLine::GetFirstPoint() const
|
||||
{
|
||||
return qvariant_cast<quint32>(CURRENT_DATA(ui->comboBoxFirstPoint));
|
||||
return qvariant_cast<quint32>(ui->comboBoxFirstPoint->currentData());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -225,7 +225,7 @@ quint32 DialogLine::GetFirstPoint() const
|
|||
*/
|
||||
quint32 DialogLine::GetSecondPoint() const
|
||||
{
|
||||
return qvariant_cast<quint32>(CURRENT_DATA(ui->comboBoxSecondPoint));
|
||||
return qvariant_cast<quint32>(ui->comboBoxSecondPoint->currentData());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -61,9 +61,7 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
number = 0;
|
||||
InitOkCancelApply(ui);
|
||||
|
|
|
@ -68,9 +68,7 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -61,9 +61,7 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -45,9 +45,7 @@ DialogPointFromArcAndTangent::DialogPointFromArcAndTangent(const VContainer *dat
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
labelEditNamePoint = ui->labelEditNamePoint;
|
||||
|
|
|
@ -58,9 +58,7 @@ DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContaine
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
labelEditNamePoint = ui->labelEditNamePoint;
|
||||
|
|
|
@ -60,9 +60,7 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -53,9 +53,7 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, con
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
labelEditNamePoint = ui->labelEditNamePoint;
|
||||
|
|
|
@ -47,9 +47,7 @@ DialogPointOfIntersectionArcs::DialogPointOfIntersectionArcs(const VContainer *d
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
labelEditNamePoint = ui->labelEditNamePoint;
|
||||
|
|
|
@ -59,9 +59,7 @@ DialogPointOfIntersectionCircles::DialogPointOfIntersectionCircles(const VContai
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
labelEditNamePoint = ui->labelEditNamePoint;
|
||||
|
|
|
@ -49,9 +49,7 @@ DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContaine
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
labelEditNamePoint = ui->labelEditNamePoint;
|
||||
|
|
|
@ -62,9 +62,7 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
InitFormulaUI(ui);
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
|
|
|
@ -47,9 +47,7 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, const quint32 &tool
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditName->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->doubleSpinBoxX->setRange(0, qApp->fromPixel(SceneSize));
|
||||
ui->doubleSpinBoxY->setRange(0, qApp->fromPixel(SceneSize));
|
||||
|
|
|
@ -361,11 +361,8 @@ QString DialogTool::GetComboBoxCurrentData(const QComboBox *box, const QString &
|
|||
{
|
||||
SCASSERT(box != nullptr)
|
||||
QString value;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
value = box->itemData(box->currentIndex()).toString();
|
||||
#else
|
||||
value = box->currentData().toString();
|
||||
#endif
|
||||
|
||||
if (value.isEmpty())
|
||||
{
|
||||
value = def;
|
||||
|
|
|
@ -409,11 +409,8 @@ inline T DialogTool::getCurrentCrossPoint(QComboBox *box) const
|
|||
{
|
||||
int value;
|
||||
bool ok = false;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
||||
value = box->itemData(box->currentIndex()).toInt(&ok);
|
||||
#else
|
||||
value = box->currentData().toInt(&ok);
|
||||
#endif
|
||||
|
||||
if (not ok)
|
||||
{
|
||||
return static_cast<T>(1);
|
||||
|
|
|
@ -53,9 +53,7 @@ DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QW
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
labelEditNamePoint = ui->labelEditNamePoint;
|
||||
|
|
|
@ -56,10 +56,8 @@ DialogTrueDarts::DialogTrueDarts(const VContainer *data, const quint32 &toolId,
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditFirstNewDartPoint->setClearButtonEnabled(true);
|
||||
ui->lineEditSecondNewDartPoint->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
const QString name1 = qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel);
|
||||
const QString name2 = qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel, name1);
|
||||
|
|
|
@ -319,7 +319,7 @@ void DialogPiecePath::NodeChanged(int index)
|
|||
if (index != -1)
|
||||
{
|
||||
const VPiecePath path = CreatePath();
|
||||
const int nodeIndex = path.indexOfNode(CURRENT_DATA(ui->comboBoxNodes).toUInt());
|
||||
const int nodeIndex = path.indexOfNode(ui->comboBoxNodes->currentData().toUInt());
|
||||
if (nodeIndex != -1)
|
||||
{
|
||||
const VPieceNode &node = path.at(nodeIndex);
|
||||
|
@ -396,7 +396,7 @@ void DialogPiecePath::PassmarkChanged(int index)
|
|||
if (index != -1)
|
||||
{
|
||||
const VPiecePath path = CreatePath();
|
||||
const int nodeIndex = path.indexOfNode(CURRENT_DATA(ui->comboBoxPassmarks).toUInt());
|
||||
const int nodeIndex = path.indexOfNode(ui->comboBoxPassmarks->currentData().toUInt());
|
||||
if (nodeIndex != -1)
|
||||
{
|
||||
const VPieceNode &node = path.at(nodeIndex);
|
||||
|
@ -480,7 +480,7 @@ void DialogPiecePath::PassmarkLineTypeChanged(int id)
|
|||
const int i = ui->comboBoxPassmarks->currentIndex();
|
||||
if (i != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxPassmarks).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(ui->comboBoxPassmarks->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
@ -522,7 +522,7 @@ void DialogPiecePath::PassmarkAngleTypeChanged(int id)
|
|||
const int i = ui->comboBoxPassmarks->currentIndex();
|
||||
if (i != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxPassmarks).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(ui->comboBoxPassmarks->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
@ -701,9 +701,7 @@ void DialogPiecePath::DeployWidthAfterFormulaTextEdit()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::InitPathTab()
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
ui->lineEditName->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
FillComboBoxTypeLine(ui->comboBoxPenType, CurvePenStylesPics());
|
||||
|
||||
|
@ -799,7 +797,7 @@ void DialogPiecePath::InitPathTypes()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::InitNodesList()
|
||||
{
|
||||
const quint32 id = CURRENT_DATA(ui->comboBoxNodes).toUInt();
|
||||
const quint32 id = ui->comboBoxNodes->currentData().toUInt();
|
||||
|
||||
ui->comboBoxNodes->blockSignals(true);
|
||||
ui->comboBoxNodes->clear();
|
||||
|
@ -833,7 +831,7 @@ void DialogPiecePath::InitNodesList()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::InitPassmarksList()
|
||||
{
|
||||
const quint32 id = CURRENT_DATA(ui->comboBoxPassmarks).toUInt();
|
||||
const quint32 id = ui->comboBoxPassmarks->currentData().toUInt();
|
||||
|
||||
ui->comboBoxPassmarks->blockSignals(true);
|
||||
ui->comboBoxPassmarks->clear();
|
||||
|
@ -870,10 +868,10 @@ void DialogPiecePath::NodeAngleChanged(int index)
|
|||
const int i = ui->comboBoxNodes->currentIndex();
|
||||
if (i != -1 && index != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxNodes).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(ui->comboBoxNodes->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
const PieceNodeAngle angle = static_cast<PieceNodeAngle>(CURRENT_DATA(ui->comboBoxAngle).toUInt());
|
||||
const PieceNodeAngle angle = static_cast<PieceNodeAngle>(ui->comboBoxAngle->currentData().toUInt());
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
rowNode.SetAngleType(angle);
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
||||
|
@ -914,7 +912,7 @@ void DialogPiecePath::SetPiecePath(const VPiecePath &path)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
PiecePathType DialogPiecePath::GetType() const
|
||||
{
|
||||
return static_cast<PiecePathType>(CURRENT_DATA(ui->comboBoxType).toInt());
|
||||
return static_cast<PiecePathType>(ui->comboBoxType->currentData().toInt());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -994,7 +992,7 @@ void DialogPiecePath::UpdateNodeSABefore(const QString &formula)
|
|||
const int index = ui->comboBoxNodes->currentIndex();
|
||||
if (index != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxNodes).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(ui->comboBoxNodes->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
@ -1010,7 +1008,7 @@ void DialogPiecePath::UpdateNodeSAAfter(const QString &formula)
|
|||
const int index = ui->comboBoxNodes->currentIndex();
|
||||
if (index != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(ui->comboBoxNodes).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(ui->comboBoxNodes->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
|
|
@ -495,7 +495,7 @@ void DialogSeamAllowance::AddUpdate()
|
|||
MaterialCutPlacement mcp;
|
||||
QStringList qslUserMaterials = qApp->Settings()->GetUserDefinedMaterials();
|
||||
|
||||
const int i = CURRENT_DATA(uiTabLabels->comboBoxMaterial).toInt();
|
||||
const int i = uiTabLabels->comboBoxMaterial->currentData().toInt();
|
||||
QString qsMat = uiTabLabels->comboBoxMaterial->currentText();
|
||||
if (i < m_qslMaterials.count() && qsMat == m_qslMaterials[i])
|
||||
{
|
||||
|
@ -809,7 +809,7 @@ void DialogSeamAllowance::NodeChanged(int index)
|
|||
if (index != -1)
|
||||
{
|
||||
const VPiece piece = CreatePiece();
|
||||
const int nodeIndex = piece.GetPath().indexOfNode(CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt());
|
||||
const int nodeIndex = piece.GetPath().indexOfNode(uiTabPaths->comboBoxNodes->currentData().toUInt());
|
||||
if (nodeIndex != -1)
|
||||
{
|
||||
const VPieceNode &node = piece.GetPath().at(nodeIndex);
|
||||
|
@ -882,7 +882,7 @@ void DialogSeamAllowance::PassmarkChanged(int index)
|
|||
if (index != -1)
|
||||
{
|
||||
const VPiece piece = CreatePiece();
|
||||
const int nodeIndex = piece.GetPath().indexOfNode(CURRENT_DATA(uiTabPassmarks->comboBoxPassmarks).toUInt());
|
||||
const int nodeIndex = piece.GetPath().indexOfNode(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
|
||||
if (nodeIndex != -1)
|
||||
{
|
||||
const VPieceNode &node = piece.GetPath().at(nodeIndex);
|
||||
|
@ -961,7 +961,7 @@ void DialogSeamAllowance::CSAStartPointChanged(int index)
|
|||
QListWidgetItem *rowItem = uiTabPaths->listWidgetCustomSA->item(row);
|
||||
SCASSERT(rowItem != nullptr);
|
||||
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
|
||||
record.startPoint = CURRENT_DATA(uiTabPaths->comboBoxStartPoint).toUInt();
|
||||
record.startPoint = uiTabPaths->comboBoxStartPoint->currentData().toUInt();
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
|
||||
}
|
||||
|
||||
|
@ -979,7 +979,7 @@ void DialogSeamAllowance::CSAEndPointChanged(int index)
|
|||
QListWidgetItem *rowItem = uiTabPaths->listWidgetCustomSA->item(row);
|
||||
SCASSERT(rowItem != nullptr);
|
||||
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
|
||||
record.endPoint = CURRENT_DATA(uiTabPaths->comboBoxEndPoint).toUInt();
|
||||
record.endPoint = uiTabPaths->comboBoxEndPoint->currentData().toUInt();
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
|
||||
}
|
||||
|
||||
|
@ -997,7 +997,7 @@ void DialogSeamAllowance::CSAIncludeTypeChanged(int index)
|
|||
QListWidgetItem *rowItem = uiTabPaths->listWidgetCustomSA->item(row);
|
||||
SCASSERT(rowItem != nullptr);
|
||||
CustomSARecord record = qvariant_cast<CustomSARecord>(rowItem->data(Qt::UserRole));
|
||||
record.includeType = static_cast<PiecePathIncludeType>(CURRENT_DATA(uiTabPaths->comboBoxIncludeType).toUInt());
|
||||
record.includeType = static_cast<PiecePathIncludeType>(uiTabPaths->comboBoxIncludeType->currentData().toUInt());
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(record));
|
||||
}
|
||||
|
||||
|
@ -1007,11 +1007,11 @@ void DialogSeamAllowance::NodeAngleChanged(int index)
|
|||
const int i = uiTabPaths->comboBoxNodes->currentIndex();
|
||||
if (i != -1 && index != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(uiTabPaths->comboBoxNodes->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
rowNode.SetAngleType(static_cast<PieceNodeAngle>(CURRENT_DATA(uiTabPaths->comboBoxAngle).toUInt()));
|
||||
rowNode.SetAngleType(static_cast<PieceNodeAngle>(uiTabPaths->comboBoxAngle->currentData().toUInt()));
|
||||
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
|
||||
|
||||
ListChanged();
|
||||
|
@ -1198,7 +1198,7 @@ void DialogSeamAllowance::PassmarkLineTypeChanged(int id)
|
|||
const int i = uiTabPassmarks->comboBoxPassmarks->currentIndex();
|
||||
if (i != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPassmarks->comboBoxPassmarks).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
@ -1240,7 +1240,7 @@ void DialogSeamAllowance::PassmarkAngleTypeChanged(int id)
|
|||
const int i = uiTabPassmarks->comboBoxPassmarks->currentIndex();
|
||||
if (i != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPassmarks->comboBoxPassmarks).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
@ -1273,7 +1273,7 @@ void DialogSeamAllowance::PassmarkShowSecondChanged(int state)
|
|||
const int i = uiTabPassmarks->comboBoxPassmarks->currentIndex();
|
||||
if (i != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPassmarks->comboBoxPassmarks).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
@ -2310,7 +2310,7 @@ bool DialogSeamAllowance::MainPathIsClockwise() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::InitNodesList()
|
||||
{
|
||||
const quint32 id = CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt();
|
||||
const quint32 id = uiTabPaths->comboBoxNodes->currentData().toUInt();
|
||||
|
||||
uiTabPaths->comboBoxNodes->blockSignals(true);
|
||||
uiTabPaths->comboBoxNodes->clear();
|
||||
|
@ -2344,7 +2344,7 @@ void DialogSeamAllowance::InitNodesList()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::InitPassmarksList()
|
||||
{
|
||||
const quint32 id = CURRENT_DATA(uiTabPassmarks->comboBoxPassmarks).toUInt();
|
||||
const quint32 id = uiTabPassmarks->comboBoxPassmarks->currentData().toUInt();
|
||||
|
||||
uiTabPassmarks->comboBoxPassmarks->blockSignals(true);
|
||||
uiTabPassmarks->comboBoxPassmarks->clear();
|
||||
|
@ -2427,7 +2427,7 @@ void DialogSeamAllowance::UpdateNodeSABefore(const QString &formula)
|
|||
const int index = uiTabPaths->comboBoxNodes->currentIndex();
|
||||
if (index != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(uiTabPaths->comboBoxNodes->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
@ -2443,7 +2443,7 @@ void DialogSeamAllowance::UpdateNodeSAAfter(const QString &formula)
|
|||
const int index = uiTabPaths->comboBoxNodes->currentIndex();
|
||||
if (index != -1)
|
||||
{
|
||||
QListWidgetItem *rowItem = GetItemById(CURRENT_DATA(uiTabPaths->comboBoxNodes).toUInt());
|
||||
QListWidgetItem *rowItem = GetItemById(uiTabPaths->comboBoxNodes->currentData().toUInt());
|
||||
if (rowItem)
|
||||
{
|
||||
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
|
||||
|
@ -2600,7 +2600,7 @@ void DialogSeamAllowance::InitPinPoint(QComboBox *box)
|
|||
quint32 currentId = NULL_ID;
|
||||
if (box->count() > 0)
|
||||
{
|
||||
currentId = CURRENT_DATA(box).toUInt();
|
||||
currentId = box->currentData().toUInt();
|
||||
}
|
||||
|
||||
box->clear();
|
||||
|
@ -2643,10 +2643,8 @@ void DialogSeamAllowance::InitInternalPathsTab()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::InitPatternPieceDataTab()
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
uiTabLabels->lineEditName->setClearButtonEnabled(true);
|
||||
uiTabLabels->lineEditLetter->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
connect(uiTabLabels->lineEditName, &QLineEdit::textChanged, this, &DialogSeamAllowance::NameDetailChanged);
|
||||
|
||||
|
|
|
@ -503,7 +503,7 @@ VSimpleCurve *VAbstractOperation::InitCurve(quint32 id, VContainer *data, GOType
|
|||
curve->setParentItem(this);
|
||||
curve->SetType(curveType);
|
||||
connect(curve, &VSimpleCurve::Selected, this, &VAbstractOperation::ObjectSelected);
|
||||
connect(curve, &VSimpleCurve::ShowContextMenu, RECEIVER(this)[this](QGraphicsSceneContextMenuEvent * event)
|
||||
connect(curve, &VSimpleCurve::ShowContextMenu, this, [this](QGraphicsSceneContextMenuEvent * event)
|
||||
{
|
||||
contextMenuEvent(event);
|
||||
});
|
||||
|
@ -597,13 +597,13 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
*VAbstractTool::data.GetPatternUnit(), &factor);
|
||||
point->setParentItem(this);
|
||||
point->SetType(GOType::Point);
|
||||
connect(point, &VSimplePoint::Choosed, RECEIVER(this)[this](quint32 id)
|
||||
connect(point, &VSimplePoint::Choosed, this, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Point);
|
||||
});
|
||||
connect(point, &VSimplePoint::Selected, this, &VAbstractOperation::ObjectSelected);
|
||||
connect(point, &VSimplePoint::ShowContextMenu,
|
||||
RECEIVER(this)[this](QGraphicsSceneContextMenuEvent * event)
|
||||
this, [this](QGraphicsSceneContextMenuEvent * event)
|
||||
{
|
||||
contextMenuEvent(event);
|
||||
});
|
||||
|
@ -616,7 +616,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
case GOType::Arc:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType());
|
||||
connect(curve, &VSimpleCurve::Choosed, RECEIVER(this)[this](quint32 id)
|
||||
connect(curve, &VSimpleCurve::Choosed, this, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Arc);
|
||||
});
|
||||
|
@ -625,7 +625,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
case GOType::EllipticalArc:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType());
|
||||
connect(curve, &VSimpleCurve::Choosed, RECEIVER(this)[this](quint32 id)
|
||||
connect(curve, &VSimpleCurve::Choosed, this, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::ElArc);
|
||||
});
|
||||
|
@ -635,7 +635,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
case GOType::CubicBezier:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType());
|
||||
connect(curve, &VSimpleCurve::Choosed, RECEIVER(this)[this](quint32 id)
|
||||
connect(curve, &VSimpleCurve::Choosed, this, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Spline);
|
||||
});
|
||||
|
@ -645,7 +645,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
case GOType::CubicBezierPath:
|
||||
{
|
||||
VSimpleCurve *curve = InitCurve(object.id, &(VAbstractTool::data), obj->getType());
|
||||
connect(curve, &VSimpleCurve::Choosed, RECEIVER(this)[this](quint32 id)
|
||||
connect(curve, &VSimpleCurve::Choosed, this, [this](quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::SplinePath);
|
||||
});
|
||||
|
|
|
@ -81,7 +81,7 @@ VNodePoint::VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quin
|
|||
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||
&VNodePoint::NameChangePosition);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu,
|
||||
RECEIVER(this)[this](QGraphicsSceneContextMenuEvent *event)
|
||||
this, [this](QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
emit ShowContextMenu(event);
|
||||
});
|
||||
|
|
|
@ -778,12 +778,7 @@ quint32 TakeNextId(QVector<quint32> &children)
|
|||
quint32 idChild = NULL_ID;
|
||||
if (not children.isEmpty())
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
idChild = children.takeFirst();
|
||||
#else
|
||||
idChild = children.first();
|
||||
children.remove(0);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -617,14 +617,8 @@ qreal VGrainlineItem::GetScale() const
|
|||
{
|
||||
const QPoint pt0 = scene()->views().at(0)->mapFromScene(0, 0);
|
||||
const QPoint pt = scene()->views().at(0)->mapFromScene(0, 100);
|
||||
|
||||
const QPoint p = pt - pt0;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
qreal dScale = qSqrt(QPoint::dotProduct(p, p));
|
||||
#else
|
||||
qreal dScale = qSqrt(p.x() * p.x() + p.y() * p.y());
|
||||
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
dScale = 100.0/dScale;
|
||||
if (dScale < 1.0)
|
||||
{
|
||||
|
|
|
@ -1872,11 +1872,8 @@ void TST_VAbstractPiece::PathRemoveLoop_data() const
|
|||
path << QPointF(10, 10);
|
||||
QTest::newRow("Correct closed a path (four unique points)") << path << path;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
path.remove(path.size() - 1);
|
||||
#else
|
||||
path.removeLast();
|
||||
#endif
|
||||
|
||||
QTest::newRow("Correct unclosed a path (four unique points)") << path << path;
|
||||
|
||||
path.clear();
|
||||
|
@ -1889,11 +1886,8 @@ void TST_VAbstractPiece::PathRemoveLoop_data() const
|
|||
path << QPointF(0, 10);
|
||||
QTest::newRow("Correct closed a path (six unique points)") << path << path;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
path.remove(path.size() - 1);
|
||||
#else
|
||||
path.removeLast();
|
||||
#endif
|
||||
|
||||
QTest::newRow("Correct unclosed a path (six unique points)") << path << path;
|
||||
|
||||
path.clear();
|
||||
|
@ -1910,13 +1904,9 @@ void TST_VAbstractPiece::PathRemoveLoop_data() const
|
|||
res << QPointF(20, 10);
|
||||
QTest::newRow("One loop, closed a path (four unique points)") << path << res;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
path.remove(path.size() - 1);
|
||||
res.remove(res.size() - 1);
|
||||
#else
|
||||
path.removeLast();
|
||||
res.removeLast();
|
||||
#endif
|
||||
|
||||
QTest::newRow("One loop, unclosed a path (four unique points)") << path << res;
|
||||
|
||||
path.clear();
|
||||
|
@ -1935,13 +1925,9 @@ void TST_VAbstractPiece::PathRemoveLoop_data() const
|
|||
res << QPointF(20, 10);
|
||||
QTest::newRow("Two loops, closed a path (six unique points)") << path << res;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
path.remove(path.size() - 1);
|
||||
res.remove(res.size() - 1);
|
||||
#else
|
||||
path.removeLast();
|
||||
res.removeLast();
|
||||
#endif
|
||||
|
||||
QTest::newRow("Two loops, unclosed a path (six unique points)") << path << res;
|
||||
|
||||
path.clear();
|
||||
|
@ -1987,13 +1973,9 @@ void TST_VAbstractPiece::PathRemoveLoop_data() const
|
|||
res << QPointF(20, 10);
|
||||
QTest::newRow("One loop, the second loop, closed a path (six unique points)") << path << res;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
path.remove(path.size() - 1);
|
||||
res.remove(res.size() - 1);
|
||||
#else
|
||||
path.removeLast();
|
||||
res.removeLast();
|
||||
#endif
|
||||
|
||||
QTest::newRow("One loop, the second loop, unclosed a path (six unique points)") << path << res;
|
||||
|
||||
path.clear();
|
||||
|
@ -2005,11 +1987,8 @@ void TST_VAbstractPiece::PathRemoveLoop_data() const
|
|||
path << QPointF(20, 10);
|
||||
QTest::newRow("Correct closed a path, point on line (four unique points)") << path << path;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
path.remove(path.size() - 1);
|
||||
#else
|
||||
path.removeLast();
|
||||
#endif
|
||||
|
||||
QTest::newRow("Corect unclosed a path, point on line (four unique points)") << path << path;
|
||||
|
||||
path.clear();
|
||||
|
@ -2025,11 +2004,8 @@ void TST_VAbstractPiece::PathRemoveLoop_data() const
|
|||
|
||||
QTest::newRow("Correct closed a path, point on line (six unique points)") << path << path;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
|
||||
path.remove(path.size() - 1);
|
||||
#else
|
||||
path.removeLast();
|
||||
#endif
|
||||
|
||||
QTest::newRow("Corect unclosed a path, point on line (six unique points)") << path << path;
|
||||
|
||||
path.clear();
|
||||
|
|
Loading…
Reference in New Issue
Block a user