OSSP CVS Repository

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

Check-in Number: 3846
Date: 2002-Dec-05 19:03:53 (local)
2002-Dec-05 18:03:53 (UTC)
User:ms
Branch:
Comment: Completed dirty data state conditionals.
Tickets:
Inspections:
Files:
ossp-pkg/as/as-gui/TODO      1.33 -> 1.34     1 inserted, 0 deleted
ossp-pkg/as/as-gui/as_assist.cpp      1.50 -> 1.51     1 inserted, 1 deleted
ossp-pkg/as/as-gui/as_gui.h      1.42 -> 1.43     1 inserted, 1 deleted
ossp-pkg/as/as-gui/as_slot.cpp      1.42 -> 1.43     81 inserted, 23 deleted

ossp-pkg/as/as-gui/TODO 1.33 -> 1.34

--- TODO 2002/12/05 16:08:21     1.33
+++ TODO 2002/12/05 18:03:53     1.34
@@ -34,6 +34,7 @@
 Consistently initilize fields when selecting multiple rows
 Remove extremely stupid as_uuid logic in favor of built in QUuid class!
 Krass date block data shading keyed to sort function
+Does resetting data clean make sense after closeEvent?
 
 Beim Editmodus
 ---------------


ossp-pkg/as/as-gui/as_assist.cpp 1.50 -> 1.51

--- as_assist.cpp        2002/12/05 14:51:29     1.50
+++ as_assist.cpp        2002/12/05 18:03:53     1.51
@@ -175,7 +175,7 @@
     m_pFileopenact = new QAction(trUtf8("Open File"), QPixmap(s_kpcFileopen_xpm), trUtf8("&Open..."), CTRL+Key_O, this, "Open");
     if (m_pFileopenact == NULL) // Sanity check
         throw Genexcept("Main window file open action creation failed.");
-    connect(m_pFileopenact, SIGNAL(activated()), this, SLOT(chooseFile()));
+    connect(m_pFileopenact, SIGNAL(activated()), this, SLOT(openDoc()));
     const char *kszFileopentext = "<p><img source=\"fileopen\"> "
                                   "Click this button to open a "
                                   "<em>new file</em>. You can also select "


ossp-pkg/as/as-gui/as_gui.h 1.42 -> 1.43

--- as_gui.h     2002/12/05 14:51:29     1.42
+++ as_gui.h     2002/12/05 18:03:53     1.43
@@ -118,7 +118,7 @@
     void addEntry(int nRows= -1);       // Add task entries to the list
     void delEntry(int nRows= -1);       // Delete task entries from the list
     void newDoc(void);                  // Make and display a new document window
-    void chooseFile(void);              // Choose a file using a handy file dialog
+    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 helpContents(void);            // Use the help contents


ossp-pkg/as/as-gui/as_slot.cpp 1.42 -> 1.43

--- as_slot.cpp  2002/12/05 16:08:21     1.42
+++ as_slot.cpp  2002/12/05 18:03:53     1.43
@@ -85,8 +85,10 @@
     nRows = Selection.contains(QChar('\n'));        // How many rows
     this->addEntry(nRows);                          // Reuse slot
 
-    if (Selection)
+    if (Selection) {
         setRowdata(Selection);                      // Use accessor
+        this->setDirty(true);                       // Set dirty state
+    }
 }
 
 //
@@ -104,10 +106,12 @@
         // Add a row after selection and focus to the new row
         if (Select.bottomRow() + 1 != m_pMaintable->numRows()) { // Add upwards
             m_pMaintable->insertRows(Select.topRow(), nTotal);
+            this->setDirty(true);   // Set data to dirty state
             m_pMaintable->setCurrentCell(Select.topRow(), m_pMaintable->currentColumn());
         }
         else { // Special case on last row add downwards
             m_pMaintable->insertRows(Select.bottomRow() + 1, nTotal);
+            this->setDirty(true);   // Set data to dirty state
             m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn());
             m_pMaintable->ensureCellVisible(m_pMaintable->numRows() - 1, 0); // Scroll please
         }
@@ -118,10 +122,12 @@
         // Add a row after selection and focus to the new row
         if (nCurrent + 1 != m_pMaintable->numRows()) { // Add upwards
             m_pMaintable->insertRows(nCurrent, nTotal);
+            this->setDirty(false);  // Reset data to clean state
             m_pMaintable->setCurrentCell(nCurrent, m_pMaintable->currentColumn());
         }
         else { // Special case on last row add downwards
             m_pMaintable->insertRows(nCurrent + 1, nTotal);
+            this->setDirty(false);  // Reset data to clean state
             m_pMaintable->setCurrentCell(nCurrent + 1, m_pMaintable->currentColumn());
             m_pMaintable->ensureCellVisible(m_pMaintable->numRows() - 1, 0); // Scroll please
         }
