Spreadsheet: Issue #0004473: Expose openCommand() to translation

Continuing the work to expose the undo/redo functionality to translation. This commit does so for the Spreadsheet Wb.  
Ticket: https://tracker.freecadweb.org/view.php?id=4473
This commit is contained in:
luz paz
2020-11-28 13:54:55 -05:00
committed by wwmayer
parent a65b3788c6
commit 786d84d288
6 changed files with 22 additions and 22 deletions

View File

@@ -88,7 +88,7 @@ void CmdSpreadsheetMergeCells::activated(int iMsg)
// Execute mergeCells commands
if (ranges.size() > 0) {
Gui::Command::openCommand("Merge cells");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Merge cells"));
std::vector<Range>::const_iterator i = ranges.begin();
for (; i != ranges.end(); ++i)
if (i->size() > 1)
@@ -141,7 +141,7 @@ void CmdSpreadsheetSplitCell::activated(int iMsg)
if (current.isValid()) {
std::string address = CellAddress(current.row(), current.column()).toString();
Gui::Command::openCommand("Split cell");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Split cell"));
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.splitCell('%s')", sheet->getNameInDocument(),
address.c_str());
Gui::Command::commitCommand();
@@ -287,7 +287,7 @@ void CmdSpreadsheetAlignLeft::activated(int iMsg)
if (ranges.size() > 0) {
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Left-align cell");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Left-align cell"));
for (; i != ranges.end(); ++i)
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setAlignment('%s', 'left', 'keep')", sheet->getNameInDocument(),
i->rangeString().c_str());
@@ -339,7 +339,7 @@ void CmdSpreadsheetAlignCenter::activated(int iMsg)
if (ranges.size() > 0) {
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Center cell");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Center cell"));
for (; i != ranges.end(); ++i)
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setAlignment('%s', 'center', 'keep')", sheet->getNameInDocument(),
i->rangeString().c_str());
@@ -391,7 +391,7 @@ void CmdSpreadsheetAlignRight::activated(int iMsg)
if (ranges.size() > 0) {
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Right-align cell");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Right-align cell"));
for (; i != ranges.end(); ++i)
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setAlignment('%s', 'right', 'keep')", sheet->getNameInDocument(),
i->rangeString().c_str());
@@ -443,7 +443,7 @@ void CmdSpreadsheetAlignTop::activated(int iMsg)
if (ranges.size() > 0) {
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Top-align cell");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Top-align cell"));
for (; i != ranges.end(); ++i)
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setAlignment('%s', 'top', 'keep')", sheet->getNameInDocument(),
i->rangeString().c_str());
@@ -495,7 +495,7 @@ void CmdSpreadsheetAlignBottom::activated(int iMsg)
if (ranges.size() > 0) {
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Bottom-align cell");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Bottom-align cell"));
for (; i != ranges.end(); ++i)
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setAlignment('%s', 'bottom', 'keep')", sheet->getNameInDocument(),
i->rangeString().c_str());
@@ -547,7 +547,7 @@ void CmdSpreadsheetAlignVCenter::activated(int iMsg)
if (ranges.size() > 0) {
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Vertically center cells");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Vertically center cells"));
for (; i != ranges.end(); ++i)
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setAlignment('%s', 'vcenter', 'keep')", sheet->getNameInDocument(),
i->rangeString().c_str());
@@ -616,7 +616,7 @@ void CmdSpreadsheetStyleBold::activated(int iMsg)
std::vector<Range> ranges = sheetView->selectedRanges();
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Set bold text");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Set bold text"));
for (; i != ranges.end(); ++i) {
if (!allBold)
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setStyle('%s', 'bold', 'add')", sheet->getNameInDocument(),
@@ -690,7 +690,7 @@ void CmdSpreadsheetStyleItalic::activated(int iMsg)
std::vector<Range> ranges = sheetView->selectedRanges();
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Set italic text");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Set italic text"));
for (; i != ranges.end(); ++i) {
if (!allItalic)
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setStyle('%s', 'italic', 'add')", sheet->getNameInDocument(),
@@ -764,7 +764,7 @@ void CmdSpreadsheetStyleUnderline::activated(int iMsg)
std::vector<Range> ranges = sheetView->selectedRanges();
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Set underline text");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Set underline text"));
for (; i != ranges.end(); ++i) {
if (!allUnderline)
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setStyle('%s', 'underline', 'add')", sheet->getNameInDocument(),
@@ -875,7 +875,7 @@ void CmdCreateSpreadsheet::activated(int iMsg)
Q_UNUSED(iMsg);
std::string FeatName = getUniqueObjectName("Spreadsheet");
openCommand("Create Spreadsheet");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Spreadsheet"));
doCommand(Doc,"App.activeDocument().addObject('Spreadsheet::Sheet','%s\')",FeatName.c_str());
doCommand(Gui,"Gui.Selection.clearSelection()\n");
doCommand(Gui,"Gui.Selection.addSelection(App.activeDocument().Name,'%s\')",FeatName.c_str());

View File

@@ -225,7 +225,7 @@ PropertiesDialog::~PropertiesDialog()
void PropertiesDialog::apply()
{
if (ranges.size() > 0) {
Gui::Command::openCommand("Set cell properties");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Set cell properties"));
std::vector<Range>::const_iterator i = ranges.begin();
bool changes = false;

View File

@@ -529,7 +529,7 @@ bool SheetModel::setData(const QModelIndex & index, const QVariant & value, int
try {
QString str = value.toString();
Gui::Command::openCommand("Edit cell");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit cell"));
// Because of possible complication of recursively escaped
// characters, let's take a shortcut and bypass the command
// interface for now.

View File

@@ -158,7 +158,7 @@ void SheetTableView::insertRows()
std::sort(sortedRows.begin(), sortedRows.end());
/* Insert rows */
Gui::Command::openCommand("Insert rows");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Insert rows"));
std::vector<int>::const_reverse_iterator it = sortedRows.rbegin();
while (it != sortedRows.rend()) {
int prev = *it;
@@ -195,7 +195,7 @@ void SheetTableView::removeRows()
std::sort(sortedRows.begin(), sortedRows.end(), std::greater<int>());
/* Remove rows */
Gui::Command::openCommand("Remove rows");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Remove rows"));
for (std::vector<int>::const_iterator it = sortedRows.begin(); it != sortedRows.end(); ++it) {
Gui::cmdAppObjectArgs(sheet, "removeRows('%s', %d)", rowName(*it).c_str(), 1);
}
@@ -216,7 +216,7 @@ void SheetTableView::insertColumns()
std::sort(sortedColumns.begin(), sortedColumns.end());
/* Insert columns */
Gui::Command::openCommand("Insert columns");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Insert columns"));
std::vector<int>::const_reverse_iterator it = sortedColumns.rbegin();
while (it != sortedColumns.rend()) {
int prev = *it;
@@ -254,7 +254,7 @@ void SheetTableView::removeColumns()
std::sort(sortedColumns.begin(), sortedColumns.end(), std::greater<int>());
/* Remove columns */
Gui::Command::openCommand("Remove rows");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Remove rows"));
for (std::vector<int>::const_iterator it = sortedColumns.begin(); it != sortedColumns.end(); ++it)
Gui::cmdAppObjectArgs(sheet, "removeColumns('%s', %d)",
columnName(*it).c_str(), 1);
@@ -419,7 +419,7 @@ void SheetTableView::deleteSelection()
QModelIndexList selection = selectionModel()->selectedIndexes();
if (selection.size() > 0) {
Gui::Command::openCommand("Clear cell(s)");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Clear cell(s)"));
std::vector<Range> ranges = selectedRanges();
std::vector<Range>::const_iterator i = ranges.begin();

View File

@@ -157,7 +157,7 @@ bool SheetView::onMsg(const char *pMsg, const char **)
else if(strcmp("Std_Delete",pMsg) == 0) {
std::vector<Range> ranges = selectedRanges();
if (sheet->hasCell(ranges)) {
Gui::Command::openCommand("Clear cell(s)");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Clear cell(s)"));
std::vector<Range>::const_iterator i = ranges.begin();
for (; i != ranges.end(); ++i) {
FCMD_OBJ_CMD(sheet, "clear('" << i->rangeString() << "')");

View File

@@ -125,7 +125,7 @@ void WorkbenchHelper::setForegroundColor(const QColor & color)
if (ranges.size() > 0) {
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Set foreground color");
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());
@@ -152,7 +152,7 @@ void WorkbenchHelper::setBackgroundColor(const QColor & color)
if (ranges.size() > 0) {
std::vector<Range>::const_iterator i = ranges.begin();
Gui::Command::openCommand("Set background color");
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());