Got something working
authorMikko Siren <mikko.siren@ixonos.com>
Wed, 27 May 2009 11:10:50 +0000 (14:10 +0300)
committerMikko Siren <mikko.siren@ixonos.com>
Wed, 27 May 2009 11:10:50 +0000 (14:10 +0300)
src/BusinessLogic/Engine.cpp
src/BusinessLogic/UIManager.cpp
src/BusinessLogic/UIManager.h
src/UserInterface/Views/RoomStatusIndicatorWidget.h
src/UserInterface/Views/SettingsView.cpp
src/UserInterface/Views/SettingsView.h
src/UserInterface/Views/ViewBase.h
src/UserInterface/Views/WeeklyViewWidget.h
src/UserInterface/WindowManager.cpp
src/UserInterface/WindowManager.h

index fb0fe9f..566b885 100644 (file)
@@ -28,7 +28,8 @@ const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
 
 
 Engine::Engine() :
-               iClock( 0 ), iConfiguration( 0 ), iCommunication( 0 )
+               iClock( 0 ), iConfiguration( 0 ), iCommunication( 0 ),
+               iWindowManager( 0 ), iUIManager( 0 )
 {
        qDebug() << "Engine::Engine()";
        
@@ -204,7 +205,6 @@ void Engine::meetingsFetched(const QList<Meeting*> &aMeetings)
                        Meeting* m = new Meeting( *(aMeetings.at( i )) );
                        iMeetings.append(m);
                        // and signal the changes
-//                     iWeeklyView->insertMeeting( m );
                }
        }
 
@@ -216,7 +216,6 @@ void Engine::meetingsFetched(const QList<Meeting*> &aMeetings)
                {
                        Meeting* m = iMeetings.takeAt(i);
                        // signal the changes
-//                     iWeeklyView->deleteMeeting( m );
                        // delete the meeting from the local list
                        delete m;
                }
@@ -228,7 +227,10 @@ void Engine::meetingsFetched(const QList<Meeting*> &aMeetings)
 
 void Engine::errorHandler( int aCode, const QString &aAddInfo )
 {      
-       iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
+       if ( iWindowManager != 0 )
+       {
+               iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
+       }
 }
 
 void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
@@ -241,6 +243,8 @@ void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, con
 void Engine::fetchMeetingDetails(Meeting *aMeeting)
 {
        qDebug() << "[Engine::fetchMeetingDetails] <TODO : METHOD NOT IMPLEMENTED>";
+       Meeting tempMeeting(aMeeting->primaryId(), aMeeting->room(), aMeeting->startsAt(), aMeeting->endsAt() );
+       iCommunication->fetchMeetingDetails( tempMeeting );
 //     Meeting tempMeeting = aMeeting;
 //     iCommunication->fetchMeetingDetails( tempMeeting );
 }
index 19f445f..7e24d61 100644 (file)
@@ -71,7 +71,7 @@ void UIManager::showProgressBar( QString aText )
 {
        if ( iProgressBar != 0 )
        {
-               iProgressBar->update( tr("Changing current operation mode.") );
+               iProgressBar->update( aText );
                iWindowManager->showDialog( iProgressBar );
        }
 }
@@ -113,7 +113,7 @@ void UIManager::createPasswordDialog()
 
 void UIManager::createProgressBar()
 {
-       iProgressBar = new ProgressBar( tr("CHANGE THIS") );
+       iProgressBar = new ProgressBar( tr("CHANGE THIS"), true );
        
        // Connect to UIManager
        connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBarCancelled() ) );
@@ -132,11 +132,13 @@ void UIManager::connectDeviceManager( DeviceManager *aDeviceManager )
                        this, SLOT( changeModeOrdered( DeviceManager::OperationMode ) ) );
        
        connect( aDeviceManager, SIGNAL( changingMode( const QString & ) ), this, SLOT( updateProgressBarText( const QString & ) ) );
+       connect( aDeviceManager, SIGNAL( changeModeFailed() ), this, SLOT( hideProgressBar() ) );
 }
 
 void UIManager::connectCommunicationManager( CommunicationManager *aCommunicationManager )
 {
        connect( aCommunicationManager, SIGNAL( meetingDetailsFetched( Meeting & ) ), this, SLOT( meetingDetailsFetched( Meeting & ) ) );
+       connect( aCommunicationManager, SIGNAL( meetingsFetched( const QList<Meeting *> & ) ), this, SLOT( meetingsFetched( const QList<Meeting *> & ) ) );
 }
 
 // ============================================
