[SCM] Professional CAD system branch, master, updated. debian/2.0.5.0-1+090318-8-2-gc2e9ef4

Scott Howard showard314 at gmail.com
Wed Nov 3 05:00:36 UTC 2010


The following commit has been merged in the master branch:
commit 980949f5562a20541ff55f62090caf2da1a00cfd
Author: Scott Howard <showard314 at gmail.com>
Date:   Wed Nov 3 00:36:26 2010 -0400

    Enabled an autosave feature. Prepends a "#" to the filename part. Upon a successful save of the user file, the autosave file will be deleted.

diff --git a/debian/changelog b/debian/changelog
index f23d185..d9fb9ef 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+qcad (2.0.5.0-1+090318-9) experimental; urgency=low
+
+  * debian/patches/autosave.patch
+    - Enabled an autosave feature. Prepends a "#" to the filename part. 
+      Upon a successful save of the user file, the autosave file will be 
+      deleted. Closes: #94629
+
+ -- Scott Howard <showard314 at gmail.com>  Wed, 03 Nov 2010 00:32:25 -0400
+
 qcad (2.0.5.0-1+090318-8) unstable; urgency=low
 
   * Upload to unstable.
diff --git a/debian/patches/autosave.patch b/debian/patches/autosave.patch
new file mode 100644
index 0000000..988ff50
--- /dev/null
+++ b/debian/patches/autosave.patch
@@ -0,0 +1,362 @@
+Description: enables autosave The autosave implementation doesn't clobber 
+ the original user file but prepends a "#" to the filename part. Upon a 
+ successful save of the user file, the autosave file will be deleted.
+Origin: http://tech.groups.yahoo.com/group/qcad-user/message/1838
+Bug: 94629
+
+Index: qcad/qcad/src/qc_applicationwindow.cpp
+===================================================================
+--- qcad.orig/qcad/src/qc_applicationwindow.cpp	2010-11-03 00:22:48.000000000 -0400
++++ qcad/qcad/src/qc_applicationwindow.cpp	2010-11-03 00:23:25.188938171 -0400
+@@ -163,6 +163,11 @@
+ 	RS_DEBUG->print("QC_ApplicationWindow::QC_ApplicationWindow: init MDI");
+     initMDI();
+ 
++    // Activate autosave timer
++    autosaveTimer = new QTimer(this, "autosave");
++    connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(slotFileAutoSave()));
++    autosaveTimer->start(autosaveTime);
++
+     // Disable menu and toolbar items
+     emit windowsChanged(FALSE);
+ 
+@@ -2151,6 +2156,9 @@
+             	name = w->getDocument()->getFilename();
+             	recentFiles->add(name);
+             	w->setCaption(name);
++		if (!autosaveTimer->isActive()) {
++		    autosaveTimer->start(autosaveTime);
++		}
+ 	    }
+         } else {
+             // error
+@@ -2169,6 +2177,37 @@
+ }
+ 
+ 
++
++/**
++ * Autosave.
++ */
++void QC_ApplicationWindow::slotFileAutoSave() {
++    RS_DEBUG->print("QC_ApplicationWindow::slotFileAutoSave()");
++
++    statusBar()->message(tr("Auto-saving drawing..."));
++
++    QC_MDIWindow* w = getMDIWindow();
++    QString name;
++    if (w!=NULL) {
++	bool cancelled;
++	if (w->slotFileSave(cancelled, true)) {
++	    // auto-save cannot be cancelled by user, so the
++	    // "cancelled" parameter is a dummy
++	    statusBar()->message(tr("Auto-saved drawing"), 2000);
++	} else {
++	    // error
++	    autosaveTimer->stop();
++	    QMessageBox::information(this, QMessageBox::tr("Warning"),
++				     tr("Cannot auto-save the file\n%1\nPlease "
++					"check the permissions.\n"
++					"Auto-save disabled.")
++				     .arg(w->getDocument()->getAutoSaveFilename()),
++				     QMessageBox::Ok);
++	}
++    }
++}
++
++
+ 
+ /**
+  * Menu file -> export.
+Index: qcad/qcad/src/qc_applicationwindow.h
+===================================================================
+--- qcad.orig/qcad/src/qc_applicationwindow.h	2010-11-03 00:22:48.000000000 -0400
++++ qcad/qcad/src/qc_applicationwindow.h	2010-11-03 00:24:52.828025775 -0400
+@@ -37,6 +37,7 @@
+ #include <qsplitter.h>
+ #include <qstatusbar.h>
+ #include <qtable.h>
++#include <qtimer.h>
+ #include <qtoolbar.h>
+ #include <qtoolbutton.h>
+ #include <qwhatsthis.h>
+@@ -149,6 +150,8 @@
+     void slotFileSave();
+     /** saves a document under a different filename*/
+     void slotFileSaveAs();
++    /** auto-save document */
++    void slotFileAutoSave();
+ 	/** exports the document as bitmap */
+ 	void slotFileExport();
+ 	bool slotFileExport(const QString& name, const QString& format, 
+@@ -457,6 +460,10 @@
+     QAction *testResize800;
+     QAction *testResize1024;
+ 
++    QTimer *autosaveTimer;
++
++    const static int autosaveTime = 60 * 1000;	// 1 minute
++
+     // flag to print the hint for the qcad-doc package once
+     // for each QAssistentClient call
+     bool qcadDocHint;
+Index: qcad/qcad/src/qc_mdiwindow.cpp
+===================================================================
+--- qcad.orig/qcad/src/qc_mdiwindow.cpp	2010-10-18 19:35:31.000000000 -0400
++++ qcad/qcad/src/qc_mdiwindow.cpp	2010-11-03 00:27:59.139724105 -0400
+@@ -324,23 +324,32 @@
+ /**
+  * Saves the current file.
+  *
++ * @param  isAutoSave true if this is an "autosave" operation.
++ *                    false if this is "Save" operation requested
++ *                    by the user.
+  * @return true if the file was saved successfully.
+  *         false if the file could not be saved or the document 
+  *         is invalid.
+  */
+-bool QC_MDIWindow::slotFileSave(bool &cancelled) {
++bool QC_MDIWindow::slotFileSave(bool &cancelled, bool isAutoSave) {
+     RS_DEBUG->print("QC_MDIWindow::slotFileSave()");
+     bool ret = false;
+     cancelled = false;
+ 
+     if (document!=NULL) {
+-        if (document->getFilename().isEmpty()) {
+-            ret = slotFileSaveAs(cancelled);
++	if (isAutoSave) {
++	    // Autosave filename is always supposed to be present.
++	    // Autosave does not change the cursor.
++            ret = document->save(true);
+         } else {
+-            QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
+-            ret = document->save();
+-            QApplication::restoreOverrideCursor();
+-        }
++	    if (document->getFilename().isEmpty()) {
++		ret = slotFileSaveAs(cancelled);
++	    } else {
++		QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
++		ret = document->save();
++		QApplication::restoreOverrideCursor();
++	    }
++	}
+     }
+ 
+     return ret;
+Index: qcad/qcad/src/qc_mdiwindow.h
+===================================================================
+--- qcad.orig/qcad/src/qc_mdiwindow.h	2010-10-18 19:35:31.000000000 -0400
++++ qcad/qcad/src/qc_mdiwindow.h	2010-11-03 00:23:25.188938171 -0400
+@@ -69,7 +69,7 @@
+ 
+     void slotFileNew();
+     bool slotFileOpen(const QString& fileName, RS2::FormatType type);
+-    bool slotFileSave(bool &cancelled);
++    bool slotFileSave(bool &cancelled, bool isAutoSave=false);
+     bool slotFileSaveAs(bool &cancelled);
+     bool slotFileClose(bool force);
+     void slotFilePrint();
+Index: qcad/qcadlib/src/engine/rs_block.cpp
+===================================================================
+--- qcad.orig/qcadlib/src/engine/rs_block.cpp	2010-10-18 19:35:31.000000000 -0400
++++ qcad/qcadlib/src/engine/rs_block.cpp	2010-11-03 00:23:25.188938171 -0400
+@@ -78,10 +78,10 @@
+ }
+ 
+ 
+-bool RS_Block::save() {
++bool RS_Block::save(bool isAutoSave) {
+     RS_Graphic* g = getGraphic();
+     if (g!=NULL) {
+-        return g->save();
++        return g->save(isAutoSave);
+     } else {
+         return false;
+     }
+Index: qcad/qcadlib/src/engine/rs_block.h
+===================================================================
+--- qcad.orig/qcadlib/src/engine/rs_block.h	2010-10-18 19:35:31.000000000 -0400
++++ qcad/qcadlib/src/engine/rs_block.h	2010-11-03 00:23:25.188938171 -0400
+@@ -128,7 +128,7 @@
+     /**
+      * Reimplementation from RS_Document. Saves the parent graphic document.
+      */
+-    virtual bool save();
++    virtual bool save(bool isAutoSave = false);
+ 
+     /**
+      * Reimplementation from RS_Document. Does nothing.
+Index: qcad/qcadlib/src/engine/rs_document.cpp
+===================================================================
+--- qcad.orig/qcadlib/src/engine/rs_document.cpp	2010-10-18 19:35:31.000000000 -0400
++++ qcad/qcadlib/src/engine/rs_document.cpp	2010-11-03 00:23:25.188938171 -0400
+@@ -40,6 +40,7 @@
+     RS_DEBUG->print("RS_Document::RS_Document() ");
+ 
+     filename = "";
++    autosaveFilename = "Unnamed";
+ 	formatType = RS2::FormatUnknown;
+     setModified(false);
+     RS_Color col(RS2::FlagByLayer);
+Index: qcad/qcadlib/src/engine/rs_document.h
+===================================================================
+--- qcad.orig/qcadlib/src/engine/rs_document.h	2010-10-18 19:35:31.000000000 -0400
++++ qcad/qcadlib/src/engine/rs_document.h	2010-11-03 00:23:25.188938171 -0400
+@@ -53,7 +53,7 @@
+     virtual RS_BlockList* getBlockList() = 0;
+ 
+     virtual void newDoc() = 0;
+-    virtual bool save() = 0;
++    virtual bool save(bool isAutoSave = false) = 0;
+     virtual bool saveAs(const RS_String &filename, RS2::FormatType type) = 0;
+     virtual bool open(const RS_String &filename, RS2::FormatType type) = 0;
+ 	
+@@ -98,6 +98,13 @@
+     }
+ 	
+     /**
++     * @return Auto-save file name of the document currently loaded.
++     */
++    RS_String getAutoSaveFilename() const {
++        return autosaveFilename;
++    }
++	
++    /**
+      * Sets file name for the document currently loaded.
+      */
+     void setFilename(const RS_String& fn) {
+@@ -136,6 +143,8 @@
+     RS_Pen activePen;
+     /** File name of the document or empty for a new document. */
+     RS_String filename;
++	/** Auto-save file name of document. */
++	RS_String autosaveFilename;
+ 	/** Format type */
+ 	RS2::FormatType formatType;
+ };
+Index: qcad/qcadlib/src/engine/rs_graphic.cpp
+===================================================================
+--- qcad.orig/qcadlib/src/engine/rs_graphic.cpp	2010-10-18 19:35:31.000000000 -0400
++++ qcad/qcadlib/src/engine/rs_graphic.cpp	2010-11-03 00:23:25.188938171 -0400
+@@ -24,6 +24,8 @@
+ **
+ **********************************************************************/
+ 
++#include <qfile.h>
++#include <qfileinfo.h>
+ 
+ #include "rs_graphic.h"
+ 
+@@ -178,21 +180,46 @@
+ /**
+  * Saves this graphic with the current filename and settings.
+  */
+-bool RS_Graphic::save() {
++bool RS_Graphic::save(bool isAutoSave) {
+ 
+ 	bool ret = false;
++
+ 	
+     RS_DEBUG->print("RS_Graphic::save");
+-    RS_DEBUG->print("  file: %s", filename.latin1());
+-    RS_DEBUG->print("  format: %d", (int)formatType);
+-
+-    RS_DEBUG->print("  export...");
+-    ret = RS_FILEIO->fileExport(*this, filename, formatType);
+-
+-	if (ret) {
+-		setModified(false);
+-		layerList.setModified(false);
+-		blockList.setModified(false);
++	if (isAutoSave && !isModified()) {
++	    RS_DEBUG->print("  autsave and not modified => not saved");
++		ret = true;
++	} else {
++		const RS_String *actualName;
++		RS2::FormatType actualType;
++
++		actualType = formatType;
++		if (isAutoSave) {
++			actualName = new QString(autosaveFilename);
++			if (formatType == RS2::FormatUnknown) {
++				actualType = RS2::FormatDXF;
++			}
++		} else {
++			actualName = new QString(filename);
++		}
++	    RS_DEBUG->print("  file: %s", actualName->latin1());
++		RS_DEBUG->print("  format: %d", (int)actualType);
++		RS_DEBUG->print("  export...");
++		ret = RS_FILEIO->fileExport(*this, *actualName, actualType);
++		delete actualName;
++
++		if (ret && !isAutoSave) {
++		    setModified(false);
++			layerList.setModified(false);
++			blockList.setModified(false);
++			// Remove old autosave file
++			QFile f(autosaveFilename);
++			if (f.exists()) {
++				RS_DEBUG->print("  removing old autosave file %s",
++								autosaveFilename.latin1());
++				f.remove();
++			}
++		}
+ 	}
+ 
+     RS_DEBUG->print("RS_Graphic::save ok");
+@@ -210,9 +237,28 @@
+     RS_DEBUG->print("RS_Graphic::saveAs");
+ 
+     this->filename = filename;
++	RS_String *oldAutosaveName = new RS_String(autosaveFilename);
++	QFileInfo finfo(filename);
++	// Construct new autosave filename by prepending # to the filename
++	// part, using the same directory as the destination file.
++	this->autosaveFilename = finfo.dirPath() + "/#" + finfo.fileName();
+ 	this->formatType = type;
+ 
+-    return save();
++    bool ret = save();
++
++	if (ret) {
++		// save was successful, remove old autosave file
++		QFile f(*oldAutosaveName);
++		if (f.exists()) {
++			RS_DEBUG->print("removing old autosave file %s",
++							oldAutosaveName->latin1());
++			f.remove();
++		}
++	}
++
++	delete oldAutosaveName;
++
++	return ret;
+ }
+ 
+ 
+@@ -226,6 +272,10 @@
+ 	bool ret = false;
+ 
+     this->filename = filename;
++	QFileInfo finfo(filename);
++	// Construct new autosave filename by prepending # to the filename
++	// part, using the same directory as the destination file.
++	this->autosaveFilename = finfo.dirPath() + "/#" + finfo.fileName();
+ 
+     // clean all:
+     newDoc();
+Index: qcad/qcadlib/src/engine/rs_graphic.h
+===================================================================
+--- qcad.orig/qcadlib/src/engine/rs_graphic.h	2010-10-18 19:35:31.000000000 -0400
++++ qcad/qcadlib/src/engine/rs_graphic.h	2010-11-03 00:23:25.188938171 -0400
+@@ -69,7 +69,7 @@
+     }
+ 
+     virtual void newDoc();
+-    virtual bool save();
++    virtual bool save(bool isAutoSave = false);
+     virtual bool saveAs(const RS_String& filename, RS2::FormatType type);
+     virtual bool open(const RS_String& filename, RS2::FormatType type);
+ 	
diff --git a/debian/patches/series b/debian/patches/series
index f2632ff..26972a9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -9,3 +9,4 @@ create-about_txt.patch
 help_security_of_build_scripts.patch
 release_translations_qm_dir.patch
 qcad-2.0.5.0-latin2.patch
+autosave.patch

-- 
Professional CAD system



More information about the debian-science-commits mailing list