mirror of
https://github.com/leozide/leocad
synced 2024-12-27 21:58:37 +01:00
Merge branch 'leozide:master' into patch-1
This commit is contained in:
commit
758625674b
10 changed files with 273 additions and 89 deletions
65
.github/workflows/continuous.yml
vendored
Normal file
65
.github/workflows/continuous.yml
vendored
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
name: LeoCAD CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-ubuntu:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Install Qt
|
||||||
|
uses: jurplel/install-qt-action@v3
|
||||||
|
with:
|
||||||
|
cache: 'true'
|
||||||
|
- name: Get number of CPU cores
|
||||||
|
uses: SimenB/github-actions-cpu-cores@v1
|
||||||
|
id: cpu-cores
|
||||||
|
- name: Generate Makefile
|
||||||
|
run: qmake PREFIX=/usr
|
||||||
|
- name: Build
|
||||||
|
run: make -j ${{ steps.cpu-cores.outputs.count }}
|
||||||
|
|
||||||
|
build-macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Install Qt
|
||||||
|
uses: jurplel/install-qt-action@v3
|
||||||
|
with:
|
||||||
|
cache: 'true'
|
||||||
|
- name: Cache Library
|
||||||
|
uses: actions/cache@v3
|
||||||
|
id: cache-library
|
||||||
|
with:
|
||||||
|
path: library.bin
|
||||||
|
key: library-20.03
|
||||||
|
- name: Download Library
|
||||||
|
if: steps.cache-library.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
wget https://github.com/leozide/leocad/releases/download/v19.07.1/Library-20.03.zip -O library.zip
|
||||||
|
unzip library.zip
|
||||||
|
- name: Cache POV-Ray
|
||||||
|
uses: actions/cache@v3
|
||||||
|
id: cache-povray
|
||||||
|
with:
|
||||||
|
path: povray
|
||||||
|
key: povray-20.03
|
||||||
|
- name: Download POV-Ray
|
||||||
|
if: steps.cache-povray.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
wget https://github.com/leozide/povray/releases/download/continuous/povray
|
||||||
|
chmod +x povray
|
||||||
|
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/leozide/leocad/commits/master -o repo.txt
|
||||||
|
echo < repo.txt
|
||||||
|
echo export REMOTE=$(grep -Po '(?<=: \")(([a-z0-9])\w+)(?=\")' -m 1 repo.txt)
|
||||||
|
export REMOTE=$(grep -Po '(?<=: \")(([a-z0-9])\w+)(?=\")' -m 1 repo.txt)
|
||||||
|
echo $REMOTE
|
||||||
|
- name: Get number of CPU cores
|
||||||
|
uses: SimenB/github-actions-cpu-cores@v1
|
||||||
|
id: cpu-cores
|
||||||
|
- name: Generate Makefile
|
||||||
|
run: qmake PREFIX=/usr
|
||||||
|
- name: Build
|
||||||
|
run: make -j ${{ steps.cpu-cores.outputs.count }}
|
132
appveyor.yml
132
appveyor.yml
|
@ -1,48 +1,118 @@
|
||||||
version: '{branch}.{build}'
|
version: '{branch}.{build}'
|
||||||
skip_tags: true
|
skip_tags: true
|
||||||
image:
|
image:
|
||||||
|
- Ubuntu1604
|
||||||
|
- macos
|
||||||
- Visual Studio 2019
|
- Visual Studio 2019
|
||||||
configuration: Release
|
configuration: Release
|
||||||
platform: x64
|
platform: x64
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
GITHUB_TOKEN:
|
GITHUB_TOKEN:
|
||||||
secure: p5KEQtln6gMUfQLCkLsHUOhADIxPFjH8WICuY9pZeni1S1Es1XRGz7+OoFZKj8Ev
|
secure: ZaApxtWM3JA1AdJqs2pv+BCE5XIUrrVKXNy05q8f6f4zRZ7H/lMEJ6gZ1o2yp6NT
|
||||||
|
|
||||||
before_build:
|
for:
|
||||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
|
-
|
||||||
- set PATH=C:\Qt\5.15\msvc2019_64\bin;%PATH%
|
matrix:
|
||||||
- git rev-parse --short HEAD > version.txt
|
only:
|
||||||
- set /p VERSION= < version.txt
|
- image: Visual Studio 2019
|
||||||
- qmake -v
|
|
||||||
- qmake -tp vc
|
|
||||||
|
|
||||||
build:
|
before_build:
|
||||||
|
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
|
- set PATH=C:\Qt\5.15\msvc2019_64\bin;%PATH%
|
||||||
|
- git rev-parse --short HEAD > version.txt
|
||||||
|
- set /p VERSION= < version.txt
|
||||||
|
- qmake -v
|
||||||
|
- qmake -tp vc
|
||||||
|
|
||||||
|
build:
|
||||||
project: leocad.vcxproj
|
project: leocad.vcxproj
|
||||||
verbosity: minimal
|
verbosity: minimal
|
||||||
|
|
||||||
after_build:
|
after_build:
|
||||||
- 7z a symbols.zip build/release/leocad.exe build/release/leocad.pdb
|
- 7z a symbols.zip build/release/leocad.exe build/release/leocad.pdb
|
||||||
- mkdir appdir
|
- mkdir appdir
|
||||||
- copy build\release\leocad.exe appdir
|
- copy build\release\leocad.exe appdir
|
||||||
- copy docs\readme.md appdir\readme.txt
|
- copy docs\readme.md appdir\readme.txt
|
||||||
- appveyor DownloadFile https://github.com/leozide/leocad/releases/download/v19.07.1/Library-20.03.zip -FileName library.zip
|
- appveyor DownloadFile https://github.com/leozide/leocad/releases/download/v19.07.1/Library-20.03.zip -FileName library.zip
|
||||||
- 7z e library.zip
|
- 7z e library.zip
|
||||||
- copy library.bin appdir\\library.bin
|
- copy library.bin appdir\\library.bin
|
||||||
- appveyor DownloadFile https://github.com/leozide/povray/releases/download/continuous/povconsole32-sse2.exe -FileName appdir\povconsole32-sse2.exe
|
- appveyor DownloadFile https://github.com/leozide/povray/releases/download/continuous/povconsole32-sse2.exe -FileName appdir\povconsole32-sse2.exe
|
||||||
- windeployqt appdir\leocad.exe
|
- windeployqt appdir\leocad.exe
|
||||||
- copy tools\setup\leocad.nsi .
|
- copy tools\setup\leocad.nsi .
|
||||||
- copy tools\setup\setup.ico .
|
- copy tools\setup\setup.ico .
|
||||||
- 'copy "%VCToolsRedistDir%\vcredist_x64.exe" appdir'
|
- 'copy "%VCToolsRedistDir%\vcredist_x64.exe" appdir'
|
||||||
- '"C:\Program Files (x86)\NSIS\makensis.exe" /V4 /DX64 "/XOutFile LeoCAD-Windows-%VERSION%.exe" leocad.nsi'
|
- '"C:\Program Files (x86)\NSIS\makensis.exe" /V4 /DX64 "/XOutFile LeoCAD-Windows-%VERSION%.exe" leocad.nsi'
|
||||||
- set TRAVIS_TAG=%APPVEYOR_REPO_TAG_NAME%
|
- set TRAVIS_TAG=%APPVEYOR_REPO_TAG_NAME%
|
||||||
- set TRAVIS_REPO_SLUG=%APPVEYOR_REPO_NAME%
|
- set TRAVIS_REPO_SLUG=%APPVEYOR_REPO_NAME%
|
||||||
- set TRAVIS_COMMIT=%APPVEYOR_REPO_COMMIT%
|
- set TRAVIS_COMMIT=%APPVEYOR_REPO_COMMIT%
|
||||||
- appveyor DownloadFile https://github.com/probonopd/uploadtool/raw/master/upload.sh
|
- appveyor DownloadFile https://github.com/probonopd/uploadtool/raw/master/upload.sh
|
||||||
- if not defined APPVEYOR_PULL_REQUEST_NUMBER (bash upload.sh LeoCAD*.exe)
|
- if not defined APPVEYOR_PULL_REQUEST_NUMBER (bash upload.sh LeoCAD*.exe)
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: symbols.zip
|
- path: symbols.zip
|
||||||
name: symbols
|
name: symbols
|
||||||
- path: LeoCAD-Windows-$(VERSION).exe
|
- path: LeoCAD-Windows-$(VERSION).exe
|
||||||
name: leocad
|
name: leocad
|
||||||
|
|
||||||
|
-
|
||||||
|
matrix:
|
||||||
|
only:
|
||||||
|
- image: Ubuntu1604
|
||||||
|
|
||||||
|
install:
|
||||||
|
- sudo apt-get -y install libqt5opengl5-dev
|
||||||
|
|
||||||
|
before_build:
|
||||||
|
- export PATH=$HOME/Qt/5.15/gcc_64/bin:$PATH
|
||||||
|
- export TRAVIS_TAG=$APPVEYOR_REPO_TAG_NAME
|
||||||
|
- export TRAVIS_REPO_SLUG=$APPVEYOR_REPO_NAME
|
||||||
|
- export TRAVIS_COMMIT=$APPVEYOR_REPO_COMMIT
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- qmake PREFIX=/usr
|
||||||
|
- make
|
||||||
|
|
||||||
|
after_build:
|
||||||
|
- cp build/release/leocad .
|
||||||
|
- export VERSION=$(git rev-parse --short HEAD)
|
||||||
|
- zip LeoCAD-Linux-$VERSION-arm64.zip leocad
|
||||||
|
- 'curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/leozide/leocad/commits/master -o repo.txt'
|
||||||
|
- 'export REMOTE=$(grep -Po ''(?<=: \")(([a-z0-9])\w+)(?=\")'' -m 1 repo.txt)'
|
||||||
|
- export LOCAL=$(git rev-parse HEAD)
|
||||||
|
- if [[ "$REMOTE" != "$LOCAL" ]]; then echo "Build no longer current. $REMOTE vs $LOCAL - aborting upload."; travis_terminate 0; fi;
|
||||||
|
- appveyor DownloadFile https://github.com/probonopd/uploadtool/raw/master/upload.sh
|
||||||
|
- bash upload.sh LeoCAD*.zip
|
||||||
|
|
||||||
|
-
|
||||||
|
matrix:
|
||||||
|
only:
|
||||||
|
- image: macos
|
||||||
|
|
||||||
|
install:
|
||||||
|
- brew install grep
|
||||||
|
|
||||||
|
before_build:
|
||||||
|
- export PATH=$HOME/Qt/5.15/clang_64/bin:$PATH
|
||||||
|
- export TRAVIS_TAG=$APPVEYOR_REPO_TAG_NAME
|
||||||
|
- export TRAVIS_REPO_SLUG=$APPVEYOR_REPO_NAME
|
||||||
|
- export TRAVIS_COMMIT=$APPVEYOR_REPO_COMMIT
|
||||||
|
- appveyor DownloadFile https://github.com/leozide/povray/releases/download/continuous/povray
|
||||||
|
- chmod +x povray
|
||||||
|
- appveyor DownloadFile https://github.com/leozide/leocad/releases/download/v19.07.1/Library-20.03.zip -FileName library.zip
|
||||||
|
- unzip library.zip
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- qmake PREFIX=/usr
|
||||||
|
- make
|
||||||
|
|
||||||
|
after_build:
|
||||||
|
- cd build/release
|
||||||
|
- macdeployqt LeoCAD.app -dmg
|
||||||
|
- mv LeoCAD.dmg LeoCAD-macOS-$(git rev-parse --short HEAD).dmg
|
||||||
|
- 'curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/leozide/leocad/commits/master -o repo.txt'
|
||||||
|
- 'export REMOTE=$(ggrep -Po ''(?<=: \")(([a-z0-9])\w+)(?=\")'' -m 1 repo.txt)'
|
||||||
|
- export LOCAL=$(git rev-parse HEAD)
|
||||||
|
- if [[ "$REMOTE" != "$LOCAL" ]]; then echo "Build no longer current. $REMOTE vs $LOCAL - aborting upload."; exit 0; fi;
|
||||||
|
- appveyor DownloadFile https://github.com/probonopd/uploadtool/raw/master/upload.sh
|
||||||
|
- bash upload.sh LeoCAD*.dmg*
|
||||||
|
|
|
@ -354,20 +354,6 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||||
|
|
||||||
lcCommandLineOptions Options;
|
lcCommandLineOptions Options;
|
||||||
|
|
||||||
Options.ParseOK = true;
|
|
||||||
Options.Exit = false;
|
|
||||||
Options.SaveImage = false;
|
|
||||||
Options.SaveWavefront = false;
|
|
||||||
Options.Save3DS = false;
|
|
||||||
Options.SaveCOLLADA = false;
|
|
||||||
Options.SaveHTML = false;
|
|
||||||
Options.SetCameraAngles = false;
|
|
||||||
Options.SetCameraPosition = false;
|
|
||||||
Options.Orthographic = false;
|
|
||||||
Options.SetFoV = false;
|
|
||||||
Options.SetZPlanes = false;
|
|
||||||
Options.SetFadeStepsColor = false;
|
|
||||||
Options.SetHighlightColor = false;
|
|
||||||
Options.FadeSteps = Preferences.mFadeSteps;
|
Options.FadeSteps = Preferences.mFadeSteps;
|
||||||
Options.ImageHighlight = Preferences.mHighlightNewParts;
|
Options.ImageHighlight = Preferences.mHighlightNewParts;
|
||||||
Options.ImageWidth = lcGetProfileInt(LC_PROFILE_IMAGE_WIDTH);
|
Options.ImageWidth = lcGetProfileInt(LC_PROFILE_IMAGE_WIDTH);
|
||||||
|
@ -788,6 +774,11 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||||
Options.SaveCOLLADA = true;
|
Options.SaveCOLLADA = true;
|
||||||
ParseString(Options.SaveCOLLADAName, false);
|
ParseString(Options.SaveCOLLADAName, false);
|
||||||
}
|
}
|
||||||
|
else if (Option == QLatin1String("-csv") || Option == QLatin1String("--export-csv"))
|
||||||
|
{
|
||||||
|
Options.SaveCSV = true;
|
||||||
|
ParseString(Options.SaveCSVName, false);
|
||||||
|
}
|
||||||
else if (Option == QLatin1String("-html") || Option == QLatin1String("--export-html"))
|
else if (Option == QLatin1String("-html") || Option == QLatin1String("--export-html"))
|
||||||
{
|
{
|
||||||
Options.SaveHTML = true;
|
Options.SaveHTML = true;
|
||||||
|
@ -842,6 +833,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||||
Options.StdOut += tr(" -obj, --export-wavefront <outfile.obj>: Export the model to Wavefront OBJ format.\n");
|
Options.StdOut += tr(" -obj, --export-wavefront <outfile.obj>: Export the model to Wavefront OBJ format.\n");
|
||||||
Options.StdOut += tr(" -3ds, --export-3ds <outfile.3ds>: Export the model to 3D Studio 3DS format.\n");
|
Options.StdOut += tr(" -3ds, --export-3ds <outfile.3ds>: Export the model to 3D Studio 3DS format.\n");
|
||||||
Options.StdOut += tr(" -dae, --export-collada <outfile.dae>: Export the model to COLLADA DAE format.\n");
|
Options.StdOut += tr(" -dae, --export-collada <outfile.dae>: Export the model to COLLADA DAE format.\n");
|
||||||
|
Options.StdOut += tr(" -csv, --export-csv <outfile.csv>: Export the list of parts used in csv format.\n");
|
||||||
Options.StdOut += tr(" -html, --export-html <folder>: Create an HTML page for the model.\n");
|
Options.StdOut += tr(" -html, --export-html <folder>: Create an HTML page for the model.\n");
|
||||||
Options.StdOut += tr(" -v, --version: Output version information and exit.\n");
|
Options.StdOut += tr(" -v, --version: Output version information and exit.\n");
|
||||||
Options.StdOut += tr(" -?, --help: Display this help message and exit.\n");
|
Options.StdOut += tr(" -?, --help: Display this help message and exit.\n");
|
||||||
|
@ -888,7 +880,7 @@ lcCommandLineOptions lcApplication::ParseCommandLineOptions()
|
||||||
Options.StdErr += tr("--camera-position is ignored when --camera-angles is set.\n");
|
Options.StdErr += tr("--camera-position is ignored when --camera-angles is set.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool SaveAndExit = (Options.SaveImage || Options.SaveWavefront || Options.Save3DS || Options.SaveCOLLADA || Options.SaveHTML);
|
const bool SaveAndExit = (Options.SaveImage || Options.SaveWavefront || Options.Save3DS || Options.SaveCOLLADA || Options.SaveCSV || Options.SaveHTML);
|
||||||
|
|
||||||
if (SaveAndExit && Options.ProjectName.isEmpty())
|
if (SaveAndExit && Options.ProjectName.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -929,7 +921,7 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
|
||||||
return lcStartupMode::Error;
|
return lcStartupMode::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool SaveAndExit = (Options.SaveImage || Options.SaveWavefront || Options.Save3DS || Options.SaveCOLLADA || Options.SaveHTML);
|
const bool SaveAndExit = (Options.SaveImage || Options.SaveWavefront || Options.Save3DS || Options.SaveCOLLADA || Options.SaveCSV || Options.SaveHTML);
|
||||||
|
|
||||||
if (!SaveAndExit)
|
if (!SaveAndExit)
|
||||||
{
|
{
|
||||||
|
@ -1191,6 +1183,31 @@ lcStartupMode lcApplication::Initialize(const QList<QPair<QString, bool>>& Libra
|
||||||
StdOut << tr("Saved '%1'.\n").arg(FileName);
|
StdOut << tr("Saved '%1'.\n").arg(FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Options.SaveCSV)
|
||||||
|
{
|
||||||
|
QString FileName;
|
||||||
|
|
||||||
|
if (!Options.SaveCSVName.isEmpty())
|
||||||
|
FileName = Options.SaveCSVName;
|
||||||
|
else
|
||||||
|
FileName = Options.ProjectName;
|
||||||
|
|
||||||
|
QString Extension = QFileInfo(FileName).suffix().toLower();
|
||||||
|
|
||||||
|
if (Extension.isEmpty())
|
||||||
|
{
|
||||||
|
FileName += ".csv";
|
||||||
|
}
|
||||||
|
else if (Extension != "csv")
|
||||||
|
{
|
||||||
|
FileName = FileName.left(FileName.length() - Extension.length() - 1);
|
||||||
|
FileName += ".csv";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mProject->ExportCSV(FileName))
|
||||||
|
StdOut << tr("Saved '%1'.\n").arg(FileName);
|
||||||
|
}
|
||||||
|
|
||||||
if (Options.SaveHTML)
|
if (Options.SaveHTML)
|
||||||
{
|
{
|
||||||
lcHTMLExportOptions HTMLOptions(mProject);
|
lcHTMLExportOptions HTMLOptions(mProject);
|
||||||
|
|
|
@ -101,23 +101,24 @@ public:
|
||||||
|
|
||||||
struct lcCommandLineOptions
|
struct lcCommandLineOptions
|
||||||
{
|
{
|
||||||
bool ParseOK;
|
bool ParseOK = true;
|
||||||
bool Exit;
|
bool Exit = false;
|
||||||
bool SaveImage;
|
bool SaveImage = false;
|
||||||
bool SaveWavefront;
|
bool SaveWavefront = false;
|
||||||
bool Save3DS;
|
bool Save3DS = false;
|
||||||
bool SaveCOLLADA;
|
bool SaveCOLLADA = false;
|
||||||
bool SaveHTML;
|
bool SaveCSV = false;
|
||||||
bool SetCameraAngles;
|
bool SaveHTML = false;
|
||||||
bool SetCameraPosition;
|
bool SetCameraAngles = false;
|
||||||
bool Orthographic;
|
bool SetCameraPosition = false;
|
||||||
bool SetFoV;
|
bool Orthographic = false;
|
||||||
bool SetZPlanes;
|
bool SetFoV = false;
|
||||||
bool SetFadeStepsColor;
|
bool SetZPlanes = false;
|
||||||
bool SetHighlightColor;
|
bool SetFadeStepsColor = false;
|
||||||
bool FadeSteps;
|
bool SetHighlightColor = false;
|
||||||
bool ImageHighlight;
|
bool FadeSteps = false;
|
||||||
bool AutomateEdgeColor;
|
bool ImageHighlight = false;
|
||||||
|
bool AutomateEdgeColor = false;
|
||||||
int ImageWidth;
|
int ImageWidth;
|
||||||
int ImageHeight;
|
int ImageHeight;
|
||||||
int AASamples;
|
int AASamples;
|
||||||
|
@ -146,6 +147,7 @@ struct lcCommandLineOptions
|
||||||
QString SaveWavefrontName;
|
QString SaveWavefrontName;
|
||||||
QString Save3DSName;
|
QString Save3DSName;
|
||||||
QString SaveCOLLADAName;
|
QString SaveCOLLADAName;
|
||||||
|
QString SaveCSVName;
|
||||||
QString SaveHTMLName;
|
QString SaveHTMLName;
|
||||||
QList<QPair<QString, bool>> LibraryPaths;
|
QList<QPair<QString, bool>> LibraryPaths;
|
||||||
QString StdOut;
|
QString StdOut;
|
||||||
|
|
|
@ -250,4 +250,7 @@ void lcInstructions::AddDefaultPages(lcModel* Model, std::vector<const lcModel*>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Page.Steps.empty())
|
||||||
|
mPages.emplace_back(std::move(Page));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2590,7 +2590,7 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_FILE_EXPORT_CSV:
|
case LC_FILE_EXPORT_CSV:
|
||||||
lcGetActiveProject()->ExportCSV();
|
lcGetActiveProject()->ExportCSV(QString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LC_FILE_EXPORT_POVRAY:
|
case LC_FILE_EXPORT_POVRAY:
|
||||||
|
|
|
@ -1428,7 +1428,7 @@ bool Project::ExportCOLLADA(const QString& FileName)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::ExportCSV()
|
bool Project::ExportCSV(const QString& FileName)
|
||||||
{
|
{
|
||||||
lcPartsList PartsList;
|
lcPartsList PartsList;
|
||||||
|
|
||||||
|
@ -1438,13 +1438,13 @@ void Project::ExportCSV()
|
||||||
if (PartsList.empty())
|
if (PartsList.empty())
|
||||||
{
|
{
|
||||||
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to export."));
|
QMessageBox::information(gMainWindow, tr("LeoCAD"), tr("Nothing to export."));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SaveFileName = GetExportFileName(QString(), "csv", tr("Export CSV"), tr("CSV Files (*.csv);;All Files (*.*)"));
|
QString SaveFileName = GetExportFileName(FileName, "csv", tr("Export CSV"), tr("CSV Files (*.csv);;All Files (*.*)"));
|
||||||
|
|
||||||
if (SaveFileName.isEmpty())
|
if (SaveFileName.isEmpty())
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
lcDiskFile CSVFile(SaveFileName);
|
lcDiskFile CSVFile(SaveFileName);
|
||||||
char Line[1024];
|
char Line[1024];
|
||||||
|
@ -1452,7 +1452,7 @@ void Project::ExportCSV()
|
||||||
if (!CSVFile.Open(QIODevice::WriteOnly))
|
if (!CSVFile.Open(QIODevice::WriteOnly))
|
||||||
{
|
{
|
||||||
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Could not open file '%1' for writing.").arg(SaveFileName));
|
QMessageBox::warning(gMainWindow, tr("LeoCAD"), tr("Could not open file '%1' for writing.").arg(SaveFileName));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVFile.WriteLine("Part Name,Color,Quantity,Part ID,Color Code\n");
|
CSVFile.WriteLine("Part Name,Color,Quantity,Part ID,Color Code\n");
|
||||||
|
@ -1463,10 +1463,15 @@ void Project::ExportCSV()
|
||||||
|
|
||||||
for (const auto& ColorIt : PartIt.second)
|
for (const auto& ColorIt : PartIt.second)
|
||||||
{
|
{
|
||||||
sprintf(Line, "\"%s\",\"%s\",%d,%s,%d\n", Info->m_strDescription, gColorList[ColorIt.first].Name, ColorIt.second, Info->mFileName, gColorList[ColorIt.first].Code);
|
std::string Description = Info->m_strDescription;
|
||||||
|
Description.erase(std::remove(Description.begin(), Description.end(), ','), Description.end());
|
||||||
|
|
||||||
|
sprintf(Line, "\"%s\",\"%s\",%d,%s,%d\n", Description.c_str(), gColorList[ColorIt.first].Name, ColorIt.second, Info->mFileName, gColorList[ColorIt.first].Code);
|
||||||
CSVFile.WriteLine(Line);
|
CSVFile.WriteLine(Line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
lcInstructions* Project::GetInstructions()
|
lcInstructions* Project::GetInstructions()
|
||||||
|
|
|
@ -93,7 +93,7 @@ public:
|
||||||
bool Export3DStudio(const QString& FileName);
|
bool Export3DStudio(const QString& FileName);
|
||||||
void ExportBrickLink();
|
void ExportBrickLink();
|
||||||
bool ExportCOLLADA(const QString& FileName);
|
bool ExportCOLLADA(const QString& FileName);
|
||||||
void ExportCSV();
|
bool ExportCSV(const QString& FileName);
|
||||||
void ExportHTML(const lcHTMLExportOptions& Options);
|
void ExportHTML(const lcHTMLExportOptions& Options);
|
||||||
bool ExportPOVRay(const QString& FileName);
|
bool ExportPOVRay(const QString& FileName);
|
||||||
bool ExportWavefront(const QString& FileName);
|
bool ExportWavefront(const QString& FileName);
|
||||||
|
|
|
@ -47,40 +47,56 @@ float lcParseValueLocalized(const QString& Value)
|
||||||
|
|
||||||
// Resize all columns to content except for one stretching column. (taken from QT creator)
|
// Resize all columns to content except for one stretching column. (taken from QT creator)
|
||||||
lcQTreeWidgetColumnStretcher::lcQTreeWidgetColumnStretcher(QTreeWidget *treeWidget, int columnToStretch)
|
lcQTreeWidgetColumnStretcher::lcQTreeWidgetColumnStretcher(QTreeWidget *treeWidget, int columnToStretch)
|
||||||
: QObject(treeWidget->header()), m_columnToStretch(columnToStretch)
|
: QObject(treeWidget->header()), m_columnToStretch(columnToStretch), m_interactiveResize(false), m_stretchWidth(0)
|
||||||
{
|
{
|
||||||
parent()->installEventFilter(this);
|
parent()->installEventFilter(this);
|
||||||
|
connect(treeWidget->header(), SIGNAL(sectionResized(int, int, int)), SLOT(sectionResized(int, int, int)));
|
||||||
QHideEvent fake;
|
QHideEvent fake;
|
||||||
lcQTreeWidgetColumnStretcher::eventFilter(parent(), &fake);
|
lcQTreeWidgetColumnStretcher::eventFilter(parent(), &fake);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcQTreeWidgetColumnStretcher::sectionResized(int LogicalIndex, int OldSize, int NewSize)
|
||||||
|
{
|
||||||
|
Q_UNUSED(OldSize)
|
||||||
|
|
||||||
|
if (LogicalIndex == m_columnToStretch)
|
||||||
|
{
|
||||||
|
QHeaderView* HeaderView = qobject_cast<QHeaderView*>(parent());
|
||||||
|
|
||||||
|
if (HeaderView->isVisible())
|
||||||
|
m_interactiveResize = true;
|
||||||
|
|
||||||
|
m_stretchWidth = NewSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool lcQTreeWidgetColumnStretcher::eventFilter(QObject* Object, QEvent* Event)
|
bool lcQTreeWidgetColumnStretcher::eventFilter(QObject* Object, QEvent* Event)
|
||||||
{
|
{
|
||||||
if (Object == parent())
|
if (Object == parent())
|
||||||
{
|
|
||||||
if (Event->type() == QEvent::Show)
|
|
||||||
{
|
{
|
||||||
QHeaderView* HeaderView = qobject_cast<QHeaderView*>(Object);
|
QHeaderView* HeaderView = qobject_cast<QHeaderView*>(Object);
|
||||||
|
|
||||||
|
if (Event->type() == QEvent::Show)
|
||||||
|
{
|
||||||
for (int i = 0; i < HeaderView->count(); ++i)
|
for (int i = 0; i < HeaderView->count(); ++i)
|
||||||
HeaderView->setSectionResizeMode(i, QHeaderView::Interactive);
|
HeaderView->setSectionResizeMode(i, QHeaderView::Interactive);
|
||||||
|
|
||||||
|
m_stretchWidth = HeaderView->sectionSize(m_columnToStretch);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (Event->type() == QEvent::Hide)
|
else if (Event->type() == QEvent::Hide)
|
||||||
{
|
{
|
||||||
QHeaderView* HeaderView = qobject_cast<QHeaderView*>(Object);
|
if (!m_interactiveResize)
|
||||||
|
|
||||||
for (int i = 0; i < HeaderView->count(); ++i)
|
for (int i = 0; i < HeaderView->count(); ++i)
|
||||||
HeaderView->setSectionResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents);
|
HeaderView->setSectionResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents);
|
||||||
}
|
}
|
||||||
else if (Event->type() == QEvent::Resize)
|
else if (Event->type() == QEvent::Resize)
|
||||||
{
|
{
|
||||||
QHeaderView* HeaderView = qobject_cast<QHeaderView*>(Object);
|
if (HeaderView->sectionResizeMode(m_columnToStretch) == QHeaderView::Interactive) {
|
||||||
|
|
||||||
if (HeaderView->sectionResizeMode(m_columnToStretch) == QHeaderView::Interactive)
|
const int StretchWidth = HeaderView->isVisible() ? m_stretchWidth : 32;
|
||||||
{
|
|
||||||
const QResizeEvent* ResizeEvent = reinterpret_cast<QResizeEvent*>(Event);
|
HeaderView->resizeSection(m_columnToStretch, StretchWidth);
|
||||||
const int Diff = ResizeEvent->size().width() - ResizeEvent->oldSize().width() ;
|
|
||||||
HeaderView->resizeSection(m_columnToStretch, qMax(32, HeaderView->sectionSize(1) + Diff));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,13 @@ public:
|
||||||
|
|
||||||
bool eventFilter(QObject* Object, QEvent* Event) override;
|
bool eventFilter(QObject* Object, QEvent* Event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void sectionResized(int LogicalIndex, int OldSize, int NewSize);
|
||||||
|
|
||||||
|
private:
|
||||||
const int m_columnToStretch;
|
const int m_columnToStretch;
|
||||||
|
bool m_interactiveResize;
|
||||||
|
int m_stretchWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
class lcSmallLineEdit : public QLineEdit
|
class lcSmallLineEdit : public QLineEdit
|
||||||
|
|
Loading…
Reference in a new issue