OSSP CVS Repository

ossp - Difference in ossp-pkg/as/as-gui/as_slot.cpp versions 1.72 and 1.73
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/as/as-gui/as_slot.cpp 1.72 -> 1.73

--- as_slot.cpp  2002/12/19 13:23:35     1.72
+++ as_slot.cpp  2002/12/19 20:46:26     1.73
@@ -86,9 +86,6 @@
     QString Selection;          // Will receive the clipboard text
     QClipboard *pClip;          // Will reference the global clipboard
 
-    // Optimize viewing by repainting cells only once after processing
-    m_pMaintable->setUpdatesEnabled(false);
-
     if (Selection = pClip->text(QClipboard::Clipboard)) { // Windows and Unix
         nRows = Selection.contains(QChar('\n'));    // How many rows
         this->addEntry(nRows);                      // Reuse slot
@@ -102,8 +99,6 @@
         for (int nIter = 0; nIter < nRows; nIter++)
             this->validateData(m_pMaintable->currentRow() + nIter, 0);
     }
-
-    m_pMaintable->setUpdatesEnabled(true);          // Update and repaint
 }
 
 //
@@ -183,8 +178,8 @@
 //    uuid_unparse(Guid, szGuitext);
 //    m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXGUID, szGuitext);
 
-    m_pMaintable->setUpdatesEnabled(true);          // Turn updates back on
-    m_pMaintable->repaintContents(false);           // Repaint viewport
+    m_pMaintable->setUpdatesEnabled(true);  // Turn updates back on
+    m_pMaintable->repaintContents(true);    // Do a general repaint of table
 }
 
 //
@@ -232,7 +227,7 @@
         nIter++;
     }
 
-    m_pMaintable->repaintContents(true);    // Do a general repaint of table
+    m_pMaintable->repaintContents(false);   // Do a general repaint of table
     m_pStatbar->message(trUtf8("Display was refreshed"), 4000); // Announce result
 }
 
@@ -252,86 +247,29 @@
         switch (nResult) {
         case 0: // First button selected, so save first
             this->saveFile();               // Save changes first
-
-            // Reset widget text values before blanking table
-            m_pDateedit->setDate(*m_pDatezero);
-            m_pStarttime->setTime(QTime::QTime(0, 0));
-            m_pEndtime->setTime(QTime::QTime(0, 0));
-            m_pAmount->setText(NULL);
-            m_pTasks->setCurrentText(NULL);
-            m_pRemark->setText(NULL);
-
-            m_pMaintable->setEnabled(true); // Enable the table first
-            m_pMaintable->setNumRows(0);    // Remove all data in table
-            m_pLineedit->setEnabled(true);
-            m_pUseredit->setEnabled(true);
-            m_pGuidedit->setEnabled(true);
-            m_pCrcedit->setEnabled(true);
-            m_pRevedit->setEnabled(true);
-            m_pDateedit->setEnabled(true);
-            m_pStarttime->setEnabled(true);
-            m_pEndtime->setEnabled(true);
-            m_pAmount->setEnabled(true);
-            m_pTasks->setEnabled(true);
-            m_pRemark->setEnabled(true);
-            this->updEdit(0, 0);            // Reset edit controls
-            this->setCaption(trUtf8("No file name"));
-            m_pStatbar->message(trUtf8("New document"), 4000);
-            *m_szFilename = "";             // Blank the file name
-            m_pMaintable->setDirty(false);  // Reset data to clean state
             break;
-        case 1: // Second button selected, so don't save first but do new
-            m_pMaintable->setEnabled(true); // Enable the table first
-            m_pMaintable->setNumRows(0);    // Remove all data in table
-            m_pLineedit->setEnabled(true);
-            m_pUseredit->setEnabled(true);
-            m_pGuidedit->setEnabled(true);
-            m_pCrcedit->setEnabled(true);
-            m_pRevedit->setEnabled(true);
-            m_pDateedit->setEnabled(true);
-            m_pStarttime->setEnabled(true);
-            m_pEndtime->setEnabled(true);
-            m_pAmount->setEnabled(true);
-            m_pTasks->setEnabled(true);
-            m_pRemark->setEnabled(true);
-            this->updEdit(0, 0);            // Reset edit controls
-            this->setCaption(trUtf8("No file name"));
-            m_pStatbar->message(trUtf8("New document"), 4000);
-            *m_szFilename = "";             // Blank the file name
-            m_pMaintable->setDirty(false);  // Reset data to clean state
+        case 1: // Second button selected, so don't save
             break;
-        case 2: // Third button selected, so don't do a new timesheet
+        case 2: // Third button selected, so return sofort
         default:
+            return;
             break;
         }
     }
