[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kdevelop-bugs
Subject:    [Bug 135583] filter on app output-view not effective after app
From:       Jens Dagerbo <jens.dagerbo () swipnet ! se>
Date:       2007-01-01 7:10:04
Message-ID: 20070101071004.24583.qmail () ktown ! kde ! org
[Download RAW message or body]

------- 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  @
-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
 <class>FilterDlg</class>
 <widget class="QDialog">
     <property name="name">
 @ -8,8 +8,8  @
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>459</width>
-            <height>173</height>
+            <width>326</width>
+            <height>184</height>
         </rect>
     </property>
     <property name="caption">
 @ -91,7 +91,7  @
                 <cstring>filtergroup</cstring>
             </property>
             <property name="title">
-                <string>Filter Options</string>
+                <string>Filter</string>
             </property>
             <property name="checkable">
                 <bool>false</bool>
 @ -99,76 +99,52  @
             <property name="selectedId" stdset="0">
                 <number>0</number>
             </property>
-            <grid>
+            <vbox>
                 <property name="name">
                     <cstring>unnamed</cstring>
                 </property>
-                <widget class="QRadioButton" row="0" column="0">
+                <widget class="QLabel">
                     <property name="name">
-                        <cstring>rNoFilter</cstring>
+                        <cstring>textLabel1</cstring>
                     </property>
                     <property name="text">
-                        <string>No filter</string>
+                        <string>Only show lines matching:</string>
                     </property>
-                    <property name="checked">
-                        <bool>true</bool>
-                    </property>
                 </widget>
-                <widget class="QRadioButton" row="0" column="1">
+                <widget class="KLineEdit">
                     <property name="name">
-                        <cstring>rFilterStr</cstring>
+                        <cstring>filterString</cstring>
                     </property>
-                    <property name="text">
-                        <string>Filter for string</string>
-                    </property>
-                </widget>
-                <widget class="KLineEdit" row="1" column="1" rowspan="1" \
                colspan="3">
-                    <property name="name">
-                        <cstring>leFilterStr</cstring>
-                    </property>
                     <property name="enabled">
-                        <bool>false</bool>
+                        <bool>true</bool>
                     </property>
                 </widget>
-                <widget class="QRadioButton" row="0" column="2">
+                <widget class="QCheckBox">
                     <property name="name">
-                        <cstring>rFilterRegExp</cstring>
+                        <cstring>caseSensitive</cstring>
                     </property>
                     <property name="text">
-                        <string>Filter with regular expression</string>
+                        <string>C&amp;ase sensitive</string>
                     </property>
+                    <property name="accel">
+                        <string>Alt+A</string>
+                    </property>
                 </widget>
-                <spacer row="0" column="3">
+                <widget class="QCheckBox">
                     <property name="name">
-                        <cstring>spacer2</cstring>
+                        <cstring>regularExpression</cstring>
                     </property>
-                    <property name="orientation">
-                        <enum>Horizontal</enum>
-                    </property>
-                    <property name="sizeType">
-                        <enum>Expanding</enum>
-                    </property>
-                    <property name="sizeHint">
-                        <size>
-                            <width>40</width>
-                            <height>20</height>
-                        </size>
-                    </property>
-                </spacer>
-                <widget class="QCheckBox" row="2" column="1" rowspan="1" \
                colspan="3">
-                    <property name="name">
-                        <cstring>cbCase</cstring>
-                    </property>
                     <property name="text">
-                        <string>Match case-sensitve</string>
+                        <string>Re&amp;gular expression</string>
                     </property>
+                    <property name="accel">
+                        <string>Alt+G</string>
+                    </property>
                 </widget>
-            </grid>
+            </vbox>
         </widget>
     </grid>
 </widget>
-<customwidgets>
-</customwidgets>
 <connections>
     <connection>
         <sender>buttonOk</sender>
 @ -182,12 +158,6  @
         <receiver>FilterDlg</receiver>
         <slot>reject()</slot>
     </connection>
-    <connection>
-        <sender>rNoFilter</sender>
-        <signal>toggled(bool)</signal>
-        <receiver>leFilterStr</receiver>
-        <slot>setDisabled(bool)</slot>
-    </connection>
 </connections>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic