Assembly: Implement Bill Of Materials (#14198)
* Assembly: Implementation of BOM * Assembly: BOM: make it possible for BOM to be made without an assembly.
This commit is contained in:
@@ -516,6 +516,11 @@ App::Range Sheet::getRange(const char* name, bool silent) const
|
||||
return cells.getRange(name, silent);
|
||||
}
|
||||
|
||||
std::tuple<App::CellAddress, App::CellAddress> Sheet::getUsedRange() const
|
||||
{
|
||||
return cells.getUsedRange();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a map with column indices and widths.
|
||||
* @return Map with results.
|
||||
|
||||
@@ -199,6 +199,8 @@ public:
|
||||
|
||||
App::Range getRange(const char* name, bool silent = false) const;
|
||||
|
||||
std::tuple<App::CellAddress, App::CellAddress> getUsedRange() const;
|
||||
|
||||
std::map<int, int> getColumnWidths() const;
|
||||
|
||||
std::map<int, int> getRowHeights() const;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "PropertiesDialog.h"
|
||||
#include "SpreadsheetView.h"
|
||||
#include "ViewProviderSpreadsheet.h"
|
||||
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@@ -250,27 +251,10 @@ void CmdSpreadsheetExport::activated(int iMsg)
|
||||
|
||||
if (sheetView) {
|
||||
Sheet* sheet = sheetView->getSheet();
|
||||
QString selectedFilter;
|
||||
QString formatList = QObject::tr("CSV (*.csv *.CSV);;All (*)");
|
||||
QString fileName = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(),
|
||||
QObject::tr("Export file"),
|
||||
QString(),
|
||||
formatList,
|
||||
&selectedFilter);
|
||||
if (!fileName.isEmpty()) {
|
||||
if (sheet) {
|
||||
char delim, quote, escape;
|
||||
std::string errMsg = "Export";
|
||||
bool isValid = sheet->getCharsFromPrefs(delim, quote, escape, errMsg);
|
||||
|
||||
if (isValid) {
|
||||
sheet->exportToFile(fileName.toStdString(), delim, quote, escape);
|
||||
}
|
||||
else {
|
||||
Base::Console().Error(errMsg.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(sheet);
|
||||
auto* vps = dynamic_cast<ViewProviderSheet*>(vp);
|
||||
if (vps) {
|
||||
vps->exportAsFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/FileDialog.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Mod/Spreadsheet/App/Sheet.h>
|
||||
@@ -102,11 +103,7 @@ QIcon ViewProviderSheet::getIcon() const
|
||||
bool ViewProviderSheet::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
if (!this->view) {
|
||||
showSpreadsheetView();
|
||||
view->viewAll();
|
||||
}
|
||||
Gui::getMainWindow()->setActiveWindow(this->view);
|
||||
showSheetMdi();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -123,12 +120,44 @@ bool ViewProviderSheet::doubleClicked()
|
||||
Gui::Command::assureWorkbench("SpreadsheetWorkbench");
|
||||
}
|
||||
|
||||
showSheetMdi();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderSheet::showSheetMdi()
|
||||
{
|
||||
if (!this->view) {
|
||||
showSpreadsheetView();
|
||||
view->viewAll();
|
||||
}
|
||||
Gui::getMainWindow()->setActiveWindow(this->view);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderSheet::exportAsFile()
|
||||
{
|
||||
auto* sheet = static_cast<Spreadsheet::Sheet*>(getObject());
|
||||
QString selectedFilter;
|
||||
QString formatList = QObject::tr("CSV (*.csv *.CSV);;All (*)");
|
||||
QString fileName = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(),
|
||||
QObject::tr("Export file"),
|
||||
QString(),
|
||||
formatList,
|
||||
&selectedFilter);
|
||||
if (!fileName.isEmpty()) {
|
||||
if (sheet) {
|
||||
char delim, quote, escape;
|
||||
std::string errMsg = "Export";
|
||||
bool isValid = sheet->getCharsFromPrefs(delim, quote, escape, errMsg);
|
||||
|
||||
if (isValid) {
|
||||
sheet->exportToFile(fileName.toStdString(), delim, quote, escape);
|
||||
}
|
||||
else {
|
||||
Base::Console().Error(errMsg.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderSheet::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
|
||||
@@ -78,6 +78,10 @@ public:
|
||||
|
||||
PyObject* getPyObject() override;
|
||||
|
||||
void showSheetMdi();
|
||||
|
||||
void exportAsFile();
|
||||
|
||||
protected:
|
||||
SheetView* showSpreadsheetView();
|
||||
void updateData(const App::Property* prop) override;
|
||||
|
||||
@@ -20,5 +20,27 @@
|
||||
<UserDocu>Get access to the sheet view</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="showSheetMdi">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Create (if necessary) and switch to the Spreadsheet MDI.
|
||||
|
||||
showSheetMdi()
|
||||
|
||||
Returns: None
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="exportAsFile">
|
||||
<Documentation>
|
||||
<UserDocu>
|
||||
Export the sheet as a file.
|
||||
|
||||
exportAsFile()
|
||||
|
||||
Returns: None
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -59,3 +59,21 @@ int ViewProviderSpreadsheetPy::setCustomAttributes(const char* /*attr*/, PyObjec
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderSpreadsheetPy::showSheetMdi(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
this->getViewProviderSheetPtr()->showSheetMdi();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderSpreadsheetPy::exportAsFile(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
this->getViewProviderSheetPtr()->exportAsFile();
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user