-    else { // Data is already up to date
-        // Reset widget text values before blanking table
-        m_pDateedit->setDate(*m_pDatezero);
-        m_pStarttime->setTime(QTime::QTime(0, 0));
-        m_pEndtime->setTime(QTime::QTime(0, 0));
-        m_pAmount->setText(NULL);
-        m_pTasks->setCurrentText(NULL);
-        m_pRemark->setText(NULL);
-        m_pMaintable->setEnabled(true);     // Enable the table first
-        m_pMaintable->setNumRows(0);        // Remove all data in table
-        m_pLineedit->setEnabled(true);
-        m_pUseredit->setEnabled(true);
-        m_pGuidedit->setEnabled(true);
-        m_pCrcedit->setEnabled(true);
-        m_pRevedit->setEnabled(true);
-        m_pDateedit->setEnabled(true);
-        m_pStarttime->setEnabled(true);
-        m_pEndtime->setEnabled(true);
-        m_pAmount->setEnabled(true);
-        m_pTasks->setEnabled(true);
-        m_pRemark->setEnabled(true);
-        this->updEdit(0, 0);                // Reset edit controls
-        this->setCaption(trUtf8("No file name"));
-        m_pStatbar->message(trUtf8("New document"), 4000);
-        *m_szFilename = "";                 // Blank the file name
-        m_pMaintable->setDirty(false);      // Reset data to clean state
-    }
+    // Fall through to implicit new doc code
+    this->enableIface(true);            // Enable the interface
+    m_pMaintable->setNumRows(0);        // Remove all data in table
+    this->setCaption(trUtf8("No file name"));
+    m_pStatbar->message(trUtf8("New document"), 4000);
+    this->setFilename("");
+
+    // Reset widget text of edit controls
+    m_pDateedit->setDate(*m_pDatezero);
+    m_pStarttime->setTime(QTime::QTime(0, 0));
+    m_pEndtime->setTime(QTime::QTime(0, 0));
+    m_pAmount->setText(NULL);
+    m_pTasks->setCurrentText(NULL);
+    m_pRemark->setText(NULL);
 }
 
 //
@@ -353,7 +291,7 @@
             switch (nResult) {
             case 0: // Save first
                 this->saveFile();               // Save changes first
-                m_szFilename->operator=(Filestring);
+                setFilename(Filestring);        // Set the new file name
                 m_pMaintable->setNumRows(0);    // Clear out old data
                 try {
                     loadData(Filetemp);         // Pass to helper method
@@ -361,25 +299,9 @@
                 catch (Genexcept& Genex) {
                     Genex.reportErr();
                 }
-                // Reset and give output to main window
-                this->setCaption(Filestring);
-                m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000);
-                m_pMaintable->setEnabled(true); // Enable the table first
-                m_pLineedit->setEnabled(true);
-                m_pUseredit->setEnabled(true);
-                m_pGuidedit->setEnabled(true);
-                m_pCrcedit->setEnabled(true);
-                m_pRevedit->setEnabled(true);
-                m_pDateedit->setEnabled(true);
-                m_pStarttime->setEnabled(true);
-                m_pEndtime->setEnabled(true);
-                m_pAmount->setEnabled(true);
-                m_pTasks->setEnabled(true);
-                m_pRemark->setEnabled(true);
-                m_pMaintable->setDirty(false);  // Set the clean state
                 break;
             case 1: // Don't save first but do load
-                m_szFilename->operator=(Filestring);
+                setFilename(Filestring);        // Set the new file name
                 m_pMaintable->setNumRows(0);    // Clear out old data
                 try {
                     loadData(Filetemp);         // Pass to helper method
@@ -387,22 +309,6 @@
                 catch (Genexcept& Genex) {
                     Genex.reportErr();
                 }
-                // Reset and give output to main window
-                this->setCaption(Filestring);
-                m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000);
-                m_pMaintable->setEnabled(true); // Enable the table first
-                m_pLineedit->setEnabled(true);
-                m_pUseredit->setEnabled(true);
-                m_pGuidedit->setEnabled(true);
-                m_pCrcedit->setEnabled(true);
-                m_pRevedit->setEnabled(true);
-                m_pDateedit->setEnabled(true);
-                m_pStarttime->setEnabled(true);
-                m_pEndtime->setEnabled(true);
-                m_pAmount->setEnabled(true);
-                m_pTasks->setEnabled(true);
-                m_pRemark->setEnabled(true);
-                m_pMaintable->setDirty(false);  // Set the clean state
                 break;
             case 2: // Don't do a load timesheet
             default:
@@ -410,31 +316,20 @@
             }
         }
         else {
-            m_szFilename->operator=(Filestring);
-            m_pMaintable->setNumRows(0);    // Clear out old data
+            setFilename(Filestring);            // Set the new file name
+            m_pMaintable->setNumRows(0);        // Clear out old data
             try {
-                loadData(Filetemp);         // Pass to helper method
+                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);
-            m_pMaintable->setEnabled(true); // Enable the table first
-            m_pLineedit->setEnabled(true);
-            m_pUseredit->setEnabled(true);
-            m_pGuidedit->setEnabled(true);
-            m_pCrcedit->setEnabled(true);
-            m_pRevedit->setEnabled(true);
-            m_pDateedit->setEnabled(true);
-            m_pStarttime->setEnabled(true);
-            m_pEndtime->setEnabled(true);
-            m_pAmount->setEnabled(true);
-            m_pTasks->setEnabled(true);
-            m_pRemark->setEnabled(true);
-            m_pMaintable->setDirty(false);  // Set the clean state
         }
