missing methods added.
authoritkonma <marko.itkonen@ixonos.com>
Mon, 1 Jun 2009 09:00:47 +0000 (12:00 +0300)
committeritkonma <marko.itkonen@ixonos.com>
Mon, 1 Jun 2009 09:00:47 +0000 (12:00 +0300)
src/UserInterface/Views/RoomStatusIndicatorWidget.cpp

index a1f75a1..0295a40 100644 (file)
 
 #include <QtDebug>
 
-QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );
+QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0);
 
-RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) :
-               ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat )
+RoomStatusIndicatorWidget::RoomStatusIndicatorWidget(Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent) :
+       ViewBase(ViewBase::ObservedView, aParent), iTimeFormat(aTimeFormat)
 {
        QFont importantTextFont;
        //importantTextFont.setBold( true );
-       importantTextFont.setPointSize( 20 );
+       importantTextFont.setPointSize( 20);
 
        QFont regularTextFont;
        //regularTextFont.setBold( true );
-       regularTextFont.setPointSize( 12 );
+       regularTextFont.setPointSize( 12);
 
        // display for current time
        // Note: the time display receives current time info from Engine::clock()
        iTimeDisplay = new DigitalTimeDisplayWidget( QTime::currentTime(), iTimeFormat, this );
-       iTimeDisplay->setFrameVisible( false );
-       iTimeDisplay->setSize( 250, 120 );
+       iTimeDisplay->setFrameVisible( false);
+       iTimeDisplay->setSize( 250, 120);
 
        // Pegasus
-       iDefaultRoomLabel = ToolBox::createLabel( aDefaultRoom->name(), importantTextFont );
-       iDefaultRoomLabel->setAlignment( Qt::AlignHCenter );
-       iDefaultRoomLabel->setStyleSheet( "background-color: transparent" );
-       iDefaultRoomLabel->setHidden( true );
-       
+       iDefaultRoomLabel
+                       = ToolBox::createLabel(aDefaultRoom->name(), importantTextFont);
+       iDefaultRoomLabel->setAlignment(Qt::AlignHCenter);
+       iDefaultRoomLabel->setStyleSheet("background-color: transparent");
+       iDefaultRoomLabel->setHidden( true);
+
        // is busy
-       iStatusLabel = ToolBox::createLabel( tr( "is %1" ).arg( statusToText( aStatus ) ), importantTextFont );
-       iStatusLabel->setAlignment( Qt::AlignHCenter );
-       iStatusLabel->setStyleSheet( "background-color: transparent" );
-       iStatusLabel->setHidden( true );
+       iStatusLabel = ToolBox::createLabel(tr( "is %1" ).arg(statusToText(aStatus) ), importantTextFont);
+       iStatusLabel->setAlignment(Qt::AlignHCenter);
+       iStatusLabel->setStyleSheet("background-color: transparent");
+       iStatusLabel->setHidden( true);
 
        // until 13:22
-       iUntilTextLabel = ToolBox::createLabel( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ), importantTextFont );
-       iUntilTextLabel->setAlignment( Qt::AlignHCenter );
-       iUntilTextLabel->setStyleSheet( "background-color: transparent" );
-       iUntilTextLabel->setHidden( true );
-       
+       iUntilTextLabel
+                       = ToolBox::createLabel(tr( "until %1" ).arg(aUntil.toString(iTimeFormat) ), importantTextFont);
+       iUntilTextLabel->setAlignment(Qt::AlignHCenter);
+       iUntilTextLabel->setStyleSheet("background-color: transparent");
+       iUntilTextLabel->setHidden( true);
+
        // No connection to server note
-       qDebug() << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label";
+       qDebug()
+                       << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label";
        QFrame* connectionLabelFrame = new QFrame( this );
        iConnectionLabel = new QLabel( tr( "No connection to server" ), connectionLabelFrame );
-       iConnectionLabel->setFont( importantTextFont ); 
-       iConnectionLabel->setAlignment( Qt::AlignHCenter );
-       iConnectionLabel->setWordWrap( true );
-       iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" );
-       connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() );
-       if( connectedOnce && !connectionError ) iConnectionLabel->setHidden( true );
-               
+       iConnectionLabel->setFont(importantTextFont);
+       iConnectionLabel->setAlignment(Qt::AlignHCenter);
+       iConnectionLabel->setWordWrap( true);
+       iConnectionLabel->setStyleSheet("background-color: transparent; color: red; text-decoration:blink; max-width: 250px");
+       connectionLabelFrame->setFixedSize(iConnectionLabel->sizeHint() );
+       if (connectedOnce && !connectionError)
+               iConnectionLabel->setHidden( true);
 
        QVBoxLayout *topLayout = new QVBoxLayout;
        topLayout->addStretch();
-       topLayout->addWidget( iTimeDisplay );
-       topLayout->addSpacing( 28 );
-       topLayout->addWidget( iDefaultRoomLabel );
-       topLayout->addWidget( iStatusLabel );
-       topLayout->addWidget( iUntilTextLabel );
-       topLayout->addSpacing( 28 );
-       topLayout->addWidget( connectionLabelFrame );
+       topLayout->addWidget(iTimeDisplay);
+       topLayout->addSpacing( 28);
+       topLayout->addWidget(iDefaultRoomLabel);
+       topLayout->addWidget(iStatusLabel);
+       topLayout->addWidget(iUntilTextLabel);
+       topLayout->addSpacing( 28);
+       topLayout->addWidget(connectionLabelFrame);
        topLayout->addStretch();
 
        QHBoxLayout *mainLayout = new QHBoxLayout;
