--- as_slot.cpp 2002/12/13 21:25:32 1.60
+++ as_slot.cpp 2002/12/13 23:42:37 1.61
@@ -85,12 +85,18 @@
QString Selection; // Will receive the clipboard text
QClipboard *pClip; // Will reference the global clipboard
- Selection = pClip->text(QClipboard::Clipboard); // Windows and Unix
- nRows = Selection.contains(QChar('\n')); // How many rows
- this->addEntry(nRows); // Reuse slot
+ // Optimize viewing by repainting cells only once after processing
+ m_pMaintable->setUpdatesEnabled(false);
- if (Selection)
+ if (Selection = pClip->text(QClipboard::Clipboard)) { // Windows and Unix
+ nRows = Selection.contains(QChar('\n')); // How many rows
+ this->addEntry(nRows); // Reuse slot
setRowdata(Selection); // Use accessor
+ for (int nIter = 0; nIter <= nRows; nIter++)
+ this->validateData(m_pMaintable->currentRow() + nIter, 0);
+ }
+
+ m_pMaintable->setUpdatesEnabled(true); // Update and repaint
}
//
@@ -102,34 +108,62 @@
int nTotal = 0; // Total row select
int nCurrent = 0; // Current row
+ // Decide how many rows to add
Select = m_pMaintable->selection(0);
- nTotal = Select.bottomRow() - Select.topRow() + 1;
+ if (nRows > 0)
+ nTotal = nRows;
+ else
+ nTotal = Select.bottomRow() - Select.topRow() + 1;
+
+ // Optimize viewing by repainting cells only once after processing
+ m_pMaintable->setUpdatesEnabled(false);
+
// 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(); // Set data to dirty state
m_pMaintable->setCurrentCell(Select.topRow(), m_pMaintable->currentColumn());
+
+ // Update relevant data fields for all new rows
+ for (int nIter = 0; nIter < nTotal; nIter++) {
+ m_pMaintable->setPixmap(Select.topRow() + nIter, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatwarn_xpm));
+ m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER));
+ m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXGUID, ".");
+ m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXCRC, ".");
+ m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXREV, ".");
+ m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXDATE, trUtf8(TITRAQ_DATEZERO));
+ m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXSTART, "00:00");
+ m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXFINISH, "00:00");
+ m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXAMOUNT, "00:00");
+// m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXTASK, "/");
+// m_pMaintable->setText(Select.topRow() + nIter, TITRAQ_IDXREMARK, "Remark");
+ }
}
else { // Special case on last row add downwards
m_pMaintable->insertRows(Select.bottomRow() + 1, nTotal);
this->setDirty(); // Set data to dirty state
m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn());
m_pMaintable->ensureCellVisible(m_pMaintable->numRows() - 1, 0); // Scroll please
+
+ // Update relevant data fields for all new rows
+ for (int nIter = 1; nIter <= nTotal; nIter++) {
+ m_pMaintable->setPixmap(Select.bottomRow() + nIter, TITRAQ_IDXSTATUS, QPixmap(s_kpcStatwarn_xpm));
+ m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXUSER, m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER));
+ m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXGUID, ".");
+ m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXCRC, ".");
+ m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXREV, ".");
+ m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXDATE, trUtf8(TITRAQ_DATEZERO));
+ m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXSTART, "00:00");
+ m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXFINISH, "00:00");
+ m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXAMOUNT, "00:00");
+// m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXTASK, "/");
+// m_pMaintable->setText(Select.bottomRow() + nIter, TITRAQ_IDXREMARK, "Remark");
+ }
}
// Update line numbers for this new row and all subsequent rows
for (int nIter = m_pMaintable->currentRow(); nIter < m_pMaintable->numRows(); nIter++)
- m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter));
-
- updateUser(m_pPrefs->getString(TITRAQ_PREFUSER, TITRAQ_DEFUSER));
- updateGuid(".");
- updateCrc(".");
- updateRev(".");
-
- updateDate(*m_pDatezero);
- updateStart(QTime::QTime(0, 0));
- updateFinish(QTime::QTime(0, 0));
- updateAmount(trUtf8("00:00"));
+ m_pMaintable->setText(nIter, TITRAQ_IDXLINE, QString::number(nIter).rightJustify(4, QChar('0')));
// char szGuitext[37];
// uuid_t Guid;
@@ -137,6 +171,9 @@
// uuid_generate(Guid);
// 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
}
//
@@ -193,6 +230,7 @@
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);
@@ -205,9 +243,11 @@
m_pAmount->setEnabled(true);
m_pTasks->setEnabled(true);
m_pRemark->setEnabled(true);
+ this->updEdit(0, 0); // Reset edit controls
this->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);
@@ -220,6 +260,7 @@
m_pAmount->setEnabled(true);
m_pTasks->setEnabled(true);
m_pRemark->setEnabled(true);
+ this->updEdit(0, 0); // Reset edit controls
this->setDirty(false); // Reset data to clean state
break;
case 2: // Third button selected, so don't do a new timesheet
@@ -235,6 +276,7 @@
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);
@@ -247,6 +289,7 @@
m_pAmount->setEnabled(true);
m_pTasks->setEnabled(true);
m_pRemark->setEnabled(true);
+ this->updEdit(0, 0); // Reset edit controls
this->setDirty(false); // Reset data to clean state
}
}
@@ -281,6 +324,18 @@
// 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);
this->setDirty(false); // Set the clean state
break;
case 1: // Don't save first but do load
@@ -295,6 +350,18 @@
// 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);
this->setDirty(false); // Set the clean state
break;
case 2: // Don't do a load timesheet
@@ -314,6 +381,18 @@
// 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);
this->setDirty(false); // Set the clean state
}
}
@@ -626,14 +705,6 @@
}
//
-// Update the current status column item
-//
-void Titraqform::updateStatus(const QString &Instring)
-{
- m_pMaintable->setText(m_pMaintable->currentRow(), TITRAQ_IDXSTATUS, Instring);
-}
-
-//
// Update the current line number column item
//
void Titraqform::updateLine(const QString &Instring)
|