| 2098 | } |
| 2099 | |
| 2100 | void UBDocumentController::TreeViewSelectionChanged(const QModelIndex ¤t, 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 |
| 2150 | QModelIndex UBDocumentController::mapIndexToSource(const QModelIndex &index) |
no test coverage detected