Fav table update
[toast/confclerk.git] / src / gui / mainwindow.cpp
index dac002d..5747356 100644 (file)
@@ -36,12 +36,29 @@ MainWindow::MainWindow(QWidget *parent)
 
     connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &)));
 
 
     connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &)));
 
-    treeView->setHeaderHidden(true);
-    treeView->setRootIsDecorated(false);
-    treeView->setIndentation(0);
-    treeView->setAnimated(true);
-    treeView->setModel(new EventModel());
-    treeView->setItemDelegate(new Delegate(treeView));
+
+    // DAY EVENTS View
+    dayTreeView->setHeaderHidden(true);
+    dayTreeView->setRootIsDecorated(false);
+    dayTreeView->setIndentation(0);
+    dayTreeView->setAnimated(true);
+    dayTreeView->setModel(new EventModel());
+    dayTreeView->setItemDelegate(new Delegate(dayTreeView));
+
+    // FAVOURITIES View
+    favTreeView->setHeaderHidden(true);
+    favTreeView->setRootIsDecorated(false);
+    favTreeView->setIndentation(0);
+    favTreeView->setAnimated(true);
+    favTreeView->setModel(new EventModel());
+    favTreeView->setItemDelegate(new Delegate(favTreeView));
+    // TESTING: load some 'fav' data
+    if(Conference::getAll().count()) // no conference(s) in the DB
+    {
+        int confId = 1;
+        static_cast<EventModel*>(favTreeView->model())->loadFavEvents(Conference::getById(confId).start(),confId);
+        favTreeView->reset();
+    }
 
     if(!Conference::getAll().count()) // no conference(s) in the DB
         dayNavigator->hide(); // hide DayNavigatorWidget
 
     if(!Conference::getAll().count()) // no conference(s) in the DB
         dayNavigator->hide(); // hide DayNavigatorWidget
@@ -50,6 +67,9 @@ MainWindow::MainWindow(QWidget *parent)
         int confId = 1;
         dayNavigator->setDates(Conference::getById(confId).start(),Conference::getById(confId).end());
     }
         int confId = 1;
         dayNavigator->setDates(Conference::getById(confId).start(),Conference::getById(confId).end());
     }
+
+    connect(static_cast<EventModel*>(dayTreeView->model()), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), SLOT(updateFavView()));
+    connect(static_cast<EventModel*>(favTreeView->model()), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), SLOT(updateFavView()));
 }
 
 MainWindow::~MainWindow()
 }
 
 MainWindow::~MainWindow()
@@ -71,6 +91,8 @@ void MainWindow::importSchedule()
     QFile file("../schedule.en.xml");
     if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
     {
     QFile file("../schedule.en.xml");
     if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
     {
+        QString currPath = QDir::currentPath();
+        qDebug() << "current path: " << currPath;
         qDebug() << "can't open " << file.fileName();
         return;
     }
         qDebug() << "can't open " << file.fileName();
         return;
     }
@@ -103,8 +125,15 @@ void MainWindow::aboutApp()
 void MainWindow::updateDayView(const QDate &aDate)
 {
     int confId = 1;
 void MainWindow::updateDayView(const QDate &aDate)
 {
     int confId = 1;
-    static_cast<EventModel*>(treeView->model())->loadEvents(aDate,confId);
-    treeView->reset();
+    static_cast<EventModel*>(dayTreeView->model())->loadEvents(aDate,confId);
+    dayTreeView->reset();
     dayNavigator->show();
 }
 
     dayNavigator->show();
 }
 
+void MainWindow::updateFavView()
+{
+    int confId = 1;
+    static_cast<EventModel*>(favTreeView->model())->loadFavEvents(Conference::getById(confId).start(),confId);
+    favTreeView->reset();
+    updateDayView(Conference::getById(confId).start());
+}