Re-implemented the showing of meetings (Task id 1166). Corrected the errortable order...
authorJan Lapinkataja <jan.lapinkataja@ixonos.com>
Wed, 27 May 2009 10:13:45 +0000 (13:13 +0300)
committerJan Lapinkataja <jan.lapinkataja@ixonos.com>
Wed, 27 May 2009 10:13:45 +0000 (13:13 +0300)
resources/xml/errortable.xml
src/BusinessLogic/Engine.cpp
src/BusinessLogic/Engine.h
src/IO/DeviceControl/DeviceManager.cpp
src/UserInterface/Components/ScheduleWidget.cpp
src/UserInterface/Components/ScheduleWidget.h
src/UserInterface/Views/WeeklyViewWidget.cpp
src/UserInterface/Views/WeeklyViewWidget.h
src/UserInterface/WindowManager.cpp
src/UserInterface/WindowManager.h
tests/BusinessLogic/Engine/TestEngine.cpp

index 2c5d424..4706fce 100644 (file)
     <error code="109">Communication: SOAP error when fetching meeting details</error>
     <error code="110">Communication error</error>
     <error code="111">Communication: Invalid username or password</error>
-    <error code="200">Failed to change the operation mode. Error creating internal file storage.</error>
+    <error code="200">Device Control: Error creating internal file storage.</error>
     <error code="201">Failed to change the operation mode. Error removing old alarm events.</error>
        <error code="202">Failed to change the operation mode. Error sending alarm events. %1</error>
        <error code="203">Failed to change the operation mode. Error storing data about sent alarm events. Removing the already sent alarm events.</error>
-       <error code="204">Failed to change the operation mode. Error fetching data of original hardware key settings.</error>
-       <error code="205">Failed to change the operation mode. Error storing data of original hardware key settings.</error>
-       <error code="206">Failed to change the operation mode. Error changing hardware key settings.</error>
-       <error code="207">Failed to change the operation mode. Init script to auto launch the application was not installed/removed.</error>
-       <error code="208">Failed to change the operation mode. The application failed to know the current mode of itself.</error>
-       <error code="209">Failed to change the operation mode. The application failed to store the current mode of itself.</error>
-       <error code="210">Error storing data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
-       <error code="211">Error fetching data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
-       <error code="212">Failed to change the operation mode. Error changing automatic screen switching-off and dimming parameter values.</error>
+       <error code="204">Error storing data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
+       <error code="205">Error fetching data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
+       <error code="206">Failed to change the operation mode. Error changing automatic screen switching-off and dimming parameter values.</error>
+       <error code="207">Failed to change the operation mode. Error fetching data of original hardware key settings.</error>
+       <error code="208">Failed to change the operation mode. Error storing data of original hardware key settings.</error>
+       <error code="209">Failed to change the operation mode. Error changing hardware key settings.</error>
+       <error code="210">Failed to change the operation mode. Init script to auto launch the application was not installed/removed.</error>
+       <error code="211">Failed to change the operation mode. The application failed to know the current mode of itself.</error>
+       <error code="212">Failed to change the operation mode. The application failed to store the current mode of itself.</error>
        <error code="213">Failed to change the operation mode. Error restarting the device. Restart device manually.</error>
 </errors>
