View Issue Details

IDProjectCategoryView StatusLast Update
0007126ScribusUser Interfacepublic2008-09-16 19:41
Reporterelvstone Assigned Tofschmid  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Platformx86OSKubuntu LinuxOS Version8.04.1
Product Version1.3.5svn 
Fixed in Version1.3.5svn 
Summary0007126: [PATCH] Add keyword/regexp filter to the Outline palette
DescriptionThe attached patch adds a line edit to the top of the Outline palette, where you can filter the Outline on object names using a keyword/regexp. I'm also attaching an image that shows what it looks like.
TagsNo tags attached.
Patch

Relationships

related to 0007147 feedback regexp in outline dialog not working with cyr letters 

Activities

2008-07-08 18:05

 

outline-filter.diff (5,293 bytes)   
Index: scribus/outlinepalette.cpp
===================================================================
--- scribus/outlinepalette.cpp	(revision 12370)
+++ scribus/outlinepalette.cpp	(working copy)
@@ -10,6 +10,9 @@
 #include <QHelpEvent>
 #include <QImage>
 #include <QLabel>
+#include <QLineEdit>
+#include <QGridLayout>
+#include <QShortcut>
 #include <QLayout>
 #include <QList>
 #include <QMenu>
@@ -131,14 +134,16 @@
 
 OutlinePalette::OutlinePalette( QWidget* parent) : ScrPaletteBase( parent, "Tree", false, 0 )
 {
-	resize( 220, 240 );
 	setMinimumSize( QSize( 220, 240 ) );
 	setMaximumSize( QSize( 800, 600 ) );
 
+	filterEdit = new QLineEdit;
+	filterEdit->setToolTip( tr("Enter a keyword or regular expression to filter the outline.") );
+	QShortcut* filterShortcut = new QShortcut( QKeySequence( tr( "Ctrl+f", "Filter the Outline using a keyword" ) ), this );
+	filterLabel = new QLabel( tr("Filter:") );
+	filterLabel->setBuddy( filterEdit );
+
 	reportDisplay = new OutlineWidget( this );
-
-	reportDisplay->setGeometry( QRect( 0, 0, 220, 240 ) );
-	reportDisplay->setMinimumSize( QSize( 220, 240 ) );
 	reportDisplay->setRootIsDecorated( true );
 	reportDisplay->setColumnCount(1);
 	reportDisplay->setHeaderLabel( tr("Element"));
@@ -147,6 +152,14 @@
 	reportDisplay->setSortingEnabled(false);
 	reportDisplay->setSelectionMode(QAbstractItemView::ExtendedSelection);
 	reportDisplay->setContextMenuPolicy(Qt::CustomContextMenu);
+
+	QGridLayout* layout = new QGridLayout;
+	layout->addWidget( filterLabel, 0, 0 );
+	layout->addWidget( filterEdit, 0, 1 );
+	layout->addWidget( reportDisplay, 1, 0, 1, 2 );
+	layout->setContentsMargins( 3, 3, 3, 3);
+	setLayout( layout );
+
 	unsetDoc();
 	imageIcon = loadIcon("22/insert-image.png");
 	latexIcon = loadIcon("22/insert-latex.png");
@@ -172,6 +185,8 @@
 	connect(reportDisplay, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(slotRightClick(QPoint)));
 	connect(reportDisplay, SIGNAL(itemSelectionChanged()), this, SLOT(slotMultiSelect()));
 	connect(reportDisplay, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotDoRename(QTreeWidgetItem*, int)));
+	connect(filterEdit, SIGNAL(textChanged(const QString&)), this, SLOT(filterTree(const QString&)));
+	connect(filterShortcut, SIGNAL(activated()), filterEdit, SLOT(setFocus()));
 }
 
 void OutlinePalette::setMainWindow(ScribusMainWindow *mw)
@@ -280,6 +295,7 @@
 				}
 			}
 		}
+		filterTree();
 	}
 	connect(reportDisplay, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotDoRename(QTreeWidgetItem*, int)));
 }
@@ -603,11 +619,6 @@
 	selectionTriggered = false;
 }
 
-void OutlinePalette::resizeEvent(QResizeEvent *r)
-{
-	reportDisplay->resize(r->size());
-}
-
 void OutlinePalette::BuildTree(bool storeVals)
 {
 	if (!m_MainWindow || m_MainWindow->ScriptRunning)
@@ -792,11 +803,39 @@
 	setUpdatesEnabled(true);
 	if (currDoc->m_Selection->count() > 0)
 		slotShowSelect(0, -1);
+	filterTree();
 	repaint();
 	connect(reportDisplay, SIGNAL(itemSelectionChanged()), this, SLOT(slotMultiSelect()));
 	connect(reportDisplay, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotDoRename(QTreeWidgetItem*, int)));
 }
 
+void OutlinePalette::filterTree(const QString& keyword)
+{
+	OutlineTreeItem *item = NULL;
+	QTreeWidgetItemIterator it( reportDisplay );
+	while ( (*it) )
+	{
+		item = dynamic_cast<OutlineTreeItem*>(*it);
+		if (item != NULL) {
+			if ((item->type == 1) || (item->type == 3) || (item->type == 4)) {
+				if (item->PageItemObject->itemName().contains(QRegExp(keyword)))
+					item->setHidden(false);
+				else
+					item->setHidden(true);
+			} else
+				item->setHidden(false);
+		}
+
+		++it;
+	}
+}
+
+void OutlinePalette::filterTree()
+{
+	if ( !filterEdit->text().isEmpty() )
+		filterTree( filterEdit->text() );
+}
+
 void OutlinePalette::parseSubGroup(int level, OutlineTreeItem* object, QList<PageItem*> *subGroupList, int itemType)
 {
 	QList<PageItem*> *subGroup;
@@ -858,6 +897,7 @@
 {
 	setWindowTitle( tr("Outline"));
 	reportDisplay->setHeaderLabel( tr("Element"));
+	filterLabel->setText( tr("Filter:") );
 }
 
 void OutlinePalette::clearPalette()
Index: scribus/outlinepalette.h
===================================================================
--- scribus/outlinepalette.h	(revision 12370)
+++ scribus/outlinepalette.h	(working copy)
@@ -10,8 +10,9 @@
 #include <QPixmap>
 #include <QTreeWidget>
 #include <QTreeWidgetItem>
-#include <QResizeEvent>
+#include <QLineEdit>
 #include <QList>
+#include <QLabel>
 
 class QEvent;
 
@@ -52,7 +53,6 @@
 	
 	virtual void changeEvent(QEvent *e);
 	
-	void resizeEvent(QResizeEvent *r);
 	void setMainWindow(ScribusMainWindow *mw);
 	void setDoc(ScribusDoc *);
 	void unsetDoc();
@@ -64,6 +64,7 @@
 
 public slots:
 	void BuildTree(bool storeVals = true);
+	void filterTree(const QString& keyword);
 	void languageChange();
 	void slotShowSelect(uint SNr, int Nr);
 	void setPaletteShown(bool);
@@ -81,8 +82,11 @@
 	void slotMultiSelect();
 	void slotSelect(QTreeWidgetItem* ite, int col);
 protected:
+	void filterTree();
 	void clearPalette();
 	void createContextMenu(PageItem *currItem, double mx, double my);
+	QLabel* filterLabel;
+	QLineEdit* filterEdit;
 	OutlineWidget* reportDisplay;
 	QTreeWidgetItem* freeObjects;
 	QTreeWidgetItem* rootObject;
outline-filter.diff (5,293 bytes)   

2008-07-08 18:05

 

outline-filter.png (192,534 bytes)   
outline-filter.png (192,534 bytes)   

Issue History

Date Modified Username Field Change
2008-07-08 18:05 elvstone New Issue
2008-07-08 18:05 elvstone File Added: outline-filter.diff
2008-07-08 18:05 elvstone File Added: outline-filter.png
2008-07-09 11:04 fschmid Status new => assigned
2008-07-09 11:04 fschmid Assigned To => fschmid
2008-07-09 20:35 fschmid Status assigned => resolved
2008-07-09 20:35 fschmid Fixed in Version => 1.3.5svn
2008-07-09 20:35 fschmid Resolution open => fixed
2008-07-19 21:13 cbradney Relationship added related to 0007147
2008-09-16 19:41 cbradney Status resolved => closed