r17551 by craig - Fwd port spelling update to trunk. Revert fileunzip changes to original, add in old code for unzip to path. Can be optimised later

scribus-commit scribus-commit at lists.scribus.net
Sun Jun 10 15:24:51 UTC 2012


Author: craig
Date: Sun Jun 10 15:24:51 2012
New Revision: 17551

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17551
Log:
Fwd port spelling update to trunk. Revert fileunzip changes to original, add in old code for unzip to path. Can be optimised later

Added:
    trunk/Scribus/scribus/ui/prefs_spelling.cpp   (with props)
    trunk/Scribus/scribus/ui/prefs_spelling.h   (with props)
    trunk/Scribus/scribus/ui/prefs_spellingbase.ui
Modified:
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/downloadmanager/scdlthread.cpp
    trunk/Scribus/scribus/fileunzip.cpp
    trunk/Scribus/scribus/fileunzip.h
    trunk/Scribus/scribus/scribusapp.cpp
    trunk/Scribus/scribus/scribusapp.h
    trunk/Scribus/scribus/ui/preferencesdialog.cpp
    trunk/Scribus/scribus/ui/preferencesdialog.h

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17551&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Sun Jun 10 15:24:51 2012
@@ -118,6 +118,7 @@
   ui/prefs_preflightverifierbase.ui
   ui/prefs_printerbase.ui
   ui/prefs_scrapbookbase.ui
+  ui/prefs_spellingbase.ui
   ui/prefs_typographybase.ui
   ui/prefs_userinterfacebase.ui
   ui/prefs_itemtoolsbase.ui
@@ -195,6 +196,8 @@
   commonstrings.h
   deferredtask.h
   docinfo.h
+  downloadmanager/scdlmgr.h
+  downloadmanager/scdlthread.h
   fileloader.h
   filesearch.h
   filewatcher.h
@@ -366,6 +369,7 @@
   ui/prefs_preflightverifier.h
   ui/prefs_printer.h
   ui/prefs_scrapbook.h
+  ui/prefs_spelling.h
   ui/prefs_typography.h
   ui/prefs_userinterface.h
   ui/prefs_itemtools.h
@@ -520,6 +524,8 @@
   docinfo.cpp
   documentchecker.cpp
   documentinformation.cpp
+  downloadmanager/scdlmgr.cpp
+  downloadmanager/scdlthread.cpp
   exif.cpp
   fileloader.cpp
   filesearch.cpp
@@ -793,6 +799,7 @@
   ui/prefs_preflightverifier.cpp
   ui/prefs_printer.cpp
   ui/prefs_scrapbook.cpp
+  ui/prefs_spelling.cpp
   ui/prefs_typography.cpp
   ui/prefs_userinterface.cpp
   ui/prefs_itemtools.cpp

Modified: trunk/Scribus/scribus/downloadmanager/scdlthread.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17551&path=/trunk/Scribus/scribus/downloadmanager/scdlthread.cpp
==============================================================================
--- trunk/Scribus/scribus/downloadmanager/scdlthread.cpp (original)
+++ trunk/Scribus/scribus/downloadmanager/scdlthread.cpp Sun Jun 10 15:24:51 2012
@@ -98,6 +98,7 @@
 	if (downloadQueue.isEmpty())
 	{
 		qDebug()<<downloadedCount<<"/"<<totalCount<<"files downloaded successfully";
+		downloadedCount=totalCount=0;
 		emit finished();
 		return;
 	}

Modified: trunk/Scribus/scribus/fileunzip.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17551&path=/trunk/Scribus/scribus/fileunzip.cpp
==============================================================================
--- trunk/Scribus/scribus/fileunzip.cpp (original)
+++ trunk/Scribus/scribus/fileunzip.cpp Sun Jun 10 15:24:51 2012
@@ -56,6 +56,7 @@
 #include <zlib.h>
 
 #include <QDir>
+#include <QDebug>
 #include <QByteArray>
 
 #include "scpaths.h"
@@ -67,6 +68,8 @@
 
 int do_extract_currentfile(unzFile uf, QString outfile, const char *password);
 int do_extract_onefile(unzFile uf, const QString& filename, QString outfile, const char *password);
