Skip to content

Commit

Permalink
Merge pull request #189 from n7space/plugin-update-4.15.2-5.0.3
Browse files Browse the repository at this point in the history
plugin-update-4.15.2-5.0.3
  • Loading branch information
hcorg authored Mar 1, 2022
2 parents e6c71ba + a308cac commit 1a1dca2
Show file tree
Hide file tree
Showing 24 changed files with 131 additions and 105 deletions.
4 changes: 2 additions & 2 deletions Asn1Acn.json.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
\"Name\" : \"ASN.1/ACN\",
\"Version\" : \"4.15.2\",
\"CompatVersion\" : \"4.15.0\",
\"Version\" : \"5.0.3\",
\"CompatVersion\" : \"5.0.0\",
\"Vendor\" : \"N7 Space sp. z o.o.\",
\"Copyright\" : \"(C) 2017-2022 N7 Space sp. z o.o.\",
\"License\" : \"GPL v3.0\",
Expand Down
2 changes: 1 addition & 1 deletion src/asn1acnbuildstep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ void Asn1AcnBuildStep::updateProcess(const QString &command, const QString &arg)
{
auto *pp = processParameters();
Utils::CommandLine commandLine(command);
commandLine.addArg(arg);
commandLine.addArgs(arg, Utils::CommandLine::Raw);
pp->setCommandLine(commandLine);
}
19 changes: 13 additions & 6 deletions src/kitaspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ KitAspect::KitAspect()
{
setObjectName(QLatin1String("Asn1SccKitAspect"));
setId(KitAspect::id());
setDisplayName(tr("ASN1SCC:"));
setDisplayName(tr("ASN1SCC"));
setPriority(12000);
}

Expand Down Expand Up @@ -72,10 +72,19 @@ void KitAspect::setAsn1Exe(Kit *k, const Utils::FilePath &v)
QVariant KitAspect::defaultValue(const Kit *k) const
{
Q_UNUSED(k);
const QString path = Core::ICore::libexecPath() + QLatin1String("/asn1scc/asn1.exe");
const QString path = Core::ICore::libexecPath().toString() + QLatin1String("/asn1scc/asn1.exe");
return path;
}

void KitAspect::setup(Kit *k)
{
if (!k)
return;

if (!k->hasValue(id()))
k->setValue(id(), defaultValue(k));
}

ProjectExplorer::Tasks KitAspect::validate(const Kit *k) const
{
ProjectExplorer::Tasks result;
Expand Down Expand Up @@ -113,14 +122,12 @@ ProjectExplorer::KitAspectWidget *KitAspect::createConfigWidget(Kit *kit) const
return new KitAspectWidget(kit, this);
}

void KitAspect::addToEnvironment(const Kit *k, Utils::Environment &env) const
void KitAspect::addToBuildEnvironment(const Kit *k, Utils::Environment &env) const
{
env.set(QLatin1String("ASN1SCC"), asn1Exe(k).toUserOutput());
}

void KitAspect::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const
{
expander->registerFileVariables("Asn1Scc", tr("ASN1SCC Path"), [kit]() -> QString {
return asn1Exe(kit).toString();
});
expander->registerFileVariables("Asn1Scc", tr("ASN1SCC Path"), [kit] { return asn1Exe(kit); });
}
3 changes: 2 additions & 1 deletion src/kitaspect.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ class KitAspect : public ProjectExplorer::KitAspect
static Utils::FilePath asn1Exe(const Kit *k);
static void setAsn1Exe(Kit *k, const Utils::FilePath &v);

void setup(Kit *k) override;
ProjectExplorer::Tasks validate(const Kit *k) const override;

ItemList toUserOutput(const Kit *kit) const override;
ProjectExplorer::KitAspectWidget *createConfigWidget(Kit *kit) const override;

void addToEnvironment(const Kit *k, Utils::Environment &env) const override;
void addToBuildEnvironment(const Kit *k, Utils::Environment &env) const override;
void addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const override;

private:
Expand Down
15 changes: 6 additions & 9 deletions src/kitaspectwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "kitaspectwidget.h"
#include <utils/layoutbuilder.h>

#include "kitaspect.h"
#include "kitaspectwidget.h"

using namespace Asn1Acn::Internal;

