r21372 by craig -
scribus-commit
scribus-commit at lists.scribus.net
Thu Jun 9 21:34:57 UTC 2016
Author: craig
Date: Thu Jun 9 21:34:57 2016
New Revision: 21372
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21372
Log:
#8998, #11294: Fix sorting of filter lists in file dialogs for file open, vector import, image import. Ensure Scribus ones stay at the top.
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/scribus.cpp
trunk/Scribus/scribus/util_formats.cpp
Modified: trunk/Scribus/scribus/loadsaveplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21372&path=/trunk/Scribus/scribus/loadsaveplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/loadsaveplugin.cpp (original)
+++ trunk/Scribus/scribus/loadsaveplugin.cpp Thu Jun 9 21:34:57 2016
@@ -190,27 +190,32 @@
// highest priority entry for each ID, and we can start with the first entry
// in the list.
//First, check if we even have any plugins to load with
- if (it!=itEnd)
- {
- filterList.append((*it).filter);
- unsigned int lastID = (*it).formatId;
+ if (it==itEnd)
+ {
+ qDebug("%s", tr("No File Loader Plugins Found").toLocal8Bit().data());
+ return filterList;
+ }
+ unsigned int lastID = 0;
+ QStringList scribusList;
+ while (it!=itEnd)
+ {
+ // Find the next load/save (as appropriate) plugin for the next format type
+ if ( (forLoad ? (*it).load : (*it).save) && ((*it).formatId > lastID) )
+ {
+ // And add it to the filter list, since we know it's
+ // the highest priority because of the sort order.
+ // #11294, sort them and keep Scribus ones at the top
+ if((*it).nativeScribus)
+ scribusList.append((*it).filter);
+ else
+ filterList.append((*it).filter);
+ lastID = (*it).formatId;
+ }
++it;
- for ( ; it != itEnd ; ++it )
- {
- // Find the next load/save (as appropriate) plugin for the next format type
- if ( (forLoad ? (*it).load : (*it).save) && ((*it).formatId > lastID) )
- {
- // And add it to the filter list, since we know it's
- // the highest priority because of the sort order.
- filterList.append((*it).filter);
- lastID = (*it).formatId;
- }
- }
- }
- else
- qDebug("%s", tr("No File Loader Plugins Found").toLocal8Bit().data());
+ }
+ filterList.sort(Qt::CaseInsensitive);
filterList.append( tr("All Files (*)"));
- return filterList;
+ return scribusList+filterList;
}
bool LoadSavePlugin::saveFile(const QString & /* fileName */,
@@ -469,6 +474,26 @@
return (plug && save) ? plug->saveElements(xp, yp, wp, hp, selection, prevData) : "";
}
+FileFormat::FileFormat() :
+ load(false),
+ save(false),
+ thumb(false),
+ colorReading(false),
+ nativeScribus(false),
+ plug(0)
+{
+}
+
+FileFormat::FileFormat(LoadSavePlugin* plug) :
+ load(false),
+ save(false),
+ thumb(false),
+ colorReading(false),
+ nativeScribus(false),
+ plug(plug)
+{
+}
+
bool FileFormat::loadElements(const QString & data, QString fileDir, int toLayer, double Xp_in, double Yp_in, bool loc) const
{
return (plug && load) ? plug->loadElements(data, fileDir, toLayer, Xp_in, Yp_in, loc) : false;
Modified: trunk/Scribus/scribus/loadsaveplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21372&path=/trunk/Scribus/scribus/loadsaveplugin.h
==============================================================================
--- trunk/Scribus/scribus/loadsaveplugin.h (original)
+++ trunk/Scribus/scribus/loadsaveplugin.h Thu Jun 9 21:34:57 2016
@@ -191,9 +191,9 @@
{
public:
// Default ctor to make QValueList happy
- FileFormat() : load(false), save(false), thumb(false), colorReading(false), plug(0) {}
+ FileFormat();
// Standard ctor that sets up a valid FileFormat
- FileFormat(LoadSavePlugin * plug) : load(false), save(false), thumb(false), colorReading(false), plug(plug) {}
+ FileFormat(LoadSavePlugin * plug);
bool loadElements(const QString & data, QString fileDir, int toLayer, double Xp_in, double Yp_in, bool loc) const;
// Load a file with this format
@@ -245,6 +245,8 @@
bool thumb;
// Can we load colors?
bool colorReading;
+ //Native Scribus format (for putting at the top of the file loader lists)
+ bool nativeScribus;
// Priority of this format from 0 (lowest, tried last) to
// 255 (highest, tried first). 64-128 recommended in general.
// Priority controls the order options are displayed in when a file
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21372&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 Thu Jun 9 21:34:57 2016
@@ -125,6 +125,7 @@
fmt.mimeTypes.append("application/x-scribus");
fmt.fileExtensions = QStringList() << "sla" << "sla.gz" << "scd" << "scd.gz";
fmt.priority = 64;
+ fmt.nativeScribus = true;
registerFormat(fmt);
}
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21372&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 Thu Jun 9 21:34:57 2016
@@ -110,6 +110,7 @@
fmt.mimeTypes.append("application/x-scribus");
fmt.fileExtensions = QStringList() << "sla" << "sla.gz" << "scd" << "scd.gz";
fmt.priority = 64;
+ fmt.nativeScribus = true;
registerFormat(fmt);
}
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21372&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 Thu Jun 9 21:34:57 2016
@@ -104,6 +104,7 @@
fmt.mimeTypes.append("application/x-scribus");
fmt.fileExtensions = QStringList() << "sla" << "sla.gz" << "scd" << "scd.gz";
fmt.priority = 64;
+ fmt.nativeScribus = true;
registerFormat(fmt);
}
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21372&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 Thu Jun 9 21:34:57 2016
@@ -115,6 +115,7 @@
fmt.mimeTypes.append("application/x-scribus");
fmt.fileExtensions = QStringList() << "sla" << "sla.gz" << "scd" << "scd.gz";
fmt.priority = 64;
+ fmt.nativeScribus = true;
registerFormat(fmt);
}
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21372&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Thu Jun 9 21:34:57 2016
@@ -3130,7 +3130,7 @@
}
allFormats += "*.sce *.SCE);;";
formats.append("Scribus Objects (*.sce *.SCE)");
- qSort(formats);
+ formats.sort(Qt::CaseInsensitive);
allFormats += formats.join(";;");
PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
QString wdir = dirs->get("pastefile", ".");
Modified: trunk/Scribus/scribus/util_formats.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21372&path=/trunk/Scribus/scribus/util_formats.cpp
==============================================================================
--- trunk/Scribus/scribus/util_formats.cpp (original)
+++ trunk/Scribus/scribus/util_formats.cpp Thu Jun 9 21:34:57 2016
@@ -273,8 +273,8 @@
void FormatsManager::fileTypeStrings(int type, QString& formatList, QString& formatText, QString& formatAll, bool lowerCaseOnly)
{
- QString fmtList = QObject::tr("All Supported Formats")+" (";
- QString fmtText;
+ QString allFormats = QObject::tr("All Supported Formats")+" (";
+ QStringList formats;
QMapIterator<int, QStringList> it(m_fmts);
bool first=true;
int n=0;
@@ -292,34 +292,34 @@
first=false;
else
{
- fmtList += " ";
- fmtText += ";;";
+ allFormats += " ";
}
QString text=m_fmtNames[it.key()] + " (";
QStringListIterator itSL(it.value());
while (itSL.hasNext())
{
QString t("*." + itSL.next());
- fmtList += t;
+ allFormats += t;
text += t;
if(!lowerCaseOnly)
{
- fmtList += " " + t.toUpper();
+ allFormats += " " + t.toUpper();
text += " " + t.toUpper();
}
if (itSL.hasNext())
{
- fmtList += " ";
+ allFormats += " ";
text += " ";
}
}
text += ")";
- fmtText += text;
+ formats.append(text);
}
++n;
}
- formatList+=fmtList + ");;";
- formatText+=fmtText;
+ formatList+=allFormats + ");;";
+ formats.sort(Qt::CaseInsensitive);
+ formatText+=formats.join(";;");
formatAll=QObject::tr("All Files (*)");
}
More information about the scribus-commit
mailing list