+
+        // Fall through to implicit open code
+        this->setCaption(Filestring);
+        m_pStatbar->message(trUtf8("Loaded document ") + Filestring, 4000);
+        this->enableIface(true);    // Turn on the lights
     }
     else
         m_pStatbar->message(trUtf8("Loading aborted"), 4000);
@@ -445,23 +340,24 @@
 //
 void Titraqform::saveFile(void)
 {
-    // First time saves are really just saveAs in disguise
-    if (m_szFilename->isEmpty()) {
-        saveAs();
-        return;
-    }
-
-    // Try to open a file for writing to
-    QFile Filetemp(*m_szFilename);
+    QString Fname;
     try {
-        saveData(Filetemp); // Pass to helper method
+        Fname = QString(*this->getFilename());
+        // First time saves are really just saveAs in disguise
+        if (Fname.isEmpty()) {
+            this->saveAs();
+            return;
+        }
+        // Try to open a file for writing to
+        QFile Filetemp(Fname);
+        this->saveData(Filetemp); // Pass to helper method
     }
     catch (Genexcept& Genex) {
         Genex.reportErr();
     }
     // Reset and give output to main window
-    this->setCaption(*m_szFilename);
-    m_pStatbar->message(trUtf8("File %1 saved").arg(*m_szFilename), 4000);
+    this->setCaption(Fname);
+    m_pStatbar->message(trUtf8("File %1 saved").arg(Fname), 4000);
     m_pMaintable->setDirty(false);  // Set the clean state to allow close
 }
 
@@ -480,7 +376,7 @@
                       trUtf8(TITRAQ_OVERWRITE), trUtf8("&Yes"), trUtf8("&No"), NULL, 1, 1);
             switch (nResult) {
             case 0: // Overwrite contents
-                *m_szFilename = Filestring;
+                this->setFilename(Filestring);
                 this->saveFile();
                 break;
             case 1: // Don't overwrite
@@ -504,32 +400,33 @@
 {
     int nResult = 0;
 
+    if (!this->isOpen())    // Short circuit if user
+        qApp->quit();       // selects close twice
+
     // Check modification state of current data
     if (m_pMaintable->isDirty()) {
         nResult = QMessageBox::information(this, trUtf8(TITRAQ_APPTITLE),
                   trUtf8(TITRAQ_SAVEFIRST), trUtf8("&Save"),
                   trUtf8("&Discard"), trUtf8("Cancel"), 0, 2);
 
-        switch (nResult) {
+        switch (nResult) {      // Maybe save before closing
         case 0: // Save first
-            this->saveFile();               // Save changes first
-            m_pMaintable->setDirty(false);  // Reset data to clean state
-            pClosit->accept();              // then close timesheet
+            this->saveFile();   // Save changes first
             break;
-        case 1: // Don't save first but close
-            m_pMaintable->setDirty(false);  // Reset data to clean state
-            pClosit->accept();              // Close timesheet
+        case 1: // Don't save first
             break;
-        case 2: // Don't close
+        case 2: // Do nothing
         default:
             pClosit->ignore();
+            return; // Go away without closing
             break;
         }
     }
-    else {                                  // Data is already up to date
-        m_pMaintable->setDirty(false);      // Reset data to clean state
-        pClosit->accept();
-    }
+
+    // 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
 }
 
 //

CVSTrac 2.0.1