Sheet: Apply clang format
This commit is contained in:
@@ -24,18 +24,18 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <qobject.h>
|
||||
# include <QToolBar>
|
||||
#include <QToolBar>
|
||||
#include <qobject.h>
|
||||
#endif
|
||||
|
||||
#include "Mod/Spreadsheet/App/Sheet.h"
|
||||
#include "Mod/Spreadsheet/Gui/SpreadsheetView.h"
|
||||
#include <App/Range.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/MenuManager.h>
|
||||
#include <Gui/ToolBarManager.h>
|
||||
#include "Mod/Spreadsheet/App/Sheet.h"
|
||||
#include "Mod/Spreadsheet/Gui/SpreadsheetView.h"
|
||||
|
||||
#include "Workbench.h"
|
||||
#include "qtcolorpicker.h"
|
||||
@@ -46,7 +46,7 @@ using namespace App;
|
||||
using namespace SpreadsheetGui;
|
||||
using namespace Spreadsheet;
|
||||
|
||||
#if 0 // needed for Qt's lupdate utility
|
||||
#if 0// needed for Qt's lupdate utility
|
||||
qApp->translate("Workbench", "Spreadsheet");
|
||||
qApp->translate("Workbench", "&Spreadsheet");
|
||||
qApp->translate("Workbench", "&Alignment");
|
||||
@@ -60,49 +60,61 @@ Workbench::Workbench()
|
||||
: Gui::StdWorkbench()
|
||||
, initialized(false)
|
||||
, workbenchHelper(new WorkbenchHelper)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
Workbench::~Workbench() = default;
|
||||
|
||||
void Workbench::activated()
|
||||
{
|
||||
if (!initialized) {
|
||||
QList<QToolBar*> bars = Gui::getMainWindow()->findChildren<QToolBar*>(QString::fromLatin1("Spreadsheet"));
|
||||
QList<QToolBar*> bars =
|
||||
Gui::getMainWindow()->findChildren<QToolBar*>(QString::fromLatin1("Spreadsheet"));
|
||||
|
||||
if (bars.size() == 1) {
|
||||
QToolBar * bar = bars[0];
|
||||
QtColorPicker * foregroundColor;
|
||||
QtColorPicker * backgroundColor;
|
||||
QToolBar* bar = bars[0];
|
||||
QtColorPicker* foregroundColor;
|
||||
QtColorPicker* backgroundColor;
|
||||
QPalette palette = Gui::getMainWindow()->palette();
|
||||
|
||||
QList<QtColorPicker*> fgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(QString::fromLatin1("Spreadsheet_ForegroundColor"));
|
||||
if (!fgList.empty())
|
||||
QList<QtColorPicker*> fgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(
|
||||
QString::fromLatin1("Spreadsheet_ForegroundColor"));
|
||||
if (!fgList.empty()) {
|
||||
foregroundColor = fgList[0];
|
||||
}
|
||||
else {
|
||||
foregroundColor = new QtColorPicker(bar);
|
||||
foregroundColor->setObjectName(QString::fromLatin1("Spreadsheet_ForegroundColor"));
|
||||
foregroundColor->setStandardColors();
|
||||
foregroundColor->setCurrentColor(palette.color(QPalette::WindowText));
|
||||
QObject::connect(foregroundColor, &QtColorPicker::colorSet, workbenchHelper.get(), &WorkbenchHelper::setForegroundColor);
|
||||
QObject::connect(foregroundColor,
|
||||
&QtColorPicker::colorSet,
|
||||
workbenchHelper.get(),
|
||||
&WorkbenchHelper::setForegroundColor);
|
||||
}
|
||||
foregroundColor->setToolTip(QObject::tr("Set cell(s) foreground color"));
|
||||
foregroundColor->setWhatsThis(QObject::tr("Sets the Spreadsheet cell(s) foreground color"));
|
||||
foregroundColor->setWhatsThis(
|
||||
QObject::tr("Sets the Spreadsheet cell(s) foreground color"));
|
||||
foregroundColor->setStatusTip(QObject::tr("Set cell(s) foreground color"));
|
||||
bar->addWidget(foregroundColor);
|
||||
|
||||
QList<QtColorPicker*> bgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(QString::fromLatin1("Spreadsheet_BackgroundColor"));
|
||||
if (!bgList.empty())
|
||||
QList<QtColorPicker*> bgList = Gui::getMainWindow()->findChildren<QtColorPicker*>(
|
||||
QString::fromLatin1("Spreadsheet_BackgroundColor"));
|
||||
if (!bgList.empty()) {
|
||||
backgroundColor = bgList[0];
|
||||
}
|
||||
else {
|
||||
backgroundColor = new QtColorPicker(bar);
|
||||
backgroundColor->setObjectName(QString::fromLatin1("Spreadsheet_BackgroundColor"));
|
||||
backgroundColor->setStandardColors();
|
||||
backgroundColor->setCurrentColor(palette.color(QPalette::Base));
|
||||
QObject::connect(backgroundColor, &QtColorPicker::colorSet, workbenchHelper.get(), &WorkbenchHelper::setBackgroundColor);
|
||||
QObject::connect(backgroundColor,
|
||||
&QtColorPicker::colorSet,
|
||||
workbenchHelper.get(),
|
||||
&WorkbenchHelper::setBackgroundColor);
|
||||
}
|
||||
backgroundColor->setToolTip(QObject::tr("Set cell(s) background color"));
|
||||
backgroundColor->setWhatsThis(QObject::tr("Sets the Spreadsheet cell(s) background color"));
|
||||
backgroundColor->setWhatsThis(
|
||||
QObject::tr("Sets the Spreadsheet cell(s) background color"));
|
||||
backgroundColor->setStatusTip(QObject::tr("Set cell(s) background color"));
|
||||
bar->addWidget(backgroundColor);
|
||||
|
||||
@@ -111,16 +123,17 @@ void Workbench::activated()
|
||||
}
|
||||
}
|
||||
|
||||
void WorkbenchHelper::setForegroundColor(const QColor & color)
|
||||
void WorkbenchHelper::setForegroundColor(const QColor& color)
|
||||
{
|
||||
Gui::Document * doc = Gui::Application::Instance->activeDocument();
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
|
||||
if (doc) {
|
||||
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
|
||||
SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
|
||||
SpreadsheetGui::SheetView* sheetView =
|
||||
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
|
||||
|
||||
if (sheetView) {
|
||||
Sheet * sheet = sheetView->getSheet();
|
||||
Sheet* sheet = sheetView->getSheet();
|
||||
std::vector<Range> ranges = sheetView->selectedRanges();
|
||||
|
||||
// Execute mergeCells commands
|
||||
@@ -128,9 +141,15 @@ void WorkbenchHelper::setForegroundColor(const QColor & color)
|
||||
std::vector<Range>::const_iterator i = ranges.begin();
|
||||
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Set foreground color"));
|
||||
for (; i != ranges.end(); ++i)
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setForeground('%s', (%f,%f,%f))", sheet->getNameInDocument(),
|
||||
i->rangeString().c_str(), color.redF(), color.greenF(), color.blueF());
|
||||
for (; i != ranges.end(); ++i) {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.setForeground('%s', (%f,%f,%f))",
|
||||
sheet->getNameInDocument(),
|
||||
i->rangeString().c_str(),
|
||||
color.redF(),
|
||||
color.greenF(),
|
||||
color.blueF());
|
||||
}
|
||||
Gui::Command::commitCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
|
||||
}
|
||||
@@ -138,16 +157,17 @@ void WorkbenchHelper::setForegroundColor(const QColor & color)
|
||||
}
|
||||
}
|
||||
|
||||
void WorkbenchHelper::setBackgroundColor(const QColor & color)
|
||||
void WorkbenchHelper::setBackgroundColor(const QColor& color)
|
||||
{
|
||||
Gui::Document * doc = Gui::Application::Instance->activeDocument();
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
|
||||
if (doc) {
|
||||
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
|
||||
SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
|
||||
SpreadsheetGui::SheetView* sheetView =
|
||||
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
|
||||
|
||||
if (sheetView) {
|
||||
Sheet * sheet = sheetView->getSheet();
|
||||
Sheet* sheet = sheetView->getSheet();
|
||||
std::vector<Range> ranges = sheetView->selectedRanges();
|
||||
|
||||
// Execute mergeCells commands
|
||||
@@ -155,9 +175,15 @@ void WorkbenchHelper::setBackgroundColor(const QColor & color)
|
||||
std::vector<Range>::const_iterator i = ranges.begin();
|
||||
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Set background color"));
|
||||
for (; i != ranges.end(); ++i)
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setBackground('%s', (%f,%f,%f))", sheet->getNameInDocument(),
|
||||
i->rangeString().c_str(), color.redF(), color.greenF(), color.blueF());
|
||||
for (; i != ranges.end(); ++i) {
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.setBackground('%s', (%f,%f,%f))",
|
||||
sheet->getNameInDocument(),
|
||||
i->rangeString().c_str(),
|
||||
color.redF(),
|
||||
color.greenF(),
|
||||
color.blueF());
|
||||
}
|
||||
Gui::Command::commitCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
|
||||
}
|
||||
@@ -165,7 +191,7 @@ void WorkbenchHelper::setBackgroundColor(const QColor & color)
|
||||
}
|
||||
}
|
||||
|
||||
Gui::MenuItem *Workbench::setupMenuBar() const
|
||||
Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
{
|
||||
Gui::MenuItem* root = StdWorkbench::setupMenuBar();
|
||||
Gui::MenuItem* item = root->findItem("&Windows");
|
||||
@@ -176,35 +202,28 @@ Gui::MenuItem *Workbench::setupMenuBar() const
|
||||
// utilities
|
||||
Gui::MenuItem* alignments = new Gui::MenuItem;
|
||||
alignments->setCommand("&Alignment");
|
||||
*alignments
|
||||
<< "Spreadsheet_AlignLeft"
|
||||
<< "Spreadsheet_AlignCenter"
|
||||
<< "Spreadsheet_AlignRight"
|
||||
<< "Spreadsheet_AlignTop"
|
||||
<< "Spreadsheet_AlignVCenter"
|
||||
<< "Spreadsheet_AlignBottom"
|
||||
;
|
||||
*alignments << "Spreadsheet_AlignLeft"
|
||||
<< "Spreadsheet_AlignCenter"
|
||||
<< "Spreadsheet_AlignRight"
|
||||
<< "Spreadsheet_AlignTop"
|
||||
<< "Spreadsheet_AlignVCenter"
|
||||
<< "Spreadsheet_AlignBottom";
|
||||
|
||||
Gui::MenuItem* styles = new Gui::MenuItem;
|
||||
styles->setCommand("&Styles");
|
||||
*styles
|
||||
<< "Spreadsheet_StyleBold"
|
||||
*styles << "Spreadsheet_StyleBold"
|
||||
<< "Spreadsheet_StyleItalic"
|
||||
<< "Spreadsheet_StyleUnderline"
|
||||
;
|
||||
<< "Spreadsheet_StyleUnderline";
|
||||
|
||||
spreadsheet->setCommand("&Spreadsheet");
|
||||
*spreadsheet << "Spreadsheet_CreateSheet"
|
||||
<< "Separator"
|
||||
<< "Spreadsheet_Import"
|
||||
<< "Spreadsheet_Export"
|
||||
<< "Separator"
|
||||
<< "Spreadsheet_MergeCells"
|
||||
<< "Spreadsheet_SplitCell"
|
||||
<< "Separator"
|
||||
<< alignments
|
||||
<< styles
|
||||
;
|
||||
<< "Separator"
|
||||
<< "Spreadsheet_Import"
|
||||
<< "Spreadsheet_Export"
|
||||
<< "Separator"
|
||||
<< "Spreadsheet_MergeCells"
|
||||
<< "Spreadsheet_SplitCell"
|
||||
<< "Separator" << alignments << styles;
|
||||
|
||||
return root;
|
||||
}
|
||||
@@ -234,8 +253,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
<< "Spreadsheet_StyleUnderline"
|
||||
<< "Separator"
|
||||
<< "Spreadsheet_SetAlias"
|
||||
<< "Separator"
|
||||
;
|
||||
<< "Separator";
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user