Add two patches from Joerg Wunsch:
- Implement autosave feature - Detect filesystem full condition Both patches where sent upwards. Submitted by: joerg@
This commit is contained in:
parent
f496c21361
commit
3bd2ebb734
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=264312
345
cad/qcad/files/patch-zzz-autosave
Normal file
345
cad/qcad/files/patch-zzz-autosave
Normal file
@ -0,0 +1,345 @@
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcad/src/qc_applicationwindow.cpp ./qcad/src/qc_applicationwindow.cpp
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcad/src/qc_applicationwindow.cpp Tue Nov 22 12:49:33 2005
|
||||
+++ ./qcad/src/qc_applicationwindow.cpp Sat Aug 11 22:47:35 2007
|
||||
@@ -162,6 +162,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);
|
||||
|
||||
@@ -2133,6 +2138,9 @@
|
||||
name = w->getDocument()->getFilename();
|
||||
recentFiles->add(name);
|
||||
w->setCaption(name);
|
||||
+ if (!autosaveTimer->isActive()) {
|
||||
+ autosaveTimer->start(autosaveTime);
|
||||
+ }
|
||||
}
|
||||
} else {
|
||||
// error
|
||||
@@ -2148,6 +2156,37 @@
|
||||
QString message = tr("Saved drawing: %1").arg(name);
|
||||
statusBar()->message(message, 2000);
|
||||
commandWidget->appendHistory(message);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
+/**
|
||||
+ * 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);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcad/src/qc_applicationwindow.h ./qcad/src/qc_applicationwindow.h
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcad/src/qc_applicationwindow.h Tue Nov 22 12:49:34 2005
|
||||
+++ ./qcad/src/qc_applicationwindow.h Sat Aug 11 22:47:35 2007
|
||||
@@ -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>
|
||||
@@ -148,6 +149,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,
|
||||
@@ -456,6 +459,9 @@
|
||||
QAction *testResize800;
|
||||
QAction *testResize1024;
|
||||
|
||||
+ QTimer *autosaveTimer;
|
||||
+
|
||||
+ const static int autosaveTime = 60 * 1000; // 1 minute
|
||||
};
|
||||
|
||||
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcad/src/qc_mdiwindow.cpp ./qcad/src/qc_mdiwindow.cpp
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcad/src/qc_mdiwindow.cpp Tue Nov 22 12:49:37 2005
|
||||
+++ ./qcad/src/qc_mdiwindow.cpp Sat Aug 11 22:47:35 2007
|
||||
@@ -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;
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcad/src/qc_mdiwindow.h ./qcad/src/qc_mdiwindow.h
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcad/src/qc_mdiwindow.h Tue Nov 22 12:49:37 2005
|
||||
+++ ./qcad/src/qc_mdiwindow.h Sat Aug 11 22:47:35 2007
|
||||
@@ -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();
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_block.cpp ./qcadlib/src/engine/rs_block.cpp
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_block.cpp Tue Nov 22 12:52:35 2005
|
||||
+++ ./qcadlib/src/engine/rs_block.cpp Sat Aug 11 22:47:35 2007
|
||||
@@ -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;
|
||||
}
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_block.h ./qcadlib/src/engine/rs_block.h
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_block.h Tue Nov 22 12:52:38 2005
|
||||
+++ ./qcadlib/src/engine/rs_block.h Sat Aug 11 22:47:35 2007
|
||||
@@ -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.
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_document.cpp ./qcadlib/src/engine/rs_document.cpp
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_document.cpp Tue Nov 22 12:52:38 2005
|
||||
+++ ./qcadlib/src/engine/rs_document.cpp Sat Aug 11 22:47:35 2007
|
||||
@@ -40,6 +40,7 @@
|
||||
RS_DEBUG->print("RS_Document::RS_Document() ");
|
||||
|
||||
filename = "";
|
||||
+ autosaveFilename = "Unnamed";
|
||||
formatType = RS2::FormatUnknown;
|
||||
setModified(false);
|
||||
RS_Color col(RS2::FlagByLayer);
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_document.h ./qcadlib/src/engine/rs_document.h
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_document.h Tue Nov 22 12:52:32 2005
|
||||
+++ ./qcadlib/src/engine/rs_document.h Sat Aug 11 22:47:35 2007
|
||||
@@ -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;
|
||||
};
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_graphic.cpp ./qcadlib/src/engine/rs_graphic.cpp
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_graphic.cpp Tue Nov 22 12:52:32 2005
|
||||
+++ ./qcadlib/src/engine/rs_graphic.cpp Sat Aug 11 22:47:57 2007
|
||||
@@ -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();
|
||||
diff -ru ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_graphic.h ./qcadlib/src/engine/rs_graphic.h
|
||||
--- ../qcad-2.0.5.0-1-community.src.orig/qcadlib/src/engine/rs_graphic.h Tue Nov 22 12:52:38 2005
|
||||
+++ ./qcadlib/src/engine/rs_graphic.h Sat Aug 11 22:47:35 2007
|
||||
@@ -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);
|
||||
|
109
cad/qcad/files/patch-zzz-ioexcept
Normal file
109
cad/qcad/files/patch-zzz-ioexcept
Normal file
@ -0,0 +1,109 @@
|
||||
--- dxflib/src/dl_writer_ascii.h.orig 2005-11-22 12:46:58.000000000 +0100
|
||||
+++ dxflib/src/dl_writer_ascii.h 2010-08-05 23:56:19.000000000 +0200
|
||||
@@ -50,7 +50,9 @@
|
||||
class DL_WriterA : public DL_Writer {
|
||||
public:
|
||||
DL_WriterA(char* fname, DL_Codes::version version=VER_2000)
|
||||
- : DL_Writer(version), m_ofile(fname) {}
|
||||
+ : DL_Writer(version), m_ofile(fname) {
|
||||
+ m_ofile.exceptions(std::ofstream::failbit);
|
||||
+ }
|
||||
virtual ~DL_WriterA() {}
|
||||
|
||||
bool openFailed() const;
|
||||
--- qcadlib/src/filters/rs_filterdxf.cpp.orig 2005-11-22 12:52:41.000000000 +0100
|
||||
+++ qcadlib/src/filters/rs_filterdxf.cpp 2010-08-05 23:55:40.000000000 +0200
|
||||
@@ -1187,6 +1187,7 @@
|
||||
exportVersion = DL_Codes::AC1015;
|
||||
}
|
||||
|
||||
+ try {
|
||||
//DL_WriterA* dw = dxf.out(file, VER_R12);
|
||||
DL_WriterA* dw = dxf.out((const char*)QFile::encodeName(file), exportVersion);
|
||||
|
||||
@@ -1376,6 +1377,10 @@
|
||||
dw->close();
|
||||
|
||||
delete dw;
|
||||
+ } catch (std::ios::failure &e) {
|
||||
+ RS_DEBUG->print("RS_FilterDXF::fileExport: ios::failure exception caught");
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
// check if file was actually written (strange world of windoze xp):
|
||||
if (RS_FileInfo(file).exists()==false) {
|
||||
--- qcad/src/ts/qcad_en.ts.orig 2005-11-22 12:49:30.000000000 +0100
|
||||
+++ qcad/src/ts/qcad_en.ts 2010-08-06 00:00:02.000000000 +0200
|
||||
@@ -238,7 +238,8 @@
|
||||
<message>
|
||||
<source>Cannot save the file
|
||||
%1
|
||||
-Please check the permissions.</source>
|
||||
+Please check the permissions
|
||||
+and filesystem status (full?).</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
--- qcad/src/ts/qcad_de.ts.orig 2005-11-22 12:49:31.000000000 +0100
|
||||
+++ qcad/src/ts/qcad_de.ts 2010-08-06 00:00:53.000000000 +0200
|
||||
@@ -319,10 +319,12 @@
|
||||
<message>
|
||||
<source>Cannot save the file
|
||||
%1
|
||||
-Please check the permissions.</source>
|
||||
+Please check the permissions
|
||||
+and filesystem status (full?).</source>
|
||||
<translation>Kann Datei
|
||||
%1
|
||||
-nicht speichern. Bitte prüfen Sie die Berechtigung.</translation>
|
||||
+nicht speichern. Bitte prüfen Sie die Berechtigung
|
||||
+sowie den Zustand des Dateisystems (voll?).</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Help</source>
|
||||
--- qcad/src/ts/qcad_cs.ts.orig 2005-11-22 12:49:30.000000000 +0100
|
||||
+++ qcad/src/ts/qcad_cs.ts 2010-08-06 00:05:58.000000000 +0200
|
||||
@@ -300,10 +300,12 @@
|
||||
<message>
|
||||
<source>Cannot save the file
|
||||
%1
|
||||
-Please check the permissions.</source>
|
||||
+Please check the permissions
|
||||
+and filesystem status (full?).</source>
|
||||
<translation>Nelze uložit soubor
|
||||
%1
|
||||
-Zkontrolujte prosím přístupová práva.</translation>
|
||||
+Zkontrolujte prosím přístupová práva
|
||||
+a místo na zařizení.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>&CAM</source>
|
||||
--- qcad/src/ts/qcad_ru.ts.orig 2005-11-22 12:49:31.000000000 +0100
|
||||
+++ qcad/src/ts/qcad_ru.ts 2010-08-06 00:08:18.000000000 +0200
|
||||
@@ -288,10 +288,12 @@
|
||||
<message>
|
||||
<source>Cannot save the file
|
||||
%1
|
||||
-Please check the permissions.</source>
|
||||
+Please check the permissions
|
||||
+and filesystem status (full?).</source>
|
||||
<translation>Невозможно сохранить файл
|
||||
%1
|
||||
-Проверьте, пожалуйста, права доступа.</translation>
|
||||
+Проверьте, пожалуйста, права доступа
|
||||
+и свободное место на файлсистеме.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Launch the online manual</source>
|
||||
--- qcad/src/qc_applicationwindow.cpp~ 2010-08-05 23:41:32.000000000 +0200
|
||||
+++ qcad/src/qc_applicationwindow.cpp 2010-08-05 23:59:26.000000000 +0200
|
||||
@@ -2111,7 +2111,8 @@
|
||||
// error
|
||||
QMessageBox::information(this, QMessageBox::tr("Warning"),
|
||||
tr("Cannot save the file\n%1\nPlease "
|
||||
- "check the permissions.")
|
||||
+ "check the permissions\n"
|
||||
+ "and filesystem status (full?).")
|
||||
.arg(w->getDocument()->getFilename()),
|
||||
QMessageBox::Ok);
|
||||
}
|
Loading…
Reference in New Issue
Block a user