r18254 by fschmid - Don't use LoadSavePlugin::unregisterAll() in languageChange()

scribus-commit scribus-commit at lists.scribus.net
Wed Apr 17 19:44:03 UTC 2013


Author: fschmid
Date: Wed Apr 17 19:44:02 2013
New Revision: 18254

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18254
Log:
Don't use LoadSavePlugin::unregisterAll() in languageChange()

Modified:
    trunk/Scribus/scribus/loadsaveplugin.cpp
    trunk/Scribus/scribus/loadsaveplugin.h
    trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp
    trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp
    trunk/Scribus/scribus/plugins/import/pct/importpctplugin.cpp
    trunk/Scribus/scribus/plugins/import/pdf/importpdfplugin.cpp
    trunk/Scribus/scribus/plugins/import/shape/importshapeplugin.cpp
    trunk/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp
    trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
    trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp
    trunk/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp
    trunk/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp
    trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
    trunk/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp

Modified: trunk/Scribus/scribus/loadsaveplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/loadsaveplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/loadsaveplugin.cpp (original)
+++ trunk/Scribus/scribus/loadsaveplugin.cpp Wed Apr 17 19:44:02 2013
@@ -37,6 +37,15 @@
 }
 
 const FileFormat * LoadSavePlugin::getFormatById(const int id)
+{
+	QList<FileFormat>::iterator it(findFormat(id));
+	if (it == formats.end())
+		return 0;
+	else
+		return &(*it);
+}
+
+FileFormat * LoadSavePlugin::getFormatByID(int id)
 {
 	QList<FileFormat>::iterator it(findFormat(id));
 	if (it == formats.end())
@@ -343,34 +352,25 @@
 }
 
 QList<FileFormat>::iterator
-LoadSavePlugin::findFormat(unsigned int id,
-						   LoadSavePlugin* plug,
-						   QList<FileFormat>::iterator it)
+LoadSavePlugin::findFormat(unsigned int id, LoadSavePlugin* plug, QList<FileFormat>::iterator it)
 {
 	QList<FileFormat>::iterator itEnd(formats.end());
 	for ( ; it != itEnd ; ++it )
 	{
-		if (
-				((*it).formatId == id) &&
-				((plug == 0) || (plug == (*it).plug))
-			)
+		if (((*it).formatId == id) && ((plug == 0) || (plug == (*it).plug)))
 			return it;
 	}
 	return itEnd;
 }
 
 QList<FileFormat>::iterator
-LoadSavePlugin::findFormat(const QString& extension,
-						   LoadSavePlugin* plug,
-						   QList<FileFormat>::iterator it)
+LoadSavePlugin::findFormat(const QString& extension, LoadSavePlugin* plug, QList<FileFormat>::iterator it)
 {
 	QList<FileFormat>::iterator itEnd(formats.end());
 	for ( ; it != itEnd ; ++it )
 	{
-		if (
-			((*it).nameMatch.indexIn(extension)) &&
-				((plug == 0) || (plug == (*it).plug))
-			)
+	//	if (((*it).fileExtensions.contains(extension.toLower())) && ((plug == 0) || (plug == (*it).plug)) )
+		if ( ((*it).nameMatch.indexIn(extension)) && ((plug == 0) || (plug == (*it).plug)) )
 			return it;
 	}
 	return itEnd;

Modified: trunk/Scribus/scribus/loadsaveplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/loadsaveplugin.h
==============================================================================
--- trunk/Scribus/scribus/loadsaveplugin.h (original)
+++ trunk/Scribus/scribus/loadsaveplugin.h Wed Apr 17 19:44:02 2013
@@ -73,6 +73,7 @@
 		// Get the highest priority format of a given id, or 0 if
 		// not found / not available.
 		static const FileFormat * getFormatById(const int id);
+		static FileFormat * getFormatByID(int id);
 		static FileFormat* getFormatByExt(const QString ext);
 
 		virtual bool loadElements(const QString & data, QString fileDir, int toLayer, double Xp_in, double Yp_in, bool loc);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp Wed Apr 17 19:44:02 2013
@@ -44,19 +44,20 @@
 {
 	// Set action info in languageChange, so we only have to do
 	// it in one place. This includes registering file formats.
+	registerFormats();
 	languageChange();
 }
 
 Scribus12Format::~Scribus12Format()
 {
 	unregisterAll();
-};
+}
 
 void Scribus12Format::languageChange()
 {
-	//(Re)register file formats.
-	unregisterAll();
-	registerFormats();
+	FileFormat* fmt = getFormatByID(FORMATID_SLA12XIMPORT);
+	fmt->trName = tr("Scribus 1.2.x Document");
+	fmt->filter = fmt->trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)";
 }
 
 const QString Scribus12Format::fullTrName() const

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Wed Apr 17 19:44:02 2013
@@ -51,19 +51,20 @@
 {
 	// Set action info in languageChange, so we only have to do
 	// it in one place. This includes registering file formats.
+	registerFormats();
 	languageChange();
 }
 
 Scribus134Format::~Scribus134Format()
 {
 	unregisterAll();
-};
+}
 
 void Scribus134Format::languageChange()
 {
-	//(Re)register file formats.
-	unregisterAll();
-	registerFormats();
+	FileFormat* fmt = getFormatByID(FORMATID_SLA134IMPORT);
+	fmt->trName = tr("Scribus 1.3.4+ Document");
+	fmt->filter = fmt->trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)";
 }
 
 const QString Scribus134Format::fullTrName() const

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp Wed Apr 17 19:44:02 2013
@@ -47,19 +47,20 @@
 {
 	// Set action info in languageChange, so we only have to do
 	// it in one place. This includes registering file formats.
+	registerFormats();
 	languageChange();
 }
 
 Scribus13Format::~Scribus13Format()
 {
 	unregisterAll();
-};
+}
 
 void Scribus13Format::languageChange()
 {
-	//(Re)register file formats.
-	unregisterAll();
-	registerFormats();
+	FileFormat* fmt = getFormatByID(FORMATID_SLA13XIMPORT);
+	fmt->trName = tr("Scribus 1.3.0->1.3.3.7 Document");
+	fmt->filter = fmt->trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)";
 }
 
 const QString Scribus13Format::fullTrName() const

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Wed Apr 17 19:44:02 2013
@@ -59,19 +59,20 @@
 {
 	// Set action info in languageChange, so we only have to do
 	// it in one place. This includes registering file formats.
+	registerFormats();
 	languageChange();
 }
 
 Scribus150Format::~Scribus150Format()
 {
 	unregisterAll();
-};
+}
 
 void Scribus150Format::languageChange()
 {
-	//(Re)register file formats.
-	unregisterAll();
-	registerFormats();
+	FileFormat* fmt = getFormatByID(FORMATID_SLA150IMPORT);
+	fmt->trName = tr("Scribus 1.5.0+ Document");
+	fmt->filter = fmt->trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)";
 }
 
 const QString Scribus150Format::fullTrName() const