@@ -163,7 +165,12 @@ void UIManager::settingsOkClicked()
 
 void UIManager::meetingsFetched( const QList<Meeting*> &aMeetings )
 {
-       
+       qDebug() << "[UIManager::meetingsFetched] <SHOULD NOT SIMPLY INSERT MEETINGS TO WEEKLYVIEW !!!>";
+       for ( int i = 0; i < aMeetings.count(); i++ )
+       {
+               Meeting *m = new Meeting( *( aMeetings.at(i) ) );
+               iWeeklyView->insertMeeting( m );
+       }
 }
 
 void UIManager::showMeetingProgressBar( Meeting *aMeeting )
@@ -171,20 +178,22 @@ void UIManager::showMeetingProgressBar( Meeting *aMeeting )
        if ( iProgressBar != 0 )
        {
                iProgressBar->update( tr("Fetching meeting info...") );
-               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ) );
+               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false );
        }
 }
 
 void UIManager::meetingDetailsFetched(Meeting &aDetailedMeeting)
 {
+       qDebug() << "[UIManager::meetingDetailsFetched] <Invoked>";
        if ( iMeetingInfo != 0 )
        {
-               if ( iProgressBar != 0 )
+               if ( iProgressBar != 0 && iProgressBar->isVisible() )
                {
                        iProgressBar->close(); // Close it in case it's visible
                }
-               iMeetingInfo->setMeeting( &aDetailedMeeting );
-               iWindowManager->showDialog( static_cast<QDialog *>( iMeetingInfo ) );
+               // iMeetingInfo->setMeeting( &aDetailedMeeting );
+               MeetingInfoDialog *tmp = new MeetingInfoDialog( &aDetailedMeeting );
+               iWindowManager->showDialog( static_cast<QDialog *>( tmp/*iMeetingInfo*/ ) );
        }
 }
 
@@ -250,7 +259,7 @@ void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
                        // Show the progress bar..
                        if ( iProgressBar != 0 )
                        {
-                               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ) );
+                               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false );
                        }
                        // ... and initiate the mode changing
                        iEngine->changeDeviceMode( true );
@@ -276,3 +285,12 @@ void UIManager::updateProgressBarText(const QString &aText)
                iProgressBar->update( aText );
        }
 }
+
+void UIManager::hideProgressBar()
+{
+       qDebug() << "[UIManager::hideProgressBar] <Invoked>";
+       if ( iProgressBar != 0 && iProgressBar->isVisible() )
+       {
+               iProgressBar->close();
+       }
+}
index df7fe00..de123b6 100644 (file)
@@ -51,6 +51,7 @@ private slots:
        void passwordEntered( PasswordDialog::PasswordStatus aStatus );
        void showMeetingProgressBar( Meeting *aMeeting );
        void updateProgressBarText( const QString &aText );
+       void hideProgressBar();
 
 private:
        
index 96c4235..c20ce45 100644 (file)
@@ -56,7 +56,7 @@ public slots:
         */\r
        void statusChanged( const Room::Status aStatus, const QTime aUntil );\r
        \r
-       void viewResized(const QSize &size) { }\r
+       void viewResized(const QSize &newSize, const QSize &oldSize) { }\r
 \r
 private:\r
        //! Translates the status into human readable text.\r
index d233662..1021d77 100644 (file)
@@ -405,9 +405,12 @@ void SettingsView::handleOkClicked()
        emit okClicked();
 }
 
-void SettingsView::viewResized(const QSize &size)
+void SettingsView::viewResized(const QSize &newSize, const QSize &oldSize)
 {
-       qDebug() << "[SettingsView::viewResized] <Invoked>";
-       
-       qDebug() << "[SettingsView::viewResized] <Finished>";
+       if ( oldSize.height() > newSize.height() )
+       {
+               // Get the button's height and add that to the new size so that
+               // the ok button is hidden under the keyboard.
+               size().rheight() += iOkButton->size().height();
+       }
 }
\ No newline at end of file
index e565aa1..2845a8d 100644 (file)
@@ -31,7 +31,7 @@ signals:
        void okClicked();
        
 public slots:
