Automatic tabs update
authorfortefr <fortefr@localhost>
Tue, 19 Jan 2010 09:45:59 +0000 (09:45 +0000)
committerfortefr <fortefr@localhost>
Tue, 19 Jan 2010 09:45:59 +0000 (09:45 +0000)
M    src/gui/mainwindow.ui
M    src/gui/mainwindow.cpp
M    src/gui/mainwindow.h

src/gui/mainwindow.cpp
src/gui/mainwindow.h
src/gui/mainwindow.ui

index 0092c1a..101a4ca 100644 (file)
@@ -38,7 +38,6 @@ MainWindow::MainWindow(QWidget *parent)
 
     connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &)));
     connect(activityDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateActivitiesDayView(const QDate &)));
-    //connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(updateView(int)));
 
     // DAY EVENTS View
     dayTreeView->setHeaderHidden(true);
@@ -95,9 +94,9 @@ MainWindow::MainWindow(QWidget *parent)
         dayNavigator->setDates(aStartDate, aEndDate);
         activityDayNavigator->setDates(aStartDate, aEndDate);
     }
-    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()));
-/*    connect(static_cast<EventModel*>(favTreeView->model()), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), SLOT(updateFavViewComplete()));*/
+
+    connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTab(int)));
+
 }
 
 MainWindow::~MainWindow()
@@ -151,32 +150,31 @@ void MainWindow::aboutApp()
     dialog.exec();
 }
 
-void MainWindow::updateDayView(const QDate &aDate)
+void MainWindow::updateDayView(const QDate aDate)
 {
     int confId = 1;
-    static_cast<EventModel*>(dayTreeView->model())->loadEvents(aDate,confId);
+    static_cast<EventModel*>(dayTreeView->model())->loadEvents(Conference::getById(confId).start(),confId);
     dayTreeView->reset();
     dayNavigator->show();
 }
 
-void MainWindow::updateFavView()
+void MainWindow::updateTab(const int n)
 {
     int confId = 1;
-    static_cast<EventModel*>(favTreeView->model())->loadFavEvents(Conference::getById(confId).start(),confId);
-    favTreeView->reset(); //Necessary reset:
-                        //  if favourite event unselected as favourite is the only one in its time, and reset is not produced, crashed
-
+    if(n) //index 1 of tabWidget: favouriteTab
+    {
+        static_cast<EventModel*>(favTreeView->model())->loadFavEvents(Conference::getById(confId).start(),confId);
+        favTreeView->reset();
+    }
+    else //index 0 of tabWidget: dayViewTab
+    {
+        static_cast<EventModel*>(dayTreeView->model())->loadEvents(Conference::getById(confId).start(),confId);
+        dayTreeView->reset();
+    }
+    //TODO: update of activitiesTab needed?
     dayNavigator->show();
 }
 