Modified: trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp Wed Apr 17 19:44:02 2013
@@ -68,7 +68,7 @@
 ImportIdmlPlugin::~ImportIdmlPlugin()
 {
 	unregisterAll();
-};
+}
 
 const QString ImportIdmlPlugin::fullTrName() const
 {

Modified: trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp Wed Apr 17 19:44:02 2013
@@ -84,7 +84,7 @@
 {
 	unregisterAll();
 	// note: importAction is automatically deleted by Qt
-};
+}
 
 void OODrawImportPlugin::languageChange()
 {

Modified: trunk/Scribus/scribus/plugins/import/pct/importpctplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/pct/importpctplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pct/importpctplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pct/importpctplugin.cpp Wed Apr 17 19:44:02 2013
@@ -59,7 +59,7 @@
 ImportPctPlugin::~ImportPctPlugin()
 {
 	unregisterAll();
-};
+}
 
 const QString ImportPctPlugin::fullTrName() const
 {

Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdfplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/pdf/importpdfplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/importpdfplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/importpdfplugin.cpp Wed Apr 17 19:44:02 2013
@@ -73,7 +73,7 @@
 ImportPdfPlugin::~ImportPdfPlugin()
 {
 	unregisterAll();
-};
+}
 
 const QString ImportPdfPlugin::fullTrName() const
 {

Modified: trunk/Scribus/scribus/plugins/import/shape/importshapeplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/shape/importshapeplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/shape/importshapeplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/shape/importshapeplugin.cpp Wed Apr 17 19:44:02 2013
@@ -59,7 +59,7 @@
 ImportShapePlugin::~ImportShapePlugin()
 {
 	unregisterAll();
-};
+}
 
 const QString ImportShapePlugin::fullTrName() const
 {

Modified: trunk/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp Wed Apr 17 19:44:02 2013
@@ -59,7 +59,7 @@
 ImportSmlPlugin::~ImportSmlPlugin()
 {
 	unregisterAll();
-};
+}
 
 const QString ImportSmlPlugin::fullTrName() const
 {

Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp Wed Apr 17 19:44:02 2013
@@ -75,6 +75,7 @@
 	// Set action info in languageChange, so we only have to do
 	// it in one place. This includes registering file format
 	// support.
+	registerFormats();
 	languageChange();
 }
 /*
@@ -88,14 +89,14 @@
 SVGImportPlugin::~SVGImportPlugin()
 {
 	unregisterAll();
-};
+}
 
 void SVGImportPlugin::languageChange()
 {
 	importAction->setText( tr("Import &SVG..."));
-	// (Re)register file format support.
-	unregisterAll();
-	registerFormats();
+	FileFormat* fmt = getFormatByExt("svg");
+	fmt->trName = FormatsManager::instance()->nameOfFormat(FormatsManager::SVG);
+	fmt->filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::SVG);
 }
 
 const QString SVGImportPlugin::fullTrName() const

Modified: trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/uniconvertor/uniconvplugin.cpp Wed Apr 17 19:44:02 2013
@@ -55,19 +55,21 @@
 	// Set action info in languageChange, so we only have to do
 	// it in one place. This includes registering file format
 	// support.
+	registerFormats();
 	languageChange();
 }
 
 UniconvImportPlugin::~UniconvImportPlugin()
 {
 	unregisterAll();
-};
+}
 
 void UniconvImportPlugin::languageChange()
 {
-	// (Re)register file format support.
-	unregisterAll();
-	registerFormats();
+	QString name = tr("Uniconvertor Import");
+	FileFormat* fmt = getFormatByID(FORMATID_UNICONVIMPORT);
+	fmt->trName = name;
+	fmt->filter = name + " (" +  FormatsManager::instance()->extensionListForFormat( FormatsManager::UNICONV, 0)+")";
 }
 
 const QString UniconvImportPlugin::fullTrName() const

Modified: trunk/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp Wed Apr 17 19:44:02 2013
@@ -62,27 +62,21 @@
 	// Set action info in languageChange, so we only have to do
 	// it in one place. This includes registering file format
 	// support.
+	registerFormats();
 	languageChange();
 }
-/*
-void WMFImportPlugin::addToMainWindowMenu(ScribusMainWindow *mw)
-{
-	importAction->setEnabled(true);
-	connect( importAction, SIGNAL(triggered()), SLOT(import()) );
-	mw->scrMenuMgr->addMenuItem(importAction, "FileImport");
-}
-*/
+
 WMFImportPlugin::~WMFImportPlugin()
 {
 	unregisterAll();
-};
+}
 
 void WMFImportPlugin::languageChange()
 {
 	importAction->setText( tr("Import &WMF..."));
-	// (Re)register file format support.
-	unregisterAll();
-	registerFormats();
+	FileFormat* fmt = getFormatByExt("fig");
+	fmt->trName = FormatsManager::instance()->nameOfFormat(FormatsManager::WMF);
+	fmt->filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::WMF);
 }
 
 const QString WMFImportPlugin::fullTrName() const