+int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password);
+int do_extract_onefile(unzFile uf, const QString& filename, int opt_extract_without_path, int opt_overwrite, const char* password);
 FILE*    openfile(const QString& filename, const QString& mode);
 unzFile  unzOpenFile(const QString& filename);
 int mymkdir(const QString& dirname);
@@ -84,30 +87,48 @@
 	zipFile = zipFilePath;
 }
 
-QString FileUnzip::getFile(QString name, QString path)
+QString FileUnzip::getFile(QString name)
+{
+		QString pwd = QDir::currentPath();
+		QTemporaryFile *tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_zip_XXXXXX.dat");
+		if (tempImageFile == NULL)
+				return NULL;
+		tempImageFile->open();
+		QString fname = getLongPathName(tempImageFile->fileName());
+		tempImageFile->close();
+		tempFileList.append(tempImageFile);
+		QDir::setCurrent(QDir::tempPath());
+		unzFile uf = unzOpenFile(zipFile);
+		int ret = do_extract_onefile(uf, name, fname, NULL);
+		unzClose(uf);
+		QDir::setCurrent(pwd);
+		if (ret != 0)
+				return NULL;
+		else
+				return fname;
+}
+
+QString FileUnzip::getFileToPath(QString name, QString path)
 {
 	QString pwd = QDir::currentPath();
 	QString outDir;
 	if (path.isNull())
-		outDir = QDir::tempPath();
+		outDir = ScPaths::getTempFileDir();
 	else
 		outDir=path;
-	QTemporaryFile *tempFile = new QTemporaryFile(outDir + "/scribus_temp_zip_XXXXXX.dat");
-	if (tempFile == NULL)
-		return NULL;
-	tempFile->open();
-	QString fname = getLongPathName(tempFile->fileName());
-	tempFile->close();
-	tempFileList.append(tempFile);
+	QFile f(outDir);
+	QFileInfo fi(f);
+	if (!fi.isWritable())
+		outDir = ScPaths::getApplicationDataDir();
 	QDir::setCurrent(outDir);
 	unzFile uf = unzOpenFile(zipFile);
-	int ret = do_extract_onefile(uf, name, fname, NULL);
+	int ret = do_extract_onefile(uf,name, 0, 1, NULL);
 	unzClose(uf);
 	QDir::setCurrent(pwd);
 	if (ret != 0)
 		return NULL;
 	else
-		return fname;
+		return outDir + name;
 }
 
 FileUnzip::~FileUnzip()
@@ -213,13 +234,13 @@
 int do_extract_onefile(unzFile uf, const QString& filename, QString outfile, const char *password)
 {
 	QByteArray fname = filename.toLocal8Bit();
-    if (unzLocateFile(uf,fname.data(),CASESENSITIVITY)!=UNZ_OK)
-        return 2;
+	if (unzLocateFile(uf,fname.data(),CASESENSITIVITY)!=UNZ_OK)
+		return 2;
 
 	if (do_extract_currentfile(uf, outfile, password) == UNZ_OK)
-        return 0;
-    else
-        return 1;
+		return 0;
+	else
+		return 1;
 }
 
 int do_extract_currentfile(unzFile uf, QString outfile, const char* password)
@@ -276,6 +297,118 @@
 	return err;
 }
 
