From: Jan Lapinkataja Date: Wed, 27 May 2009 10:13:45 +0000 (+0300) Subject: Re-implemented the showing of meetings (Task id 1166). Corrected the errortable order... X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=6b92cf1ffe7ca6ffacf6740e7e8456c72cff899d;p=qtmeetings Re-implemented the showing of meetings (Task id 1166). Corrected the errortable order so that correct error messages are now shown. --- diff --git a/resources/xml/errortable.xml b/resources/xml/errortable.xml index 2c5d424..4706fce 100644 --- a/resources/xml/errortable.xml +++ b/resources/xml/errortable.xml @@ -14,18 +14,18 @@ Communication: SOAP error when fetching meeting details Communication error Communication: Invalid username or password - Failed to change the operation mode. Error creating internal file storage. + Device Control: Error creating internal file storage. Failed to change the operation mode. Error removing old alarm events. Failed to change the operation mode. Error sending alarm events. %1 Failed to change the operation mode. Error storing data about sent alarm events. Removing the already sent alarm events. - Failed to change the operation mode. Error fetching data of original hardware key settings. - Failed to change the operation mode. Error storing data of original hardware key settings. - Failed to change the operation mode. Error changing hardware key settings. - Failed to change the operation mode. Init script to auto launch the application was not installed/removed. - Failed to change the operation mode. The application failed to know the current mode of itself. - Failed to change the operation mode. The application failed to store the current mode of itself. - Error storing data of original automatic screen switching-off and dimming parameter values. Using the default values instead. - Error fetching data of original automatic screen switching-off and dimming parameter values. Using the default values instead. - Failed to change the operation mode. Error changing automatic screen switching-off and dimming parameter values. + Error storing data of original automatic screen switching-off and dimming parameter values. Using the default values instead. + Error fetching data of original automatic screen switching-off and dimming parameter values. Using the default values instead. + Failed to change the operation mode. Error changing automatic screen switching-off and dimming parameter values. + Failed to change the operation mode. Error fetching data of original hardware key settings. + Failed to change the operation mode. Error storing data of original hardware key settings. + Failed to change the operation mode. Error changing hardware key settings. + Failed to change the operation mode. Init script to auto launch the application was not installed/removed. + Failed to change the operation mode. The application failed to know the current mode of itself. + Failed to change the operation mode. The application failed to store the current mode of itself. Failed to change the operation mode. Error restarting the device. Restart device manually. diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index 25c3048..99225bf 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -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 &aList, const Meeting *aMeeting ) -{ - qDebug() << "Engine::isMeetingInList( const QList &, 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 &aMeetings ) { qDebug() << "Engine::meetingsFetched( const QList & )"; - // 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() ); } diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index 5f99630..07a073d 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -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 &aList, const Meeting *aMeeting ); //! Slot. Fetches meetings from the server. /*! * Slot. Fetches meetings from the server, exact parameters are specified in the parameter list. diff --git a/src/IO/DeviceControl/DeviceManager.cpp b/src/IO/DeviceControl/DeviceManager.cpp index 92613b2..22707d2 100644 --- a/src/IO/DeviceControl/DeviceManager.cpp +++ b/src/IO/DeviceControl/DeviceManager.cpp @@ -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 ) ) { diff --git a/src/UserInterface/Components/ScheduleWidget.cpp b/src/UserInterface/Components/ScheduleWidget.cpp index 5318df7..a1e7d2d 100644 --- a/src/UserInterface/Components/ScheduleWidget.cpp +++ b/src/UserInterface/Components/ScheduleWidget.cpp @@ -38,6 +38,7 @@ ScheduleTableWidget::~ScheduleTableWidget() void ScheduleTableWidget::paintEvent( QPaintEvent* aEvent ) { + qDebug() << "ScheduleTableWidget::paintEvent()"; QTableWidget::paintEvent( aEvent ); ScheduleWidget* schedule = static_cast( parent() ); @@ -156,6 +157,7 @@ void ScheduleTableWidget::mousePressEvent( QMouseEvent* aEvent ) void ScheduleTableWidget::populateMeetingList() { + qDebug() << "ScheduleTableWidget::populateMeetingList()"; ScheduleWidget* schedule = static_cast( 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 &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 ); diff --git a/src/UserInterface/Components/ScheduleWidget.h b/src/UserInterface/Components/ScheduleWidget.h index 690d77b..6531329 100644 --- a/src/UserInterface/Components/ScheduleWidget.h +++ b/src/UserInterface/Components/ScheduleWidget.h @@ -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 &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 iMeetings; /*! Not owned */ - //! Currently shown week. QDate iShownDate; @@ -314,6 +260,9 @@ private: //! When refresh() was called previously QTime iLastRefresh; + + //! Meetings. + QList iMeetings; /*! Not owned */ //! Color for a free cell. static const QColor sFreeBackground; diff --git a/src/UserInterface/Views/WeeklyViewWidget.cpp b/src/UserInterface/Views/WeeklyViewWidget.cpp index b33e517..773ecfe 100644 --- a/src/UserInterface/Views/WeeklyViewWidget.cpp +++ b/src/UserInterface/Views/WeeklyViewWidget.cpp @@ -106,7 +106,6 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) ); connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) ); // TODO: connect RoomCombo signals to change meetings data. - connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( clear() ) ); connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) ); connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( refresh() ) ); } @@ -160,11 +159,6 @@ WeeklyViewWidget::~WeeklyViewWidget() } } -Meeting* WeeklyViewWidget::currentMeeting() -{ - return iSchedule->currentMeeting(); -} - Room* WeeklyViewWidget::currentRoom() { return iRoomsCombo->currentRoom(); @@ -181,22 +175,13 @@ void WeeklyViewWidget::setCurrentDateTime( QDateTime aCurrentDateTime ) iSchedule->setCurrentDateTime( aCurrentDateTime ); } -void WeeklyViewWidget::insertMeeting( Meeting *aMeeting ) -{ - iSchedule->insertMeeting( aMeeting ); -} - -void WeeklyViewWidget::deleteMeeting( Meeting *aMeeting ) -{ - iSchedule->removeMeeting( aMeeting ); -} - -void WeeklyViewWidget::updateMeeting( Meeting *aMeeting ) +QDate WeeklyViewWidget::beginnigOfShownWeek() { - iSchedule->updateMeeting( aMeeting ); + return iSchedule->beginningOfShownWeek(); } -QDate WeeklyViewWidget::beginnigOfShownWeek() +void WeeklyViewWidget::refreshMeetings( const QList &aMeetings ) { - return iSchedule->beginningOfShownWeek(); + qDebug() << "WeeklyViewWidget::refreshMeetings()"; + iSchedule->refreshMeetings( aMeetings ); } diff --git a/src/UserInterface/Views/WeeklyViewWidget.h b/src/UserInterface/Views/WeeklyViewWidget.h index f0da141..5faf1ad 100644 --- a/src/UserInterface/Views/WeeklyViewWidget.h +++ b/src/UserInterface/Views/WeeklyViewWidget.h @@ -35,12 +35,6 @@ public: //! Destructor. virtual ~WeeklyViewWidget(); - //! Current meeting - /*! - * Returns the current meeting if any - * \return Current meeting if any, otherwise null pointer - */ - Meeting* currentMeeting(); //! Current room /*! * Returns the currently selected meeting room. @@ -54,6 +48,13 @@ public: * \return First day of week. */ QDate beginnigOfShownWeek(); + //! Sends the refresh command to schedule widget. + /*! + * Sends the refresh command to schedule widget. + * \param aMeetings The list of meetings. + */ + void refreshMeetings( const QList &aMeetings ); + signals: //! Signals change of the meeting room. @@ -62,12 +63,6 @@ signals: * \param aNewRoom Selected meeting room. */ void currentRoomChanged( Room *aNewRoom ); - //! Signals change of the current meeting. - /*! - * Signal is emited when new meeting is started. - * \param aNewMeeting Meeting that has been started. - */ - void currentMeetingChanged( Meeting *aNewMeeting ); //! Meeting activated. /*! * Signal is emitted when a meeting is clicked by the user. @@ -119,24 +114,6 @@ public slots: * \param aCurrentDateTime Date and time to be displayd. */ void setCurrentDateTime( QDateTime aCurrentDateTime ); - //! Insert meeting - /*! - * Inserts new meeting into the calendar - * \param aMeeting Meeting to be inserted. - */ - void insertMeeting( Meeting *aMeeting ); - //! Delete meeting - /*! - * Removes meeting from the calendar - * \param aMeeting Meeting to be deleted. - */ - void deleteMeeting( Meeting *aMeeting ); - //! Update meeting - /*! - * Updates the display of given meeting in calendar. - * \param aMeeting Meeting to be updated. - */ - void updateMeeting( Meeting *aMeeting ); private: //! Displays the selectable meeting rooms. diff --git a/src/UserInterface/WindowManager.cpp b/src/UserInterface/WindowManager.cpp index dba36b3..4c4a7f6 100644 --- a/src/UserInterface/WindowManager.cpp +++ b/src/UserInterface/WindowManager.cpp @@ -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 &aMeetings ) +{ + qDebug() << "WindowManager::refreshMeetings()"; + iWeeklyView->refreshMeetings( aMeetings ); +} diff --git a/src/UserInterface/WindowManager.h b/src/UserInterface/WindowManager.h index f284192..2267525 100644 --- a/src/UserInterface/WindowManager.h +++ b/src/UserInterface/WindowManager.h @@ -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 &aMeetings ); - void insertMeeting( Meeting *aMeeting ); - - void deleteMeeting( Meeting *aMeeting ); - signals: //! Request current status of the room. /*! diff --git a/tests/BusinessLogic/Engine/TestEngine.cpp b/tests/BusinessLogic/Engine/TestEngine.cpp index 752111b..7d6af43 100644 --- a/tests/BusinessLogic/Engine/TestEngine.cpp +++ b/tests/BusinessLogic/Engine/TestEngine.cpp @@ -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" );