index 25c3048..99225bf 100644 (file)
@@ -108,7 +108,7 @@ void Engine::closeApplication()
 void Engine::observedEventDetected()
 {
        qDebug() << "Engine::observedEventDetected()";
-       iWindowManager->showWeeklyView();
+       iWindowManager->refreshMeetings( iMeetings );
        // prepare to restart idle counter
        if ( iIdleTimeCounter->isActive() )
        {
@@ -217,50 +217,21 @@ void Engine::fetchMeetingDetails( Meeting *aMeeting )
        iCommunication->fetchMeetingDetails( *aMeeting );
 }
 
-bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting )
-{
-       qDebug() << "Engine::isMeetingInList( const QList<Meeting*> &, const Meeting * )";
-       for ( int i = 0; i < aList.count(); i++ )
-       {
-               if ( aMeeting->equals( *(aList.at( i )) ) )
-               {
-                       return true;
-               }
-       }
-       return false;
-}
-
 void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 {
        qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
-       // check if there is any new meeting in the list came from the server -> added
-       for ( int i = 0; i < aMeetings.count(); i++ )
-       {
-               // if the (i)th meeting is not in the local meeting list
-               if ( !isMeetingInList( iMeetings, aMeetings.at( i ) ) )
-               {
-                       // add to the local database =)
-                       Meeting* m = new Meeting( *(aMeetings.at( i )) );
-                       iMeetings.append( m );
-                       // and signal the changes
-                       iWindowManager->insertMeeting( m );
-               }
+       
+       for ( int i = 0; i < iMeetings.count(); ++i ) {
+               Meeting* m = iMeetings.takeAt( i );
+               delete m;
        }
-
-       // check if there is any meeting NOT in the list came from the server -> deleted
-       for ( int i = 0; i < iMeetings.count(); i++ )
-       {
-               // if the (i)th meeting is in the local but NOT in the server's meeting list
-               if ( !isMeetingInList( aMeetings, iMeetings.at( i ) ) )
-               {
-                       Meeting* m = iMeetings.takeAt( i );
-                       // signal the changes
-                       iWindowManager->deleteMeeting( m );
-                       // delete the meeting from the local list
-                       delete m;
-               }
+       iMeetings.clear();
+       for ( int i = 0; i < aMeetings.count(); ++i ) {
+               Meeting* m = new Meeting( *(aMeetings.at( i )) );
+               iMeetings.append( m );
        }
 
+       iWindowManager->refreshMeetings( iMeetings );
        // refresh room status info
        roomStatusInfoNeeded( defaultRoom() );
 }
index 5f99630..07a073d 100644 (file)
@@ -150,14 +150,6 @@ private:
         * \return Index of the meeting if found; otherwise, -1.
         */
        int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
-       //! Indicates if the QList contains the Meeting or not.
-       /*!
-        * Indicates if the QList contains the Meeting or not.
-        * \param aList List of meetings.
-        * \param aMeeting The meeting which is seeked in the list for.
-        * \return True if contains; otherwise, false.
-        */
-       static bool isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting );
        //! Slot. Fetches meetings from the server.
        /*!
         * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
index 92613b2..22707d2 100644 (file)
@@ -90,7 +90,7 @@ void DeviceManager::changeMode( bool aChange )
 
 bool DeviceManager::setCurrentOperationMode()
 {
-       qDebug() << "DeviceManager::currentOperationMode()";
+       qDebug() << "DeviceManager::setCurrentOperationMode()";
        QStringList modeResult;
        if ( !iDataStorage->readData( iDataStorage->dataSectionToString( DeviceDataStorage::DeviceMode ), modeResult ) )
        {
index 5318df7..a1e7d2d 100644 (file)
@@ -38,6 +38,7 @@ ScheduleTableWidget::~ScheduleTableWidget()
 
 void ScheduleTableWidget::paintEvent( QPaintEvent* aEvent )
 {
+       qDebug() << "ScheduleTableWidget::paintEvent()";
        QTableWidget::paintEvent( aEvent );
 
        ScheduleWidget* schedule = static_cast<ScheduleWidget*>( parent() );
@@ -156,6 +157,7 @@ void ScheduleTableWidget::mousePressEvent( QMouseEvent* aEvent )
 
 void ScheduleTableWidget::populateMeetingList()
 {
+       qDebug() << "ScheduleTableWidget::populateMeetingList()";
        ScheduleWidget* schedule = static_cast<ScheduleWidget*>( parent() );
 
        for ( int i = 0; i < schedule->weekLengthAsDays(); ++i )
@@ -343,7 +345,6 @@ ScheduleWidget::ScheduleWidget( QDateTime aCurrentDateTime, DisplaySettings *aSe
 
 ScheduleWidget::~ScheduleWidget()
 {
-       clear();
        delete iScheduleTable;
 }
 
@@ -357,51 +358,10 @@ QDate ScheduleWidget::beginningOfShownWeek()
        return iShownDate.addDays( -1 * iShownDate.dayOfWeek() + 1 );
 }
 
-Meeting* ScheduleWidget::currentMeeting()
-{
-       return meeting( iCurrentDateTime );
-}
-
-Meeting* ScheduleWidget::meeting( QDateTime aAt )
-{
-       for ( int i = 0; i < iMeetings.count(); ++i )
-       {
-               if ( iMeetings[i]->startsAt() <= aAt && iMeetings[i]->endsAt() >= aAt )
-               {
-                       return iMeetings[i];
-               }
-       }
-
-       return 0;
-}
-
-void ScheduleWidget::clear()
-{
-       qDebug() << "ScheduleWidget::clear";
-       int i = 0;
-       while ( !iMeetings.isEmpty() )
-       {
-               i++;
-               iMeetings.removeFirst();
-       }
-       qDebug() << "Deleted " << i << " items";
-}
-
-void ScheduleWidget::clear( QDateTime aFrom, QDateTime aUntil )
-{
-       for ( int i = 0; i < iMeetings.count(); ++i )
-       {
-               if (( iMeetings[i]->startsAt() >= aFrom && iMeetings[i]->startsAt() <= aUntil ) ||
-                         ( iMeetings[i]->startsAt() <= aFrom && iMeetings[i]->endsAt() >= aFrom ) )
-               {
-                       iMeetings.removeAt( i );
-                       --i;
-               }
-       }
-}
-
 void ScheduleWidget::refresh()
 {
+       qDebug() << "ScheduleWidget::refresh()";
+       
        for ( int i = 0; i < iScheduleTable->columnCount(); ++i )
        {
                QTableWidgetItem* item = iScheduleTable->item( 0, i );
@@ -426,17 +386,22 @@ void ScheduleWidget::refresh()
                        item->setFont( font );
                }
        }
-
+       
        // force repaint of the main area
        iScheduleTable->setSpan( 1, 1, iNumberOfHours, weekLengthAsDays() );
 
        iLastRefresh = iCurrentDateTime.time();
 }
 
+void ScheduleWidget::refreshMeetings( const QList<Meeting*> &aMeetings )
+{
+       iMeetings = aMeetings;
+       qDebug() << "Count: " << iMeetings.size();
+       refresh();
+}
+
 void ScheduleWidget::setCurrentDateTime( QDateTime aCurrentDateTime )
 {
-       Meeting* previous = meeting( iCurrentDateTime );
-       Meeting* current = meeting( aCurrentDateTime );
        iCurrentDateTime = aCurrentDateTime;
 
        if ( iLastRefresh.secsTo( iCurrentDateTime.time() ) > sRefreshIntervalInSeconds )
@@ -444,56 +409,8 @@ void ScheduleWidget::setCurrentDateTime( QDateTime aCurrentDateTime )
                // enough time has elapsed since last refresh
                refresh();
        }
-
-       if ( previous != current )
-       {
-               emit currentMeetingChanged( current );
-       }
-}
-
-void ScheduleWidget::insertMeeting( Meeting *aMeeting )
-{
-       Meeting* previous = meeting( iCurrentDateTime );
-       iMeetings.append( aMeeting );
-       Meeting* current = meeting( iCurrentDateTime );
-
-       qDebug() << "Inserted" << aMeeting->toString();
-
-       refresh();
-
-       if ( previous != current )
-       {
-               emit currentMeetingChanged( current );
-       }
 }
 
-void ScheduleWidget::removeMeeting( Meeting *aMeeting )
-{
-       Meeting* previous = meeting( iCurrentDateTime );
-
-       qDebug() << "Delete" << aMeeting->toString();
-       for ( int i = 0; i < iMeetings.count(); ++i )
-       {
-               if ( iMeetings[i]->equals( *(aMeeting) ) )
-               {
-                       iMeetings.removeAt( i );
-
-                       refresh();
-
-                       Meeting* current = meeting( iCurrentDateTime );
-                       if ( previous != current )
-                               emit currentMeetingChanged( current );
-
-                       return;
-               }
-       }
-}
-
-//void ScheduleWidget::updateMeeting( Meeting *aMeeting )
-//{
-//
-//}
-
 void ScheduleWidget::showPreviousWeek()
 {
        iShownDate = iShownDate.addDays( -7 );
index 690d77b..6531329 100644 (file)
@@ -39,6 +39,12 @@ public:
 
        //! Destructor.
        ~ScheduleTableWidget();
+       
+       //! Populates meeting list.
+       /*!
+        * Populates meeting list.
+        */
+       void populateMeetingList();
 
 protected:
        //! Handles drawing of main table area.
@@ -71,12 +77,6 @@ protected:
 
        
 private:
-       //! Populates meeting list.
-       /*!
-        * Populates meeting list.
-        */
-       void populateMeetingList();
-
        //! Finds overlapping meetings.
        /*!
         * Finds overlapping meetings.
@@ -160,21 +160,6 @@ public:
         */
        QDate beginningOfShownWeek();
 
-       //! Gets current meeting.
-       /*!
-        * Gets current meeting.
-        * \return current meeting, 0 if none.
-        */
-       Meeting* currentMeeting();
-
-       //! Gets meeting at a specified date and time.
-       /*!
-        * Gets meeting at a specified date and time.
-        * \param aAt Time when the meeting is.
-        * \return meeting At the given time, 0 if none.
-        */
-       Meeting* meeting( QDateTime aAt );
-
 signals:
 
        //! Signal. Emitted if a meeting is activated.
@@ -183,14 +168,6 @@ signals:
         * \param aMeeting Actived meeting.
         */
        void meetingActivated( Meeting *aMeeting );
-
-       //! Signal. Emitted when the current meeting changes to another.
-       /*!
-        * Signal. Emitted when the current meeting changes to another.
-        * \param aNewMeeting New meeting.
-        */
-       void currentMeetingChanged( Meeting *aNewMeeting );
-
        //! Signal. Emitted if the shown week has been changed.
        /*!
         * Signal. Emitted if the shown week has been changed.
@@ -200,26 +177,19 @@ signals:
 
 public slots:
 
-       //! Slot. Clears all meetings.
-       /*!
-        * Slot. Clears all meetings.
-        */
-       void clear();
-
-       //! Slot. Clears meetings based on a range.
-       /*!
-        * Slot. Clears meetings based on a range.
-        * \param aFrom Date and time from which the meetings are cleared.
-        * \param aUntil Date and time until which the meetings are cleared.
-        */
-       void clear( QDateTime aFrom, QDateTime aUntil );
-
        //! Slot. Refreshes display.
        /*!
         * Slot. Refreshes display.
+        * \param aMeetings The meeting list.
         */
        void refresh();
-
+       //! Refreshes the meeting list.
+       /*!
+        * Refreshes the meeting list.
+        * \param aMeetings The list of meetings.
+        */
+       void refreshMeetings( const QList<Meeting*> &aMeetings );
+       
        //! Slot. Sets current date and time.
        /*!
         * Slot. Sets current date and time.
@@ -227,27 +197,6 @@ public slots:
         */
        void setCurrentDateTime( QDateTime aCurrentDateTime );
 
-       //! Slot. Inserts a meeting to the schedule.
-       /*!
-        * Slot. Inserts a meeting to the schedule.
-        * \param aMeeting Meeting to be inserted.
-        */
-       void insertMeeting( Meeting *aMeeting );
-
-       //! Slot. Removes a meeting from the schedule.
-       /*!
-        * Slot. Removes a meeting from the schedule.
-        * \param aMeeting Meeting to be removed.
-        */
-       void removeMeeting( Meeting *aMeeting );
-
-       //! Slot. Updates a meeting in the schedule. (TODO)
-       /*!
-        * Slot updates a meeting in the schedule.
-        * \param aMeeting Meeting was updated.
-        */
-       void updateMeeting( Meeting */*aMeeting*/ ) {};
-
        //! Slot. Shows previous week.
        /*!
         * Slot. Shows previous week.
@@ -297,9 +246,6 @@ private:
        //! Current date and time.
        QDateTime iCurrentDateTime;
 
-       //! Meetings.
-       QList<Meeting*> iMeetings; /*! Not owned */
-
        //! Currently shown week.
        QDate iShownDate;
 
@@ -314,6 +260,9 @@ private:
 
        //! When refresh() was called previously
        QTime iLastRefresh;
+       
+       //! Meetings.
+       QList<Meeting*> iMeetings; /*! Not owned */
 
        //! Color for a free cell.
        static const QColor sFreeBackground;
index b33e517..773ecfe 100644 (file)
@@ -106,7 +106,6 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a
        connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) );\r
        connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) );\r
        // TODO: connect RoomCombo signals to change meetings data.\r
