Minor cosmetic changes
[timedsilencer] / switchingeventlist.cpp
index abcc147..8773bcb 100644 (file)
@@ -25,6 +25,8 @@
 #include "eventlistdelegate.h"
 #include "alarmd_backend.h"
 
+const int ROW_HEIGHT = 60;
+
 SwitchingEventList::SwitchingEventList(QWidget *parent) :
     QTableView(parent)
 {
@@ -44,6 +46,11 @@ SwitchingEventList::SwitchingEventList(QWidget *parent) :
   hideColumn(EV_ID);
   // Load saved events
   loadSavedEvents();
+  // Height hint
+  if(verticalHeader()->defaultSectionSize() < ROW_HEIGHT)
+    verticalHeader()->setDefaultSectionSize(ROW_HEIGHT);
+  if (sizeHintForRow(0)>0)
+    setMinimumHeight(sizeHintForRow(0) * 5);
 }
 
 SwitchingEventList::~SwitchingEventList() {
@@ -51,7 +58,7 @@ SwitchingEventList::~SwitchingEventList() {
 }
 
 void SwitchingEventList::updateRow(int row, ProfileEvent *pe) {
-  model->setData(model->index(row, EV_STATUS), pe->activated);
+  model->setData(model->index(row, EV_STATUS), pe->activated, Qt::UserRole);
   model->setData(model->index(row, EV_FROM), pe->from_time.toString());
   model->setData(model->index(row, EV_TO), pe->to_time.toString());
   model->setData(model->index(row, EV_REPEAT), ProfileEvent::formatDays(pe->days));
@@ -101,8 +108,8 @@ void SwitchingEventList::loadSavedEvents() {
     long to_cookie = settings.value("unsilencing_cookie", 0).toLongLong();
     if(to_cookie > 0)
       pe.alarmd_cookies << to_cookie;
-    if(to_cookie == 0 || from_cookie == 0)
-      pe.activated = 0;
+    if(to_cookie <= 0 || from_cookie <= 0)
+      pe.activated = false;
     events.insert(pe.getID(), pe.save());
     // Remove old format values
     settings.clear();
@@ -145,7 +152,7 @@ void SwitchingEventList::editEvent(QByteArray id, bool new_status) {
   const int row = getRowFromID(id);
   qDebug("Editing event at row %d", row);
   Q_ASSERT(row >= 0);
-  model->setData(model->index(row, EV_STATUS), new_status);
+  model->setData(model->index(row, EV_STATUS), new_status, Qt::UserRole);
 }
 
 void SwitchingEventList::deleteEvent(QByteArray id) {