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

develop
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) &&
((event->pos() - m_dragStart).manhattanLength() >= QApplication::startDragDistance()) &&
(selectedItems().count() > 0) &&
(not m_pieceList.isEmpty() &&
m_pieceList.constFirst()->Sheet() == nullptr)) // only if it's from unplaced pieces
(!selectedItems().isEmpty()) &&
(!m_pieceList.isEmpty() && m_pieceList.constFirst()->Sheet() == nullptr)) // only if it's from unplaced pieces
{
startDrag(Qt::MoveAction);
}

View File

@ -494,7 +494,7 @@ void VPApplication::ProcessArguments(const VPCommandLinePtr &cmd)
{
const QStringList rawLayouts = cmd->OptionRawLayouts();
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)
{

View File

@ -627,7 +627,7 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
}
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)
{

View File

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

View File

@ -360,7 +360,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(doc, &VPattern::CheckLayout, this,
[this]()
{
if (pattern->DataPieces()->count() == 0)
if (pattern->DataPieces()->isEmpty())
{
if (not ui->actionDraw->isChecked())
{
@ -3917,7 +3917,7 @@ void MainWindow::ActionDetails(bool checked)
if (not VAbstractValApplication::VApp()->getOpeningPattern())
{
if (pattern->DataPieces()->count() == 0)
if (pattern->DataPieces()->isEmpty())
{
QMessageBox::information(this, tr("Detail mode"),
tr("You can't use Detail mode yet. "
@ -4001,7 +4001,7 @@ void MainWindow::ActionLayout(bool checked)
if (not VAbstractValApplication::VApp()->getOpeningPattern())
{
const QHash<quint32, VPiece> *allDetails = pattern->DataPieces();
if (allDetails->count() == 0)
if (allDetails->isEmpty())
{
QMessageBox::information(this, tr("Layout mode"),
tr("You can't use Layout mode yet. "
@ -4014,7 +4014,7 @@ void MainWindow::ActionLayout(bool checked)
WarningNotUniquePieceName(allDetails);
details = SortDetailsForLayout(allDetails);
if (details.count() == 0)
if (details.isEmpty())
{
QMessageBox::information(this, tr("Layout mode"),
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());
if (detailsInLayout.count() == 0)
if (detailsInLayout.isEmpty())
{
QMessageBox::information(this, tr("Layout mode"),
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());
if (detailsInLayout.count() == 0)
if (detailsInLayout.isEmpty())
{
QMessageBox::information(this, tr("Layout mode"),
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 filename = QFileDialog::getSaveFileName(this, tr("Save Image"), path, filter, nullptr,
VAbstractApplication::VApp()->NativeFileDialog());
VAbstractApplication::VApp()->NativeFileDialog());
if (not filename.isEmpty())
{
QFile file(filename);
@ -5098,9 +5098,9 @@ void MainWindow::ActionHistory_triggered(bool checked)
void MainWindow::ActionExportRecipe_triggered()
{
QString const filters(tr("Recipe files") + QStringLiteral("(*.vpr)"));
QString const fileName = QFileDialog::getSaveFileName(this, tr("Export recipe"),
QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"),
filters, nullptr, VAbstractApplication::VApp()->NativeFileDialog());
QString const fileName = QFileDialog::getSaveFileName(
this, tr("Export recipe"), QDir::homePath() + '/' + tr("recipe") + QStringLiteral(".vpr"), filters, nullptr,
VAbstractApplication::VApp()->NativeFileDialog());
if (fileName.isEmpty())
{
return;
@ -6837,7 +6837,7 @@ void MainWindow::ExportDetailsAs(bool checked)
QVector<DetailForLayout> const detailsInLayout = SortDetailsForLayout(pattern->DataPieces());
if (detailsInLayout.count() == 0)
if (detailsInLayout.isEmpty())
{
QMessageBox::information(this, tr("Layout mode"),
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?")
.arg(path);
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)
{
return {};
@ -7192,7 +7192,7 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool
if (not VAbstractValApplication::VApp()->getOpeningPattern())
{
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.")));
QCoreApplication::exit(V_EX_DATAERR);
@ -7201,7 +7201,7 @@ auto MainWindow::DoExport(const VCommandLinePtr &expParams) -> bool
details = SortDetailsForLayout(allDetails, expParams->OptExportSuchDetails());
if (details.count() == 0)
if (details.isEmpty())
{
qCCritical(vMainWindow, "%s",
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
if (iArgCount > 1 && (stOpt.size() == 0 ||
(stOpt.top().GetCode() != cmFUNC && stOpt.top().GetCode() != cmFUNC_BULK &&
stOpt.top().GetCode() != cmFUNC_STR)))
if (iArgCount > 1 &&
(stOpt.isEmpty() || (stOpt.top().GetCode() != cmFUNC && stOpt.top().GetCode() != cmFUNC_BULK &&
stOpt.top().GetCode() != cmFUNC_STR)))
{
Error(ecUNEXPECTED_ARG, m_pTokenReader->GetPos());
}
@ -1587,7 +1587,7 @@ void QmuParserBase::CreateRPN() const
Error(ecINTERNAL_ERROR, 9);
}
if (stVal.size() == 0)
if (stVal.isEmpty())
{
Error(ecEMPTY_EXPRESSION);
}

View File

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

View File

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

View File

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