KitAspectWidget::KitAspectWidget(ProjectExplorer::Kit *kit, const ProjectExplorer::KitAspect *ka)
: ProjectExplorer::KitAspectWidget(kit, ka)
, m_chooser(new Utils::PathChooser)
, m_chooser(createSubWidget<Utils::PathChooser>())
{
m_chooser->setToolTip(tr("Path to ASN1SCC executable."));
m_chooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
Expand Down Expand Up @@ -62,12 +63,8 @@ void KitAspectWidget::makeReadOnly()
m_chooser->setReadOnly(true);
}

QWidget *KitAspectWidget::mainWidget() const
{
return m_chooser->lineEdit();
}

QWidget *KitAspectWidget::buttonWidget() const
void KitAspectWidget::addToLayout(Utils::LayoutBuilder &builder)
{
return m_chooser->buttonAtIndex(0);
addMutableAction(m_chooser);
builder.addItem(Utils::Layouting::Span(2, m_chooser));
}
8 changes: 5 additions & 3 deletions src/kitaspectwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <projectexplorer/kitmanager.h>
#include <utils/pathchooser.h>

namespace Utils {
class LayoutBuilder;
}

namespace Asn1Acn {
namespace Internal {

Expand All @@ -40,11 +44,9 @@ class KitAspectWidget : public ProjectExplorer::KitAspectWidget
void makeReadOnly() override;
void refresh() override;

QWidget *mainWidget() const override;
QWidget *buttonWidget() const override;

private:
void pathWasChanged();
void addToLayout(Utils::LayoutBuilder &builder) override;

Utils::PathChooser *m_chooser;
bool m_ignoreChange = false;
Expand Down
27 changes: 14 additions & 13 deletions src/libraries/componentimporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ComponentImporter::ComponentImporter(ProjectExplorer::Project *project)
: m_project(project)
{}

void ComponentImporter::setFiles(const QStringList &files)
void ComponentImporter::setFiles(const Utils::FilePaths &files)
{
m_sourceFiles = files;
}
Expand All @@ -49,12 +49,12 @@ void ComponentImporter::setProject(ProjectExplorer::Project *project)
m_project = project;
}

const QStringList &ComponentImporter::sourceFiles() const
const Utils::FilePaths &ComponentImporter::sourceFiles() const
{
return m_sourceFiles;
}

const QStringList &ComponentImporter::importedFiles() const
const Utils::FilePaths &ComponentImporter::importedFiles() const
{
return m_importedFiles;
}
Expand All @@ -73,16 +73,17 @@ void ComponentImporter::import()
addFilesToProject(copied);
}

QStringList ComponentImporter::copyFilesToProject()
Utils::FilePaths ComponentImporter::copyFilesToProject()
{
QStringList copiedFiles;
Utils::FilePaths copiedFiles;

for (const auto &file : m_sourceFiles) {
QString target = targetFileName(file);
const QString filePath = file.path();
const QString target = targetFileName(filePath);

createTargetDir(m_targetDir, QFileInfo(target).absolutePath());
copyFile(file, target);
copiedFiles.append(target);
copyFile(filePath, target);
copiedFiles.append(Utils::FilePath::fromString(target));
}

return copiedFiles;
Expand Down Expand Up @@ -111,20 +112,20 @@ QString ComponentImporter::targetFileName(const QString &file)
return m_targetDir.filePath(relativeSrcPath);
}

void ComponentImporter::addFilesToProject(const QStringList &files)
void ComponentImporter::addFilesToProject(const Utils::FilePaths &files)
{
m_importedFiles = createUniqueFilesList(m_project, files);
m_project->rootProjectNode()->addFiles(m_importedFiles);
}

