MCPcopy Create free account
hub / github.com/KDE/kdevelop / updateFileButtons

Method updateFileButtons

kdevplatform/shell/workingsets/workingsettooltipwidget.cpp:249–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247
248
249void 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());

Callers

nothing calls this directly

Calls 15

uiControllerMethod · 0.80
tooltipMethod · 0.80
setToolTipMethod · 0.80
setIconMethod · 0.80
showMethod · 0.80
setIsActiveFileMethod · 0.80
hasConnectedAreasMethod · 0.80
activeMainWindowMethod · 0.45
activeViewMethod · 0.45
areaMethod · 0.45
documentSpecifierMethod · 0.45

Tested by

no test coverage detected