@@ -157,9 +163,12 @@
     if (m_pMaintable->currentRow() + 1 != m_pMaintable->numRows()) {
         m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn());
         m_pMaintable->removeRows(Rowselect);
+        this->setDirty(true);   // Set data to dirty state
     }
-    else // Special case to handle removing of only row or last row
+    else {  // Special case to handle removing of only row or last row
         m_pMaintable->removeRows(Rowselect);
+        this->setDirty(true);   // Set data to dirty state
+    }
 }
 
 //
@@ -179,41 +188,88 @@
         case 0: // Save first
             this->saveFile();               // Save changes first
             m_pMaintable->setNumRows(0);    // Remove all data in table
+            this->setDirty(false);          // Reset data to clean state
             break;
         case 1: // Don't save first but do new
             m_pMaintable->setNumRows(0);    // Remove all data in table
+            this->setDirty(false);          // Reset data to clean state
             break;
         case 2: // Don't do a new timesheet
         default:
             break;
         }
     }
-    else                                    // Data is already up to date
+    else {                                  // Data is already up to date
         m_pMaintable->setNumRows(0);        // Remove all data in table
-
-    this->setDirty(false);                  // Reset data to clean state
+        this->setDirty(false);              // Reset data to clean state
+    }
 }
 
 //
-// Choose a file using a handy file dialog
+// Open and display an existing document
 //
-void Titraqform::chooseFile(void)
+void Titraqform::openDoc(void)
 {
+    int nResult = 0;    // Holds return value from save first messagebox
     QString Filestring = QFileDialog::getOpenFileName("/e/dev/as", QString::null, this, trUtf8("Chooser Dialog"), trUtf8("Choose a file to open"));
+
     if (!Filestring.isEmpty()) {
-        m_szFilename->operator=(Filestring);
-        m_pMaintable->setNumRows(0);    // Clear out old data
-        QFile Filetemp(Filestring);     // File to load
-        try {
-            loadData(Filetemp);         // Pass to helper method
-        }
-        catch (Genexcept& Genex) {
-            Genex.reportErr();
-        }
-        // Reset and give output to main window
-        this->setCaption(Filestring);
-        m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000);
-        this->setDirty(false);          // Set the clean state
+        QFile Filetemp(Filestring); // File to load
+        // Check modification state of current data
+        if (this->isDirty()) {
+            nResult = QMessageBox::information(this, trUtf8(TITRAQ_APPTITLE),
+                      trUtf8(TITRAQ_SAVEFIRST), trUtf8("&Save"),
+                      trUtf8("&Discard"), trUtf8("Cancel"), 0, 2);
+
+            switch (nResult) {
+            case 0: // Save first
+                this->saveFile();               // Save changes first
+                m_szFilename->operator=(Filestring);
+                m_pMaintable->setNumRows(0);    // Clear out old data
+                try {
+                    loadData(Filetemp);         // Pass to helper method
+                }
+                catch (Genexcept& Genex) {
+                    Genex.reportErr();
+                }
+                // Reset and give output to main window
+                this->setCaption(Filestring);
+                m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000);
+                this->setDirty(false);          // Set the clean state
+                break;
+            case 1: // Don't save first but do load
+                m_szFilename->operator=(Filestring);
+                m_pMaintable->setNumRows(0);    // Clear out old data
+                try {
+                    loadData(Filetemp);         // Pass to helper method
+                }
+                catch (Genexcept& Genex) {
+                    Genex.reportErr();
+                }
+                // Reset and give output to main window
+                this->setCaption(Filestring);
+                m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000);
+                this->setDirty(false);          // Set the clean state
+                break;
+            case 2: // Don't do a load timesheet
+            default:
+                break;
+            }
+        }
+        else {
+            m_szFilename->operator=(Filestring);
+            m_pMaintable->setNumRows(0);    // Clear out old data
+            try {
+                loadData(Filetemp);         // Pass to helper method
+            }
+            catch (Genexcept& Genex) {
+                Genex.reportErr();
+            }
+            // Reset and give output to main window
+            this->setCaption(Filestring);
+            m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000);
+            this->setDirty(false);          // Set the clean state
+        }
     }
     else
         m_pStatbar->message(trUtf8("Loading aborted"), 4000);
@@ -278,9 +334,11 @@
         case 0: // Save first
             this->saveFile();               // Save changes first
             pClosit->accept();              // then close timesheet
+            this->setDirty(false);          // Reset data to clean state
             break;
         case 1: // Don't save first but close
             pClosit->accept();              // Close timesheet
+            this->setDirty(false);          // Reset data to clean state
             break;
         case 2: // Don't close
         default:
@@ -288,10 +346,10 @@
             break;
         }
     }
-    else                                    // Data is already up to date
+    else {                                  // Data is already up to date
         pClosit->accept();
-
-    this->setDirty(false);                  // Reset data to clean state
+        this->setDirty(false);              // Reset data to clean state
+    }
 }
 
 //

CVSTrac 2.0.1