r17922 by jghali - #11184: Downloaded DE dictionaries aren't available for selection
scribus-commit
scribus-commit at lists.scribus.net
Fri Nov 30 23:19:06 UTC 2012
Author: jghali
Date: Fri Nov 30 23:19:06 2012
New Revision: 17922
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17922
Log:
#11184: Downloaded DE dictionaries aren't available for selection
Modified:
branches/Version14x/Scribus/scribus/hysettings.cpp
branches/Version14x/Scribus/scribus/hysettings.h
Modified: branches/Version14x/Scribus/scribus/hysettings.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17922&path=/branches/Version14x/Scribus/scribus/hysettings.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/hysettings.cpp (original)
+++ branches/Version14x/Scribus/scribus/hysettings.cpp Fri Nov 30 23:19:06 2012
@@ -272,33 +272,53 @@
disconnect(ScQApp->dlManager(), SIGNAL(finished()), this, SLOT(downloadDictListFinished()));
//qDebug()<<"Downloads All Finished";
QString userDictDir(ScPaths::getUserDictDir(true));
+ // List all downloaded files in order to handle identical
+ // affix files while reducing potential errors related to
+ // disk space
+ QStringList allFileList;
foreach(DictData d, downloadList)
{
+ allFileList += d.files.split(";", QString::SkipEmptyParts);
+ }
+ // Move downloaded files to destination
+ foreach(DictData d, downloadList)
+ {
QString basename = QFileInfo(d.url).fileName();
- QString filename=downloadLocation+basename;
+ QString filename = downloadLocation+basename;
+ QStringList files = d.files.split(";", QString::SkipEmptyParts);
+ QString affixFile = affixFileName(files);
+ QString dictFile = dictFileName(files);
//qDebug()<<filename;
if (d.filetype=="zip")
{
//qDebug()<<"zip data found"<<filename;
- FileUnzip* fun = new FileUnzip(filename);
- QStringList files=d.files.split(";", QString::SkipEmptyParts);
+ FileUnzip fun(filename);
foreach (QString s, files)
{
//qDebug()<<"Unzipping"<<userDictDir+s;
- QString data=fun->getFile(s, userDictDir);
+ QString data = fun.getFile(s, userDictDir);
+ allFileList.removeOne(s);
}
- delete fun;
}
if (d.filetype=="plain")
{
- QStringList files=d.files.split(";", QString::SkipEmptyParts);
foreach (QString s, files)
{
//qDebug()<<"plain data found"<<downloadLocation<<userDictDir<<s;
- moveFile(downloadLocation+s, userDictDir+s);
+ QString dstName = s;
+ if (dstName == affixFile)
+ dstName = QFileInfo(downloadLocation+dictFile).baseName() + ".aff";
+ allFileList.removeOne(s);
+ if (allFileList.contains(s))
+ {
+ copyFile(downloadLocation+s, userDictDir+dstName);
+ continue;
+ }
+ moveFile(downloadLocation+s, userDictDir+dstName);
}
}
}
+
updateDictList();
downloadProgressBar->setValue(0);
downloadProgressBar->setVisible(false);
@@ -391,6 +411,28 @@
availDictTableWidget->resizeColumnsToContents();
}
+QString HySettings::affixFileName(QStringList files)
+{
+ for (int i = 0; i < files.count(); ++i)
+ {
+ const QString& file = files.at(i);
+ if (file.endsWith(".aff", Qt::CaseInsensitive))
+ return file;
+ }
+ return QString();
+}
+
+QString HySettings::dictFileName(QStringList files)
+{
+ for (int i = 0; i < files.count(); ++i)
+ {
+ const QString& file = files.at(i);
+ if (file.endsWith(".dic", Qt::CaseInsensitive))
+ return file;
+ }
+ return QString();
+}
+
int HySettings::getWordLen()
{
return wordLen->value();
Modified: branches/Version14x/Scribus/scribus/hysettings.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17922&path=/branches/Version14x/Scribus/scribus/hysettings.h
==============================================================================
--- branches/Version14x/Scribus/scribus/hysettings.h (original)
+++ branches/Version14x/Scribus/scribus/hysettings.h Fri Nov 30 23:19:06 2012
@@ -8,7 +8,9 @@
#define HYSETTINGS_H
#include "ui_hysettingsBase.h"
+
#include <QSet>
+#include <QStringList>
#include <QHash>
#include "scribusapi.h"
@@ -20,14 +22,14 @@
//TODO: Dict license showing, URL background unzipping, checksumming, pkg mgr platforms warning
struct DictData
{
- QString lang;
- QString version;
- QString files;
- QString url;
- QString desc;
- QString license;
- QString filetype;
- bool download;
+ QString lang;
+ QString version;
+ QString files;
+ QString url;
+ QString desc;
+ QString license;
+ QString filetype;
+ bool download;
};
Q_OBJECT
@@ -61,15 +63,18 @@
void downloadDictListFinished();
void downloadSpellDictsFinished();
void updateProgressBar();
+
+private:
+ QString affixFileName(QStringList files);
+ QString dictFileName(QStringList files);
void setAvailDictsXMLFile(QString availDictsXMLDataFile);
- protected:
+protected:
QMap<QString, QString> dictionaryMap;
QStringList dictionaryPaths;
QString downloadLocation;
QList <DictData> dictList;
QList <DictData> downloadList;
-// QMap<QString,QString> langsMap;
};
#endif // HYSETTINGS_H
More information about the scribus-commit
mailing list