r22715 by jghali - fix problematic definition of PageItem's setExternalFile(), setFileIconPressed() and setFileIconRollover()

scribus-commit scribus-commit at lists.scribus.net
Sun Sep 30 22:18:38 UTC 2018


Author: jghali
Date: Sun Sep 30 22:18:38 2018
New Revision: 22715

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22715
Log:
fix problematic definition of PageItem's setExternalFile(), setFileIconPressed() and setFileIconRollover()

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22715&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Sun Sep 30 22:18:38 2018
@@ -9807,40 +9807,61 @@
 	}
 }
 
-void PageItem::setExternalFile(const QString& filename)
+void PageItem::setExternalFile(const QString& filename, const QString& baseDir)
 {
 	Pfile = filename;
-	if (!Pfile.isEmpty())
-	{
-		QString test = Pfile;
-		if (QDir::isRelativePath(test))
-			test = QDir::homePath()+"/"+Pfile;
-		test = QDir::cleanPath(QDir::toNativeSeparators(test));
-		QFileInfo pfi2(test);
-		Pfile = pfi2.absoluteFilePath();
-	}
-}
-
-void PageItem::setFileIconPressed(const QString& filename)
+	if (Pfile.isEmpty())
+		return;
+
+	QString test = Pfile;
+	if (QDir::isRelativePath(test))
+	{
+		if (baseDir.isEmpty())
+			test = QDir::homePath() + "/" + Pfile;
+		else
+			test = baseDir + "/" + Pfile;
+	}
+	test = QDir::cleanPath(QDir::toNativeSeparators(test));
+	QFileInfo pfi2(test);
+	Pfile = pfi2.absoluteFilePath();
+}
+
+void PageItem::setFileIconPressed(const QString& filename, const QString& baseDir)
 {
 	Pfile2 = filename;
-	if (!Pfile2.isEmpty())
-	{
-		QString test = QDir::cleanPath(QDir::toNativeSeparators(QDir::homePath()+"/"+Pfile2));
-		QFileInfo pfi2(test);
-		Pfile2 = pfi2.absoluteFilePath();
-	}
-}
-
-void PageItem::setFileIconRollover(const QString& filename)
+	if (Pfile2.isEmpty())
+		return;
+
+	QString test = Pfile2;
+	if (QDir::isRelativePath(test))
+	{
+		if (baseDir.isEmpty())
+			test = QDir::homePath() + "/" + Pfile2;
+		else
+			test = baseDir + "/" + Pfile2;
+	}
+	test = QDir::cleanPath(QDir::toNativeSeparators(test));
+	QFileInfo pfi2(test);
+	Pfile2 = pfi2.absoluteFilePath();
+}
+
+void PageItem::setFileIconRollover(const QString& filename, const QString& baseDir)
 {
 	Pfile3 = filename;
-	if (!Pfile3.isEmpty())
-	{
-		QString test = QDir::cleanPath(QDir::toNativeSeparators(QDir::homePath()+"/"+Pfile3));
-		QFileInfo pfi2(test);
-		Pfile3 = pfi2.absoluteFilePath();
-	}
+	if (Pfile3.isEmpty())
+		return;
+
+	QString test = Pfile3;
+	if (QDir::isRelativePath(test))
+	{
+		if (baseDir.isEmpty())
+			test = QDir::homePath() + "/" + Pfile3;
+		else
+			test = baseDir + "/" + Pfile3;
+	}
+	test = QDir::cleanPath(QDir::toNativeSeparators(test));
+	QFileInfo pfi2(test);
+	Pfile3 = pfi2.absoluteFilePath();
 }
 
 PageItem* PageItem::firstInChain()

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22715&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h	(original)
+++ trunk/Scribus/scribus/pageitem.h	Sun Sep 30 22:18:38 2018
@@ -434,15 +434,16 @@
 	void setEmbeddedImageProfile(const QString& val) { EmProfile = val; }
 	bool drawFrame() { return ((m_ItemType == TextFrame && !m_sampleItem) || (m_ItemType == ImageFrame) || (m_ItemType == PathText)); }
 	QString externalFile() const { return Pfile; }
-	void setExternalFile(const QString& filename);
+	void setExternalFile(const QString& filename, const QString& baseDir = QString());
 	void setImagePagenumber(int num) { pixm.imgInfo.actualPageNumber = num; }
 	void setResolution(int);
 
 	//FIXME: maybe these should go into annotation?
 	QString fileIconPressed() const { return Pfile2; }
-	void setFileIconPressed(const QString& filename);
+	void setFileIconPressed(const QString& filename, const QString& baseDir = QString());
 	QString fileIconRollover() const { return Pfile3; }
-	void setFileIconRollover(const QString& filename);
+	void setFileIconRollover(const QString& filename, const QString& baseDir = QString());
+
 	int  cmsRenderingIntent() const { return IRender; }
 	void setCmsRenderingIntent(eRenderIntent val) { IRender = val; }
 	QString cmsProfile() const { return IProfile; }




More information about the scribus-commit mailing list