Thu, 15 Feb 2018 14:59:04 +0200
more work on mvc
src/mainwindow.cpp | file | annotate | diff | comparison | revisions | |
src/mainwindow.h | file | annotate | diff | comparison | revisions |
--- a/src/mainwindow.cpp Thu Feb 15 14:40:59 2018 +0200 +++ b/src/mainwindow.cpp Thu Feb 15 14:59:04 2018 +0200 @@ -1041,11 +1041,21 @@ */ } +QModelIndexList MainWindow::selectedIndexes() const +{ + return this->ui.objectList->selectionModel()->selectedIndexes(); +} + // --------------------------------------------------------------------------------------------------------------------- // -const QSet<LDObject*>& MainWindow::selectedObjects() +QSet<LDObject*> MainWindow::selectedObjects() const { - return m_currentDocument->getSelection(); + QSet<LDObject*> result; + + for (const QModelIndex& index : this->selectedIndexes()) + result.insert(m_currentDocument->lookup(index)); + + return result; } // ---------------------------------------------------------------------------------------------------------------------
--- a/src/mainwindow.h Thu Feb 15 14:40:59 2018 +0200 +++ b/src/mainwindow.h Thu Feb 15 14:59:04 2018 +0200 @@ -98,7 +98,8 @@ int ringToolSegments() const; bool save (LDDocument* doc, bool saveAs); void saveShortcuts(); - const QSet<LDObject*>& selectedObjects(); + QModelIndexList selectedIndexes() const; + QSet<LDObject*> selectedObjects() const; void setQuickColors (const QVector<ColorToolbarItem> &colors); void spawnContextMenu (const QPoint& position); int suggestInsertPoint();