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.49' '-r1.50' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_assist.cpp,v' 2>/dev/null --- as_assist.cpp 2002/12/05 10:33:25 1.49 +++ as_assist.cpp 2002/12/05 14:51:29 1.50 @@ -498,7 +498,7 @@ connect(m_pMaintable, SIGNAL(currentChanged(int, int)), this, SLOT(updEdit(int, int))); connect(m_pMaintable, SIGNAL(doubleClicked(int, int, int, const QPoint&)), this, SLOT(inplaceEdit(int, int, int, const QPoint&))); connect(m_pTablehead, SIGNAL(sizeChange(int, int, int)), this, SLOT(updSizes(int, int, int))); -// connect(m_pMaintable, SIGNAL(valueChanged(int, int)), this, SLOT(tableChanged(int, int))); + connect(m_pMaintable, SIGNAL(valueChanged(int, int)), this, SLOT(dataChanged(int, int))); } // 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.15' '-r1.16' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_const.h,v' 2>/dev/null --- as_const.h 2002/12/04 18:56:59 1.15 +++ as_const.h 2002/12/05 14:51:29 1.16 @@ -48,6 +48,7 @@ #define TITRAQ_DEFREMOTELOG "no" #define TITRAQ_PREFLOCALLOG "loglocal" #define TITRAQ_DEFLOCALLOG "no" +#define TITRAQ_SAVEFIRST "The timesheet contains unsaved changes\nDo you want to save the changes or discard them?" // Other string constants #define TITRAQ_DATEZERO "0000-00-00" @@ -77,5 +78,8 @@ #define TITRAQ_MINAMOUNT 0 // Minimum valid amount #define TITRAQ_STEPAMOUNT 15 // Line step interval #define TITRAQ_MINSINHOUR 60 // Only idiots don't know this +#define TITRAQ_YES 1 // To signal yes in general +#define TITRAQ_NO 0 // To signal no in general +#define TITRAQ_CANCEL -1 // To not signal anything #endif // TITCONST_H 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.41' '-r1.42' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_gui.h,v' 2>/dev/null --- as_gui.h 2002/12/04 23:22:52 1.41 +++ as_gui.h 2002/12/05 14:51:29 1.42 @@ -129,6 +129,7 @@ void inplaceEdit(int, int, int, const QPoint &); // Enter in place edit mode void updEdit(int, int); // Update edit controls void updSizes(int, int, int); // Update edit sizes + void dataChanged(int, int); // Timesheet data changed void updateDate(const QDate &); // Update date column void updateStart(const QTime &); // Update start column void updateFinish(const QTime &); // Update finish column 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.40' '-r1.41' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_slot.cpp,v' 2>/dev/null --- as_slot.cpp 2002/12/04 23:22:52 1.40 +++ as_slot.cpp 2002/12/05 14:51:29 1.41 @@ -167,7 +167,29 @@ // void Titraqform::newDoc(void) { - m_pMaintable->setNumRows(0); // Get rid of any data in table + int nResult = 0; + + // 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_pMaintable->setNumRows(0); // Remove all data in table + break; + case 1: // Don't save first but do new + m_pMaintable->setNumRows(0); // Remove all data in table + break; + case 2: // Don't do a new timesheet + default: + break; + } + } + else // Data is already up to date + m_pMaintable->setNumRows(0); // Remove all data in table } // @@ -242,28 +264,30 @@ // void Titraqform::closeEvent(QCloseEvent *pClosit) { + int nResult = 0; + // Check modification state of current data - if (!this->isDirty()) { - pClosit->accept(); - return; + 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 + pClosit->accept(); // then close timesheet + break; + case 1: // Don't save first but close + pClosit->accept(); // Close timesheet + break; + case 2: // Don't close + default: + pClosit->ignore(); + break; + } } - - // Ask user to acknowlege a possibly data-damaging close event - switch(QMessageBox::information(this, "OSSP titraq", - trUtf8("The document has been\nchanged since the last save.")), - trUtf8("Save Now"), trUtf8("Cancel"), trUtf8("Leave Anyway"), 0, 1) { - case 0: - saveFile(); - pClosit->accept(); - break; - case 1: - default: // Just for sanity - pClosit->ignore(); - break; - case 2: + else // Data is already up to date pClosit->accept(); - break; - } } // @@ -291,6 +315,44 @@ // void Titraqform::updSizes(int nSection, int nOldsize, int nNewsize) { + switch (nSection) { + case TITRAQ_IDXALLCTRLS: + m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING + TITRAQ_SPACING / 2); + m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING); + m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING); + m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING); + m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING); +// m_pRemark->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXREMARK) - TITRAQ_SPACING); + break; + case TITRAQ_IDXDATE: + m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING + TITRAQ_SPACING / 2); + break; + case TITRAQ_IDXSTART: + m_pStarttime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXSTART) - TITRAQ_SPACING); + break; + case TITRAQ_IDXFINISH: + m_pEndtime->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXFINISH) - TITRAQ_SPACING); + break; + case TITRAQ_IDXAMOUNT: + m_pAmount->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXAMOUNT) - TITRAQ_SPACING); + break; + case TITRAQ_IDXTASK: + m_pTasks->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXTASK) - TITRAQ_SPACING); + break; + case TITRAQ_IDXREMARK: +// m_pRemark->setFixedWidth(nNewsize); + break; + default: + throw Genexcept("Unrecognized main window column header."); + break; + } +} + +// +// +// +void Titraqform::updSizes(int nSection, int nOldsize, int nNewsize) +{ switch (nSection) { case TITRAQ_IDXALLCTRLS: m_pDateedit->setFixedWidth(m_pMaintable->horizontalHeader()->sectionSize(TITRAQ_IDXDATE) - TITRAQ_SPACING + TITRAQ_SPACING / 2); Index: ossp-pkg/as/as-gui/as_table.h RCS File: /v/ossp/cvs/ossp-pkg/as/as-gui/as_table.h,v rcsdiff -q -kk '-r1.6' '-r1.7' -u '/v/ossp/cvs/ossp-pkg/as/as-gui/as_table.h,v' 2>/dev/null --- as_table.h 2002/12/04 20:30:54 1.6 +++ as_table.h 2002/12/05 14:51:29 1.7 @@ -42,7 +42,7 @@ // Try to match QTable's default constructor with an initializer list TiTable(QWidget *pParent = 0, const char *szName = 0) : QTable(pParent, szName) { - this->installEventFilter(this); + horizontalHeader()->installEventFilter(this); this->setEdition(); // Reset edition state };