Skip to content

Commit

Permalink
Spreadsheet: Improve python code when the Delete key is pressed.
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindkv authored and wwmayer committed Nov 28, 2015
1 parent 8b745b3 commit 45a2207
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.cpp
Expand Up @@ -36,6 +36,7 @@
#include "SpreadsheetView.h"

#include <Mod/Spreadsheet/App/Sheet.h>
#include <Mod/Spreadsheet/App/Range.h>
#include <App/Document.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Application.h>
Expand Down Expand Up @@ -157,10 +158,12 @@ bool ViewProviderSheet::onDelete(const std::vector<std::string> &)

if (selection.size() > 0) {
Gui::Command::openCommand("Clear cell(s)");
for (QModelIndexList::const_iterator it = selection.begin(); it != selection.end(); ++it) {
std::string address = CellAddress((*it).row(), (*it).column()).toString();
std::vector<Range> ranges = sheetView->selectedRanges();
std::vector<Range>::const_iterator i = ranges.begin();

for (; i != ranges.end(); ++i) {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.clear('%s')", sheet->getNameInDocument(),
address.c_str());
i->rangeString().c_str());
}
Gui::Command::commitCommand();
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
Expand Down

0 comments on commit 45a2207

Please sign in to comment.