| 247 | |
| 248 | |
| 249 | void WorkingSetToolTipWidget::updateFileButtons() |
| 250 | { |
| 251 | auto* mainWindow = qobject_cast<MainWindow*>(Core::self()->uiController()->activeMainWindow()); |
| 252 | Q_ASSERT(mainWindow); |
| 253 | |
| 254 | WorkingSetController* controller = Core::self()->workingSetControllerInternal(); |
| 255 | ActiveToolTip* tooltip = controller->tooltip(); |
| 256 | |
| 257 | QString activeFile; |
| 258 | if(mainWindow->area()->activeView()) |
| 259 | activeFile = mainWindow->area()->activeView()->document()->documentSpecifier(); |
| 260 | |
| 261 | WorkingSet* currentWorkingSet = nullptr; |
| 262 | QSet<QString> openFiles; |
| 263 | |
| 264 | if(!mainWindow->area()->workingSet().isEmpty()) |
| 265 | { |
| 266 | currentWorkingSet = controller->workingSet(mainWindow->area()->workingSet()); |
| 267 | openFiles = currentWorkingSet->fileSet(); |
| 268 | } |
| 269 | |
| 270 | bool allOpen = true; |
| 271 | bool noneOpen = true; |
| 272 | |
| 273 | bool needResize = false; |
| 274 | |
| 275 | bool allHidden = true; |
| 276 | |
| 277 | for(QMap< QString, FileWidget* >::iterator it = m_fileWidgets.begin(); it != m_fileWidgets.end(); ++it) { |
| 278 | if(openFiles.contains(it.key())) { |
| 279 | noneOpen = false; |
| 280 | (*it)->m_button->setToolTip(i18nc("@info:tooltip", "Remove this file from the current working set")); |
| 281 | (*it)->m_button->setIcon(QIcon::fromTheme(QStringLiteral("list-remove"))); |
| 282 | (*it)->show(); |
| 283 | }else{ |
| 284 | allOpen = false; |
| 285 | (*it)->m_button->setToolTip(i18nc("@info:tooltip", "Add this file to the current working set")); |
| 286 | (*it)->m_button->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); |
| 287 | if(currentWorkingSet == m_set) |
| 288 | { |
| 289 | (*it)->hide(); |
| 290 | needResize = true; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | |
| 295 | if(!(*it)->isHidden()) |
| 296 | allHidden = false; |
| 297 | |
| 298 | (*it)->m_label->setIsActiveFile(it.key() == activeFile); |
| 299 | } |
| 300 | |
| 301 | // NOTE: always hide merge&subtract all on current working set |
| 302 | // if we want to enable mergeButton, we have to fix it's behavior since it operates directly on the |
| 303 | // set contents and not on the m_fileWidgets |
| 304 | m_mergeButton->setHidden(allOpen || currentWorkingSet == m_set); |
| 305 | m_subtractButton->setHidden(noneOpen || currentWorkingSet == m_set); |
| 306 | m_deleteButton->setHidden(m_set->hasConnectedAreas()); |
nothing calls this directly
no test coverage detected