OSSP CVS Repository

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

Check-in Number: 3973
Date: 2003-Jan-30 23:02:41 (local)
2003-Jan-30 22:02:41 (UTC)
User:ms
Branch:
Comment: Fixed dirty data double check on implicit save ops, fixed close event method, and plugged holes where no exception handling existed for an except condition.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/ChangeLog      1.21 -> 1.22     3 inserted, 0 deleted
ossp-pkg/as/as-gui/TODO      1.67 -> 1.68     2 inserted, 3 deleted
ossp-pkg/as/as-gui/as_assist.cpp      1.90 -> 1.91     13 inserted, 8 deleted
ossp-pkg/as/as-gui/as_const.h      1.41 -> 1.42     1 inserted, 0 deleted
ossp-pkg/as/as-gui/as_gui.h      1.66 -> 1.67     1 inserted, 0 deleted
ossp-pkg/as/as-gui/as_slot.cpp      1.95 -> 1.96     69 inserted, 9 deleted

ossp-pkg/as/as-gui/ChangeLog 1.21 -> 1.22

--- ChangeLog    2003/01/30 20:26:03     1.21
+++ ChangeLog    2003/01/30 22:02:41     1.22
@@ -5,6 +5,9 @@
        Added aggregate class User, and prefer user data from environment
        Fixed ignored prepared entry bug on new document operation
        Implemented writing and testing of a data version symbol
+       Fixed missing double dirty data check on implicit saveAs ops
+       Fixed close document operation with bad caption and status message
+       Added exception handlers where none existed to close possible bugs
 
 030129 Fixed the autoscroll before show bug, causing wrong data position
 


ossp-pkg/as/as-gui/TODO 1.67 -> 1.68

--- TODO 2003/01/30 20:26:03     1.67
+++ TODO 2003/01/30 22:02:41     1.68
@@ -32,6 +32,7 @@
 Use namespace 'AS' or unique identifier 'AS' for all classnames
 Unify class mycl = class(), class mycl(), class *pMycl, auto_ptr<class *>
 Win32 code in User class is only half written, and incomplete homedir
+Remove all exception raises from slot code
 
 For immediate release
 ---------------------
@@ -46,13 +47,12 @@
 When sorting rows, sometimes a false extra highlight appears
 Disabled actions still show enabled icons in menu popups
 Pressing escape on task data cells does not exit edit mode
-On dirty, save is asked, if cancel from file dialog, doesn't revert
 On win32, all or some file reads and writes probably need IO_Translate?
 Method saveData(stream) must write to a new file, otherwise writes data pattern
 
 Nice to have
 ------------
-After undo and backup, implement drag and drop row swapping
+Implement drag and drop selected row swapping
 Implement an unlimited and generic undo and redo buffer class
 Support pasting into as_gui from other app (like vim)
 Add optional automatic file personal data file backup
@@ -61,7 +61,6 @@
 Soll mehr intuitive, mit sekondaer/dritte Keycolumn
 CRC und Rev sollen nicht in gleiche Methode berechnet
 No need to have upd slots for non-changeable upd controls
-Use argc and argv to open a task file on startup
 
 Architectural
 -------------


ossp-pkg/as/as-gui/as_assist.cpp 1.90 -> 1.91

--- as_assist.cpp        2003/01/30 16:51:45     1.90
+++ as_assist.cpp        2003/01/30 22:02:41     1.91
@@ -1018,15 +1018,20 @@
     if (nNumargs > 1) { // Warm up a nice cascade, to set my mind on four weeks of vacation
         for (int nIter = 1; nIter < nNumargs; nIter++) {    // Salad in New Zealand
             if (QChar(*qApp->argv()[nIter]) != '-') {       // Bunuelos in Colombia
-                this->setFilename(qApp->argv()[nIter]);     // Store inital filename
-                Initial.setName(*this->getFilename());      // Initial file to load
-                if (Initial.exists(*getFilename())) {
-                    this->loadData(Initial);                // Pass to helper method
-                    enableIface(true);                      // Turn on the lights
-                    m_pStatbar->message(trUtf8("Loaded document ") + *this->getFilename());
+                try {
+                    this->setFilename(qApp->argv()[nIter]); // Store inital filename
+                    Initial.setName(*this->getFilename());  // Initial file to load
+                    if (Initial.exists(*getFilename())) {
+                        this->loadData(Initial);            // Pass to helper method
+                        enableIface(true);                  // Turn on the lights
+                        m_pStatbar->message(trUtf8("Loaded document ") + *this->getFilename());
+                    }
+                    else // The inital file name does not correspond to a file
+                        m_pStatbar->message(trUtf8(QString("The file ") + *this->getFilename() + QString(" does not exist.")));
+                }
+                catch (Genexcept& Genex) {
+                    Genex.reportErr();
                 }
-                else    // The inital file name does not correspond to a file
-                    m_pStatbar->message(trUtf8(QString("The file ") + *this->getFilename() + QString(" does not exist.")));
             }
         }
     }


ossp-pkg/as/as-gui/as_const.h 1.41 -> 1.42

--- as_const.h   2003/01/30 20:26:03     1.41
+++ as_const.h   2003/01/30 22:02:41     1.42
@@ -151,6 +151,7 @@
 #define TITRAQ_BADVERSIONMIN    "Incompatible data format. Please either\nupgrade this application or downgrade\nthe data you are using with it."
 #define TITRAQ_INCOMPATDATA     "Error: incompatible data format."
 #define TITRAQ_INVALIDDATA      "Error: invalid data format."
+#define TITRAQ_SAVECANCELLED    "Warning: save operation failed, because the user cancelled."
 
 // Indexes of table columns
 #define TITRAQ_IDXALLCTRLS     -1


ossp-pkg/as/as-gui/as_gui.h 1.66 -> 1.67

--- as_gui.h     2003/01/30 14:36:01     1.66
+++ as_gui.h     2003/01/30 22:02:41     1.67
@@ -164,6 +164,7 @@
     void openDoc(void);                 // Open and display an existing document
     void saveFile(void);                // Serialize to the current file
     void saveAs(void);                  // Serialize to a selected file
+    void saveName(void);                // Implicitly serialize to a selected file
     void helpContents(void);            // Use the help contents
     void aboutTitraq(void);             // Learn more about this program itself
     void aboutOSSP(void);               // Learn more about the OSSP


ossp-pkg/as/as-gui/as_slot.cpp 1.95 -> 1.96

--- as_slot.cpp  2003/01/30 20:26:03     1.95
+++ as_slot.cpp  2003/01/30 22:02:41     1.96
@@ -303,7 +303,7 @@
     m_pMaintable->setNumRows(0);        // Remove all data in table
     this->setCaption(trUtf8("No file name"));
     m_pStatbar->message(trUtf8("New document"), 4000);
-    this->setFilename("");
+    this->setFilename(QString(""));
     this->addEntry(1);                  // Default new op adds a row
     m_pMaintable->setDirty(false);      // Start out clean
 }