-       void viewResized(const QSize &size);
+       void viewResized(const QSize &newSize, const QSize &oldSize);
 
 private slots:
        //! Slot to handle the Ok button pressing.
index 00bcf70..631a089 100644 (file)
@@ -49,7 +49,7 @@ public slots:
         * after it has been resized, for example when the on screen keyboard is
         * displayed.
         */
-       virtual void viewResized(const QSize &size) = 0;
+       virtual void viewResized(const QSize &newSize, const QSize &oldSize) = 0;
        
 signals:
        /*!
index da71191..2f9c799 100644 (file)
@@ -147,7 +147,7 @@ public slots:
         * Handle possible resize changes after the view is resized\r
         * to match the window managers client area.\r
         */\r
-       void viewResized(const QSize &size) { }\r
+       void viewResized(const QSize &newSize, const QSize &oldSize) { }\r
 \r
 private:\r
        //! Displays the selectable meeting rooms.\r
index 7be6080..af006f1 100644 (file)
@@ -43,7 +43,7 @@ void WindowManager::showView( ViewBase *view )
        // Make the new view visible and handle connections
        iCurrentView = view;
        connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
-       connect( this, SIGNAL( viewResized(const QSize &) ), iCurrentView, SLOT( viewResized( const QSize & ) ) );
+       connect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), iCurrentView, SLOT( viewResized( const QSize &, const QSize & ) ) );
        view->resize( this->size() );
        
        view->show();
@@ -52,18 +52,25 @@ void WindowManager::showView( ViewBase *view )
        if ( oldView != 0 )
        {
                disconnect( oldView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
-               disconnect( this, SIGNAL( viewResized(const QSize &) ), oldView, SLOT( viewResized(const QSize &) ) );
+               disconnect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), oldView, SLOT( viewResized(const QSize &, const QSize &) ) );
                oldView->hide();
        }
        
 }
 
-void WindowManager::showDialog(QDialog *dialog)
+void WindowManager::showDialog(QDialog *aDialog, bool blocking, bool aSendSignal)
 {
        // Handle dialog displaying
-       emit dialogActivated();
-       dialog->exec();
-       emit dialogDeactivated();
+       if ( aSendSignal ) emit dialogActivated();
+       if ( blocking )
+       {
+               aDialog->exec();
+       }
+       else
+       {
+               aDialog->show();
+       }
+       if ( aSendSignal ) emit dialogDeactivated();
 }
 
 void WindowManager::viewEventDetected()
@@ -94,8 +101,9 @@ bool WindowManager::event(QEvent *event)
        {
                if ( iCurrentView != 0 )
                {
+                       QSize currentSize = iCurrentView->size();
                        iCurrentView->setFixedSize( this->size() );
-                       emit viewResized( this->size() );
+                       emit viewResized( this->size(), currentSize );
                }
        }
        
@@ -104,9 +112,13 @@ bool WindowManager::event(QEvent *event)
 
 void WindowManager::error( const QString &aErrorMessage )
 {
-       qDebug() << "WindowManager::showErrorPopup";
+       qDebug() << "WindowManager::error       ";
 
-       showDialog( static_cast<QDialog *>( PopUpMessageBox::error( 0, aErrorMessage ) ) );
+       PopUpMessageBox *popup = PopUpMessageBox::error( 0, aErrorMessage );
+       if ( popup != 0 )
+       {
+               showDialog( static_cast<QDialog *>( popup ), false );
+       }
 }
 
 void WindowManager::setFullscreen()
index fe594c2..2f46050 100644 (file)
@@ -47,7 +47,7 @@ signals:
         * i.e. it received resized QEvent.\r
         * \param The new view size.\r
         */\r
-       void viewResized(const QSize &);\r
+       void viewResized(const QSize &newSize, const QSize &oldSize);\r
        \r
        //! Previous view is restored.\r
        /*!\r
@@ -77,7 +77,7 @@ public slots:
         * QDialog's exec() method and emits dialogDeactivated signal when\r
         * the exec() method returns.\r
         */\r
-       void showDialog( QDialog *dialog );\r
+       void showDialog( QDialog *aDialog, bool blocking = true, bool aSendSignal = true );\r
        \r
        //! View event is detected.\r
        /*!\r