Fixed Image Preview in FileDialog
authorinsilmaril
Wed, 08 Mar 2006 12:59:07 +0000
changeset 2345115a9d93e86
parent 233 c3943fbd0e74
child 235 402f4cde3ea6
Fixed Image Preview in FileDialog
exports.cpp
exports.h
file.cpp
     1.1 --- a/exports.cpp	Tue Mar 07 11:32:02 2006 +0000
     1.2 +++ b/exports.cpp	Wed Mar 08 12:59:07 2006 +0000
     1.3 @@ -231,6 +231,7 @@
     1.4  ExportOO::ExportOO()
     1.5  {
     1.6  	useSections=false;
     1.7 +	skipPageFlag="cross-red";
     1.8  }
     1.9  
    1.10  ExportOO::~ExportOO()
    1.11 @@ -247,17 +248,20 @@
    1.12      if (bo)
    1.13      {
    1.14          // Start list
    1.15 -        r+="<text:list text:style-name=\"L4\">\n";
    1.16 +        r+="<text:list text:style-name=\"vym-list\">\n";
    1.17          while (bo)
    1.18          {
    1.19 -            r+="<text:list-item><text:p >";
    1.20 -			r+=quotemeta(bo->getHeading());
    1.21 -			// If necessary, write note
    1.22 -			if (!bo->getNote().isEmpty())
    1.23 -				r+=bo->getNoteOpenDoc();
    1.24 -			r+="</text:p>";
    1.25 -			r+=buildList (bo);	// recursivly add deeper branches
    1.26 -            r+="</text:list-item>\n";
    1.27 +			if (!bo->isActiveFlag (skipPageFlag))
    1.28 +			{
    1.29 +				r+="<text:list-item><text:p >";
    1.30 +				r+=quotemeta(bo->getHeading());
    1.31 +				// If necessary, write note
    1.32 +				if (!bo->getNote().isEmpty())
    1.33 +					r+=bo->getNoteOpenDoc();
    1.34 +				r+="</text:p>";
    1.35 +				r+=buildList (bo);	// recursivly add deeper branches
    1.36 +				r+="</text:list-item>\n";
    1.37 +			}
    1.38  			i++;
    1.39  			bo=current->getBranchNum(i);
    1.40          }
    1.41 @@ -305,11 +309,14 @@
    1.42  		while (pagesBO)
    1.43  		{
    1.44  			// Add page with list of items
    1.45 -			onePage=pageTemplate;
    1.46 -			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
    1.47 -			list=buildList (pagesBO);
    1.48 -			onePage.replace ("<!-- INSERT LIST -->", list);
    1.49 -			allPages+=onePage;
    1.50 +			if (!pagesBO->isActiveFlag (skipPageFlag))
    1.51 +			{
    1.52 +				onePage=pageTemplate;
    1.53 +				onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
    1.54 +				list=buildList (pagesBO);
    1.55 +				onePage.replace ("<!-- INSERT LIST -->", list);
    1.56 +				allPages+=onePage;
    1.57 +			}
    1.58  			j++;
    1.59  			pagesBO=sectionBO->getBranchNum(j);
    1.60  		}
     2.1 --- a/exports.h	Tue Mar 07 11:32:02 2006 +0000
     2.2 +++ b/exports.h	Wed Mar 08 12:59:07 2006 +0000
     2.3 @@ -69,6 +69,7 @@
     2.4  	bool setConfigFile (const QString &);
     2.5  private:
     2.6  	QString buildList (BranchObj*);
     2.7 +	QString skipPageFlag;
     2.8  	bool useSections;
     2.9  	QString configFile;
    2.10  	QString configDir;
     3.1 --- a/file.cpp	Tue Mar 07 11:32:02 2006 +0000
     3.2 +++ b/file.cpp	Wed Mar 08 12:59:07 2006 +0000
     3.3 @@ -257,8 +257,9 @@
     3.4  }
     3.5  
     3.6  
     3.7 -ImagePreview::ImagePreview (QWidget *parent=0): QLabel (parent)
     3.8 +ImagePreview::ImagePreview (QWidget *par=0): QLabel (par)
     3.9  {
    3.10 +	fdia=(QFileDialog*)par;
    3.11  }
    3.12  
    3.13  void ImagePreview::previewUrl( const QUrl &u )
    3.14 @@ -266,7 +267,18 @@
    3.15      QString path = u.path();
    3.16      QPixmap pix( path );
    3.17      if ( pix.isNull() )
    3.18 -        setText( QObject::tr("This is not an image.") );
    3.19 +	{
    3.20 +		// Strange: If we have fd->setMode (QFileDialog::ExistingFiles)
    3.21 +		// in the filedialog, then there are 3 calls to previewURL 
    3.22 +		// for each selection. And only the first is the actual selected file
    3.23 +		// while the following 2 point to the directory above the current one.
    3.24 +		// So here's my workaround:
    3.25 +		
    3.26 +		if (fdia && fdia->selectedFiles().count()==0)
    3.27 +			setText( QObject::tr("This is not an image.") );
    3.28 +		if (fdia &&fdia->selectedFiles().count()>1)
    3.29 +			setText( QObject::tr("Sorry, no preview for\nmultiple selected files.") );
    3.30 +	}	
    3.31      else
    3.32  	{
    3.33  		float max_w=300;