| 347 | } |
| 348 | |
| 349 | void UBFeaturesWidget::addElementsToFavorite() |
| 350 | { |
| 351 | if ( centralWidget->currentView() == UBFeaturesCentralWidget::FeaturePropertiesList ) { |
| 352 | UBFeature feature = centralWidget->getCurElementFromProperties(); |
| 353 | if ( feature != UBFeature() && !UBApplication::isFromWeb(feature.getFullPath().toString())) { |
| 354 | controller->addToFavorite( feature.getFullPath() ); |
| 355 | } |
| 356 | |
| 357 | } else if ( centralWidget->currentView() == UBFeaturesCentralWidget::MainList ) { |
| 358 | QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes(); |
| 359 | for ( int i = 0; i < selected.size(); ++i ) { |
| 360 | UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>(); |
| 361 | if (feature.getType() == UBFeatureElementType::FEATURE_DOCUMENT) |
| 362 | { |
| 363 | //case where a recently open document is marked as favorite. |
| 364 | //The element is already in the favorite folder, as a recently open document, |
| 365 | // but not in the favorite list. We just need to insert it in the favoriteSet |
| 366 | controller->storeAsFavorite(feature); |
| 367 | |
| 368 | QString documentFolderName = feature.getFullPath().toString().section('/', -2, -2); //section before "/metadata.rdf" is documentFolderName |
| 369 | |
| 370 | std::shared_ptr<UBDocumentProxy> document = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->findDocumentByFolderName(documentFolderName); |
| 371 | if (document) |
| 372 | { |
| 373 | document->setIsInFavoristeList(true); |
| 374 | } |
| 375 | } |
| 376 | else |
| 377 | { |
| 378 | controller->addToFavorite(feature.getFullPath()); |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | controller->refreshModels(); |
| 384 | } |
| 385 | |
| 386 | void UBFeaturesWidget::removeElementsFromFavorite() |
| 387 | { |
nothing calls this directly
no test coverage detected