Modified: trunk/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp Wed Apr 17 19:44:02 2013
@@ -44,28 +44,22 @@
 {
 	// Set action info in languageChange, so we only have to do it in one
 	// place. This includes registering file format support.
+	registerFormats();
 	languageChange();
 }
-/*
-void ImportXfigPlugin::addToMainWindowMenu(ScribusMainWindow *mw)
-{
-	importAction->setEnabled(true);
-	connect( importAction, SIGNAL(triggered()), SLOT(import()) );
-	mw->scrMenuMgr->addMenuItem(importAction, "FileImport");
-}
-*/
+
 void ImportWpgPlugin::languageChange()
 {
 	importAction->setText( tr("Import WPG..."));
-	// (Re)register file format support
-	unregisterAll();
-	registerFormats();
+	FileFormat* fmt = getFormatByExt("wpg");
+	fmt->trName = FormatsManager::instance()->nameOfFormat(FormatsManager::WPG);
+	fmt->filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::WPG);
 }
 
 ImportWpgPlugin::~ImportWpgPlugin()
 {
 	unregisterAll();
-};
+}
 
 const QString ImportWpgPlugin::fullTrName() const
 {

Modified: trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp Wed Apr 17 19:44:02 2013
@@ -59,7 +59,7 @@
 ImportXarPlugin::~ImportXarPlugin()
 {
 	unregisterAll();
-};
+}
 
 const QString ImportXarPlugin::fullTrName() const
 {

Modified: trunk/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18254&path=/trunk/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp Wed Apr 17 19:44:02 2013
@@ -44,28 +44,22 @@
 {
 	// Set action info in languageChange, so we only have to do it in one
 	// place. This includes registering file format support.
+	registerFormats();
 	languageChange();
 }
-/*
-void ImportXfigPlugin::addToMainWindowMenu(ScribusMainWindow *mw)
-{
-	importAction->setEnabled(true);
-	connect( importAction, SIGNAL(triggered()), SLOT(import()) );
-	mw->scrMenuMgr->addMenuItem(importAction, "FileImport");
-}
-*/
+
 void ImportXfigPlugin::languageChange()
 {
 	importAction->setText( tr("Import Xfig..."));
-	// (Re)register file format support
-	unregisterAll();
-	registerFormats();
+	FileFormat* fmt = getFormatByExt("fig");
+	fmt->trName = FormatsManager::instance()->nameOfFormat(FormatsManager::XFIG);
+	fmt->filter = FormatsManager::instance()->extensionsForFormat(FormatsManager::XFIG);
 }
 
 ImportXfigPlugin::~ImportXfigPlugin()
 {
 	unregisterAll();
-};
+}
 
 const QString ImportXfigPlugin::fullTrName() const
 {




More information about the scribus-commit mailing list