Skip to content

Commit

Permalink
Some code indentations
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Jan 17, 2025
1 parent 25536dc commit 8133107
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 54 deletions.
89 changes: 45 additions & 44 deletions src/app/commands_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@ struct OpenFileNames {
QString* dlgPtrSelFilter = &result.lastIoSettings.selectedFilter;
if (option == OpenFileNames::GetOne) {
const QString strFilepath =
QFileDialog::getOpenFileName(
parentWidget, dlgTitle, dlgOpenDir, dlgFilter, dlgPtrSelFilter
);
QFileDialog::getOpenFileName(
parentWidget, dlgTitle, dlgOpenDir, dlgFilter, dlgPtrSelFilter
);
result.listFilepath.clear();
result.listFilepath.push_back(filepathFrom(strFilepath));
}
else {
const QStringList listStrFilePath =
QFileDialog::getOpenFileNames(
parentWidget, dlgTitle, dlgOpenDir, dlgFilter, dlgPtrSelFilter
);
QFileDialog::getOpenFileNames(
parentWidget, dlgTitle, dlgOpenDir, dlgFilter, dlgPtrSelFilter
);
result.listFilepath.clear();
for (const QString& strFilePath : listStrFilePath)
result.listFilepath.push_back(filepathFrom(strFilePath));
Expand All @@ -137,9 +137,10 @@ struct OpenFileNames {
if (!result.listFilepath.empty()) {
result.lastIoSettings.openDir = result.listFilepath.front();
result.selectedFormat =
result.lastIoSettings.selectedFilter != allFilesFilter ?
formatFromFilter(result.lastIoSettings.selectedFilter) :
IO::Format_Unknown;
result.lastIoSettings.selectedFilter != allFilesFilter ?
formatFromFilter(result.lastIoSettings.selectedFilter) :
IO::Format_Unknown
;
ImportExportSettings::save(result.lastIoSettings);
}

Expand Down Expand Up @@ -188,7 +189,7 @@ void FileCommandTools::openDocumentsFromList(IAppContext* context, Span<const Fi
QElapsedTimer chrono;
chrono.start();
const bool okImport =
appModule->ioSystem()->importInDocument()
appModule->ioSystem()->importInDocument()
.targetDocument(app->findDocumentByIdentifier(newDocId))
.withFilepath(fp)
.withParametersProvider(appModule)
Expand All @@ -199,7 +200,7 @@ void FileCommandTools::openDocumentsFromList(IAppContext* context, Span<const Fi
.withEntityPostProcessInfoProgress(20, Command::textIdTr("Mesh BRep shapes"))
.withMessenger(appModule)
.withTaskProgress(progress)
.execute();
.execute();
if (okImport)
appModule->emitInfo(fmt::format(Command::textIdTr("Import time: {}ms"), chrono.elapsed()));
});
Expand Down Expand Up @@ -230,18 +231,19 @@ void FileCommandTools::importInDocument(
chrono.start();

auto doc = appModule->application()->findDocumentByIdentifier(targetDocId);
const bool okImport = appModule->ioSystem()->importInDocument()
.targetDocument(doc)
.withFilepaths(listFilePaths)
.withParametersProvider(appModule)
.withEntityPostProcess([=](TDF_Label labelEntity, TaskProgress* progress) {
appModule->computeBRepMesh(labelEntity, progress);
})
.withEntityPostProcessRequiredIf(&IO::formatProvidesBRep)
.withEntityPostProcessInfoProgress(20, Command::textIdTr("Mesh BRep shapes"))
.withMessenger(appModule)
.withTaskProgress(progress)
.execute();
const bool okImport =
appModule->ioSystem()->importInDocument()
.targetDocument(doc)
.withFilepaths(listFilePaths)
.withParametersProvider(appModule)
.withEntityPostProcess([=](TDF_Label labelEntity, TaskProgress* progress) {
appModule->computeBRepMesh(labelEntity, progress);
})
.withEntityPostProcessRequiredIf(&IO::formatProvidesBRep)
.withEntityPostProcessInfoProgress(20, Command::textIdTr("Mesh BRep shapes"))
.withMessenger(appModule)
.withTaskProgress(progress)
.execute();
if (okImport)
appModule->emitInfo(fmt::format(Command::textIdTr("Import time: {}ms"), chrono.elapsed()));
});
Expand Down Expand Up @@ -340,10 +342,7 @@ CommandRecentFiles::CommandRecentFiles(IAppContext* context)
CommandRecentFiles::CommandRecentFiles(IAppContext* context, QMenu* containerMenu)
: CommandRecentFiles(context)
{
QObject::connect(
containerMenu, &QMenu::aboutToShow,
this, &CommandRecentFiles::recreateEntries
);
QObject::connect(containerMenu, &QMenu::aboutToShow, this, &CommandRecentFiles::recreateEntries);
}

void CommandRecentFiles::execute()
Expand Down Expand Up @@ -434,13 +433,13 @@ void CommandExportSelectedApplicationItems::execute()

auto lastSettings = ImportExportSettings::load();
const QString strFilepath =
QFileDialog::getSaveFileName(
this->widgetMain(),
Command::tr("Select Output File"),
filepathTo<QString>(lastSettings.openDir),
listWriterFileFilter.join(QLatin1String(";;")),
&lastSettings.selectedFilter
);
QFileDialog::getSaveFileName(
this->widgetMain(),
Command::tr("Select Output File"),
filepathTo<QString>(lastSettings.openDir),
listWriterFileFilter.join(QLatin1String(";;")),
&lastSettings.selectedFilter
);
if (strFilepath.isEmpty())
return;

Expand All @@ -450,14 +449,14 @@ void CommandExportSelectedApplicationItems::execute()
QElapsedTimer chrono;
chrono.start();
const bool okExport =
appModule->ioSystem()->exportApplicationItems()
appModule->ioSystem()->exportApplicationItems()
.targetFile(filepathFrom(strFilepath))
.targetFormat(format)
.withItems(this->guiApp()->selectionModel()->selectedItems())
.withParameters(appModule->findWriterParameters(format))
.withMessenger(appModule)
.withTaskProgress(progress)
.execute();
.execute();
if (okExport)
appModule->emitInfo(fmt::format(Command::textIdTr("Export time: {}ms"), chrono.elapsed()));
});
Expand All @@ -483,8 +482,8 @@ CommandCloseCurrentDocument::CommandCloseCurrentDocument(IAppContext* context)
this->setAction(action);