-       connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( clear() ) );\r
        connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );\r
        connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( refresh() ) );\r
 }\r
@@ -160,11 +159,6 @@ WeeklyViewWidget::~WeeklyViewWidget()
        }\r
 }\r
 \r
-Meeting* WeeklyViewWidget::currentMeeting()\r
-{\r
-       return iSchedule->currentMeeting();\r
-}\r
-\r
 Room* WeeklyViewWidget::currentRoom()\r
 {\r
        return iRoomsCombo->currentRoom();\r
@@ -181,22 +175,13 @@ void WeeklyViewWidget::setCurrentDateTime( QDateTime aCurrentDateTime )
        iSchedule->setCurrentDateTime( aCurrentDateTime );\r
 }\r
 \r
-void WeeklyViewWidget::insertMeeting( Meeting *aMeeting )\r
-{\r
-       iSchedule->insertMeeting( aMeeting );\r
-}\r
-\r
-void WeeklyViewWidget::deleteMeeting( Meeting *aMeeting )\r
-{\r
-       iSchedule->removeMeeting( aMeeting );\r
-}\r
-\r
-void WeeklyViewWidget::updateMeeting( Meeting *aMeeting )\r
+QDate WeeklyViewWidget::beginnigOfShownWeek()\r
 {\r
-       iSchedule->updateMeeting( aMeeting );\r
+       return iSchedule->beginningOfShownWeek();\r
 }\r
 \r
