void UBFeaturesWidget::currentSelected(const QModelIndex ¤t) { if (!current.isValid()) { qWarning() << "SLOT:currentSelected, invalid index catched"; return; } QString objName = sender()->objectName(); if (objName.isEmpty()) { qWarning() << "incorrect sender"; } else if (objName == objNamePathList) { //Calling to reset the model for listView. Maybe separate function needed controller->searchStarted("", centralWidget->listView()); } UBFeature feature = controller->getFeature(current, objName); if ( feature.isFolder() ) { QString newPath = feature.getFullVirtualPath(); controller->setCurrentElement(feature); controller->siftElements(newPath); centralWidget->switchTo(UBFeaturesCentralWidget::MainList); if ( feature.getType() == FEATURE_FAVORITE ) { mActionBar->setCurrentState( IN_FAVORITE ); } else if ( feature.getType() == FEATURE_CATEGORY && feature.getName() == "root" ) { mActionBar->setCurrentState( IN_ROOT ); } else if (feature.getType() == FEATURE_TRASH) { mActionBar->setCurrentState(IN_TRASH); } else if (feature.getType() == FEATURE_SEARCH) { //The search feature behavior is not standard. If features list clicked - show empty element //else show existing saved features search QWebView if (sender()->objectName() == objNameFeatureList) { centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturesWebView); } else if (sender()->objectName() == objNamePathList) { centralWidget->switchTo(UBFeaturesCentralWidget::FeaturesWebView); } } else { mActionBar->setCurrentState(IN_FOLDER); } // } else if (feature.getType() == FEATURE_SEARCH) { // centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturesWebView); } else { centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList); mActionBar->setCurrentState( IN_PROPERTIES ); } mActionBar->cleanText(); }
void UBFeaturesWidget::currentSelected(const QModelIndex ¤t) { if (current.isValid()) { QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() ); /*QString name = model->data(current).toString(); QString path = model->data(current, Qt::UserRole).toString(); eUBLibElementType type = (eUBLibElementType)model->data(current, Qt::UserRole + 1).toInt();*/ UBFeature feature = model->data(current, Qt::UserRole + 1).value<UBFeature>(); if ( feature.isFolder() ) { QString newPath = feature.getFullVirtualPath(); //pathViewer->addPathElement( feature.getThumbnail(), newPath ); controller->setCurrentElement( feature ); model->setFilterFixedString( newPath ); model->invalidate(); switchToListView(); featuresPathModel->setPath( newPath ); featuresPathModel->invalidate(); if ( feature.getType() == FEATURE_FAVORITE ) { mActionBar->setCurrentState( IN_FAVORITE ); } else if (feature.getType() == FEATURE_TRASH) { mActionBar->setCurrentState( IN_TRASH ); } else { mActionBar->setCurrentState( IN_FOLDER ); } } else if ( feature.getType() == FEATURE_SEARCH ) { webView->showElement( feature ); switchToWebView(); } else { featureProperties->showElement( feature ); switchToProperties(); mActionBar->setCurrentState( IN_PROPERTIES ); } } }