"empty()" or "isEmpty()" should be used to test for emptiness.

This commit is contained in:
Roman Telezhynskyi 2024-02-21 11:48:58 +02:00
parent b6b278997a
commit 1249e1f2fc
9 changed files with 28 additions and 29 deletions

View File

@ -140,9 +140,8 @@ void VPCarrouselPieceList::mouseMoveEvent(QMouseEvent *event)
{ {
if (((event->buttons() & Qt::LeftButton) != 0U) && if (((event->buttons() & Qt::LeftButton) != 0U) &&
((event->pos() - m_dragStart).manhattanLength() >= QApplication::startDragDistance()) && ((event->pos() - m_dragStart).manhattanLength() >= QApplication::startDragDistance()) &&
(selectedItems().count() > 0) && (!selectedItems().isEmpty()) &&
(not m_pieceList.isEmpty() && (!m_pieceList.isEmpty() && m_pieceList.constFirst()->Sheet() == nullptr)) // only if it's from unplaced pieces
m_pieceList.constFirst()->Sheet() == nullptr)) // only if it's from unplaced pieces
{ {
startDrag(Qt::MoveAction); startDrag(Qt::MoveAction);
} }

View File

@ -494,7 +494,7 @@ void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd)
{ {
const QStringList rawLayouts = cmd->OptionRawLayouts(); const QStringList rawLayouts = cmd->OptionRawLayouts();
const QStringList args = cmd->OptionFileNames(); const QStringList args = cmd->OptionFileNames();
bool const success = args.count() > 0 ? StartWithFiles(cmd, rawLayouts) : SingleStart(cmd, rawLayouts); bool const success = !args.isEmpty() ? StartWithFiles(cmd, rawLayouts) : SingleStart(cmd, rawLayouts);
if (not success) if (not success)
{ {

View File

@ -627,7 +627,7 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
} }
const QStringList args = parser.positionalArguments(); const QStringList args = parser.positionalArguments();
bool const success = args.count() > 0 ? StartWithFiles(parser) : SingleStart(parser); bool const success = !args.isEmpty() ? StartWithFiles(parser) : SingleStart(parser);
if (not success) if (not success)
{ {

View File

@ -185,7 +185,7 @@ void VWidgetDetails::FillTable(const QHash<quint32, VPiece> *details)
void VWidgetDetails::ToggleSectionDetails(bool select) void VWidgetDetails::ToggleSectionDetails(bool select)
{ {
const QHash<quint32, VPiece> *allDetails = m_data->DataPieces(); const QHash<quint32, VPiece> *allDetails = m_data->DataPieces();
if (allDetails->count() == 0) if (allDetails->isEmpty())
{ {
return; return;
} }
@ -335,7 +335,7 @@ void VWidgetDetails::ShowContextMenu(const QPoint &pos)
} }
const QHash<quint32, VPiece> *allDetails = m_data->DataPieces(); const QHash<quint32, VPiece> *allDetails = m_data->DataPieces();
if (allDetails->count() == 0) if (allDetails->isEmpty())
{ {
return; return;
} }

View File

@ -360,7 +360,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(doc, &VPattern::CheckLayout, this, connect(doc, &VPattern::CheckLayout, this,
[this]() [this]()
{ {
if (pattern->DataPieces()->count() == 0) if (pattern->DataPieces()->isEmpty())
{ {
if (not ui->actionDraw->isChecked()) if (not ui->actionDraw->isChecked())
{ {
@ -3917,7 +3917,7 @@ void MainWindow::ActionDetails(bool checked)
if (not VAbstractValApplication::VApp()->getOpeningPattern()) if (not VAbstractValApplication::VApp()->getOpeningPattern())
{ {
if (pattern->DataPieces()->count() == 0) if (pattern->DataPieces()->isEmpty())
{ {
QMessageBox::information(this, tr("Detail mode"), QMessageBox::information(this, tr("Detail mode"),
tr("You can't use Detail mode yet. " tr("You can't use Detail mode yet. "
@ -4001,7 +4001,7 @@ void MainWindow::ActionLayout(bool checked)
if (not VAbstractValApplication::VApp()->getOpeningPattern()) if (not VAbstractValApplication::VApp()->getOpeningPattern())
{ {
const QHash<quint32, VPiece> *allDetails = pattern->DataPieces(); const QHash<quint32, VPiece> *allDetails = pattern->DataPieces();
if (allDetails->count() == 0) if (allDetails->isEmpty())
{ {
QMessageBox::information(this, tr("Layout mode"), QMessageBox::information(this, tr("Layout mode"),
tr("You can't use Layout mode yet. " tr("You can't use Layout mode yet. "
@ -4014,7 +4014,7 @@ void MainWindow::ActionLayout(bool checked)
WarningNotUniquePieceName(allDetails); WarningNotUniquePieceName(allDetails);
details = SortDetailsForLayout(allDetails); details = SortDetailsForLayout(allDetails);
if (details.count() == 0) if (details.isEmpty())
{ {
QMessageBox::information(this, tr("Layout mode"), QMessageBox::information(this, tr("Layout mode"),
tr("You can't use Layout mode yet. Please, " tr("You can't use Layout mode yet. Please, "
@ -4228,7 +4228,7 @@ void MainWindow::on_actionCreateManualLayout_triggered()
{ {
QVector<DetailForLayout> const detailsInLayout = SortDetailsForLayout(pattern->DataPieces()); QVector<DetailForLayout> const detailsInLayout = SortDetailsForLayout(pattern->DataPieces());
if (detailsInLayout.count() == 0) if (detailsInLayout.isEmpty())
{ {
QMessageBox::information(this, tr("Layout mode"), QMessageBox::information(this, tr("Layout mode"),
tr("You don't have enough details to export. Please, " tr("You don't have enough details to export. Please, "
@ -4308,7 +4308,7 @@ void MainWindow::on_actionUpdateManualLayout_triggered()
{ {
QVector<DetailForLayout> const detailsInLayout = SortDetailsForLayout(pattern->DataPieces()); QVector<DetailForLayout> const detailsInLayout = SortDetailsForLayout(pattern->DataPieces());
if (detailsInLayout.count() == 0) if (detailsInLayout.isEmpty())
{ {
QMessageBox::information(this, tr("Layout mode"), QMessageBox::information(this, tr("Layout mode"),
tr("You don't have enough details to export. Please, " tr("You don't have enough details to export. Please, "
@ -5039,7 +5039,7 @@ void MainWindow::SaveBackgroundImage(const QUuid &id)
QString const filter = filters.join(QStringLiteral(";;")); QString const filter = filters.join(QStringLiteral(";;"));
QString const filename = QFileDialog::getSaveFileName(this, tr("Save Image"), path, filter, nullptr, QString const filename = QFileDialog::getSaveFileName(this, tr("Save Image"), path, filter, nullptr,
VAbstractApplication::VApp()->NativeFileDialog()); VAbstractApplication::VApp()->NativeFileDialog());
if (not filename.isEmpty()) if (not filename.isEmpty())
{ {
QFile file(filename); QFile file(filename);
@ -5098,9 +5098,9 @@ void MainWindow::ActionHistory_triggered(bool checked)
void MainWindow::ActionExportRecipe_triggered() void MainWindow::ActionExportRecipe_triggered()
{ {
QString const filters(tr("Recipe files") + QStringLiteral("(*.vpr)")); QString const filters(tr("Recipe files") + QStringLiteral("(*.vpr)"));
QString const fileName = QFileDialog::getSaveFileName(this, tr("Export recipe"), QString const fileName = QFileDialog::getSaveFileName(
QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), this, tr("Export recipe"), QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), filters, nullptr,
filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog()); VAbstractApplication::VApp()->NativeFileDialog());
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
return; return;
@ -6837,7 +6837,7 @@ void MainWindow::ExportDetailsAs(bool checked)
QVector<DetailForLayout> const detailsInLayout = SortDetailsForLayout(pattern->DataPieces()); QVector<DetailForLayout> const detailsInLayout = SortDetailsForLayout(pattern->DataPieces());
if (detailsInLayout.count() == 0) if (detailsInLayout.isEmpty())
{ {
QMessageBox::information(this, tr("Layout mode"), QMessageBox::information(this, tr("Layout mode"),
tr("You don't have enough details to export. Please, " tr("You don't have enough details to export. Please, "
@ -6979,7 +6979,7 @@ auto MainWindow::CheckPathToMeasurements(const QString &patternPath, const QStri
"want to update the file location?") "want to update the file location?")
.arg(path); .arg(path);
QMessageBox::StandardButton const res = QMessageBox::question(this, tr("Loading measurements file"), text, QMessageBox::StandardButton const res = QMessageBox::question(this, tr("Loading measurements file"), text,
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (res == QMessageBox::No) if (res == QMessageBox::No)
{ {
return {}; return {};
@ -7192,7 +7192,7 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool
if (not VAbstractValApplication::VApp()->getOpeningPattern()) if (not VAbstractValApplication::VApp()->getOpeningPattern())
{ {
const QHash<quint32, VPiece> *allDetails = pattern->DataPieces(); const QHash<quint32, VPiece> *allDetails = pattern->DataPieces();
if (allDetails->count() == 0) if (allDetails->isEmpty())
{ {
qCCritical(vMainWindow, "%s", qUtf8Printable(tr("You can't export empty scene."))); qCCritical(vMainWindow, "%s", qUtf8Printable(tr("You can't export empty scene.")));
QCoreApplication::exit(V_EX_DATAERR); QCoreApplication::exit(V_EX_DATAERR);
@ -7201,7 +7201,7 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool
details = SortDetailsForLayout(allDetails, expParams->OptExportSuchDetails()); details = SortDetailsForLayout(allDetails, expParams->OptExportSuchDetails());
if (details.count() == 0) if (details.isEmpty())
{ {
qCCritical(vMainWindow, "%s", qCCritical(vMainWindow, "%s",
qUtf8Printable(tr("You can't export empty scene. Please, " qUtf8Printable(tr("You can't export empty scene. Please, "

View File

@ -1442,9 +1442,9 @@ void QmuParserBase::CreateRPN() const
stOpt.pop(); // Take opening bracket from stack stOpt.pop(); // Take opening bracket from stack
if (iArgCount > 1 && (stOpt.size() == 0 || if (iArgCount > 1 &&
(stOpt.top().GetCode() != cmFUNC && stOpt.top().GetCode() != cmFUNC_BULK && (stOpt.isEmpty() || (stOpt.top().GetCode() != cmFUNC && stOpt.top().GetCode() != cmFUNC_BULK &&
stOpt.top().GetCode() != cmFUNC_STR))) stOpt.top().GetCode() != cmFUNC_STR)))
{ {
Error(ecUNEXPECTED_ARG, m_pTokenReader->GetPos()); Error(ecUNEXPECTED_ARG, m_pTokenReader->GetPos());
} }
@ -1587,7 +1587,7 @@ void QmuParserBase::CreateRPN() const
Error(ecINTERNAL_ERROR, 9); Error(ecINTERNAL_ERROR, 9);
} }
if (stVal.size() == 0) if (stVal.isEmpty())
{ {
Error(ecEMPTY_EXPRESSION); Error(ecEMPTY_EXPRESSION);
} }

View File

@ -2191,7 +2191,7 @@ auto dxfRW::writeObjects() -> bool
writer->writeInt16(281, 1); writer->writeInt16(281, 1);
writer->writeString(3, "ACAD_GROUP"); writer->writeString(3, "ACAD_GROUP");
writer->writeString(350, "D"); writer->writeString(350, "D");
if (imageDef.size() != 0) if (!imageDef.empty())
{ {
writer->writeString(3, "ACAD_IMAGE_DICT"); writer->writeString(3, "ACAD_IMAGE_DICT");
imgDictH = toHexStr(++entCount); imgDictH = toHexStr(++entCount);
@ -2216,7 +2216,7 @@ auto dxfRW::writeObjects() -> bool
writer->writeString(330, (*it).second); writer->writeString(330, (*it).second);
} }
} }
if (imageDef.size() != 0) if (!imageDef.empty())
{ {
writer->writeString(0, "DICTIONARY"); writer->writeString(0, "DICTIONARY");
writer->writeString(5, imgDictH); writer->writeString(5, imgDictH);

View File

@ -118,7 +118,7 @@ QPainterPath DumpDetails(const QVector<VLayoutPiece> &details)
{ {
QPainterPath path; QPainterPath path;
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
if (details.count() > 0) if (!details.isEmpty())
{ {
for (auto &detail : details) for (auto &detail : details)
{ {

View File

@ -939,7 +939,7 @@ void ColorPickerPopup::showEvent(QShowEvent *)
if (!foundSelected) if (!foundSelected)
{ {
if (items.count() == 0) if (items.isEmpty())
{ {
setFocus(); setFocus();
} }