-QDate WeeklyViewWidget::beginnigOfShownWeek()\r
+void WeeklyViewWidget::refreshMeetings( const QList<Meeting*> &aMeetings )\r
 {\r
-       return iSchedule->beginningOfShownWeek();\r
+       qDebug() << "WeeklyViewWidget::refreshMeetings()";\r
+       iSchedule->refreshMeetings( aMeetings );\r
 }\r
index f0da141..5faf1ad 100644 (file)
@@ -35,12 +35,6 @@ public:
        //! Destructor.\r
        virtual ~WeeklyViewWidget();\r
 \r
-       //! Current meeting\r
-       /*!\r
-        * Returns the current meeting if any\r
-        * \return Current meeting if any, otherwise null pointer\r
-        */\r
-       Meeting* currentMeeting();\r
        //! Current room\r
        /*!\r
         * Returns the currently selected meeting room.\r
@@ -54,6 +48,13 @@ public:
         * \return First day of week.\r
         */\r
        QDate beginnigOfShownWeek();\r
+       //! Sends the refresh command to schedule widget.\r
+       /*!\r
+        * Sends the refresh command to schedule widget.\r
+        * \param aMeetings The list of meetings.\r
+        */\r
+       void refreshMeetings( const QList<Meeting*> &aMeetings );\r
+       \r
 \r
 signals:\r
        //! Signals change of the meeting room.\r
