Refactoring.
Code style.
This commit is contained in:
parent
807964e019
commit
bc1f47921f
|
@ -27,16 +27,16 @@
|
|||
*************************************************************************/
|
||||
#include "vpcarrousel.h"
|
||||
#include "ui_vpcarrousel.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QFontMetrics>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QFontMetrics>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
||||
#include "../vmisc/backport/qoverload.h"
|
||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
||||
#include "../layout/vpsheet.h"
|
||||
#include "../layout/vplayout.h"
|
||||
#include "../layout/vpsheet.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QMenu>
|
||||
|
@ -51,8 +51,8 @@ Q_LOGGING_CATEGORY(pCarrousel, "p.carrousel") // NOLINT
|
|||
QT_WARNING_POP
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::VPCarrousel),
|
||||
m_layout(layout)
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ void VPCarrousel::Refresh()
|
|||
|
||||
ui->comboBoxPieceList->blockSignals(true);
|
||||
|
||||
for (const auto& sheet: qAsConst(m_pieceLists))
|
||||
for (const auto &sheet : qAsConst(m_pieceLists))
|
||||
{
|
||||
ui->comboBoxPieceList->addItem(GetSheetName(sheet), sheet.sheetUuid);
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ void VPCarrousel::RefreshSheetNames()
|
|||
return;
|
||||
}
|
||||
|
||||
for (int i=0; i < m_pieceLists.size(); ++i)
|
||||
for (int i = 0; i < m_pieceLists.size(); ++i)
|
||||
{
|
||||
if (not m_pieceLists.at(i).unplaced)
|
||||
{
|
||||
|
@ -257,7 +257,7 @@ void VPCarrousel::SetOrientation(Qt::Orientation orientation)
|
|||
void VPCarrousel::RefreshOrientation()
|
||||
{
|
||||
// then update the scrollarea min height / width and scrollbar behaviour
|
||||
if(m_orientation == Qt::Horizontal)
|
||||
if (m_orientation == Qt::Horizontal)
|
||||
{
|
||||
ui->comboBoxPieceList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
|
|
|
@ -27,17 +27,17 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vplayout.h"
|
||||
#include "vppiece.h"
|
||||
#include "vpsheet.h"
|
||||
#include "../vpapplication.h"
|
||||
#include "../vptilefactory.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../ifc/xml/vwatermarkconverter.h"
|
||||
#include "../vformat/vwatermark.h"
|
||||
#include "../ifc/exception/vexception.h"
|
||||
#include "../vpapplication.h"
|
||||
#include "../vptilefactory.h"
|
||||
#include "vppiece.h"
|
||||
#include "vpsheet.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QUndoStack>
|
||||
#include <QPixmapCache>
|
||||
#include <QUndoStack>
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")
|
||||
|
@ -48,10 +48,10 @@ Q_LOGGING_CATEGORY(pLayout, "p.layout") // NOLINT
|
|||
QT_WARNING_POP
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPLayout::VPLayout(QUndoStack *undoStack) :
|
||||
m_undoStack(undoStack)
|
||||
VPLayout::VPLayout(QUndoStack *undoStack)
|
||||
: m_undoStack(undoStack)
|
||||
{
|
||||
SCASSERT(m_undoStack != nullptr)
|
||||
SCASSERT(m_undoStack != nullptr);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -60,6 +60,7 @@ VPLayout::~VPLayout()
|
|||
delete m_tileFactory;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
||||
{
|
||||
SCASSERT(undoStack != nullptr)
|
||||
|
@ -69,7 +70,7 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
|||
|
||||
// create a standard sheet
|
||||
VPSheetPtr sheet(new VPSheet(layout));
|
||||
sheet->SetName(tr("Sheet %1").arg(layout->GetAllSheets().size()+1));
|
||||
sheet->SetName(tr("Sheet %1").arg(layout->GetAllSheets().size() + 1));
|
||||
layout->AddSheet(sheet);
|
||||
layout->SetFocusedSheet(sheet);
|
||||
|
||||
|
@ -79,8 +80,8 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
|||
|
||||
layout->LayoutSettings().SetShowTiles(settings->GetLayoutTileShowTiles());
|
||||
layout->LayoutSettings().SetShowWatermark(settings->GetLayoutTileShowWatermark());
|
||||
layout->LayoutSettings().SetTilesSize(QSizeF(settings->GetLayoutTilePaperWidth(),
|
||||
settings->GetLayoutTilePaperHeight()));
|
||||
layout->LayoutSettings().SetTilesSize(
|
||||
QSizeF(settings->GetLayoutTilePaperWidth(), settings->GetLayoutTilePaperHeight()));
|
||||
layout->LayoutSettings().SetIgnoreTilesMargins(settings->GetLayoutTileIgnoreMargins());
|
||||
layout->LayoutSettings().SetTilesMargins(settings->GetLayoutTileMargins());
|
||||
|
||||
|
@ -151,7 +152,7 @@ void VPLayout::SetTileFactory(VPTileFactory *newTileFactory)
|
|||
void VPLayout::RefreshScenePieces() const
|
||||
{
|
||||
const QList<VPSheetPtr> sheets = GetSheets();
|
||||
for (const auto& sheet : sheets)
|
||||
for (const auto &sheet : sheets)
|
||||
{
|
||||
if (not sheet.isNull())
|
||||
{
|
||||
|
@ -204,7 +205,8 @@ auto VPLayout::IsSheetsUniform() const -> bool
|
|||
|
||||
QSizeF sheetSize = sheet->GetSheetSize().toSize();
|
||||
|
||||
return std::all_of(sheets.begin(), sheets.end(), [sheetSize](const VPSheetPtr &sheet)
|
||||
return std::all_of(sheets.begin(), sheets.end(),
|
||||
[sheetSize](const VPSheetPtr &sheet)
|
||||
{
|
||||
if (sheet.isNull())
|
||||
{
|
||||
|
@ -227,7 +229,7 @@ auto VPLayout::GetPlacedPieces() const -> QList<VPPiecePtr>
|
|||
QList<VPPiecePtr> pieces;
|
||||
pieces.reserve(m_pieces.size());
|
||||
|
||||
for (const auto& piece : m_pieces)
|
||||
for (const auto &piece : m_pieces)
|
||||
{
|
||||
if (not piece->isNull() && piece->Sheet() != VPSheetPtr() && piece->Sheet() != m_trashSheet)
|
||||
{
|
||||
|
@ -340,7 +342,7 @@ auto VPLayout::PiecesForSheet(const VPSheetPtr &sheet) const -> QList<VPPiecePtr
|
|||
QList<VPPiecePtr> list;
|
||||
list.reserve(m_pieces.size());
|
||||
|
||||
for (const auto& piece : m_pieces)
|
||||
for (const auto &piece : m_pieces)
|
||||
{
|
||||
if (not piece.isNull() && piece->Sheet() == sheet)
|
||||
{
|
||||
|
@ -357,7 +359,7 @@ auto VPLayout::PiecesForSheet(const QUuid &uuid) const -> QList<VPPiecePtr>
|
|||
QList<VPPiecePtr> list;
|
||||
list.reserve(m_pieces.size());
|
||||
|
||||
for (const auto& piece : m_pieces)
|
||||
for (const auto &piece : m_pieces)
|
||||
{
|
||||
if (not piece.isNull())
|
||||
{
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
#include <QMap>
|
||||
#include <QUuid>
|
||||
|
||||
#include "vplayoutsettings.h"
|
||||
#include "layoutdef.h"
|
||||
#include "vplayoutsettings.h"
|
||||
|
||||
class VPPiece;
|
||||
class VPSheet;
|
||||
|
@ -44,6 +44,7 @@ struct VWatermarkData;
|
|||
class VPLayout : public QObject
|
||||
{
|
||||
Q_OBJECT // NOLINT
|
||||
|
||||
public:
|
||||
~VPLayout() override;
|
||||
|
||||
|
|
|
@ -27,15 +27,14 @@
|
|||
*************************************************************************/
|
||||
#include "vpsheet.h"
|
||||
|
||||
#include "vplayout.h"
|
||||
#include "vppiece.h"
|
||||
#include "../scene/vpgraphicspiece.h"
|
||||
#include "../scene/vpgraphicspiececontrols.h"
|
||||
#include "../scene/vpgraphicssheet.h"
|
||||
#include "../scene/vpgraphicstilegrid.h"
|
||||
#include "../vpapplication.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../scene/vpgraphicssheet.h"
|
||||
#include "../scene/vpgraphicspiece.h"
|
||||
#include "../scene/vpgraphicstilegrid.h"
|
||||
#include "../scene/vpgraphicspiececontrols.h"
|
||||
#include "../scene/vpgraphicstilegrid.h"
|
||||
#include "vplayout.h"
|
||||
#include "vppiece.h"
|
||||
|
||||
// VPSheetSceneData
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -60,10 +59,10 @@ VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheet
|
|||
m_rotationOrigin->setVisible(false);
|
||||
m_scene->addItem(m_rotationOrigin);
|
||||
|
||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::ShowOrigin,
|
||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_ShowOrigin);
|
||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::TransformationOriginChanged,
|
||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::SetTransformationOrigin);
|
||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::ShowOrigin, m_rotationOrigin,
|
||||
&VPGraphicsTransformationOrigin::on_ShowOrigin);
|
||||
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::TransformationOriginChanged, m_rotationOrigin,
|
||||
&VPGraphicsTransformationOrigin::SetTransformationOrigin);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -95,7 +94,7 @@ void VPSheetSceneData::RefreshPieces()
|
|||
m_graphicsPieces.clear();
|
||||
|
||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||
if(layout.isNull())
|
||||
if (layout.isNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -140,7 +139,7 @@ void VPSheetSceneData::PrepareForExport()
|
|||
VPSheetPtr sheet = layout->GetSheet(m_sheetUuid);
|
||||
m_slectedPiecesTmp = sheet->GetSelectedPieces();
|
||||
|
||||
for (const auto& piece : qAsConst(m_slectedPiecesTmp))
|
||||
for (const auto &piece : qAsConst(m_slectedPiecesTmp))
|
||||
{
|
||||
if (not piece.isNull())
|
||||
{
|
||||
|
@ -173,7 +172,7 @@ void VPSheetSceneData::CleanAfterExport()
|
|||
layout->LayoutSettings().SetShowGrid(m_showGridTmp);
|
||||
layout->LayoutSettings().SetShowTiles(m_showTilesTmp);
|
||||
|
||||
for (const auto& piece : qAsConst(m_slectedPiecesTmp))
|
||||
for (const auto &piece : qAsConst(m_slectedPiecesTmp))
|
||||
{
|
||||
if (not piece.isNull())
|
||||
{
|
||||
|
@ -202,7 +201,7 @@ auto VPSheetSceneData::GraphicsPiecesAsItems() const -> QList<QGraphicsItem *>
|
|||
QList<QGraphicsItem *> items;
|
||||
items.reserve(m_graphicsPieces.size());
|
||||
|
||||
for(auto *item : m_graphicsPieces)
|
||||
for (auto *item : m_graphicsPieces)
|
||||
{
|
||||
items.append(item);
|
||||
}
|
||||
|
@ -305,20 +304,17 @@ void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece)
|
|||
return;
|
||||
}
|
||||
|
||||
QObject::connect(layout.data(), &VPLayout::PieceTransformationChanged, piece,
|
||||
&VPGraphicsPiece::on_RefreshPiece);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceZValueChanged, piece,
|
||||
&VPGraphicsPiece::PieceZValueChanged);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceSelectionChanged,
|
||||
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
||||
QObject::connect(layout.data(), &VPLayout::PiecePositionValidityChanged,
|
||||
piece, &VPGraphicsPiece::on_RefreshPiece);
|
||||
QObject::connect(piece, &VPGraphicsPiece::PieceTransformationChanged,
|
||||
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
||||
m_rotationControls, &VPGraphicsPieceControls::on_HideHandles);
|
||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_HideHandles);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceTransformationChanged, piece, &VPGraphicsPiece::on_RefreshPiece);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceZValueChanged, piece, &VPGraphicsPiece::PieceZValueChanged);
|
||||
QObject::connect(layout.data(), &VPLayout::PieceSelectionChanged, m_rotationControls,
|
||||
&VPGraphicsPieceControls::on_UpdateControls);
|
||||
QObject::connect(layout.data(), &VPLayout::PiecePositionValidityChanged, piece, &VPGraphicsPiece::on_RefreshPiece);
|
||||
QObject::connect(piece, &VPGraphicsPiece::PieceTransformationChanged, m_rotationControls,
|
||||
&VPGraphicsPieceControls::on_UpdateControls);
|
||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles, m_rotationControls,
|
||||
&VPGraphicsPieceControls::on_HideHandles);
|
||||
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles, m_rotationOrigin,
|
||||
&VPGraphicsTransformationOrigin::on_HideHandles);
|
||||
}
|
||||
|
||||
// VPSheet
|
||||
|
@ -371,7 +367,7 @@ auto VPSheet::GetSelectedPieces() const -> QList<VPPiecePtr>
|
|||
QList<VPPiecePtr> selected;
|
||||
selected.reserve(list.size());
|
||||
|
||||
for (const auto& piece : list)
|
||||
for (const auto &piece : list)
|
||||
{
|
||||
if (not piece.isNull() && piece->IsSelected())
|
||||
{
|
||||
|
@ -393,7 +389,7 @@ auto VPSheet::GetAsLayoutPieces() const -> QVector<VLayoutPiece>
|
|||
QVector<VLayoutPiece> details;
|
||||
details.reserve(pieces.size());
|
||||
|
||||
for (const auto& piece : pieces)
|
||||
for (const auto &piece : pieces)
|
||||
{
|
||||
if (not piece.isNull())
|
||||
{
|
||||
|
@ -571,7 +567,6 @@ void VPSheet::ValidatePieceOutOfBound(const VPPiecePtr &piece) const
|
|||
emit layout->PiecePositionValidityChanged(piece);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -620,7 +615,7 @@ void VPSheet::RemoveUnusedLength()
|
|||
|
||||
QRectF piecesBoundingRect;
|
||||
|
||||
for (const auto& piece : pieces)
|
||||
for (const auto &piece : pieces)
|
||||
{
|
||||
if (not piece.isNull())
|
||||
{
|
||||
|
@ -698,7 +693,7 @@ auto VPSheet::SceneData() const -> VPSheetSceneData *
|
|||
void VPSheet::ClearSelection() const
|
||||
{
|
||||
QList<VPPiecePtr> selectedPieces = GetSelectedPieces();
|
||||
for (const auto& piece : selectedPieces)
|
||||
for (const auto &piece : selectedPieces)
|
||||
{
|
||||
if (piece->IsSelected())
|
||||
{
|
||||
|
@ -774,8 +769,7 @@ void VPSheet::SetSheetSize(const QSizeF &size)
|
|||
void VPSheet::SetSheetSizeConverted(const QSizeF &size)
|
||||
{
|
||||
Unit unit = SheetUnits();
|
||||
m_size = QSizeF(UnitConvertor(size.width(), unit, Unit::Px),
|
||||
UnitConvertor(size.height(), unit, Unit::Px));
|
||||
m_size = QSizeF(UnitConvertor(size.width(), unit, Unit::Px), UnitConvertor(size.height(), unit, Unit::Px));
|
||||
|
||||
if (m_sceneData != nullptr)
|
||||
{
|
||||
|
@ -793,10 +787,8 @@ auto VPSheet::GetSheetSize() const -> QSizeF
|
|||
auto VPSheet::GetSheetSizeConverted() const -> QSizeF
|
||||
{
|
||||
Unit unit = SheetUnits();
|
||||
QSizeF convertedSize = QSizeF(
|
||||
UnitConvertor(m_size.width(), Unit::Px, unit),
|
||||
UnitConvertor(m_size.height(), Unit::Px, unit)
|
||||
);
|
||||
QSizeF convertedSize =
|
||||
QSizeF(UnitConvertor(m_size.width(), Unit::Px, unit), UnitConvertor(m_size.height(), Unit::Px, unit));
|
||||
|
||||
return convertedSize;
|
||||
}
|
||||
|
|
|
@ -612,9 +612,16 @@ void VApplication::BeginLogging()
|
|||
void VApplication::ClearOldLogs()
|
||||
{
|
||||
const QString workingDirectory = QDir::currentPath(); // Save the app working directory
|
||||
QDir logsDir(LogDirPath());
|
||||
const QString logDirPath = LogDirPath();
|
||||
QDir logsDir(logDirPath);
|
||||
|
||||
if (!logsDir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
logsDir.setNameFilters(QStringList(QStringLiteral("*.log")));
|
||||
QDir::setCurrent(LogDirPath());
|
||||
QDir::setCurrent(logDirPath);
|
||||
|
||||
// Restore working directory
|
||||
auto restore = qScopeGuard([workingDirectory] { QDir::setCurrent(workingDirectory); });
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <QLineF>
|
||||
#include <QSharedData>
|
||||
#include <QtDebug>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "../qmuparser/qmutokenparser.h"
|
||||
#include "../vmisc/def.h"
|
||||
|
|
|
@ -408,8 +408,6 @@ void VLayoutExporter::ExportToHPGL2(const QVector<VLayoutPiece> &details) const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VLayoutExporter::SupportPDFConversion() -> bool
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
QProcess proc;
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_OSX)
|
||||
// Seek pdftops in app bundle or near valentina.exe
|
||||
|
@ -421,13 +419,11 @@ auto VLayoutExporter::SupportPDFConversion() -> bool
|
|||
const int timeout = 15000;
|
||||
if (proc.waitForStarted(timeout) && (proc.waitForFinished(timeout) || proc.state() == QProcess::NotRunning))
|
||||
{
|
||||
res = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
qDebug() << *PDFTOPS << "error" << proc.error() << proc.errorString();
|
||||
}
|
||||
return res;
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
#include "dialogexporttocsv.h"
|
||||
#include "ui_dialogexporttocsv.h"
|
||||
|
||||
#include "../vcommonsettings.h"
|
||||
#include "../qxtcsvmodel.h"
|
||||
#include "../vabstractapplication.h"
|
||||
#include "../vcommonsettings.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPushButton>
|
||||
#include <QShowEvent>
|
||||
#include <QDebug>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include "../vtextcodec.h"
|
||||
|
@ -71,7 +71,8 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent)
|
|||
|
||||
QPushButton *bDefaults = ui->buttonBox->button(QDialogButtonBox::RestoreDefaults);
|
||||
SCASSERT(bDefaults != nullptr)
|
||||
connect(bDefaults, &QPushButton::clicked, this, [this]()
|
||||
connect(bDefaults, &QPushButton::clicked, this,
|
||||
[this]()
|
||||
{
|
||||
ui->comboBoxCodec->blockSignals(true);
|
||||
ui->checkBoxWithHeader->blockSignals(true);
|
||||
|
@ -91,12 +92,12 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent)
|
|||
|
||||
ui->groupBoxPreview->setVisible(false);
|
||||
|
||||
connect(ui->comboBoxCodec, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](){ShowPreview();});
|
||||
connect(ui->checkBoxWithHeader, &QCheckBox::stateChanged, this, [this](){ShowPreview();});
|
||||
connect(ui->comboBoxCodec, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]() { ShowPreview(); });
|
||||
connect(ui->checkBoxWithHeader, &QCheckBox::stateChanged, this, [this]() { ShowPreview(); });
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
connect(ui->buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), this, [this](){ShowPreview();});
|
||||
connect(ui->buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), this, [this]() { ShowPreview(); });
|
||||
#else
|
||||
connect(ui->buttonGroup, &QButtonGroup::idClicked, this, [this](){ShowPreview();});
|
||||
connect(ui->buttonGroup, &QButtonGroup::idClicked, this, [this]() { ShowPreview(); });
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -180,8 +181,8 @@ void DialogExportToCSV::changeEvent(QEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogExportToCSV::showEvent(QShowEvent *event)
|
||||
{
|
||||
QDialog::showEvent( event );
|
||||
if ( event->spontaneous() )
|
||||
QDialog::showEvent(event);
|
||||
if (event->spontaneous())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -204,7 +205,7 @@ void DialogExportToCSV::showEvent(QShowEvent *event)
|
|||
setMinimumSize(size());
|
||||
}
|
||||
|
||||
isInitialized = true;//first show windows are held
|
||||
isInitialized = true; // first show windows are held
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -229,7 +230,7 @@ void DialogExportToCSV::ShowPreview()
|
|||
ui->tableWidget->horizontalHeader()->setVisible(IsWithHeader());
|
||||
if (IsWithHeader())
|
||||
{
|
||||
for(int column=0; column<columns; ++column)
|
||||
for (int column = 0; column < columns; ++column)
|
||||
{
|
||||
QTableWidgetItem *header = new QTableWidgetItem(csv.headerText(column));
|
||||
ui->tableWidget->setHorizontalHeaderItem(column, header);
|
||||
|
@ -237,9 +238,9 @@ void DialogExportToCSV::ShowPreview()
|
|||
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
|
||||
for (int row=0; row < rows; ++row)
|
||||
for (int row = 0; row < rows; ++row)
|
||||
{
|
||||
for(int column=0; column<columns; ++column)
|
||||
for (int column = 0; column < columns; ++column)
|
||||
{
|
||||
QTableWidgetItem *item = new QTableWidgetItem(csv.text(row, column));
|
||||
item->setToolTip(csv.text(row, column));
|
||||
|
@ -260,7 +261,7 @@ void DialogExportToCSV::ShowPreview()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogExportToCSV::SetSeparator(const QChar &separator)
|
||||
{
|
||||
switch(separator.toLatin1())
|
||||
switch (separator.toLatin1())
|
||||
{
|
||||
case '\t':
|
||||
ui->radioButtonTab->setChecked(true);
|
||||
|
@ -294,7 +295,7 @@ auto DialogExportToCSV::MakeHelpCodecsList() -> QString
|
|||
if (VTextCodec *codec = VTextCodec::codecForMib(list.at(i)))
|
||||
{
|
||||
out += QStringLiteral("\t* ") + codec->name();
|
||||
out += i < list.size()-1 ? QLatin1String(",\n") : QLatin1String(".\n");
|
||||
out += i < list.size() - 1 ? QLatin1String(",\n") : QLatin1String(".\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
#include "../vmisc/defglobal.h"
|
||||
#include "../defglobal.h"
|
||||
#endif
|
||||
|
||||
enum class VColorSheme
|
||||
|
|
|
@ -32,37 +32,37 @@
|
|||
#include <QCursor>
|
||||
#include <QEvent>
|
||||
#include <QFlags>
|
||||
#include <QGestureEvent>
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsScene>
|
||||
#include <QLineF>
|
||||
#include <QList>
|
||||
#include <QMessageLogger>
|
||||
#include <QMimeData>
|
||||
#include <QMimeDatabase>
|
||||
#include <QMouseEvent>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QPainter>
|
||||
#include <QPoint>
|
||||
#include <QScreen>
|
||||
#include <QScrollBar>
|
||||
#include <QThread>
|
||||
#include <QTimeLine>
|
||||
#include <QTransform>
|
||||
#include <QWheelEvent>
|
||||
#include <QWidget>
|
||||
#include <QThread>
|
||||
#include <QGestureEvent>
|
||||
#include <QScreen>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QMimeData>
|
||||
#include <QMimeDatabase>
|
||||
#include <QtMath>
|
||||
|
||||
#include "../ifc/xml/utils.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "vmaingraphicsscene.h"
|
||||
#include "vsimplecurve.h"
|
||||
#include "vcontrolpointspline.h"
|
||||
#include "../vmisc/literals.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/vcommonsettings.h"
|
||||
#include "../vmisc/literals.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
#include "global.h"
|
||||
#include "../ifc/xml/utils.h"
|
||||
#include "vcontrolpointspline.h"
|
||||
#include "vmaingraphicsscene.h"
|
||||
#include "vsimplecurve.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ auto PrepareScrolling(qreal scheduledScrollings, QWheelEvent *wheel_event) -> qr
|
|||
|
||||
if (qFuzzyIsNull(numSteps))
|
||||
{
|
||||
return scheduledScrollings;//Just ignore
|
||||
return scheduledScrollings; // Just ignore
|
||||
}
|
||||
|
||||
if (std::signbit(scheduledScrollings) != std::signbit(numSteps))
|
||||
|
@ -133,10 +133,10 @@ auto PrioritizeItems(const QList<QGraphicsItem *> &list) -> QList<QGraphicsItem
|
|||
|
||||
return prioritized + nonPrioritized;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view)
|
||||
GraphicsViewZoom::GraphicsViewZoom(QGraphicsView *view)
|
||||
: QObject(view),
|
||||
_view(view),
|
||||
_modifiers(Qt::ControlModifier),
|
||||
|
@ -174,8 +174,8 @@ void GraphicsViewZoom::gentle_zoom(double factor)
|
|||
FictiveSceneRect(_view->scene(), _view);
|
||||
}
|
||||
_view->centerOn(target_scene_pos);
|
||||
QPointF delta_viewport_pos = target_viewport_pos - QPointF(_view->viewport()->width() / 2.0,
|
||||
_view->viewport()->height() / 2.0);
|
||||
QPointF delta_viewport_pos =
|
||||
target_viewport_pos - QPointF(_view->viewport()->width() / 2.0, _view->viewport()->height() / 2.0);
|
||||
QPointF viewport_center = _view->mapFromScene(target_scene_pos) - delta_viewport_pos;
|
||||
_view->centerOn(_view->mapToScene(viewport_center.toPoint()));
|
||||
// In the end we just set correct scene size
|
||||
|
@ -273,7 +273,7 @@ auto GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) -> bool
|
|||
* This data need for gentle_zoom().
|
||||
* Almoust the same we do in method GraphicsViewZoom::animFinished.
|
||||
*/
|
||||
QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);
|
||||
QMouseEvent *mouse_event = static_cast<QMouseEvent *>(event);
|
||||
QPointF delta = target_viewport_pos - mouse_event->pos();
|
||||
if (qAbs(delta.x()) > 5 || qAbs(delta.y()) > 5)
|
||||
{
|
||||
|
@ -331,25 +331,25 @@ void GraphicsViewZoom::FictiveSceneRect(QGraphicsScene *sc, QGraphicsView *view)
|
|||
SCASSERT(sc != nullptr)
|
||||
SCASSERT(view != nullptr)
|
||||
|
||||
//Calculate view rect
|
||||
//to receive the currently visible area, map the widgets bounds to the scene
|
||||
const QPointF a = view->mapToScene(0, 0 );
|
||||
// Calculate view rect
|
||||
// to receive the currently visible area, map the widgets bounds to the scene
|
||||
const QPointF a = view->mapToScene(0, 0);
|
||||
const QPointF b = view->mapToScene(view->viewport()->width(), view->viewport()->height());
|
||||
QRectF viewRect = QRectF( a, b );
|
||||
QRectF viewRect = QRectF(a, b);
|
||||
|
||||
//Scale view
|
||||
// Scale view
|
||||
QLineF topLeftRay(viewRect.center(), viewRect.topLeft());
|
||||
topLeftRay.setLength(topLeftRay.length()*2);
|
||||
topLeftRay.setLength(topLeftRay.length() * 2);
|
||||
|
||||
QLineF bottomRightRay(viewRect.center(), viewRect.bottomRight());
|
||||
bottomRightRay.setLength(bottomRightRay.length()*2);
|
||||
bottomRightRay.setLength(bottomRightRay.length() * 2);
|
||||
|
||||
viewRect = QRectF(topLeftRay.p2(), bottomRightRay.p2());
|
||||
|
||||
//Calculate scene rect
|
||||
// Calculate scene rect
|
||||
const QRectF sceneRect = sc->sceneRect();
|
||||
|
||||
//Unite two rects
|
||||
// Unite two rects
|
||||
const QRectF newRect = sceneRect.united(viewRect);
|
||||
|
||||
sc->setSceneRect(newRect);
|
||||
|
@ -379,8 +379,8 @@ void GraphicsViewZoom::StartHorizontalScrollings(QWheelEvent *wheel_event)
|
|||
{
|
||||
if (not wheel_event->pixelDelta().isNull())
|
||||
{ // Native scrolling animation
|
||||
_view->horizontalScrollBar()->setValue(qCeil(_view->horizontalScrollBar()->value() -
|
||||
ScrollingSteps(wheel_event)));
|
||||
_view->horizontalScrollBar()->setValue(
|
||||
qCeil(_view->horizontalScrollBar()->value() - ScrollingSteps(wheel_event)));
|
||||
animFinished();
|
||||
}
|
||||
else
|
||||
|
@ -453,7 +453,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
|
|||
this->setInteractive(true);
|
||||
SetAntialiasing(true);
|
||||
|
||||
connect(zoom, &GraphicsViewZoom::zoomed, this, [this](){emit ScaleChanged(transform().m11());});
|
||||
connect(zoom, &GraphicsViewZoom::zoomed, this, [this]() { emit ScaleChanged(transform().m11()); });
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -488,7 +488,7 @@ void VMainGraphicsView::ZoomOut()
|
|||
// See issue #532: Unexpected error occurs when zoom out image.
|
||||
if (this->transform().m11() >= MinScale())
|
||||
{
|
||||
scale(1.0/1.1, 1.0/1.1);
|
||||
scale(1.0 / 1.1, 1.0 / 1.1);
|
||||
VMainGraphicsView::NewSceneRect(this->scene(), this);
|
||||
emit ScaleChanged(transform().m11());
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *event)
|
|||
auto *scene = qobject_cast<VMainGraphicsScene *>(this->scene());
|
||||
const QList<QGraphicsItem *> list = items(event->pos());
|
||||
if (list.isEmpty() || (scene && scene->IsNonInteractive()))
|
||||
{// Only when the user clicks on the scene background or non interactive scene
|
||||
{ // Only when the user clicks on the scene background or non interactive scene
|
||||
m_ptStartPos = event->pos();
|
||||
m_oldCursor = viewport()->cursor();
|
||||
QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag);
|
||||
|
@ -602,10 +602,9 @@ void VMainGraphicsView::mouseMoveEvent(QMouseEvent *event)
|
|||
{
|
||||
QCursor cur = viewport()->cursor();
|
||||
// No way to restore bitmap from shape and we really don't need this for now.
|
||||
if (m_currentCursor != Qt::BitmapCursor
|
||||
&& cur.shape() == Qt::BitmapCursor
|
||||
&& cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowOpenHand).cacheKey()
|
||||
&& cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowCloseHand).cacheKey())
|
||||
if (m_currentCursor != Qt::BitmapCursor && cur.shape() == Qt::BitmapCursor &&
|
||||
cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowOpenHand).cacheKey() &&
|
||||
cur.pixmap().cacheKey() != QPixmapFromCache(cursorArrowCloseHand).cacheKey())
|
||||
{
|
||||
viewport()->setCursor(m_currentCursor);
|
||||
}
|
||||
|
@ -633,8 +632,8 @@ void VMainGraphicsView::mouseMoveEvent(QMouseEvent *event)
|
|||
*/
|
||||
void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
QGraphicsView::mouseReleaseEvent ( event ); // First because need to hide a rubber band
|
||||
QGraphicsView::setDragMode( QGraphicsView::NoDrag );
|
||||
QGraphicsView::mouseReleaseEvent(event); // First because need to hide a rubber band
|
||||
QGraphicsView::setDragMode(QGraphicsView::NoDrag);
|
||||
if (event->button() == Qt::MiddleButton)
|
||||
{
|
||||
viewport()->setCursor(m_oldCursor);
|
||||
|
@ -748,8 +747,7 @@ void VMainGraphicsView::EnsureItemVisibleWithDelay(const QGraphicsItem *item, un
|
|||
const QRectF itemRect = item->mapToScene(item->boundingRect()).boundingRect();
|
||||
|
||||
// If item's rect is bigger than view's rect ensureVisible works very unstable.
|
||||
if (itemRect.height() + 2*ymargin < viewRect.height() &&
|
||||
itemRect.width() + 2*xmargin < viewRect.width())
|
||||
if (itemRect.height() + 2 * ymargin < viewRect.height() && itemRect.width() + 2 * xmargin < viewRect.width())
|
||||
{
|
||||
EnsureVisibleWithDelay(item, msecs, xmargin, ymargin);
|
||||
}
|
||||
|
@ -759,8 +757,8 @@ void VMainGraphicsView::EnsureItemVisibleWithDelay(const QGraphicsItem *item, un
|
|||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(item->scene());
|
||||
SCASSERT(currentScene);
|
||||
const QPointF cursorPosition = currentScene->getScenePos();
|
||||
EnsureVisibleWithDelay(QRectF(cursorPosition.x()-5/scale, cursorPosition.y()-5/scale, 10/scale, 10/scale),
|
||||
msecs);
|
||||
EnsureVisibleWithDelay(
|
||||
QRectF(cursorPosition.x() - 5 / scale, cursorPosition.y() - 5 / scale, 10 / scale, 10 / scale), msecs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -844,15 +842,15 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG
|
|||
|
||||
if (item == nullptr)
|
||||
{
|
||||
//Calculate view rect
|
||||
// Calculate view rect
|
||||
const QRectF viewRect = SceneVisibleArea(view);
|
||||
|
||||
//Calculate scene rect
|
||||
// Calculate scene rect
|
||||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(sc);
|
||||
SCASSERT(currentScene)
|
||||
const QRectF itemsRect = currentScene->VisibleItemsBoundingRect();
|
||||
|
||||
//Unite two rects
|
||||
// Unite two rects
|
||||
sc->setSceneRect(itemsRect.united(viewRect));
|
||||
}
|
||||
else
|
||||
|
@ -861,7 +859,7 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG
|
|||
const QList<QGraphicsItem *> children = item->childItems();
|
||||
for (auto *child : children)
|
||||
{
|
||||
if(child->isVisible())
|
||||
if (child->isVisible())
|
||||
{
|
||||
rect = rect.united(child->sceneBoundingRect());
|
||||
}
|
||||
|
@ -878,6 +876,6 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG
|
|||
auto VMainGraphicsView::SceneVisibleArea(QGraphicsView *view) -> QRectF
|
||||
{
|
||||
SCASSERT(view != nullptr)
|
||||
//to receive the currently visible area, map the widgets bounds to the scene
|
||||
// to receive the currently visible area, map the widgets bounds to the scene
|
||||
return QRectF(view->mapToScene(0, 0), view->mapToScene(view->width(), view->height()));
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "../vmisc/svgfont/vsvgfontdatabase.h"
|
||||
#include "../vmisc/vabstractvalapplication.h"
|
||||
#include "vtextgraphicsitem.h"
|
||||
#include <QtMath>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user