-/*
-void MainWindow::updateFavViewComplete()
-{
-    int confId = 1;
-    updateFavView();
-    updateDayView(Conference::getById(confId).start());
-}
-*/
 
 void MainWindow::updateActivitiesDayView(const QDate &aDate)
 {
index 6d7fcae..dcbc14a 100644 (file)
@@ -18,8 +18,8 @@ private slots:
     void importSchedule();
     void showParsingProgress(int aStatus);
     void aboutApp();
-    void updateDayView(const QDate &aDate);
-    void updateFavView();
+    void updateDayView(const QDate aDate);
+    void updateTab(const int n);
     /*void updateFavViewComplete();*/
     void updateActivitiesDayView(const QDate &aDate);
     void itemDoubleClicked(const QModelIndex &aIndex);
index 25b46e2..0b56fc5 100644 (file)
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
-  <property name="geometry" >
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <height>375</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>MainWindow</string>
   </property>
-  <widget class="QWidget" name="centralwidget" >
-   <layout class="QGridLayout" name="gridLayout" >
-    <item row="0" column="0" >
-     <widget class="QTabWidget" name="tabWidget" >
-      <property name="currentIndex" >
+  <widget class="QWidget" name="centralwidget">
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0">
+     <widget class="QTabWidget" name="tabWidget">
+      <property name="currentIndex">
        <number>0</number>
       </property>
-      <widget class="QWidget" name="dayViewTab" >
-       <attribute name="title" >
+      <widget class="QWidget" name="dayViewTab">
+       <attribute name="title">
         <string>Day View</string>
        </attribute>
-       <layout class="QGridLayout" name="gridLayout_2" >
-        <item row="0" column="0" >
-         <layout class="QVBoxLayout" name="verticalLayout" >
+       <layout class="QGridLayout" name="gridLayout_2">
+        <item row="0" column="0">
+         <layout class="QVBoxLayout" name="verticalLayout">
           <item>
-           <widget class="DayNavigatorWidget" native="1" name="dayNavigator" />
+           <widget class="DayNavigatorWidget" name="dayNavigator" native="true"/>
           </item>
           <item>
-           <widget class="TreeView" name="dayTreeView" >
-            <property name="maximumSize" >
+           <widget class="TreeView" name="dayTreeView">
+            <property name="maximumSize">
              <size>
               <width>16777215</width>
               <height>16777215</height>
         </item>
        </layout>
       </widget>
-      <widget class="QWidget" name="favouritesTab" >
-       <attribute name="title" >
+      <widget class="QWidget" name="favouritesTab">
+       <attribute name="title">
         <string>Favourites</string>
        </attribute>
-       <layout class="QGridLayout" name="gridLayout_3" >
-        <item row="0" column="0" >
-         <widget class="TreeView" name="favTreeView" />
+       <layout class="QGridLayout" name="gridLayout_3">
+        <item row="0" column="0">
+         <widget class="TreeView" name="favTreeView"/>
         </item>
        </layout>
       </widget>
-      <widget class="QWidget" name="activitiesTab" >
-       <attribute name="title" >
+      <widget class="QWidget" name="activitiesTab">
+       <attribute name="title">
         <string>Activities</string>
        </attribute>
-       <layout class="QGridLayout" name="gridLayout_4" >
-        <item row="0" column="0" >
-         <layout class="QVBoxLayout" name="activitiesVerticalLayout" >
+       <layout class="QGridLayout" name="gridLayout_4">
+        <item row="0" column="0">
+         <layout class="QVBoxLayout" name="activitiesVerticalLayout">
           <item>
-           <widget class="DayNavigatorWidget" native="1" name="activityDayNavigator" />
+           <widget class="DayNavigatorWidget" name="activityDayNavigator" native="true"/>
           </item>
           <item>
-           <widget class="TreeView" name="actTreeView" >
-            <property name="maximumSize" >
+           <widget class="TreeView" name="actTreeView">
+            <property name="maximumSize">
              <size>
               <width>16777215</width>
               <height>16777215</height>
         </item>
        </layout>
       </widget>
-      <widget class="QWidget" name="searchTab" >
-       <attribute name="title" >
+      <widget class="QWidget" name="searchTab">
+       <attribute name="title">
         <string>Search</string>
        </attribute>
       </widget>
-      <widget class="QWidget" name="mapTab" >
-       <attribute name="title" >
+      <widget class="QWidget" name="mapTab">
+       <attribute name="title">
         <string>Map</string>
        </attribute>
       </widget>
     </item>
    </layout>
   </widget>
-  <widget class="QMenuBar" name="menubar" >
-   <property name="geometry" >
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
     <rect>
      <x>0</x>
      <y>0</y>
      <width>534</width>
-     <height>22</height>
+     <height>24</height>
     </rect>
    </property>
-   <widget class="QMenu" name="menuFile" >
-    <property name="title" >
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
      <string>File</string>
     </property>
-    <addaction name="actionImportSchedule" />
-    <addaction name="actionQuit" />
+    <addaction name="actionImportSchedule"/>
+    <addaction name="actionQuit"/>
    </widget>
-   <widget class="QMenu" name="menuAbout" >
-    <property name="title" >
+   <widget class="QMenu" name="menuAbout">
+    <property name="title">
      <string>Help</string>
     </property>
-    <addaction name="actionAboutQt" />
-    <addaction name="actionAboutApplication" />
+    <addaction name="actionAboutQt"/>
+    <addaction name="actionAboutApplication"/>
    </widget>
-   <addaction name="menuAbout" />
-   <addaction name="menuFile" />
+   <addaction name="menuAbout"/>
+   <addaction name="menuFile"/>
   </widget>
-  <widget class="QStatusBar" name="statusbar" />
-  <action name="actionImportSchedule" >
-   <property name="text" >
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionImportSchedule">
+   <property name="text">
     <string>Import Schedule</string>
    </property>
   </action>
-  <action name="actionAboutQt" >
-   <property name="text" >
+  <action name="actionAboutQt">
+   <property name="text">
     <string>About Qt</string>
    </property>
   </action>
-  <action name="actionAboutApplication" >
-   <property name="text" >
+  <action name="actionAboutApplication">
+   <property name="text">
     <string>About application</string>
    </property>
   </action>
-  <action name="actionQuit" >
-   <property name="text" >
+  <action name="actionQuit">
+   <property name="text">
     <string>Quit</string>
    </property>
   </action>
    <receiver>MainWindow</receiver>
    <slot>close()</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>-1</x>
      <y>-1</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>266</x>
      <y>187</y>
     </hint>