MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / TreeViewSelectionChanged

Method TreeViewSelectionChanged

src/document/UBDocumentController.cpp:2100–2147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2098}
2099
2100void UBDocumentController::TreeViewSelectionChanged(const QModelIndex &current, const QModelIndex &previous)
2101{
2102 UBDocumentTreeModel *docModel = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel;
2103
2104 QModelIndex current_index = mapIndexToSource(current);
2105
2106 //N/C - NNE - 20140414
2107 //if the selection contains more than one object, don't show the thumbnail.
2108 //We have just to pass a null proxy to disable the display of thumbnail
2109 std::shared_ptr<UBDocumentProxy> currentDocumentProxy = 0;
2110
2111 if(current_index.isValid() && mDocumentUI->documentTreeView->selectionModel()->selectedRows(0).size() == 1)
2112 {
2113 if (docModel->isDocument(current_index))
2114 {
2115 currentDocumentProxy = docModel->proxyData(current_index);
2116 const auto converter{UBDocumentVersionConverter{currentDocumentProxy}};
2117 const auto result = converter.convert();
2118
2119 if (result == UBDocumentVersionConverter::DENIED || result == UBDocumentVersionConverter::FAILED)
2120 {
2121 // deferred selection of previous entry to avoid double triggering of selection change
2122 QTimer::singleShot(0, [this, previous](){
2123 mDocumentUI->documentTreeView->selectionModel()->select(previous, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
2124 });
2125 return;
2126 }
2127
2128 if (isBrokenDocument(currentDocumentProxy))
2129 {
2130 showBrokenDocumentWarning();
2131 }
2132 }
2133
2134 setDocument(currentDocumentProxy, false);
2135 }
2136 //N/C - NNE - 20140414 : END
2137
2138
2139 if (mCurrentIndexMoved) {
2140 if (docModel->isDocument(current_index)) {
2141 docModel->setCurrentDocument(currentDocumentProxy);
2142 } else if (docModel->isCatalog(current_index)) {
2143 docModel->setCurrentDocument(0);
2144 }
2145 mCurrentIndexMoved = false;
2146 }
2147}
2148
2149//N/C - NNE - 20140402 : workaround for using a proxy model
2150QModelIndex UBDocumentController::mapIndexToSource(const QModelIndex &index)

Callers 1

copyDocumentSceneMethod · 0.80

Calls 9

isDocumentMethod · 0.80
convertMethod · 0.80
setCurrentDocumentMethod · 0.80
isCatalogMethod · 0.80
emptyMethod · 0.80
isValidMethod · 0.45
sizeMethod · 0.45
proxyDataMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected