# HG changeset patch
# User insilmaril
# Date 1141822747 0
# Node ID 5115a9d93e867a2beaf3a0015cc05c17ea233c0c
# Parent  c3943fbd0e74de04c49d62a598c583cc7763a782
Fixed Image Preview in FileDialog

diff -r c3943fbd0e74 -r 5115a9d93e86 exports.cpp
--- a/exports.cpp	Tue Mar 07 11:32:02 2006 +0000
+++ b/exports.cpp	Wed Mar 08 12:59:07 2006 +0000
@@ -231,6 +231,7 @@
 ExportOO::ExportOO()
 {
 	useSections=false;
+	skipPageFlag="cross-red";
 }
 
 ExportOO::~ExportOO()
@@ -247,17 +248,20 @@
     if (bo)
     {
         // Start list
-        r+="<text:list text:style-name=\"L4\">\n";
+        r+="<text:list text:style-name=\"vym-list\">\n";
         while (bo)
         {
-            r+="<text:list-item><text:p >";
-			r+=quotemeta(bo->getHeading());
-			// If necessary, write note
-			if (!bo->getNote().isEmpty())
-				r+=bo->getNoteOpenDoc();
-			r+="</text:p>";
-			r+=buildList (bo);	// recursivly add deeper branches
-            r+="</text:list-item>\n";
+			if (!bo->isActiveFlag (skipPageFlag))
+			{
+				r+="<text:list-item><text:p >";
+				r+=quotemeta(bo->getHeading());
+				// If necessary, write note
+				if (!bo->getNote().isEmpty())
+					r+=bo->getNoteOpenDoc();
+				r+="</text:p>";
+				r+=buildList (bo);	// recursivly add deeper branches
+				r+="</text:list-item>\n";
+			}
 			i++;
 			bo=current->getBranchNum(i);
         }
@@ -305,11 +309,14 @@
 		while (pagesBO)
 		{
 			// Add page with list of items
-			onePage=pageTemplate;
-			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
-			list=buildList (pagesBO);
-			onePage.replace ("<!-- INSERT LIST -->", list);
-			allPages+=onePage;
+			if (!pagesBO->isActiveFlag (skipPageFlag))
+			{
+				onePage=pageTemplate;
+				onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
+				list=buildList (pagesBO);
+				onePage.replace ("<!-- INSERT LIST -->", list);
+				allPages+=onePage;
+			}
 			j++;
 			pagesBO=sectionBO->getBranchNum(j);
 		}
diff -r c3943fbd0e74 -r 5115a9d93e86 exports.h
--- a/exports.h	Tue Mar 07 11:32:02 2006 +0000
+++ b/exports.h	Wed Mar 08 12:59:07 2006 +0000
@@ -69,6 +69,7 @@
 	bool setConfigFile (const QString &);
 private:
 	QString buildList (BranchObj*);
+	QString skipPageFlag;
 	bool useSections;
 	QString configFile;
 	QString configDir;
diff -r c3943fbd0e74 -r 5115a9d93e86 file.cpp
--- a/file.cpp	Tue Mar 07 11:32:02 2006 +0000
+++ b/file.cpp	Wed Mar 08 12:59:07 2006 +0000
@@ -257,8 +257,9 @@
 }
 
 
-ImagePreview::ImagePreview (QWidget *parent=0): QLabel (parent)
+ImagePreview::ImagePreview (QWidget *par=0): QLabel (par)
 {
+	fdia=(QFileDialog*)par;
 }
 
 void ImagePreview::previewUrl( const QUrl &u )
@@ -266,7 +267,18 @@
     QString path = u.path();
     QPixmap pix( path );
     if ( pix.isNull() )
-        setText( QObject::tr("This is not an image.") );
+	{
+		// Strange: If we have fd->setMode (QFileDialog::ExistingFiles)
+		// in the filedialog, then there are 3 calls to previewURL 
+		// for each selection. And only the first is the actual selected file
+		// while the following 2 point to the directory above the current one.
+		// So here's my workaround:
+		
+		if (fdia && fdia->selectedFiles().count()==0)
+			setText( QObject::tr("This is not an image.") );
+		if (fdia &&fdia->selectedFiles().count()>1)
+			setText( QObject::tr("Sorry, no preview for\nmultiple selected files.") );
+	}	
     else
 	{
 		float max_w=300;