diff data/model/ModelDataTableModel.cpp @ 1527:710e6250a401 zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:14 +0100
parents ec9e65fcf749
children 70e172e6cc59
line wrap: on
line diff
--- a/data/model/ModelDataTableModel.cpp	Mon Dec 12 15:18:52 2016 +0000
+++ b/data/model/ModelDataTableModel.cpp	Mon Sep 17 13:51:14 2018 +0100
@@ -73,16 +73,12 @@
     if (!m_model) return false;
     if (parent.isValid()) return false;
 
-    emit beginInsertRows(parent, row, row);
-
     Command *command = m_model->getInsertRowCommand(getUnsorted(row));
 
     if (command) {
         emit addCommand(command);
     }
 
-    emit endInsertRows();
-
     return (command ? true : false);
 }
 
@@ -92,16 +88,12 @@
     if (!m_model) return false;
     if (parent.isValid()) return false;
 
-    emit beginRemoveRows(parent, row, row);
-
     Command *command = m_model->getRemoveRowCommand(getUnsorted(row));
 
     if (command) {
         emit addCommand(command);
     }
 
-    emit endRemoveRows();
-
     return (command ? true : false);
 }
 
@@ -144,7 +136,8 @@
 {
     if (!m_model) return 0;
     if (parent.isValid()) return 0;
-    return m_model->getRowCount();
+    int count = m_model->getRowCount();
+    return count;
 }
 
 int
@@ -215,14 +208,37 @@
 void
 ModelDataTableModel::modelChanged()
 {
+    SVDEBUG << "ModelDataTableModel::modelChanged" << endl;
+    QModelIndex ix0;
+    QModelIndex ix1;
+    if (rowCount() > 0) {
+        ix0 = createIndex(0, 0);
+        int lastCol = columnCount() - 1;
+        if (lastCol < 0) lastCol = 0;
+        ix1 = createIndex(rowCount(), lastCol);
+    }
+    SVDEBUG << "emitting dataChanged from row " << ix0.row() << " to " << ix1.row() << endl;
+    emit dataChanged(ix0, ix1);
     clearSort();
     emit layoutChanged();
 }
 
 void 
-ModelDataTableModel::modelChangedWithin(sv_frame_t, sv_frame_t)
+ModelDataTableModel::modelChangedWithin(sv_frame_t f0, sv_frame_t f1)
 {
-    //!!! inefficient
+    SVDEBUG << "ModelDataTableModel::modelChangedWithin(" << f0 << "," << f1 << ")" << endl;
+    QModelIndex ix0 = getModelIndexForFrame(f0);
+    QModelIndex ix1 = getModelIndexForFrame(f1);
+    int row0 = ix0.row();
+    int row1 = ix1.row();
+    if (row0 > 0) {
+        ix0 = createIndex(row0 - 1, ix0.column(), (void *)0);
+    }
+    if (row1 + 1 < rowCount()) {
+        ix1 = createIndex(row1 + 1, ix1.column(), (void *)0);
+    }
+    SVDEBUG << "emitting dataChanged from row " << ix0.row() << " to " << ix1.row() << endl;
+    emit dataChanged(ix0, ix1);
     clearSort();
     emit layoutChanged();
 }