OSSP CVS Repository

ossp - Check-in [4019]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4019
Date: 2003-Feb-08 19:10:09 (local)
2003-Feb-08 18:10:09 (UTC)
User:ms
Branch:
Comment: Implemented a class Simplefile to decouple simple file operations from app.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/Makefile.in      1.41 -> 1.42     2 inserted, 2 deleted
ossp-pkg/as/as-gui/TODO      1.81 -> 1.82     1 inserted, 0 deleted
ossp-pkg/as/as-gui/as_sfile.cpp      added-> 1.1
ossp-pkg/as/as-gui/as_sfile.h      added-> 1.1
ossp-pkg/as/as-gui/as_slot.cpp      1.115 -> 1.116     7 inserted, 19 deleted

ossp-pkg/as/as-gui/Makefile.in 1.41 -> 1.42

--- Makefile.in  2003/02/07 16:37:55     1.41
+++ Makefile.in  2003/02/08 18:10:09     1.42
@@ -72,9 +72,9 @@
 TARGET_PROGS    = as-gui
 TARGET_MANS     = as-gui.1 as-gui.conf.5
 
-SRCS            = as_main.cpp as_gui.cpp as_assist.cpp as_slot.cpp as_dataop.cpp as_except.cpp as_generic.cpp as_amount.cpp as_table.cpp as_panel.cpp as_pref.cpp as_user.cpp as_rand.cpp as_crc.cpp as_uuid.cpp as_version.cpp
+SRCS            = as_main.cpp as_gui.cpp as_assist.cpp as_slot.cpp as_dataop.cpp as_except.cpp as_generic.cpp as_amount.cpp as_table.cpp as_panel.cpp as_sfile.cpp as_pref.cpp as_user.cpp as_rand.cpp as_crc.cpp as_uuid.cpp as_version.cpp
 
-OBJS            = as_main.o as_gui.o as_assist.o as_slot.o as_dataop.o as_except.o as_generic.o as_amount.o as_table.o as_panel.o as_pref.o as_user.o as_rand.o as_crc.o as_uuid.o as_version.o
+OBJS            = as_main.o as_gui.o as_assist.o as_slot.o as_dataop.o as_except.o as_generic.o as_amount.o as_table.o as_panel.o as_sfile.o as_pref.o as_user.o as_rand.o as_crc.o as_uuid.o as_version.o
 
 GRAFX           = gfx/ossplogo.xpm
 


ossp-pkg/as/as-gui/TODO 1.81 -> 1.82

--- TODO 2003/02/06 16:47:19     1.81
+++ TODO 2003/02/08 18:10:09     1.82
@@ -64,6 +64,7 @@
 No need to have upd slots for non-changeable upd controls
 Before openDoc, closeEvent should be used instead of new code
 Align CRC field data to left edge of table items
+Make Simplefile class non-Qt specific
 
 Screwey user notes ;-)
 ----------------------


ossp-pkg/as/as-gui/as_sfile.cpp -> 1.1

*** /dev/null    Sat Nov 23 06:30:34 2024
--- -    Sat Nov 23 06:30:39 2024
***************
*** 0 ****
--- 1,63 ----
+ //
+ //  OSSP asgui - Accounting system graphical user interface
+ //  Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/)
+ //  Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ //  Copyright (c) 2002-2003 Ralf S. Engelschall <rse@engelschall.com>
+ //  Copyright (c) 2002-2003 Michael Schloh von Bennewitz <michael@schloh.com>
+ //
+ //  This file is part of OSSP asgui, an accounting system graphical user
+ //  interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
+ //
+ //  Permission to use, copy, modify, and distribute this software for
+ //  any purpose with or without fee is hereby granted, provided that
+ //  the above copyright notice and this permission notice appear in all
+ //  copies.
+ //
+ //  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ //  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ //  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ //  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ //  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ //  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ //  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ //  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ //  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ //  SUCH DAMAGE.
+ //
+ //  as_sfile.cpp: ISO C++ implementation
+ //
+ 
+ #include "as_sfile.h"
+ #include "as_except.h"
+ 
+ 
+ //
+ // Serialize a backup of an incoming file object
+ //
+ void Simplefile::makeBackup(void)
+ {
+     QFile Filein;           // Input readonly file
+     QFile Filebak;          // Backup writeonly file
+     QString Fname;          // Filename of input file
+     QTextStream Streamin;   // Stream to read from (Filein)
+     QTextStream Streambak;  // Stream to write to (Filebak)
+ 
+     try {
+         Q_ASSERT(!this->exists());          // Conditionally short circuit
+         Fname = this->name();               // Copy filename from original
+         Filein.setName(Fname);              // Set filename of original
+         Filein.open(IO_ReadOnly);           // Open original read-only
+         Filebak.setName(Fname + ".bak");    // Set filename of backup
+         Filebak.open(IO_WriteOnly);         // Open backup write-only
+         Streamin.setDevice(&Filein);        // Set incoming stream
+         Streambak.setDevice(&Filebak);      // Set outgoing stream
+         Streambak << Streamin.read();       // Do actual writing
+         Filein.close();                     // Close original
+         Filebak.close();                    // Close backup
+     }
+     catch (Genexcept& Genex) {
+         Genex.reportErr();
+     }
+ }


