Changeset View
Changeset View
Standalone View
Standalone View
plugins/projectmanagerview/projecttreeview.cpp
Show All 28 Lines | |||||
29 | #include <QHeaderView> | 29 | #include <QHeaderView> | ||
30 | #include <QMenu> | 30 | #include <QMenu> | ||
31 | #include <QPainter> | 31 | #include <QPainter> | ||
32 | 32 | | |||
33 | #include <KConfigGroup> | 33 | #include <KConfigGroup> | ||
34 | #include <KLocalizedString> | 34 | #include <KLocalizedString> | ||
35 | 35 | | |||
36 | #include <project/projectmodel.h> | 36 | #include <project/projectmodel.h> | ||
37 | #include <language/duchain/duchainutils.h> | | |||
38 | #include <interfaces/contextmenuextension.h> | 37 | #include <interfaces/contextmenuextension.h> | ||
39 | #include <interfaces/iprojectcontroller.h> | 38 | #include <interfaces/iprojectcontroller.h> | ||
40 | #include <interfaces/iproject.h> | 39 | #include <interfaces/iproject.h> | ||
41 | #include <interfaces/context.h> | 40 | #include <interfaces/context.h> | ||
42 | #include <interfaces/iplugincontroller.h> | 41 | #include <interfaces/iplugincontroller.h> | ||
43 | #include <interfaces/icore.h> | 42 | #include <interfaces/icore.h> | ||
44 | #include <interfaces/iselectioncontroller.h> | 43 | #include <interfaces/iselectioncontroller.h> | ||
45 | #include <interfaces/isession.h> | 44 | #include <interfaces/isession.h> | ||
46 | #include <project/interfaces/iprojectfilemanager.h> | 45 | #include <project/interfaces/iprojectfilemanager.h> | ||
47 | #include <project/interfaces/ibuildsystemmanager.h> | 46 | #include <project/interfaces/ibuildsystemmanager.h> | ||
48 | 47 | | |||
49 | #include "projectmanagerviewplugin.h" | 48 | #include "projectmanagerviewplugin.h" | ||
50 | #include "projectmodelsaver.h" | 49 | #include "projectmodelsaver.h" | ||
51 | #include "projectmodelitemdelegate.h" | 50 | #include "projectmodelitemdelegate.h" | ||
52 | #include "debug.h" | 51 | #include "debug.h" | ||
53 | #include <language/duchain/duchainlock.h> | | |||
54 | #include <language/duchain/duchain.h> | | |||
55 | #include <language/util/navigationtooltip.h> | | |||
56 | #include <project/projectutils.h> | 52 | #include <project/projectutils.h> | ||
57 | #include <widgetcolorizer.h> | 53 | #include <widgetcolorizer.h> | ||
58 | 54 | | |||
59 | using namespace KDevelop; | 55 | using namespace KDevelop; | ||
60 | 56 | | |||
61 | namespace { | 57 | namespace { | ||
62 | const char settingsConfigGroup[] = "ProjectTreeView"; | 58 | const char settingsConfigGroup[] = "ProjectTreeView"; | ||
63 | 59 | | |||
▲ Show 20 Lines • Show All 390 Lines • ▼ Show 20 Line(s) | |||||
454 | { | 450 | { | ||
455 | // save all projects, not just the selected ones | 451 | // save all projects, not just the selected ones | ||
456 | const auto projects = ICore::self()->projectController()->projects(); | 452 | const auto projects = ICore::self()->projectController()->projects(); | ||
457 | for ( const auto& project: projects ) { | 453 | for ( const auto& project: projects ) { | ||
458 | saveState( project ); | 454 | saveState( project ); | ||
459 | } | 455 | } | ||
460 | } | 456 | } | ||
461 | 457 | | |||
462 | bool ProjectTreeView::event(QEvent* event) | | |||
463 | { | | |||
464 | if(event->type()==QEvent::ToolTip) | | |||
465 | { | | |||
466 | QHelpEvent* helpEvent = static_cast<QHelpEvent*>(event); | | |||
467 | QModelIndex idxView = indexAt(helpEvent->pos()); | | |||
468 | | ||||
469 | ProjectBaseItem* it = idxView.data(ProjectModel::ProjectItemRole).value<ProjectBaseItem*>(); | | |||
470 | QModelIndex idx; | | |||
471 | if(it) | | |||
472 | idx = it->index(); | | |||
473 | | ||||
474 | if((m_idx!=idx || !m_tooltip) && it && it->file()) | | |||
475 | { | | |||
476 | m_idx=idx; | | |||
477 | ProjectFileItem* file=it->file(); | | |||
478 | KDevelop::DUChainReadLocker lock(KDevelop::DUChain::lock()); | | |||
479 | TopDUContext* top= DUChainUtils::standardContextForUrl(file->path().toUrl()); | | |||
480 | | ||||
481 | if(m_tooltip) | | |||
482 | m_tooltip->close(); | | |||
483 | | ||||
484 | if(top) | | |||
485 | { | | |||
486 | QWidget* navigationWidget = top->createNavigationWidget(); | | |||
487 | if( navigationWidget ) | | |||
488 | { | | |||
489 | m_tooltip = new KDevelop::NavigationToolTip(this, helpEvent->globalPos() + QPoint(40, 0), navigationWidget); | | |||
490 | m_tooltip->resize( navigationWidget->sizeHint() + QSize(10, 10) ); | | |||
491 | qCDebug(PLUGIN_PROJECTMANAGERVIEW) << "tooltip size" << m_tooltip->size(); | | |||
492 | ActiveToolTip::showToolTip(m_tooltip); | | |||
493 | return true; | | |||
494 | } | | |||
495 | } | | |||
496 | } | | |||
497 | } | | |||
498 | | ||||
499 | return QAbstractItemView::event(event); | | |||
500 | } | | |||
501 | | ||||
502 | void ProjectTreeView::keyPressEvent(QKeyEvent* event) | 458 | void ProjectTreeView::keyPressEvent(QKeyEvent* event) | ||
503 | { | 459 | { | ||
504 | if (event->key() == Qt::Key_Return && currentIndex().isValid() && state()!=QAbstractItemView::EditingState) | 460 | if (event->key() == Qt::Key_Return && currentIndex().isValid() && state()!=QAbstractItemView::EditingState) | ||
505 | { | 461 | { | ||
506 | event->accept(); | 462 | event->accept(); | ||
507 | slotActivated(currentIndex()); | 463 | slotActivated(currentIndex()); | ||
508 | } | 464 | } | ||
509 | else | 465 | else | ||
Show All 13 Lines |