Merge branch 'master' of https://git.maemo.org/projects/qtmeetings
authorZoltan Papp <zoltan.papp@ixonos.com>
Mon, 1 Jun 2009 07:12:18 +0000 (10:12 +0300)
committerZoltan Papp <zoltan.papp@ixonos.com>
Mon, 1 Jun 2009 07:12:18 +0000 (10:12 +0300)
1  2 
src/BusinessLogic/Engine.cpp
src/BusinessLogic/UIManager.cpp
src/UserInterface/Views/RoomStatusIndicatorWidget.cpp

@@@ -32,8 -32,6 +32,8 @@@ Engine::Engine() 
                iWindowManager( 0 ), iUIManager( 0 )
  {
        qDebug() << "Engine::Engine()";
 +      iCommunicationFailed = false;
 +      iCurrentWeekFetched = false;
        
        initConfiguration();
        initDevice();
@@@ -109,7 -107,7 +109,7 @@@ void Engine::checkStatusOfAllRooms(
        for (int i = 0; i < iConfiguration->rooms().count(); i++)
        {
                // and check the status
-               roomStatusInfoNeeded(iConfiguration->rooms().at(i) );
+               roomStatusInfoNeeded( iConfiguration->rooms().at(i) );
        }
  }
  
@@@ -181,16 -179,8 +181,16 @@@ void Engine::fetchMeetingDetails( Meeti
  void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
  {
        qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
 -      
 -      for ( int i = 0; i < iMeetings.count(); ++i ) {
 +      // TODO: should check if this week's meetings were fetched
 +      if( iCommunicationFailed || !iCurrentWeekFetched )
 +      {
 +              iCurrentWeekFetched = true;
 +              iCommunicationFailed = false;
 +              iUIManager->connectionEstablished();
 +      }
 +
 +      for ( int i = 0; i < iMeetings.count(); ++i ) 
 +      {
                Meeting* m = iMeetings.takeAt( i );
                delete m;
        }
  
  void Engine::errorHandler( int aCode, const QString &aAddInfo )
  {     
 +      if( aCode >= 100 && aCode < 150 )
 +      {
 +              iCommunicationFailed = true;
 +              if ( iUIManager != 0 ) iUIManager->connectionLost();
 +      }
        if ( iWindowManager != 0 )
        {
                iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
@@@ -369,4 -354,4 +369,4 @@@ void Engine::currentRoomChanged(Room *a
        qDebug() << "[Engine::currentRoomChanged] <invoked>";
        iCurrentRoom = aRoom;
        roomStatusInfoNeeded( iCurrentRoom );
- }
+ }
@@@ -90,7 -90,7 +90,7 @@@ void UIManager::createSettingsView(
  void UIManager::createRoomStatusIndicator()
  {
        iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->timeFormat() );
-       connect( iEngine, SIGNAL( roomStatusChanged( Room::Status, QTime ) ), this, SLOT( statusChanged( Room::Status, QTime ) ) );
+       connect( iEngine, SIGNAL( roomStatusChanged( Room::Status, QTime ) ), iRoomStatusIndicator, SLOT( statusChanged( Room::Status, QTime ) ) );
        connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), iRoomStatusIndicator, SLOT( currentRoomChanged( Room * ) ) );
  }
  
@@@ -222,22 -222,6 +222,22 @@@ void UIManager::changeModeOrdered( Devi
        }
  }
  
 +void UIManager::connectionLost()
 +{
 +      qDebug() << "UIManager::connectionLost()";
 +      iWeeklyView->connectionLost();
 +      iSettingsView->connectionLost();
 +      iRoomStatusIndicator->connectionLost();
 +}
 +
 +void UIManager::connectionEstablished()
 +{
 +      qDebug() << "UIManager::connectionEstablished()";
 +      iWeeklyView->connectionEstablished();
 +      iSettingsView->connectionEstablished();
 +      iRoomStatusIndicator->connectionEstablished();
 +}
 +
  void UIManager::currentRoomChanged(Room *aRoom)
  {
        qDebug() << "[UIManager::currentRoomChanged] <Invoked>";
@@@ -33,48 -33,28 +33,48 @@@ RoomStatusIndicatorWidget::RoomStatusIn
        iDefaultRoomLabel = ToolBox::createLabel( aDefaultRoom->name(), importantTextFont );\r
        iDefaultRoomLabel->setAlignment( Qt::AlignHCenter );\r
        iDefaultRoomLabel->setStyleSheet( "background-color: transparent" );\r
 +      iDefaultRoomLabel->setHidden( true );\r
 +      \r
        // is busy\r
        iStatusLabel = ToolBox::createLabel( tr( "is %1" ).arg( statusToText( aStatus ) ), importantTextFont );\r
        iStatusLabel->setAlignment( Qt::AlignHCenter );\r
        iStatusLabel->setStyleSheet( "background-color: transparent" );\r
 +      iStatusLabel->setHidden( true );\r
  \r
        // until 13:22\r
        iUntilTextLabel = ToolBox::createLabel( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ), importantTextFont );\r
        iUntilTextLabel->setAlignment( Qt::AlignHCenter );\r
        iUntilTextLabel->setStyleSheet( "background-color: transparent" );\r
 +      iUntilTextLabel->setHidden( true );\r
 +      \r
 +      // No connection to server note\r
 +      qDebug() << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label";\r
 +      QFrame* connectionLabelFrame = new QFrame( this );\r
 +      iConnectionLabel = new QLabel( tr( "No connection to server" ), connectionLabelFrame );\r
 +      iConnectionLabel->setFont( importantTextFont ); \r
 +      iConnectionLabel->setAlignment( Qt::AlignHCenter );\r
 +      iConnectionLabel->setWordWrap( true );\r
 +      iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" );\r
 +      connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() );\r
 +      if( connectedOnce && !connectionError ) iConnectionLabel->setHidden( true );\r
 +              \r
  \r
        QVBoxLayout *topLayout = new QVBoxLayout;\r
        topLayout->addStretch();\r
        topLayout->addWidget( iTimeDisplay );\r
 +      topLayout->addSpacing( 28 );\r
        topLayout->addWidget( iDefaultRoomLabel );\r
        topLayout->addWidget( iStatusLabel );\r
        topLayout->addWidget( iUntilTextLabel );\r
 +      topLayout->addSpacing( 28 );\r
 +      topLayout->addWidget( connectionLabelFrame );\r
        topLayout->addStretch();\r
  \r
        QHBoxLayout *mainLayout = new QHBoxLayout;\r
        mainLayout->addLayout( topLayout );\r
        mainLayout->addStretch();\r
 -      mainLayout->setMargin( 65 );\r
 +      //mainLayout->setMargin( 65 );\r
 +      mainLayout->setContentsMargins( 65, 65, 65, 0 );\r
        setLayout( mainLayout );\r
  \r
        statusChanged( aStatus, aUntil );\r
@@@ -96,28 -76,26 +96,26 @@@ QString RoomStatusIndicatorWidget::stat
  \r
  QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus )\r
  {\r
-       // QPixmap pixmap( aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free" );\r
        QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free";\r
+       QPixmap pixmap( image );\r
  \r
        // The image needs to be moved in normal mode so the traffic light not partly outside the screen\r
        const int xoffset( 60 );\r
        const int yoffset( 19 );\r
- //    int cropwidth( pixmap.width() - xoffset );\r
- //    int cropheight( pixmap.height() - yoffset );\r
+       int cropwidth( pixmap.width() - xoffset );\r
+       int cropheight( pixmap.height() - yoffset );\r
        \r
        QBrush brush;\r
        if ( windowState() == Qt::WindowFullScreen )\r
        {\r
                // Use the full image in full screen mode\r
- //            brush.setTexture( pixmap );\r
-               brush.setTexture( QPixmap(image) );\r
+               brush.setTexture( pixmap );\r
        }\r
        else\r
        {\r
                // Take part of the image so the traffic lights are moved xoffset poxels to left \r
                // and yoffset pixels to up\r
- //            brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );\r
-               brush.setTexture( QPixmap(image) );\r
+               brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );\r
        }\r
  \r
        QPalette palette;\r