-       mainLayout->addLayout( topLayout );
+       mainLayout->addLayout(topLayout);
        mainLayout->addStretch();
        //mainLayout->setMargin( 65 );
-       mainLayout->setContentsMargins( 65, 65, 65, 0 );
-       setLayout( mainLayout );
+       mainLayout->setContentsMargins( 65, 65, 65, 0);
+       setLayout(mainLayout);
 
-       statusChanged( aStatus, aUntil );
+       statusChanged(aStatus, aUntil);
 
-       setFocusPolicy( Qt::StrongFocus );
-       setEnabled( true ); // enable mouse & key events
+       setFocusPolicy(Qt::StrongFocus);
+       setEnabled( true); // enable mouse & key events
 }
 
 RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget()
@@ -89,77 +92,104 @@ RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget()
        iTimeDisplay = 0;
 }
 
-QString RoomStatusIndicatorWidget::statusToText( const Room::Status aStatus )
+QString RoomStatusIndicatorWidget::statusToText(const Room::Status aStatus)
 {
-       return ( aStatus == Room::BusyStatus ) ? tr( "busy" ) : tr( "free" );
+       return (aStatus == Room::BusyStatus ) ? tr("busy") : tr("free");
 }
 
-QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus )
+QPalette RoomStatusIndicatorWidget::createPalette(Room::Status aStatus)
 {
-       QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free";
-       QPixmap pixmap( image );
+       QString
+                       image =
+                                       aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free";
+       QPixmap pixmap(image);
 
        // The image needs to be moved in normal mode so the traffic light not partly outside the screen
-       const int xoffset( 60 );
-       const int yoffset( 19 );
-       int cropwidth( pixmap.width() - xoffset );
-       int cropheight( pixmap.height() - yoffset );
-       
+       const int xoffset( 60);
+       const int yoffset( 19);
+       int cropwidth(pixmap.width() - xoffset);
+       int cropheight(pixmap.height() - yoffset);
+
        QBrush brush;
-       if ( windowState() == Qt::WindowFullScreen )
+       if (windowState() == Qt::WindowFullScreen)
        {
                // Use the full image in full screen mode
-               brush.setTexture( pixmap );
+               brush.setTexture(pixmap);
        }
        else
        {
                // Take part of the image so the traffic lights are moved xoffset poxels to left 
                // and yoffset pixels to up
-               brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );
+               brush.setTexture(pixmap.copy(xoffset, yoffset, cropwidth, cropheight) );
        }
 
        QPalette palette;
-       palette.setBrush( QPalette::Window, brush );
+       palette.setBrush(QPalette::Window, brush);
        return palette;
 }
 
-void RoomStatusIndicatorWidget::setCurrentTime( QTime aCurrentTime )
+void RoomStatusIndicatorWidget::setCurrentTime(QTime aCurrentTime)
 {
-       iTimeDisplay->setTime( aCurrentTime );
+       iTimeDisplay->setTime(aCurrentTime);
 }
 
-void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const QTime aUntil )
+void RoomStatusIndicatorWidget::statusChanged(const Room::Status aStatus, const QTime aUntil)
 {
-       iStatusLabel->setText( tr( "is %1" ).arg( statusToText( aStatus ) ) );
-       if ( aUntil == RoomStatusIndicatorWidget::endOfTheDay )
+       iStatusLabel->setText(tr( "is %1" ).arg(statusToText(aStatus) ) );
+       if (aUntil == RoomStatusIndicatorWidget::endOfTheDay)
        {
-               iUntilTextLabel->setText( tr( "whole day." ) );
+               iUntilTextLabel->setText(tr("whole day.") );
        }
        else
        {
-               iUntilTextLabel->setText( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ) );
+               iUntilTextLabel->setText(tr( "until %1" ).arg(aUntil.toString(iTimeFormat) ) );
        }
-       setPalette( createPalette( aStatus ) );
+       setPalette(createPalette(aStatus) );
 }
 
-void RoomStatusIndicatorWidget::currentRoomChanged( Room *aRoom )
+void RoomStatusIndicatorWidget::currentRoomChanged(Room *aRoom)
 {
-       iDefaultRoomLabel->setText( aRoom->name() );
+       iDefaultRoomLabel->setText(aRoom->name() );
 }
 
 bool RoomStatusIndicatorWidget::event(QEvent *event)
 {
-       switch(event->type())
+       switch (event->type())
        {
                case QEvent::Paint:
                        qDebug() << "[RoomStatusIndicatorWidget::event] <Paint event>";
                        break;
                case QEvent::PaletteChange:
-                       qDebug() << "[RoomStatusIndicatorWidget::event] <Palette change event>";
+                       qDebug()
+                                       << "[RoomStatusIndicatorWidget::event] <Palette change event>";
                        break;
                default:
                        break;
        }
-       
-       return ViewBase::event( event );
+
+       return ViewBase::event(event);
+}
+
+void RoomStatusIndicatorWidget::connectionEstablished()
+{
+       if ( !connectedOnce)
+       { 
+               // Just got the required meetings for the first time              
+               qDebug() << "RoomStatusIndicatorWidget::connectionEstablished() first call";
+               iDefaultRoomLabel->setHidden( false);
+               iUntilTextLabel->setHidden( false);
+               iStatusLabel->setHidden( false);
+       }
+       else
+       {
+               qDebug() << "RoomStatusIndicatorWidget::connectionEstablished()";
+       }
+       ViewBase::connectionEstablished();
+       iConnectionLabel->setHidden( true);
+}
+
+void RoomStatusIndicatorWidget::connectionLost()
+{
+       ViewBase::connectionLost();
+       iConnectionLabel->setHidden( false);
 }