QStringList ComponentImporter::createUniqueFilesList(const ProjectExplorer::Project *project,
const QStringList &newFiles)
Utils::FilePaths ComponentImporter::createUniqueFilesList(const ProjectExplorer::Project *project,
const Utils::FilePaths &newFiles)
{
QStringList uniqueFiles;
Utils::FilePaths uniqueFiles;
const auto projectFiles = project->files(ProjectExplorer::Project::SourceFiles);

for (const auto &file : newFiles)
if (!projectFiles.contains(Utils::FilePath::fromString(file)))
if (!projectFiles.contains(file))
uniqueFiles.append(file);

return uniqueFiles;
Expand Down
21 changes: 11 additions & 10 deletions src/libraries/componentimporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

#include <QDir>
#include <QString>
#include <QStringList>

#include <utils/fileutils.h>

namespace ProjectExplorer {
class Project;
Expand All @@ -43,25 +44,25 @@ class ComponentImporter
ComponentImporter(ProjectExplorer::Project *project);

void setDirectory(const QString &path);
void setFiles(const QStringList &files);
void setFiles(const Utils::FilePaths &files);
void setProject(ProjectExplorer::Project *project);

const QStringList &sourceFiles() const;
const QStringList &importedFiles() const;
const Utils::FilePaths &sourceFiles() const;
const Utils::FilePaths &importedFiles() const;

void import();

private:
QStringList copyFilesToProject();
Utils::FilePaths copyFilesToProject();
void createTargetDir(QDir &parent, const QString &path);
QString targetFileName(const QString &file);
void addFilesToProject(const QStringList &files);
void addFilesToProject(const Utils::FilePaths &files);
void copyFile(const QString &source, const QString &target);
QStringList createUniqueFilesList(const ProjectExplorer::Project *project,
const QStringList &newFiles);
Utils::FilePaths createUniqueFilesList(const ProjectExplorer::Project *project,
const Utils::FilePaths &newFiles);

QStringList m_sourceFiles;
QStringList m_importedFiles;
Utils::FilePaths m_sourceFiles;
Utils::FilePaths m_importedFiles;

QDir m_sourceDir;
QDir m_targetDir;
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/wizard/componentselector.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#pragma once

#include <QModelIndex>
#include <QStringList>
#include <QTreeView>
#include <utils/fileutils.h>

namespace Asn1Acn {
namespace Internal {
Expand All @@ -44,7 +44,7 @@ class ComponentSelector : public QObject
{}

public:
virtual QStringList pathsToImport() = 0;
virtual Utils::FilePaths pathsToImport() = 0;
};

} // namespace Wizard
Expand Down
16 changes: 8 additions & 8 deletions src/libraries/wizard/filecomponentselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ FileComponentSelector::FileComponentSelector(FileModel *model,
, m_nameFilter(nameFilter)
{}

QStringList FileComponentSelector::pathsToImport()
Utils::FilePaths FileComponentSelector::pathsToImport()
{
return selectedPathsFromModelItem(m_model->rootPath());
}

QStringList FileComponentSelector::selectedPathsFromModelItem(const QString &parentPath) const
Utils::FilePaths FileComponentSelector::selectedPathsFromModelItem(const QString &parentPath) const
{
const auto parent = m_model->index(parentPath);

if (!parent.isValid())
return {};

QStringList paths;
Utils::FilePaths paths;
for (int i = 0; i < m_model->rowCount(parent); ++i)
for (int j = 0; j < m_model->columnCount(parent); ++j)
paths.append(pathsFromChildIndex(m_model->index(i, j, parent)));

return paths;
}

QStringList FileComponentSelector::pathsFromChildIndex(const QModelIndex &child) const
Utils::FilePaths FileComponentSelector::pathsFromChildIndex(const QModelIndex &child) const
{
const auto state = child.data(Qt::CheckStateRole);
if (state == Qt::Unchecked)
Expand All @@ -73,16 +73,16 @@ QStringList FileComponentSelector::pathsFromChildIndex(const QModelIndex &child)

QTC_ASSERT(state == Qt::Checked, return {});

return {m_model->filePath(child)};
return {Utils::FilePath::fromString(m_model->filePath(child))};
}

QStringList FileComponentSelector::selectedPathsFromFilesystemItem(const QString &path) const
Utils::FilePaths FileComponentSelector::selectedPathsFromFilesystemItem(const QString &path) const
{
QDirIterator it(path, m_nameFilter, QDir::Files, QDirIterator::Subdirectories);

QStringList paths;
Utils::FilePaths paths;
while (it.hasNext())
paths.append(it.next());
paths.append(Utils::FilePath::fromString(it.next()));

return paths;
}
8 changes: 4 additions & 4 deletions src/libraries/wizard/filecomponentselector.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ class FileComponentSelector : public ComponentSelector
public:
FileComponentSelector(FileModel *model, const QStringList nameFilter, QObject *parent = nullptr);

QStringList pathsToImport() override;
Utils::FilePaths pathsToImport() override;

private:
QStringList selectedPathsFromModelItem(const QString &parentPath) const;
QStringList pathsFromChildIndex(const QModelIndex &child) const;
Utils::FilePaths selectedPathsFromModelItem(const QString &parentPath) const;
Utils::FilePaths pathsFromChildIndex(const QModelIndex &child) const;

QStringList selectedPathsFromFilesystemItem(const QString &path) const;
Utils::FilePaths selectedPathsFromFilesystemItem(const QString &path) const;

FileModel *m_model;
const QStringList m_nameFilter;
Expand Down
Loading

0 comments on commit 1a1dca2

Please sign in to comment.