]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
Align numbers in Data and Integration tables to the right.
authorMichal Malý <madcatxster@prifuk.cz>
Sun, 17 Nov 2013 13:50:50 +0000 (14:50 +0100)
committerMichal Malý <madcatxster@prifuk.cz>
Sun, 17 Nov 2013 13:50:50 +0000 (14:50 +0100)
integrationtablemodel.cpp
signaldatatablemodel.cpp

index 9a2c200b66aeb77c5319826099e4c3b306205d74..429b7d150c607473f333e856ac786526b80fe2ca 100644 (file)
@@ -29,21 +29,30 @@ IntegrationTableModel::IntegrationTableModel(const std::shared_ptr<Integrator> i
 
 QVariant IntegrationTableModel::data(const QModelIndex& index, int role) const
 {
-  if (role != Qt::DisplayRole)
-    return QVariant();
   if (index.row() >= m_integrator->peakCount())
     return QVariant();
 
   const std::shared_ptr<IntegratedPeak> peak = m_integrator->peakByIdx(index.row());
-  switch (index.column()) {
-    case 0:
-      return QString::number(peak->peakTime(), 'f', 4);
-    case 1:
-      return QString::number(peak->auc(), 'f', 4);
-    case 2:
-      return QString::number(peak->height(), 'f', 4);
-    case 3:
-      return QString::number(peak->width(), 'f', 4);
+  switch (role) {
+    case Qt::DisplayRole:
+    switch (index.column()) {
+      case 0:
+        return peak->peakTime();
+        //return QString::number(peak->peakTime(), 'f', 4);
+      case 1:
+        return QString::number(peak->auc(), 'f', 4);
+      case 2:
+        return QString::number(peak->height(), 'f', 4);
+      case 3:
+        return QString::number(peak->width(), 'f', 4);
+      default:
+        return QVariant();
+    }
+    break;
+    case Qt::TextAlignmentRole:
+      return Qt::AlignRight + Qt::AlignVCenter;
+    default:
+      return QVariant();
   }
   return QVariant();
 }
index 1db8db45dc89ca7c7801c91fedf7cce945a6cb69..760a64bcac567df6886c537db54e7126caa35a3f 100644 (file)
@@ -29,15 +29,25 @@ SignalDataTableModel::SignalDataTableModel(std::shared_ptr<Signal> signal, QObje
 
 QVariant SignalDataTableModel::data(const QModelIndex& index, int role) const
 {
-  if (role != Qt::DisplayRole)
-    return QVariant();
   if (index.row() >= m_signal->valuesCount())
     return QVariant();
 
-  if (index.column() == 0)
-    return m_signal->timeAt(index.row());
-  else if (index.column() == 1)
-    return m_signal->valueAt(index.row());
+  switch (role) {
+    case Qt::DisplayRole:
+      switch (index.column()) {
+        case 0:
+          return m_signal->timeAt(index.row());
+        case 1:
+          return m_signal->valueAt(index.row());
+        default:
+          return QVariant();
+      }
+      break;
+    case Qt::TextAlignmentRole:
+      return Qt::AlignRight + Qt::AlignVCenter;
+    default:
+      return QVariant();
+  }
 
   return QVariant();
 }