ossp-pkg/as/as-gui/as_sfile.h -> 1.1

*** /dev/null    Sat Nov 23 06:30:34 2024
--- -    Sat Nov 23 06:30:39 2024
***************
*** 0 ****
--- 1,47 ----
+ //
+ //  OSSP asgui - Accounting system graphical user interface
+ //  Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/)
+ //  Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/)
+ //  Copyright (c) 2002-2003 Ralf S. Engelschall <rse@engelschall.com>
+ //  Copyright (c) 2002-2003 Michael Schloh von Bennewitz <michael@schloh.com>
+ //
+ //  This file is part of OSSP asgui, an accounting system graphical user
+ //  interface which can be found at http://www.ossp.org/pkg/tool/asgui/.
+ //
+ //  Permission to use, copy, modify, and distribute this software for
+ //  any purpose with or without fee is hereby granted, provided that
+ //  the above copyright notice and this permission notice appear in all
+ //  copies.
+ //
+ //  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ //  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ //  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ //  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ //  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ //  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ //  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ //  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ //  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ //  SUCH DAMAGE.
+ //
+ //  as_sfile.h: ISO C++ interface
+ //
+ 
+ #ifndef SIMPLEFILE_H
+ #define SIMPLEFILE_H
+ 
+ #include <qfile.h>
+ #include <qtextstream.h>
+ 
+ 
+ class Simplefile : public QFile
+ {
+ public:
+     Simplefile(void) : QFile() {};
+     Simplefile(const QString &Name) : QFile(Name) {};
+     void makeBackup(void);
+ };
+ 
+ #endif // SIMPLEFILE_H


ossp-pkg/as/as-gui/as_slot.cpp 1.115 -> 1.116

--- as_slot.cpp  2003/02/07 16:37:55     1.115
+++ as_slot.cpp  2003/02/08 18:10:09     1.116
@@ -46,8 +46,9 @@
 #include "as_generic.h"         // Generic classes
 #include "as_uuid.h"            // UUID classes
 #include "as_datedit.h"         // Derived from QDateEdit
-#include "as_crc.h"             // Useful qualistring class
-#include "as_panel.h"           // For prefpanel class
+#include "as_crc.h"             // Useful Qualistring class
+#include "as_panel.h"           // For Prefpanel class
+#include "as_sfile.h"           // For Simplefile class
 
 // RPC headers
 #ifdef HAVE_ESOAP
@@ -431,8 +432,7 @@
 void Titraqform::saveFile(void)
 {
     QString Fname;
-    QFile Filevents, Filebak;
-    QTextStream Streamevents, Streambak;
+    Simplefile Filevents;
 
     try {
         Fname = *this->getFilename();
@@ -449,21 +449,9 @@
             }
         }
 
-        Filevents.setName(Fname); // Construct a file to back up and write
-
-        // Make a backup before overwriting
-        if (Filevents.exists()) {
-            Filevents.open(IO_ReadOnly);
-            Filebak.setName(Fname + ".bak");
-            Filebak.open(IO_WriteOnly);
-            Streamevents.setDevice(&Filevents);
-            Streambak.setDevice(&Filebak);
-            Streambak << Streamevents.read();
-            Filevents.close();
-            Filebak.close();
-        }
-
-        this->saveData(Filevents); // Pass to helper method
+        Filevents.setName(Fname);   // Construct a file to write
+        Filevents.makeBackup();     // Back up to filename.bak
+        this->saveData(Filevents);  // Pass to helper method
     }
     catch (Genexcept& Genex) {
         Genex.reportErr();

CVSTrac 2.0.1