OSSP CVS Repository

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

ossp-pkg/as/as-gui/as_slot.cpp 1.39 -> 1.40

--- as_slot.cpp  2002/12/04 21:35:55     1.39
+++ as_slot.cpp  2002/12/04 23:22:52     1.40
@@ -77,41 +77,61 @@
 //
 void Titraqform::pasteEntry(void)
 {
+    int nRows = 0;              // Paste so many rows as are stored
     QString Selection;          // Will receive the clipboard text
     QClipboard *pClip;          // Will reference the global clipboard
 
-    this->addEntry();           // Reuse slot
     Selection = pClip->text(QClipboard::Clipboard); // Windows and Unix
+    nRows = Selection.contains(QChar('\n'));        // How many rows
+    this->addEntry(nRows);                          // Reuse slot
 
     if (Selection)
-        setRowdata(Selection);  // Use accessor
+        setRowdata(Selection);                      // Use accessor
 }
 
 //
 // Append a blank row entry
 //
-void Titraqform::addEntry(void)
+void Titraqform::addEntry(int nRows)
 {
-    int nCurrentrow = 0;
-
-    // Add a row after selection and focus to the new row
-    if (m_pMaintable->currentRow() + 1 != m_pMaintable->numRows()) { // Add upwards
-        m_pMaintable->insertRows(m_pMaintable->currentRow());
-        m_pMaintable->setCurrentCell(m_pMaintable->currentRow() - 2, m_pMaintable->currentColumn());
-        updateDate(*m_pDatezero);
-        updateStart(QTime::QTime(0, 0));
-        updateFinish(QTime::QTime(0, 0));
-        updateAmount(trUtf8("00:00"));
+    QTableSelection Select; // Highlighted text
+    int nTotal = 0;         // Total row select
+    int nCurrent = 0;       // Current row
+
+    if (nRows == -1) {      // Assume a user selection range
+        Select = m_pMaintable->selection(0);
+        nTotal = Select.bottomRow() - Select.topRow() + 1;
+        // 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);
+            m_pMaintable->setCurrentCell(Select.topRow(), m_pMaintable->currentColumn());
+        }
+        else { // Special case on last row add downwards
+            m_pMaintable->insertRows(Select.bottomRow() + 1, nTotal);
+            m_pMaintable->setCurrentCell(Select.bottomRow() + 1, m_pMaintable->currentColumn());
+            m_pMaintable->ensureCellVisible(m_pMaintable->numRows() - 1, 0); // Scroll please
+        }
     }
-    else { // Special case on last row add downwards
-        m_pMaintable->insertRows(m_pMaintable->currentRow() + 1);
-        m_pMaintable->setCurrentCell(m_pMaintable->currentRow() + 1, m_pMaintable->currentColumn());
-        updateDate(*m_pDatezero);
-        updateStart(QTime::QTime(0, 0));
-        updateFinish(QTime::QTime(0, 0));
-        updateAmount(trUtf8("00:00"));
+    else {                  // Do not count a user selection
+        nTotal   = nRows;
+        nCurrent = m_pMaintable->currentRow();
+        // Add a row after selection and focus to the new row
+        if (nCurrent + 1 != m_pMaintable->numRows()) { // Add upwards
+            m_pMaintable->insertRows(nCurrent, nTotal);
+            m_pMaintable->setCurrentCell(nCurrent, m_pMaintable->currentColumn());
+        }
+        else { // Special case on last row add downwards
+            m_pMaintable->insertRows(nCurrent + 1, nTotal);
+            m_pMaintable->setCurrentCell(nCurrent + 1, m_pMaintable->currentColumn());
+            m_pMaintable->ensureCellVisible(m_pMaintable->numRows() - 1, 0); // Scroll please
+        }
     }
 
+//    updateDate(*m_pDatezero);
+//    updateStart(QTime::QTime(0, 0));
+//    updateFinish(QTime::QTime(0, 0));
+//    updateAmount(trUtf8("00:00"));
+
 //    char szGuitext[37];
 //    uuid_t Guid;
 //
@@ -123,7 +143,7 @@
 //
 // Delete a row entry
 //
-void Titraqform::delEntry(void)
+void Titraqform::delEntry(int nRows)
 {
     QTableSelection Select = m_pMaintable->selection(0);    // Highlighted text
     int nTotal = Select.bottomRow() - Select.topRow() + 1;  // Total row select

CVSTrac 2.0.1