--- 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);
|