@@ -390,12 +390,18 @@
     QTextStream Streamevents, Streambak;
 
     try {
-        Fname = QString(*this->getFilename());
+        Fname = *this->getFilename();
 
-        // First time saves are really just saveAs in disguise
+        // First time saves are really just saveName in disguise
         if (Fname.isEmpty()) {
-            this->saveAs();
-            return;
+            try {
+                this->saveName();       // Try to 'save as'
+                return;                 // and short circuit
+            }
+            catch (Genexcept& Genex) {
+                Genex.reportErr();      // Report the error
+                return;                 // and short circuit
+            }
         }
 
         Filevents.setName(Fname); // Construct a file to back up and write
@@ -459,9 +465,55 @@
             this->saveFile();               // Finish by calling the save action
         }
     }
-    else {
+    else
         // User did not select a valid file and push okay button
         m_pStatbar->message(trUtf8("Saving aborted"), 4000);
+}
+
+//
+// Implicitly serialize current state to a selected file
+// The main difference with saveAs is that this uses exceptions
+//
+void Titraqform::saveName(void)
+{
+    int nResult = 0; // For checking user's answer
+
+    // Make sure we correctly get the name of the default file to open
+    QString Openas = m_pPrefs->getString(TITRAQ_PREFASFILE, TITRAQ_DEFASFILE);
+    if (Openas.startsWith(TITRAQ_HOMEDIRTOK))
+        Openas = QDir::homeDirPath() + Openas.remove(0, QString(TITRAQ_HOMEDIRTOK).length() - 1);
+
+    nResult = 1;            // We loop on this dialog only if an indecisive user
+    while (nResult > 0) {   // is hesitant to overwrite a file over and over again
+        QString Filestring = QFileDialog::getSaveFileName(Openas, trUtf8("Accounting Data (*.as);;Text files (*.txt);;All Files (*)"), this, trUtf8("ChooserDialog"), trUtf8("Choose a file to save"), NULL, false);
+        if (!Filestring.isEmpty()) {
+            if (QFile::exists(Filestring)) {
+                nResult = QMessageBox::warning(this, trUtf8(TITRAQ_APPTITLE),
+                          trUtf8(TITRAQ_OVERWRITE), trUtf8("&Yes"), trUtf8("&No"), NULL, 1, 1);
+                switch (nResult) {
+                case 0: // Overwrite contents
+                    this->setFilename(Filestring);
+                    this->saveFile();
+                    break;
+                case 1: // Don't overwrite
+                default:
+                    break;
+                }
+            }
+            else {
+                QString Extension = TITRAQ_FEXTENSION;  // Logic to handle
+                if (!Filestring.endsWith(Extension))    // AS file extension
+                    Filestring += Extension;            // insertion
+                this->setFilename(Filestring);  // Set filename of object first
+                nResult = 0;                    // Reset our loop control
+                this->saveFile();               // Finish by calling the save action
+            }
+        }
+        else {
+            // User did not select a valid file and push okay button
+            m_pStatbar->message(trUtf8("Saving aborted"), 4000);
+            throw Genexcept(TITRAQ_SAVECANCELLED);
+        }
     }
 }
 
@@ -496,9 +548,17 @@
     }
 
     // Fall through to implicit close code
-    this->enableIface(false);   // Turn off the lights
-    this->setOpen(false);       // Set doc state to closed
-    pClosit->ignore();          // Finish off by not closing
+    this->setCaption(TITRAQ_APPTITLE);
+    try { // There might be problems, so wrap these last ops with error handling
+        if (this->isOpen())
+            m_pStatbar->message(trUtf8("Closed document ") + *this->getFilename(), 4000);
+        this->setOpen(false);       // Set doc state to closed
+        this->enableIface(false);   // Turn off the lights
+    }
+    catch (Genexcept& Genex) {
+        Genex.reportErr();
+    }
+    pClosit->ignore();              // Finish off by not closing
 }
 
 //

CVSTrac 2.0.1