Changeset View
Changeset View
Standalone View
Standalone View
plugins/standardoutputview/outputwidget.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 55 | OutputWidget::OutputWidget(QWidget* parent, const ToolViewData* tvdata) | |||
---|---|---|---|---|---|
67 | , m_filterAction(nullptr) | 67 | , m_filterAction(nullptr) | ||
68 | { | 68 | { | ||
69 | setWindowTitle(i18n("Output View")); | 69 | setWindowTitle(i18n("Output View")); | ||
70 | setWindowIcon(tvdata->icon); | 70 | setWindowIcon(tvdata->icon); | ||
71 | QVBoxLayout* layout = new QVBoxLayout(this); | 71 | QVBoxLayout* layout = new QVBoxLayout(this); | ||
72 | layout->setMargin(0); | 72 | layout->setMargin(0); | ||
73 | if( data->type & KDevelop::IOutputView::MultipleView ) | 73 | if( data->type & KDevelop::IOutputView::MultipleView ) | ||
74 | { | 74 | { | ||
75 | m_tabwidget = new QTabWidget(this); | 75 | m_tabwidget.reset(new QTabWidget); | ||
76 | layout->addWidget( m_tabwidget ); | 76 | layout->addWidget(m_tabwidget.data()); | ||
77 | m_closeButton = new QToolButton( this ); | 77 | m_closeButton = new QToolButton( this ); | ||
78 | connect( m_closeButton, &QToolButton::clicked, this, &OutputWidget::closeActiveView ); | 78 | connect( m_closeButton, &QToolButton::clicked, this, &OutputWidget::closeActiveView ); | ||
79 | m_closeButton->setIcon( QIcon::fromTheme( QStringLiteral( "tab-close") ) ); | 79 | m_closeButton->setIcon( QIcon::fromTheme( QStringLiteral( "tab-close") ) ); | ||
80 | m_closeButton->setToolTip( i18n( "Close the currently active output view") ); | 80 | m_closeButton->setToolTip( i18n( "Close the currently active output view") ); | ||
81 | m_closeButton->setAutoRaise(true); | 81 | m_closeButton->setAutoRaise(true); | ||
82 | 82 | | |||
83 | m_closeOthersAction = new QAction( this ); | 83 | m_closeOthersAction = new QAction( this ); | ||
84 | connect(m_closeOthersAction, &QAction::triggered, this, &OutputWidget::closeOtherViews); | 84 | connect(m_closeOthersAction, &QAction::triggered, this, &OutputWidget::closeOtherViews); | ||
85 | m_closeOthersAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-close-other"))); | 85 | m_closeOthersAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-close-other"))); | ||
86 | m_closeOthersAction->setToolTip( i18n( "Close all other output views" ) ); | 86 | m_closeOthersAction->setToolTip( i18n( "Close all other output views" ) ); | ||
87 | m_closeOthersAction->setText( m_closeOthersAction->toolTip() ); | 87 | m_closeOthersAction->setText( m_closeOthersAction->toolTip() ); | ||
88 | addAction(m_closeOthersAction); | 88 | addAction(m_closeOthersAction); | ||
89 | 89 | | |||
90 | m_tabwidget->setCornerWidget(m_closeButton, Qt::TopRightCorner); | 90 | m_tabwidget->setCornerWidget(m_closeButton, Qt::TopRightCorner); | ||
91 | m_tabwidget->setDocumentMode(true); | 91 | m_tabwidget->setDocumentMode(true); | ||
92 | } else if ( data->type == KDevelop::IOutputView::HistoryView ) | 92 | } else if ( data->type == KDevelop::IOutputView::HistoryView ) | ||
93 | { | 93 | { | ||
94 | m_stackwidget = new QStackedWidget( this ); | 94 | m_stackwidget.reset(new QStackedWidget); | ||
95 | layout->addWidget( m_stackwidget ); | 95 | layout->addWidget(m_stackwidget.data()); | ||
96 | 96 | | |||
97 | m_previousAction = new QAction( QIcon::fromTheme( QStringLiteral( "arrow-left" ) ), i18n("Previous Output"), this ); | 97 | m_previousAction = new QAction( QIcon::fromTheme( QStringLiteral( "arrow-left" ) ), i18n("Previous Output"), this ); | ||
98 | connect(m_previousAction, &QAction::triggered, this, &OutputWidget::previousOutput); | 98 | connect(m_previousAction, &QAction::triggered, this, &OutputWidget::previousOutput); | ||
99 | addAction(m_previousAction); | 99 | addAction(m_previousAction); | ||
100 | m_nextAction = new QAction( QIcon::fromTheme( QStringLiteral( "arrow-right" ) ), i18n("Next Output"), this ); | 100 | m_nextAction = new QAction( QIcon::fromTheme( QStringLiteral( "arrow-right" ) ), i18n("Next Output"), this ); | ||
101 | connect(m_nextAction, &QAction::triggered, this, &OutputWidget::nextOutput); | 101 | connect(m_nextAction, &QAction::triggered, this, &OutputWidget::nextOutput); | ||
102 | addAction(m_nextAction); | 102 | addAction(m_nextAction); | ||
103 | } | 103 | } | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 154 | { | |||
165 | connect(m_filterAction, &QAction::triggered, this, [this]() {m_filterInput->setFocus();}); | 165 | connect(m_filterAction, &QAction::triggered, this, [this]() {m_filterInput->setFocus();}); | ||
166 | m_filterAction->setDefaultWidget(m_filterInput); | 166 | m_filterAction->setDefaultWidget(m_filterInput); | ||
167 | addAction(m_filterAction); | 167 | addAction(m_filterAction); | ||
168 | 168 | | |||
169 | connect(m_filterInput, &QLineEdit::textEdited, | 169 | connect(m_filterInput, &QLineEdit::textEdited, | ||
170 | this, &OutputWidget::outputFilter ); | 170 | this, &OutputWidget::outputFilter ); | ||
171 | if( data->type & KDevelop::IOutputView::MultipleView ) | 171 | if( data->type & KDevelop::IOutputView::MultipleView ) | ||
172 | { | 172 | { | ||
173 | connect(m_tabwidget, &QTabWidget::currentChanged, | 173 | connect(m_tabwidget.data(), &QTabWidget::currentChanged, | ||
174 | this, &OutputWidget::updateFilter); | 174 | this, &OutputWidget::updateFilter); | ||
175 | } else if ( data->type == KDevelop::IOutputView::HistoryView ) | 175 | } else if ( data->type == KDevelop::IOutputView::HistoryView ) | ||
176 | { | 176 | { | ||
177 | connect(m_stackwidget, &QStackedWidget::currentChanged, | 177 | connect(m_stackwidget.data(), &QStackedWidget::currentChanged, | ||
178 | this, &OutputWidget::updateFilter); | 178 | this, &OutputWidget::updateFilter); | ||
179 | } | 179 | } | ||
180 | } | 180 | } | ||
181 | 181 | | |||
182 | addActions(data->actionList); | 182 | addActions(data->actionList); | ||
183 | 183 | | |||
184 | connect( data, &ToolViewData::outputAdded, | 184 | connect( data, &ToolViewData::outputAdded, | ||
185 | this, &OutputWidget::addOutput ); | 185 | this, &OutputWidget::addOutput ); | ||
186 | 186 | | |||
187 | connect( this, &OutputWidget::outputRemoved, | 187 | connect( this, &OutputWidget::outputRemoved, | ||
188 | data->plugin, &StandardOutputView::outputRemoved ); | 188 | data->plugin, &StandardOutputView::outputRemoved ); | ||
189 | 189 | | |||
190 | foreach( int id, data->outputdata.keys() ) | 190 | foreach( int id, data->outputdata.keys() ) | ||
191 | { | 191 | { | ||
192 | changeModel( id ); | 192 | changeModel( id ); | ||
193 | changeDelegate( id ); | 193 | changeDelegate( id ); | ||
194 | } | 194 | } | ||
195 | enableActions(); | 195 | enableActions(); | ||
196 | } | 196 | } | ||
197 | 197 | | |||
198 | OutputWidget::~OutputWidget() = default; | ||||
199 | | ||||
198 | void OutputWidget::clearModel() | 200 | void OutputWidget::clearModel() | ||
199 | { | 201 | { | ||
200 | auto view = qobject_cast<QAbstractItemView*>(currentWidget()); | 202 | auto view = qobject_cast<QAbstractItemView*>(currentWidget()); | ||
201 | if( !view || !view->isVisible()) | 203 | if( !view || !view->isVisible()) | ||
202 | return; | 204 | return; | ||
kossebau: Isn't m_views destroyed (and thus implicitely cleared) before reaching the ~QWidget and… | |||||
203 | 205 | | |||
204 | KDevelop::OutputModel *outputModel = nullptr; | 206 | KDevelop::OutputModel *outputModel = nullptr; | ||
205 | if (auto proxy = qobject_cast<QAbstractProxyModel*>(view->model())) { | 207 | if (auto proxy = qobject_cast<QAbstractProxyModel*>(view->model())) { | ||
206 | outputModel = qobject_cast<KDevelop::OutputModel*>(proxy->sourceModel()); | 208 | outputModel = qobject_cast<KDevelop::OutputModel*>(proxy->sourceModel()); | ||
207 | } else { | 209 | } else { | ||
This here might be more the actual issue, preventing the updateFilter slot being invoked during destruction because tabwidget or stackwidget emitting signals on their subwidgets being removed, Not sure what is the better approach, only disconnecting from the currentChanged signals or straight deleting the widgets. Personally I tend to only handle the connections, and leave memory management of widgets completly to the Qt internals. kossebau: This here might be more the actual issue, preventing the updateFilter slot being invoked during… | |||||
208 | outputModel = qobject_cast<KDevelop::OutputModel*>(view->model()); | 210 | outputModel = qobject_cast<KDevelop::OutputModel*>(view->model()); | ||
209 | } | 211 | } | ||
210 | outputModel->clear(); | 212 | outputModel->clear(); | ||
211 | } | 213 | } | ||
212 | 214 | | |||
213 | void OutputWidget::addOutput( int id ) | 215 | void OutputWidget::addOutput( int id ) | ||
214 | { | 216 | { | ||
215 | QTreeView* listview = createListView(id); | 217 | QTreeView* listview = createListView(id); | ||
Show All 36 Lines | 253 | { | |||
252 | addOutput( id ); | 254 | addOutput( id ); | ||
253 | } | 255 | } | ||
254 | } | 256 | } | ||
255 | 257 | | |||
256 | void OutputWidget::removeOutput( int id ) | 258 | void OutputWidget::removeOutput( int id ) | ||
257 | { | 259 | { | ||
258 | if( data->outputdata.contains( id ) && m_views.contains( id ) ) | 260 | if( data->outputdata.contains( id ) && m_views.contains( id ) ) | ||
259 | { | 261 | { | ||
260 | QTreeView *view = m_views.value(id).view.data(); | 262 | auto view = m_views.value(id).view; | ||
261 | if( data->type & KDevelop::IOutputView::MultipleView || data->type & KDevelop::IOutputView::HistoryView ) | 263 | if( data->type & KDevelop::IOutputView::MultipleView || data->type & KDevelop::IOutputView::HistoryView ) | ||
262 | { | 264 | { | ||
263 | if( data->type & KDevelop::IOutputView::MultipleView ) | 265 | if( data->type & KDevelop::IOutputView::MultipleView ) | ||
264 | { | 266 | { | ||
265 | int idx = m_tabwidget->indexOf( view ); | 267 | int idx = m_tabwidget->indexOf( view ); | ||
266 | if (idx != -1) | 268 | if (idx != -1) | ||
267 | { | 269 | { | ||
268 | m_tabwidget->removeTab( idx ); | 270 | m_tabwidget->removeTab( idx ); | ||
269 | } | 271 | } | ||
270 | } else | 272 | } else | ||
271 | { | 273 | { | ||
272 | int idx = m_stackwidget->indexOf( view ); | 274 | int idx = m_stackwidget->indexOf( view ); | ||
273 | if (idx != -1) | 275 | if (idx != -1) | ||
274 | { | 276 | { | ||
275 | m_stackwidget->removeWidget(view); | 277 | m_stackwidget->removeWidget(view); | ||
276 | } | 278 | } | ||
277 | } | 279 | } | ||
278 | } else { // KDevelop::IOutputView::OneView | 280 | } else { | ||
279 | /* TODO: this branch of execution has no result because of the "m_views.remove( id );" | 281 | // KDevelop::IOutputView::OneView case | ||
280 | * after the if-else block. Need to find out which behavior has sense. | 282 | // Do nothig here - our single view was added to the layout so we doesn't need | ||
281 | */ | 283 | // to delete it manually. | ||
282 | FilteredView& fview = m_views[id]; | | |||
283 | fview.view->setModel(nullptr); | | |||
284 | fview.view->setItemDelegate(nullptr); | | |||
285 | if (fview.proxyModel) { | | |||
286 | fview.proxyModel = QSharedPointer<QSortFilterProxyModel>(); | | |||
287 | fview.filter = QString(); | | |||
288 | } | | |||
289 | } | 284 | } | ||
290 | m_views.remove(id); | 285 | m_views.remove(id); | ||
291 | emit outputRemoved( data->toolViewId, id ); | 286 | emit outputRemoved( data->toolViewId, id ); | ||
292 | } | 287 | } | ||
293 | enableActions(); | 288 | enableActions(); | ||
294 | } | 289 | } | ||
295 | 290 | | |||
296 | void OutputWidget::closeActiveView() | 291 | void OutputWidget::closeActiveView() | ||
Show All 40 Lines | 330 | { | |||
337 | if( data->type & KDevelop::IOutputView::MultipleView ) | 332 | if( data->type & KDevelop::IOutputView::MultipleView ) | ||
338 | { | 333 | { | ||
339 | widget = m_tabwidget->currentWidget(); | 334 | widget = m_tabwidget->currentWidget(); | ||
340 | } else if( data->type & KDevelop::IOutputView::HistoryView ) | 335 | } else if( data->type & KDevelop::IOutputView::HistoryView ) | ||
341 | { | 336 | { | ||
342 | widget = m_stackwidget->currentWidget(); | 337 | widget = m_stackwidget->currentWidget(); | ||
343 | } else | 338 | } else | ||
344 | { | 339 | { | ||
345 | widget = m_views.begin().value().view.data(); | 340 | widget = m_views.begin().value().view; | ||
346 | } | 341 | } | ||
347 | return widget; | 342 | return widget; | ||
348 | } | 343 | } | ||
349 | 344 | | |||
350 | KDevelop::IOutputViewModel *OutputWidget::outputViewModel() const | 345 | KDevelop::IOutputViewModel *OutputWidget::outputViewModel() const | ||
351 | { | 346 | { | ||
352 | auto view = qobject_cast<QAbstractItemView*>(currentWidget()); | 347 | auto view = qobject_cast<QAbstractItemView*>(currentWidget()); | ||
353 | if( !view || !view->isVisible()) | 348 | if( !view || !view->isVisible()) | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 462 | { | |||
469 | auto view = outputView(); | 464 | auto view = outputView(); | ||
470 | if( ! view || ! iface ) | 465 | if( ! view || ! iface ) | ||
471 | return; | 466 | return; | ||
472 | activateIndex(index, view, iface); | 467 | activateIndex(index, view, iface); | ||
473 | } | 468 | } | ||
474 | 469 | | |||
475 | QTreeView* OutputWidget::createListView(int id) | 470 | QTreeView* OutputWidget::createListView(int id) | ||
476 | { | 471 | { | ||
477 | auto createHelper = [&]() -> QSharedPointer<QTreeView> { | 472 | auto createHelper = [&]() -> QTreeView* { | ||
478 | KDevelop::FocusedTreeView* listview = new KDevelop::FocusedTreeView(this); | 473 | KDevelop::FocusedTreeView* listview = new KDevelop::FocusedTreeView(this); | ||
479 | listview->setEditTriggers( QAbstractItemView::NoEditTriggers ); | 474 | listview->setEditTriggers( QAbstractItemView::NoEditTriggers ); | ||
480 | listview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); //Always enable the scrollbar, so it doesn't flash around | 475 | listview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); //Always enable the scrollbar, so it doesn't flash around | ||
481 | listview->setHeaderHidden(true); | 476 | listview->setHeaderHidden(true); | ||
482 | listview->setUniformRowHeights(true); | 477 | listview->setUniformRowHeights(true); | ||
483 | listview->setRootIsDecorated(false); | 478 | listview->setRootIsDecorated(false); | ||
484 | listview->setSelectionMode( QAbstractItemView::ContiguousSelection ); | 479 | listview->setSelectionMode( QAbstractItemView::ContiguousSelection ); | ||
485 | 480 | | |||
486 | if (data->outputdata.value(id)->behaviour & KDevelop::IOutputView::AutoScroll) { | 481 | if (data->outputdata.value(id)->behaviour & KDevelop::IOutputView::AutoScroll) { | ||
487 | listview->setAutoScrollAtEnd(true); | 482 | listview->setAutoScrollAtEnd(true); | ||
488 | } | 483 | } | ||
489 | 484 | | |||
490 | connect(listview, &QTreeView::activated, this, &OutputWidget::activate); | 485 | connect(listview, &QTreeView::activated, this, &OutputWidget::activate); | ||
491 | connect(listview, &QTreeView::clicked, this, &OutputWidget::activate); | 486 | connect(listview, &QTreeView::clicked, this, &OutputWidget::activate); | ||
492 | 487 | | |||
493 | return QSharedPointer<QTreeView>(listview); | 488 | return listview; | ||
494 | }; | 489 | }; | ||
495 | 490 | | |||
496 | QSharedPointer<QTreeView> listview; | 491 | QTreeView* listview = nullptr; | ||
497 | if( !m_views.contains(id) ) | 492 | if( !m_views.contains(id) ) | ||
498 | { | 493 | { | ||
499 | bool newView = true; | 494 | bool newView = true; | ||
500 | 495 | | |||
501 | if( data->type & KDevelop::IOutputView::MultipleView || data->type & KDevelop::IOutputView::HistoryView ) | 496 | if( data->type & KDevelop::IOutputView::MultipleView || data->type & KDevelop::IOutputView::HistoryView ) | ||
502 | { | 497 | { | ||
503 | qCDebug(PLUGIN_STANDARDOUTPUTVIEW) << "creating listview"; | 498 | qCDebug(PLUGIN_STANDARDOUTPUTVIEW) << "creating listview"; | ||
504 | listview = createHelper(); | 499 | listview = createHelper(); | ||
505 | 500 | | |||
506 | if( data->type & KDevelop::IOutputView::MultipleView ) | 501 | if( data->type & KDevelop::IOutputView::MultipleView ) | ||
507 | { | 502 | { | ||
508 | m_tabwidget->addTab(listview.data(), data->outputdata.value(id)->title); | 503 | m_tabwidget->addTab(listview, data->outputdata.value(id)->title); | ||
509 | } else | 504 | } else | ||
510 | { | 505 | { | ||
511 | m_stackwidget->addWidget(listview.data()); | 506 | const int index = m_stackwidget->addWidget(listview); | ||
512 | m_stackwidget->setCurrentWidget(listview.data()); | 507 | m_stackwidget->setCurrentIndex(index); | ||
513 | } | 508 | } | ||
514 | } else | 509 | } else | ||
515 | { | 510 | { | ||
516 | if( m_views.isEmpty() ) | 511 | if( m_views.isEmpty() ) | ||
517 | { | 512 | { | ||
518 | listview = createHelper(); | 513 | listview = createHelper(); | ||
519 | layout()->addWidget(listview.data()); | 514 | layout()->addWidget(listview); | ||
520 | } else | 515 | } else | ||
521 | { | 516 | { | ||
522 | listview = m_views.begin().value().view; | 517 | listview = m_views.begin()->view; | ||
523 | newView = false; | 518 | newView = false; | ||
524 | } | 519 | } | ||
525 | } | 520 | } | ||
526 | m_views[id].view = listview; | 521 | m_views[id].view = listview; | ||
527 | 522 | | |||
528 | changeModel( id ); | 523 | changeModel( id ); | ||
529 | changeDelegate( id ); | 524 | changeDelegate( id ); | ||
530 | 525 | | |||
531 | if (newView) | 526 | if (newView) | ||
532 | listview->scrollToBottom(); | 527 | listview->scrollToBottom(); | ||
533 | } else | 528 | } else | ||
534 | { | 529 | { | ||
535 | listview = m_views.value(id).view; | 530 | listview = m_views.value(id).view; | ||
536 | } | 531 | } | ||
537 | enableActions(); | 532 | enableActions(); | ||
538 | return listview.data(); | 533 | return listview; | ||
539 | } | 534 | } | ||
540 | 535 | | |||
541 | void OutputWidget::raiseOutput(int id) | 536 | void OutputWidget::raiseOutput(int id) | ||
542 | { | 537 | { | ||
543 | if( m_views.contains(id) ) | 538 | if( m_views.contains(id) ) | ||
544 | { | 539 | { | ||
545 | auto view = m_views.value(id).view.data(); | 540 | auto view = m_views.value(id).view; | ||
546 | if( data->type & KDevelop::IOutputView::MultipleView ) | 541 | if( data->type & KDevelop::IOutputView::MultipleView ) | ||
547 | { | 542 | { | ||
548 | int idx = m_tabwidget->indexOf(view); | 543 | int idx = m_tabwidget->indexOf(view); | ||
549 | if( idx >= 0 ) | 544 | if( idx >= 0 ) | ||
550 | { | 545 | { | ||
551 | m_tabwidget->setCurrentIndex( idx ); | 546 | m_tabwidget->setCurrentIndex( idx ); | ||
552 | } | 547 | } | ||
553 | } else if( data->type & KDevelop::IOutputView::HistoryView ) | 548 | } else if( data->type & KDevelop::IOutputView::HistoryView ) | ||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 625 | { | |||
636 | { | 631 | { | ||
637 | index = m_stackwidget->currentIndex(); | 632 | index = m_stackwidget->currentIndex(); | ||
638 | } | 633 | } | ||
639 | return index; | 634 | return index; | ||
640 | } | 635 | } | ||
641 | 636 | | |||
642 | void OutputWidget::outputFilter(const QString& filter) | 637 | void OutputWidget::outputFilter(const QString& filter) | ||
643 | { | 638 | { | ||
644 | QAbstractItemView *view = qobject_cast<QAbstractItemView*>(currentWidget()); | 639 | auto view = qobject_cast<QAbstractItemView*>(currentWidget()); | ||
645 | if( !view ) | 640 | if(!view) { | ||
Please no drive-by changes to lines not touched otherwise, especially non-whitespace changes. That make the "git blame" annotations confusing. kossebau: Please no drive-by changes to lines not touched otherwise, especially non-whitespace changes. | |||||
646 | return; | 641 | return; | ||
642 | } | ||||
647 | 643 | | |||
648 | auto fvIt = findFilteredView(view); | 644 | auto fvIt = findFilteredView(view); | ||
649 | auto proxyModel = qobject_cast<QSortFilterProxyModel*>(view->model()); | 645 | auto proxyModel = qobject_cast<QSortFilterProxyModel*>(view->model()); | ||
650 | if( !proxyModel ) | 646 | if(!proxyModel) | ||
651 | { | 647 | { | ||
652 | proxyModel = new QSortFilterProxyModel(view->model()); | 648 | fvIt->proxyModel = proxyModel = new QSortFilterProxyModel(view); | ||
653 | proxyModel->setDynamicSortFilter(true); | 649 | proxyModel->setDynamicSortFilter(true); | ||
654 | proxyModel->setSourceModel(view->model()); | 650 | proxyModel->setSourceModel(view->model()); | ||
655 | fvIt->proxyModel = QSharedPointer<QSortFilterProxyModel>(proxyModel); | | |||
656 | view->setModel(proxyModel); | 651 | view->setModel(proxyModel); | ||
657 | } | 652 | } | ||
658 | QRegExp regExp(filter, Qt::CaseInsensitive); | 653 | | ||
659 | proxyModel->setFilterRegExp(regExp); | 654 | proxyModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive)); | ||
kossebau: Unrelated change? | |||||
660 | fvIt->filter = filter; | 655 | fvIt->filter = filter; | ||
661 | } | 656 | } | ||
662 | 657 | | |||
663 | void OutputWidget::updateFilter(int index) | 658 | void OutputWidget::updateFilter(int index) | ||
664 | { | 659 | { | ||
665 | QWidget *view = (data->type & KDevelop::IOutputView::MultipleView) | 660 | if (index < 0) { | ||
666 | ? m_tabwidget->widget(index) : m_stackwidget->widget(index); | 661 | return; | ||
667 | auto fvIt = findFilteredView(qobject_cast<QAbstractItemView*>(view)); | 662 | } | ||
668 | 663 | | |||
669 | if (fvIt != m_views.end() && !fvIt->filter.isEmpty()) | 664 | QWidget* view = | ||
670 | { | 665 | (data->type & KDevelop::IOutputView::MultipleView) ? | ||
666 | m_tabwidget->widget(index) : | ||||
667 | m_stackwidget->widget(index); | ||||
668 | | ||||
669 | auto fvIt = findFilteredView(qobject_cast<QAbstractItemView*>(view)); | ||||
670 | if (fvIt != m_views.end() && !fvIt->filter.isEmpty()) { | ||||
671 | m_filterInput->setText(fvIt->filter); | 671 | m_filterInput->setText(fvIt->filter); | ||
672 | } else | 672 | } | ||
673 | { | 673 | else { | ||
674 | m_filterInput->clear(); | 674 | m_filterInput->clear(); | ||
675 | } | 675 | } | ||
676 | } | 676 | } | ||
677 | 677 | | |||
678 | void OutputWidget::setTitle(int outputId, const QString& title) | 678 | void OutputWidget::setTitle(int outputId, const QString& title) | ||
679 | { | 679 | { | ||
680 | auto fview = m_views.value(outputId, FilteredView{}); | 680 | auto fview = m_views.value(outputId, FilteredView{}); | ||
681 | if (fview.view && (data->type & KDevelop::IOutputView::MultipleView)) { | 681 | if (fview.view && (data->type & KDevelop::IOutputView::MultipleView)) { | ||
682 | int idx = m_tabwidget->indexOf(fview.view.data()); | 682 | const int idx = m_tabwidget->indexOf(fview.view); | ||
683 | if (idx >= 0) { | 683 | if (idx >= 0) { | ||
684 | m_tabwidget->setTabText(idx, title); | 684 | m_tabwidget->setTabText(idx, title); | ||
685 | } | 685 | } | ||
686 | } | 686 | } | ||
687 | } | 687 | } | ||
688 | 688 | | |||
689 | QHash<int, OutputWidget::FilteredView>::iterator OutputWidget::findFilteredView(QAbstractItemView *view) | 689 | QHash<int, OutputWidget::FilteredView>::iterator OutputWidget::findFilteredView(QAbstractItemView *view) | ||
690 | { | 690 | { | ||
691 | for (auto it = m_views.begin(); it != m_views.end(); ++it) { | 691 | for (auto it = m_views.begin(); it != m_views.end(); ++it) { | ||
692 | if (it->view == view) { | 692 | if (it->view == view) { | ||
693 | return it; | 693 | return it; | ||
694 | } | 694 | } | ||
695 | } | 695 | } | ||
696 | return m_views.end(); | 696 | return m_views.end(); | ||
697 | } | 697 | } |
Isn't m_views destroyed (and thus implicitely cleared) before reaching the ~QWidget and ~QObject destructors where then any QObject-child-tree memory management is done?
So do we really need to explicitly call this here?