r17133 by fschmid - Fixed Bug 9097: "OSG doesn't list supported file formats"

scribus-commit scribus-commit at lists.scribus.net
Wed Dec 28 18:18:55 UTC 2011


Author: fschmid
Date: Wed Dec 28 18:18:55 2011
New Revision: 17133

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17133
Log:
Fixed Bug 9097: "OSG doesn't list supported file formats"

Modified:
    trunk/Scribus/scribus/ui/osgeditor.cpp

Modified: trunk/Scribus/scribus/ui/osgeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17133&path=/trunk/Scribus/scribus/ui/osgeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/osgeditor.cpp (original)
+++ trunk/Scribus/scribus/ui/osgeditor.cpp Wed Dec 28 18:18:55 2011
@@ -25,6 +25,8 @@
 ***************************************************************************/
 
 #include <osgDB/ReadFile>
+#include <osgDB/ReaderWriter>
+#include <osgDB/PluginQuery>
 #include <osgViewer/Viewer>
 #include <osgGA/TrackballManipulator>
 #include <osgUtil/Optimizer>
@@ -569,8 +571,36 @@
 	QString fileName;
 	PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
 	QString wdir = dirs->get("models", ".");
-	QString docexts("*.ac *.osg");
-	QString filter = tr("All Supported Formats (%1);;All Files (*)").arg(docexts);
+	QStringList supportedExts;
+	supportedExts << "osg" << "dxf" << "flt" << "ive" << "geo" << "sta" << "stl" << "logo" << "3ds" << "ac" << "obj";
+	QStringList realSupportedExts;
+	QMap<QString, QString> formats;
+	osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
+	for(osgDB::FileNameList::iterator itr = plugins.begin(); itr != plugins.end(); ++itr)
+	{
+		osgDB::ReaderWriterInfoList infoList;
+		if (osgDB::queryPlugin(*itr, infoList))
+		{
+			for(osgDB::ReaderWriterInfoList::iterator rwi_itr = infoList.begin(); rwi_itr != infoList.end(); ++rwi_itr)
+			{
+				osgDB::ReaderWriterInfo& info = *(*rwi_itr);
+				osgDB::ReaderWriter::FormatDescriptionMap::iterator fdm_itr;
+				for(fdm_itr = info.extensions.begin(); fdm_itr != info.extensions.end(); ++fdm_itr)
+				{
+					if (supportedExts.contains(QString::fromStdString(fdm_itr->first)))
+					{
+						qDebug() << QString::fromStdString(fdm_itr->first) << QString::fromStdString(fdm_itr->second);
+						formats.insert("*." + QString::fromStdString(fdm_itr->first) + " *." + QString::fromStdString(fdm_itr->first).toUpper(), QString::fromStdString(fdm_itr->second) + " (*." + QString::fromStdString(fdm_itr->first) + " *." + QString::fromStdString(fdm_itr->first).toUpper() + ")");
+					}
+				}
+			}
+		}
+	}
+	realSupportedExts = formats.keys();
+	QString docexts = realSupportedExts.join(" ");
+	QStringList longList = formats.values();
+	QString longDesc = longList.join(";;") + ";;";
+	QString filter = tr("All Supported Formats (%1);;%2All Files (*)").arg(docexts).arg(longDesc);
 	CustomFDialog dia(this, wdir, tr("Import 3-D Model"), filter, fdHidePreviewCheckBox);
 	if (dia.exec() == QDialog::Accepted)
 		fileName = dia.selectedFile();




More information about the scribus-commit mailing list