@@ -62,12 +63,6 @@ signals:
         * \param aNewRoom Selected meeting room.\r
         */\r
        void currentRoomChanged( Room *aNewRoom );\r
-       //! Signals change of the current meeting.\r
-       /*!\r
-        * Signal is emited when new meeting is started.\r
-        * \param aNewMeeting Meeting that has been started.\r
-        */\r
-       void currentMeetingChanged( Meeting *aNewMeeting );\r
        //! Meeting activated.\r
        /*!\r
         * Signal is emitted when a meeting is clicked by the user.\r
@@ -119,24 +114,6 @@ public slots:
         * \param aCurrentDateTime Date and time to be displayd.\r
         */\r
        void setCurrentDateTime( QDateTime aCurrentDateTime );\r
-       //! Insert meeting\r
-       /*!\r
-        * Inserts new meeting into the calendar\r
-        * \param aMeeting Meeting to be inserted.\r
-        */\r
-       void insertMeeting( Meeting *aMeeting );\r
-       //! Delete meeting\r
-       /*!\r
-        * Removes meeting from the calendar\r
-        * \param aMeeting Meeting to be deleted.\r
-        */\r
-       void deleteMeeting( Meeting *aMeeting );\r
-       //! Update meeting\r
-       /*!\r
-        * Updates the display of given meeting in calendar.\r
-        * \param aMeeting Meeting to be updated.\r
-        */\r
-       void updateMeeting( Meeting *aMeeting );\r
 \r
 private:\r
        //! Displays the selectable meeting rooms.\r
