------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. http://bugs.kde.org/show_bug.cgi?id=135583 jens.dagerbo swipnet se changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED ------- Additional Comments From jens.dagerbo swipnet se 2007-01-01 08:10 ------- SVN commit 618398 by dagerbo: Patch to: # make UI understandable # persist the filter and apply it during a run, not just after BUG: 135583 M +2 -2 appoutputviewpart.cpp M +110 -74 appoutputwidget.cpp M +19 -11 appoutputwidget.h M +24 -54 filterdlg.ui --- branches/kdevelop/3.4/parts/outputviews/appoutputviewpart.cpp #618397:618398 @ -110,7 +110,7 @ } else cmd = program; - m_widget->strList.clear(); + m_widget->clearViewAndContents(); if ( directory.isNull() ) // use the user's home directory @ -145,7 +145,7 @ void AppOutputViewPart::clearView() { - m_widget->clearView(); + m_widget->clearViewAndContents(); } #include "appoutputviewpart.moc" --- branches/kdevelop/3.4/parts/outputviews/appoutputwidget.cpp #618397:618398 @ -34,8 +34,7 @ #include "kdevproject.h" AppOutputWidget::AppOutputWidget(AppOutputViewPart* part) - : ProcessWidget(0, "app output widget"), iFilterType(eNoFilter) - , m_part(part) + : ProcessWidget(0, "app output widget"), m_part(part) { connect(this, SIGNAL(executed(QListBoxItem*)), SLOT(slotRowSelected(QListBoxItem*))); connect(this, SIGNAL(rightButtonClicked( QListBoxItem *, const QPoint & )), @ -45,9 +44,9 @ setFont(config->readFontEntry("OutputViewFont")); } -void AppOutputWidget::clearView() +void AppOutputWidget::clearViewAndContents() { - strList.clear(); + m_contentList.clear(); clear(); } @ -95,101 +94,138 @ void AppOutputWidget::insertStdoutLine(const QString &line) { kdDebug(9004) << k_funcinfo << line << endl; - strList.append(QString("o-")+line); - ProcessWidget::insertStdoutLine(line); + m_contentList.append(QString("o-")+line); + if ( filterSingleLine( line ) ) + { + ProcessWidget::insertStdoutLine(line); + } } void AppOutputWidget::insertStderrLine(const QString &line) { kdDebug(9004) << k_funcinfo << line << endl; - strList.append(QString("e-")+line); - ProcessWidget::insertStderrLine(line); + m_contentList.append(QString("e-")+line); + if ( filterSingleLine( line ) ) + { + ProcessWidget::insertStderrLine(line); + } } +void AppOutputWidget::editFilter() +{ + FilterDlg dlg( this ); + dlg.caseSensitive->setChecked( m_filter.m_caseSensitive ); + dlg.regularExpression->setChecked( m_filter.m_isRegExp ); + dlg.filterString->setText( m_filter.m_filterString ); -void AppOutputWidget::slotContextMenu( QListBoxItem *, const QPoint &p ) + if ( dlg.exec() == QDialog::Accepted ) + { + m_filter.m_caseSensitive = dlg.caseSensitive->isChecked(); + m_filter.m_isRegExp = dlg.regularExpression->isChecked(); + m_filter.m_filterString = dlg.filterString->text(); + + m_filter.m_isActive = !m_filter.m_filterString.isEmpty(); + + reinsertAndFilter(); + } + +} +bool AppOutputWidget::filterSingleLine(const QString & line) { - //generate the popupmenu first - KPopupMenu popup(this, "filter output"); + if ( !m_filter.m_isActive ) return true; - int idNoFilter = popup.insertItem( i18n("Do Not Filter Output") ); - popup.setItemChecked(idNoFilter, iFilterType == eNoFilter); + if ( m_filter.m_isRegExp ) + { + return ( line.find( QRegExp( m_filter.m_filterString, m_filter.m_caseSensitive, false ) ) != -1 ); + } + else + { + return ( line.find( m_filter.m_filterString, 0, m_filter.m_caseSensitive ) != -1 ); + } +} - int idFilter = popup.insertItem( i18n("Filter Output") ); - popup.setItemChecked(idFilter, iFilterType == eFilterStr || iFilterType == eFilterRegExp); +void AppOutputWidget::reinsertAndFilter() +{ + //copy the first item from the listbox + //if a programm was started, this contains the issued command + QString issuedCommand; + if ( count() > 0 ) + { + setTopItem(0); + issuedCommand = item(topItem())->text(); + } - popup.insertSeparator(); - popup.insertItem( i18n("Hide view"), this, SLOT(hideView()) ); + clear(); - //pop it up - int res = popup.exec(p); + //write back the issued command + if ( !issuedCommand.isEmpty() ) + { + insertItem( new ProcessListBoxItem( issuedCommand, ProcessListBoxItem::Diagnostic ) ); + } - //init the query dialog with current data - FilterDlg dlg(this, "filter output settings"); - dlg.filtergroup->setButton((int)iFilterType); - dlg.cbCase->setChecked(bCS); - dlg.leFilterStr->setText(strFilterStr); - - //did user select the filter item from the popup - //and did he accept the filter-dialog - if (res == idFilter || res == idNoFilter) { - if (res == idFilter) { - if ( dlg.exec() != QDialog::Accepted ) - return; - //get back data from the dialog - if (dlg.rNoFilter->isChecked()) - iFilterType = eNoFilter; - else if (dlg.rFilterStr->isChecked()) - iFilterType = eFilterStr; - else if (dlg.rFilterRegExp->isChecked()) - iFilterType = eFilterRegExp; - strFilterStr = dlg.leFilterStr->text(); - bCS = dlg.cbCase->isChecked(); - } else { - iFilterType = eNoFilter; + //grep through the list for items matching the filter... + QStringList strListFound; + if ( m_filter.m_isActive ) + { + if ( m_filter.m_isRegExp ) + { + strListFound = m_contentList.grep( QRegExp(m_filter.m_filterString, m_filter.m_caseSensitive, false ) ); } - - //copy the first item from the listbox - //if a programm was started, this contains the issued command - QString strFirst=QString::null; - if (count()) { - setTopItem(0); - strFirst = item(topItem())->text(); + else + { + strListFound = m_contentList.grep( m_filter.m_filterString, m_filter.m_caseSensitive ); } - //clear the listbox and write back the issued command - clear(); - if (strFirst != QString::null) - insertItem(new ProcessListBoxItem(strFirst, ProcessListBoxItem::Diagnostic)); + } + else + { + strListFound = m_contentList; + } - //grep through the QList for items matching the filter... - QStringList strListFound; - if (iFilterType == eFilterStr) - strListFound = strList.grep(strFilterStr, bCS); - else if (iFilterType == eFilterRegExp) - strListFound = strList.grep(QRegExp(strFilterStr, bCS, false)); - else if (iFilterType == eNoFilter) - strListFound = strList; - - //... and reinsert the found items into the listbox - for ( QStringList::Iterator it = strListFound.begin(); it != strListFound.end(); ++it ) { - if ((*it).startsWith("o-")) { - (*it).remove(0,2); - insertItem(new ProcessListBoxItem(*it, ProcessListBoxItem::Normal)); - } else if ((*it).startsWith("e")) { - (*it).remove(0,2); - insertItem(new ProcessListBoxItem(*it, ProcessListBoxItem::Error)); - } + //... and reinsert the found items into the listbox + for ( QStringList::Iterator it = strListFound.begin(); it != strListFound.end(); ++it ) + { + if ((*it).startsWith("o-")) + { + (*it).remove(0,2); + insertItem(new ProcessListBoxItem(*it, ProcessListBoxItem::Normal)); + } + else if ((*it).startsWith("e")) + { + (*it).remove(0,2); + insertItem(new ProcessListBoxItem(*it, ProcessListBoxItem::Error)); } - } else if (res == idNoFilter) { - iFilterType = eNoFilter; } } +void AppOutputWidget::clearFilter() +{ + m_filter.m_isActive = false; + reinsertAndFilter(); +} + +void AppOutputWidget::slotContextMenu( QListBoxItem *, const QPoint &p ) +{ + KPopupMenu popup(this, "filter output"); + + int id = popup.insertItem( i18n("Clear output"), this, SLOT(clearViewAndContents()) ); + popup.setItemEnabled( id, m_contentList.size() > 0 ); + popup.insertSeparator(); + + id = popup.insertItem( i18n("Clear filter"), this, SLOT(clearFilter()) ); + popup.setItemEnabled( id, m_filter.m_isActive ); + + popup.insertItem( i18n("Edit Filter"), this, SLOT(editFilter() ) ); + + popup.insertSeparator(); + popup.insertItem( i18n("Hide view"), this, SLOT(hideView()) ); + + popup.exec(p); +} + void AppOutputWidget::hideView() { m_part->mainWindow()->setViewAvailable( this , false ); } - #include "appoutputwidget.moc" --- branches/kdevelop/3.4/parts/outputviews/appoutputwidget.h #618397:618398 @ -19,12 +19,6 @ class AppOutputViewPart; -enum FilterType { - eNoFilter=0, - eFilterStr=1, - eFilterRegExp=2 -}; - class AppOutputWidget : public ProcessWidget { Q_OBJECT @ -33,7 +27,6 @ AppOutputWidget(AppOutputViewPart* part); ~AppOutputWidget(); // clears our own store and the one of our base ProcessWidget - void clearView(); public slots: void slotRowSelected(QListBoxItem* row); @ -41,16 +34,31 @ void insertStderrLine(const QString &line); void slotContextMenu(QListBoxItem *, const QPoint &); void hideView(); + void clearViewAndContents(); + void clearFilter(); + void editFilter(); private: virtual void childFinished(bool normal, int status); + void reinsertAndFilter(); + bool filterSingleLine( const QString & line ); - QStringList strList; - FilterType iFilterType; - QString strFilterStr; - bool bCS; + QStringList m_contentList; +// FilterType iFilterType; +// QString strFilterStr; +// bool bCS; + struct OutputFilter + { + OutputFilter() : m_isActive(false), m_isRegExp(false), m_caseSensitive(false) {} + bool m_isActive; + bool m_isRegExp; + bool m_caseSensitive; + QString m_filterString; + }; + AppOutputViewPart* m_part; + OutputFilter m_filter; }; #endif --- branches/kdevelop/3.4/parts/outputviews/filterdlg.ui #618397:618398 @ -1,4 +1,4 @ - + FilterDlg @ -8,8 +8,8 @ 0 0 - 459 - 173 + 326 + 184 @ -91,7 +91,7 @ filtergroup - Filter Options + Filter false @ -99,76 +99,52 @ 0 - + unnamed - + - rNoFilter + textLabel1 - No filter + Only show lines matching: - - true - - + - rFilterStr + filterString - - Filter for string - - - - - leFilterStr - - false + true - + - rFilterRegExp + caseSensitive - Filter with regular expression + C&ase sensitive + + Alt+A + - + - spacer2 + regularExpression - - Horizontal - - - Expanding - - - - 40 - 20 - - - - - - cbCase - - Match case-sensitve + Re&gular expression + + Alt+G + - + - - buttonOk @ -182,12 +158,6 @ FilterDlg reject() - - rNoFilter - toggled(bool) - leFilterStr - setDisabled(bool) -