Spreadsheet: improve range binding feature (#6995)
* Spreadsheet: improve range binding feature
This commit is contained in:
@@ -249,28 +249,9 @@ void SheetTableView::cellProperties()
|
||||
|
||||
std::vector<Range> SheetTableView::selectedRanges() const
|
||||
{
|
||||
QModelIndexList list = selectionModel()->selectedIndexes();
|
||||
std::vector<Range> result;
|
||||
|
||||
// Insert selected cells into set. This variable should ideally be a hash_set
|
||||
// but that is not part of standard stl.
|
||||
std::set<std::pair<int, int> > cells;
|
||||
for (QModelIndexList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||
cells.insert(std::make_pair<int,int>((*it).row(), (*it).column()));
|
||||
|
||||
// Create rectangular cells from the unordered collection of selected cells
|
||||
std::map<std::pair<int, int>, std::pair<int, int> > rectangles;
|
||||
createRectangles(cells, rectangles);
|
||||
|
||||
std::map<std::pair<int, int>, std::pair<int, int> >::const_iterator i = rectangles.begin();
|
||||
for (; i != rectangles.end(); ++i) {
|
||||
std::pair<int, int> ul = (*i).first;
|
||||
std::pair<int, int> size = (*i).second;
|
||||
|
||||
result.emplace_back(ul.first, ul.second,
|
||||
ul.first + size.first - 1, ul.second + size.second - 1);
|
||||
}
|
||||
|
||||
for (const auto &sel : selectionModel()->selection())
|
||||
result.emplace_back(sel.top(), sel.left(), sel.bottom(), sel.right());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user