@@@ -132,7 -110,6 +130,6 @@@ void RoomStatusIndicatorWidget::setCurr
  \r
  void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const QTime aUntil )\r
  {\r
-       qDebug() << "[RoomStatusIndicatorWidget::statusChanged] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";\r
        iStatusLabel->setText( tr( "is %1" ).arg( statusToText( aStatus ) ) );\r
        if ( aUntil == RoomStatusIndicatorWidget::endOfTheDay )\r
        {\r
@@@ -166,26 -143,3 +163,26 @@@ bool RoomStatusIndicatorWidget::event(Q
        \r
        return ViewBase::event( event );\r
  }\r
 +\r
 +void RoomStatusIndicatorWidget::connectionEstablished()\r
 +{\r
 +      \r
 +      if( !connectedOnce )\r
 +      {\r
 +              // Just got the required meetings for the first time\r
 +              qDebug() << "RoomStatusIndicatorWidget::connectionEstablished() first call";\r
 +              iDefaultRoomLabel->setHidden( false );\r
 +              iUntilTextLabel->setHidden( false );\r
 +              iStatusLabel->setHidden( false );\r
 +      }\r
 +      else qDebug() << "RoomStatusIndicatorWidget::connectionEstablished()";\r
 +      ViewBase::connectionEstablished();\r
 +      iConnectionLabel->setHidden( true );\r
 +}\r
 +\r
 +void RoomStatusIndicatorWidget::connectionLost()\r
 +{\r
 +      ViewBase::connectionLost();\r
 +      iConnectionLabel->setHidden( false );\r
 +}\r
 +\r