Index: ossp-pkg/as/as-gui/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/ChangeLog,v rcsdiff -q -kk '-r1.21' '-r1.22' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/ChangeLog,v' 2>/dev/null --- 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 Index: ossp-pkg/as/as-gui/TODO RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v rcsdiff -q -kk '-r1.67' '-r1.68' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/TODO,v' 2>/dev/null --- 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 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 ------------- Index: ossp-pkg/as/as-gui/as_assist.cpp RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_assist.cpp,v rcsdiff -q -kk '-r1.90' '-r1.91' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_assist.cpp,v' 2>/dev/null --- 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."))); } } } Index: ossp-pkg/as/as-gui/as_const.h RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_const.h,v rcsdiff -q -kk '-r1.41' '-r1.42' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_const.h,v' 2>/dev/null --- 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 Index: ossp-pkg/as/as-gui/as_gui.h RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_gui.h,v rcsdiff -q -kk '-r1.66' '-r1.67' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_gui.h,v' 2>/dev/null --- 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 Index: ossp-pkg/as/as-gui/as_slot.cpp RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_slot.cpp,v rcsdiff -q -kk '-r1.95' '-r1.96' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_slot.cpp,v' 2>/dev/null --- 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 } //