+int do_extract_onefile(unzFile uf, const QString& filename, int opt_extract_without_path, int opt_overwrite, const char* password)
+{
+//    int err = UNZ_OK;
+	QByteArray fname = filename.toLocal8Bit();
+	if (unzLocateFile(uf,fname.data(),CASESENSITIVITY)!=UNZ_OK)
+		return 2;
+
+	if (do_extract_currentfile(uf,&opt_extract_without_path,
+									  &opt_overwrite,
+									  password) == UNZ_OK)
+		return 0;
+	else
+		return 1;
+}
+
+int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int*, const char* password)
+{
+	char  fn_inzip[256];
+	QString filename_inzip;
+	QString filename_withoutpath;
+	int err=UNZ_OK;
+	FILE *fout=NULL;
+	void* buf;
+	uInt size_buf;
+
+	unz_file_info file_info;
+	//uLong ratio=0;
+	err = unzGetCurrentFileInfo(uf,&file_info,fn_inzip,sizeof(fn_inzip),NULL,0,NULL,0);
+
+	if (err!=UNZ_OK)
+		return err;
+
+	size_buf = WRITEBUFFERSIZE;
+	buf = (void*)malloc(size_buf);
+	if (buf==NULL)
+		return UNZ_INTERNALERROR;
+
+	QChar p;
+//	uint cIndex = 0;
+	filename_inzip = QString::fromLocal8Bit(fn_inzip);
+	filename_withoutpath = filename_inzip;
+	for (int i = 0; i < filename_inzip.length(); i++)
+	{
+		p = filename_inzip[i];
+		if( (p == '/') || (p =='\\'))
+			filename_withoutpath = filename_inzip.mid(i+1);
+	}
+
+	if (filename_withoutpath.isEmpty())
+	{
+		if ((*popt_extract_without_path)==0)
+			mymkdir(filename_inzip);
+	}
+	else
+	{
+		QString write_filename;
+		int skip=0;
+
+		if ((*popt_extract_without_path)==0)
+			write_filename = filename_inzip;
+		else
+			write_filename = filename_withoutpath;
+
+		err = unzOpenCurrentFilePassword(uf,password);
+
+		if ((skip==0) && (err==UNZ_OK))
+		{
+			fout = openfile(write_filename, "wb");
+			/* some zipfile don't contain directory alone before file */
+			if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
+								(filename_withoutpath != filename_inzip))
+			{
+				uint len = filename_inzip.length() - filename_withoutpath.length() - 1;
+				QString write_dir = filename_inzip.left(len);
+				makedir(write_dir);
+				fout = openfile(write_filename, "wb");
+			}
+		}
+
+		if (fout!=NULL)
+		{
+			do
+			{
+				err = unzReadCurrentFile(uf,buf,size_buf);
+				if (err<0)
+					break;
+				if (err>0)
+					if (fwrite(buf,err,1,fout)!=1)
+					{
+						err=UNZ_ERRNO;
+						break;
+					}
+			}
+			while (err>0);
+			if (fout)
+				fclose(fout);
+
+			if (err==0)
+				change_file_date(write_filename,file_info.dosDate,
+									file_info.tmu_date);
+		}
+
+		if (err==UNZ_OK)
+			err = unzCloseCurrentFile (uf);
+		else
+			unzCloseCurrentFile(uf); /* don't lose the error */
+	}
+
+	free(buf);
+	return err;
+}
+
 /* change_file_date : change the date/time of a file
     filename : the filename of the file where date/time must be modified
     dosdate : the new date at the MSDos format (4 bytes)

Modified: trunk/Scribus/scribus/fileunzip.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17551&path=/trunk/Scribus/scribus/fileunzip.h
==============================================================================
--- trunk/Scribus/scribus/fileunzip.h (original)
+++ trunk/Scribus/scribus/fileunzip.h Sun Jun 10 15:24:51 2012
@@ -48,7 +48,8 @@
 public:
 	FileUnzip(QString zipFilePath);
 	~FileUnzip();
-	QString getFile(QString name, QString path=QString::null);
+	QString getFile(QString name);
+	QString getFileToPath(QString name, QString path);
 };
 
 #endif

Modified: trunk/Scribus/scribus/scribusapp.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17551&path=/trunk/Scribus/scribus/scribusapp.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusapp.cpp (original)
+++ trunk/Scribus/scribus/scribusapp.cpp Sun Jun 10 15:24:51 2012
@@ -99,6 +99,8 @@
 {
 	ScQApp=this;
 	ScCore=NULL;
+
+	initDLMgr();
 }
 
 ScribusQApp::~ScribusQApp()
@@ -112,6 +114,12 @@
 
 	if (!langs.isEmpty())
 		installTranslators(langs);
+}
+
+void ScribusQApp::initDLMgr()
+{
+	m_scDLMgr=new ScDLManager(this);
+	connect(m_scDLMgr, SIGNAL(fileReceived(const QString&)), SLOT(downloadComplete(const QString&)));
 }
 
 void ScribusQApp::parseCommandLine()
@@ -531,6 +539,11 @@
 	return QFileInfo(ScPaths::getApplicationDataDir() + ".neversplash").exists();
 }
 
+void ScribusQApp::downloadComplete(const QString &t)
+{
+	qDebug()<<"ScribusQApp: download finished:"<<t;
+}
+
 bool ScribusQApp::event(QEvent *event)
 {
 	switch (event->type()) 

Modified: trunk/Scribus/scribus/scribusapp.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17551&path=/trunk/Scribus/scribus/scribusapp.h
==============================================================================
--- trunk/Scribus/scribus/scribusapp.h (original)
+++ trunk/Scribus/scribus/scribusapp.h Sun Jun 10 15:24:51 2012
@@ -25,6 +25,7 @@
 #include <QString>
 
 #include "scribusapi.h"
+#include "downloadmanager/scdlmgr.h"
 class ScribusCore;
 class ScribusMainWindow;
 
@@ -37,6 +38,7 @@
 		~ScribusQApp();
 		int init();
 		void initLang();
+		void initDLMgr();
 		void parseCommandLine();
 		void changeGUILanguage(const QString & lang);
 		/*!
@@ -65,7 +67,8 @@
 		static bool useGUI;
 		void neverSplash(bool splashOff);
 		bool neverSplashExists();
-		const QString& currGUILanguage() {return GUILang;};
+		const QString& currGUILanguage() { return GUILang; }
+		ScDLManager* dlManager() { return m_scDLMgr; }
 
 	private:
 		ScribusCore* m_ScCore;
@@ -95,9 +98,13 @@
 		QString prefsUserFile;
 		QList<QString> filesToLoad;
 		QString fileName;
+		ScDLManager *m_scDLMgr;
 
 	protected:
 		virtual bool event(QEvent *event);
+
+	protected slots:
+		void downloadComplete(const QString& t);
 };
 
 #endif

Modified: trunk/Scribus/scribus/ui/preferencesdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17551&path=/trunk/Scribus/scribus/ui/preferencesdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/preferencesdialog.cpp (original)
+++ trunk/Scribus/scribus/ui/preferencesdialog.cpp Sun Jun 10 15:24:51 2012
@@ -46,6 +46,7 @@
 	prefs_Plugins(0),prefs_PreflightVerifier(0),
 	prefs_Printer(0),
 	prefs_Scrapbook(0),
+	prefs_Spelling(0),
 	prefs_TableOfContents(0),
 	prefs_Typography(0),
 	prefs_UserInterface(0),
@@ -93,6 +94,7 @@
 		prefs_Paths = new Prefs_Paths(prefsStackWidget, m_Doc);
 		prefs_Plugins = new Prefs_Plugins(prefsStackWidget, m_Doc);
 		prefs_Scrapbook = new Prefs_Scrapbook(prefsStackWidget, m_Doc);
+		prefs_Spelling = new Prefs_Spelling(prefsStackWidget, m_Doc);
 		prefs_UserInterface = new Prefs_UserInterface(prefsStackWidget, m_Doc);
 	}
 	// Add Stack Widgets if required
@@ -126,6 +128,7 @@
 	{
 		addItem( tr("Keyboard Shortcuts"), loadIcon("16/preferences-desktop-keyboard-shortcuts.png"), prefs_KeyboardShortcuts);
 		addItem( tr("Scrapbook"), loadIcon("scrap_16.png"), prefs_Scrapbook);
+		addItem( tr("Spelling"), loadIcon("signature_16.png"), prefs_Spelling);
 	}
 	addItem( tr("Display"), loadIcon("16/video-display.png"), prefs_Display);
 	if (!doc)
@@ -204,6 +207,7 @@
 		prefs_ColorManagement->restoreDefaults(&localPrefs);
 	}
 	if (prefs_Scrapbook) prefs_Scrapbook->restoreDefaults(&localPrefs);
+	if (prefs_Spelling) prefs_Spelling->restoreDefaults(&localPrefs);
 	if (prefs_Display) prefs_Display->restoreDefaults(&localPrefs);
 	if (prefs_ExternalTools) prefs_ExternalTools->restoreDefaults(&localPrefs);
 	if (prefs_Plugins) prefs_Plugins->restoreDefaults(&localPrefs);
@@ -234,6 +238,7 @@
 	if (prefs_KeyboardShortcuts) prefs_KeyboardShortcuts->saveGuiToPrefs(&localPrefs);
 	if (prefs_ColorManagement) prefs_ColorManagement->saveGuiToPrefs(&localPrefs);
 	if (prefs_Scrapbook) prefs_Scrapbook->saveGuiToPrefs(&localPrefs);
+	if (prefs_Spelling) prefs_Spelling->saveGuiToPrefs(&localPrefs);
 	if (prefs_Display) prefs_Display->saveGuiToPrefs(&localPrefs);
 	if (prefs_ExternalTools) prefs_ExternalTools->saveGuiToPrefs(&localPrefs);
 	if (prefs_Plugins) prefs_Plugins->saveGuiToPrefs(&localPrefs);

Modified: trunk/Scribus/scribus/ui/preferencesdialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17551&path=/trunk/Scribus/scribus/ui/preferencesdialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/preferencesdialog.h (original)
+++ trunk/Scribus/scribus/ui/preferencesdialog.h Sun Jun 10 15:24:51 2012
@@ -17,30 +17,32 @@
 #include "ui_preferencesdialogbase.h"
 
 #include "ui/prefs_colormanagement.h"
-#include "ui/prefs_userinterface.h"
+#include "ui/prefs_display.h"
 #include "ui/prefs_documentinformation.h"
+#include "ui/prefs_documentitemattributes.h"
 #include "ui/prefs_documentsections.h"
 #include "ui/prefs_documentsetup.h"
-#include "ui/prefs_display.h"
+#include "ui/prefs_externaltools.h"
+#include "ui/prefs_fonts.h"
 #include "ui/prefs_guides.h"
-#include "ui/prefs_externaltools.h"
+#include "ui/prefs_hyphenator.h"
+#include "ui/prefs_imagecache.h"
+#include "ui/prefs_itemtools.h"
 #include "ui/prefs_keyboardshortcuts.h"
+#include "ui/prefs_miscellaneous.h"
+#include "ui/prefs_operatortools.h"
+#include "ui/prefs_pagesizes.h"
 #include "ui/prefs_paths.h"
-#include "ui/prefs_printer.h"
-#include "ui/prefs_hyphenator.h"
-#include "ui/prefs_miscellaneous.h"
-#include "ui/prefs_pagesizes.h"
+#include "ui/prefs_pdfexport.h"
 #include "ui/prefs_plugins.h"
 #include "ui/prefs_preflightverifier.h"
+#include "ui/prefs_printer.h"
 #include "ui/prefs_scrapbook.h"
+#include "ui/prefs_spelling.h"
+#include "ui/prefs_tableofcontents.h"
 #include "ui/prefs_typography.h"
-#include "ui/prefs_itemtools.h"
-#include "ui/prefs_operatortools.h"
-#include "ui/prefs_fonts.h"
-#include "ui/prefs_tableofcontents.h"
-#include "ui/prefs_pdfexport.h"
-#include "ui/prefs_documentitemattributes.h"
-#include "ui/prefs_imagecache.h"
+#include "ui/prefs_userinterface.h"
+
 
 class PrefsManager;
 class ScribusMainWindow;
@@ -107,9 +109,11 @@
 		Prefs_PreflightVerifier *prefs_PreflightVerifier;
 		Prefs_Printer *prefs_Printer;
 		Prefs_Scrapbook *prefs_Scrapbook;
+		Prefs_Spelling *prefs_Spelling;
 		Prefs_TableOfContents *prefs_TableOfContents;
 		Prefs_Typography *prefs_Typography;
 		Prefs_UserInterface *prefs_UserInterface;
+
 
 		QMap<QListWidgetItem*, int> stackWidgetMap;
 		int counter;




More information about the scribus-commit mailing list