Skip to content

Commit

Permalink
Spreadsheet: Issue #4473: Expose openCommand() to translation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
luzpaz authored and wwmayer committed Dec 1, 2020
1 parent faa8688 commit 7b6af35
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
24 changes: 12 additions & 12 deletions src/Mod/Spreadsheet/Gui/Command.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Spreadsheet/Gui/PropertiesDialog.cpp
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Spreadsheet/Gui/SheetModel.cpp
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/Mod/Spreadsheet/Gui/SheetTableView.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp
Expand Up @@ -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() << "')");
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Spreadsheet/Gui/Workbench.cpp
Expand Up @@ -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());
Expand All @@ -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());
Expand Down

0 comments on commit 7b6af35

Please sign in to comment.