QObject::connect(
context, &IAppContext::currentDocumentChanged,
this, &CommandCloseCurrentDocument::updateActionText
context, &IAppContext::currentDocumentChanged,
this, &CommandCloseCurrentDocument::updateActionText
);
this->app()->signalDocumentNameChanged.connectSlot([=](const DocumentPtr& doc) {
if (this->currentDocument() == doc->identifier())
Expand All @@ -509,9 +508,10 @@ void CommandCloseCurrentDocument::updateActionText(Document::Identifier docId)
DocumentPtr docPtr = this->app()->findDocumentByIdentifier(docId);
const QString docName = to_QString(docPtr ? docPtr->name() : std::string{});
const QString textActionClose =
docPtr ?
Command::tr("Close %1").arg(strFilepathQuoted(docName)) :
Command::tr("Close");
docPtr ?
Command::tr("Close %1").arg(strFilepathQuoted(docName)) :
Command::tr("Close")
;
this->action()->setText(textActionClose);
this->action()->setToolTip(textActionClose);
}
Expand Down Expand Up @@ -580,9 +580,10 @@ void CommandCloseAllDocumentsExceptCurrent::updateActionText(Document::Identifie
DocumentPtr docPtr = this->app()->findDocumentByIdentifier(docId);
const QString docName = to_QString(docPtr ? docPtr->name() : std::string{});
const QString textActionClose =
docPtr ?
Command::tr("Close all except %1").arg(strFilepathQuoted(docName)) :
Command::tr("Close all except current");
docPtr ?
Command::tr("Close all except %1").arg(strFilepathQuoted(docName)) :
Command::tr("Close all except current")
;
this->action()->setText(textActionClose);
}

Expand Down
8 changes: 2 additions & 6 deletions src/app/library_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,12 @@ std::vector<LibraryInfo>& getLibraryInfos()
} // namespace

void LibraryInfoArray::add(
std::string_view libName,
std::string_view version,
std::string_view versionDetails
std::string_view libName, std::string_view version, std::string_view versionDetails
)
{
if (!libName.empty() && !version.empty()) {
const LibraryInfo libInfo{
std::string(libName),
std::string(version),
std::string(versionDetails)
std::string{libName}, std::string{version}, std::string{versionDetails}
};
getLibraryInfos().push_back(std::move(libInfo));
}
Expand Down
4 changes: 1 addition & 3 deletions src/app/library_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ struct LibraryInfo {

struct LibraryInfoArray {
static void add(
std::string_view libName,
std::string_view version,
std::string_view versionDetails = ""
std::string_view libName, std::string_view version, std::string_view versionDetails = ""
);

static Span<const LibraryInfo> get();
Expand Down
2 changes: 1 addition & 1 deletion src/app/widget_gui_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ namespace Mayo {

class ButtonFlat;
class GuiDocument;
class IWidgetOccView;
class WidgetClipPlanes;
class WidgetExplodeAssembly;
class WidgetGrid;
class WidgetMeasure;
class IWidgetOccView;

class WidgetGuiDocument : public QWidget {
Q_OBJECT
Expand Down

0 comments on commit 8133107

Please sign in to comment.