index dba36b3..4c4a7f6 100644 (file)
@@ -129,16 +129,6 @@ void WindowManager::fullScreen()
        iFullScreen = true;
 }
 
-void WindowManager::insertMeeting( Meeting *aMeeting )
-{
-       iWeeklyView->insertMeeting( aMeeting );
-}
-
-void WindowManager::deleteMeeting( Meeting *aMeeting )
-{
-       iWeeklyView->deleteMeeting( aMeeting );
-}
-
 void WindowManager::showMeetingInfo( Meeting *aMeeting )
 {
        iMeetingInfo = new MeetingInfoDialog( aMeeting );
@@ -214,3 +204,9 @@ void WindowManager::updateProgressBar( const QString &aMessage )
        if( iProgressBar != 0 )
                iProgressBar->update( aMessage );
 }
+
+void WindowManager::refreshMeetings( const QList<Meeting*> &aMeetings )
+{
+       qDebug() << "WindowManager::refreshMeetings()";
+       iWeeklyView->refreshMeetings( aMeetings );
+}
index f284192..2267525 100644 (file)
@@ -95,11 +95,13 @@ public:
         * Closes the progress bar.
         */
        void closeProgressBar();
+       //! Sends the refresh command to weekly view widget.
+       /*!
+        * Sends the refresh command to weekly view widget.
+        * \param aMeetings The list of meetings.
+        */
+       void refreshMeetings( const QList<Meeting*> &aMeetings );
        
-       void insertMeeting( Meeting *aMeeting );
-       
-       void deleteMeeting( Meeting *aMeeting );
-
 signals:
        //! Request current status of the room.
        /*!
index 752111b..7d6af43 100644 (file)
@@ -63,16 +63,6 @@ void TestEngine::testCreateMeeting()
        delete room;
 }
 
-void TestEngine::testUpdateMeeting()
-{
-       Room* room = new Room( "foo", "bar" );
-       Meeting* meeting = new Meeting( 1234, room, QDateTime( QDate( 2009, 4, 1 ), QTime( 12, 0, 0 ) ),
-                                                 QDateTime( QDate( 2009, 4, 1 ), QTime( 12, 30, 0 ) ) );
-       iEngine->updateMeeting( meeting, "foo", "bar" );
-       delete meeting;
-       delete room;
-}
-
 void TestEngine::testDeleteMeeting()
 {
        Room* room = new Room( "foo", "bar" );