1 #include "WeeklyViewWidget.h"
\r
4 #include <QPushButton>
\r
5 #include <QVBoxLayout>
\r
9 #include <QTabletEvent>
\r
10 #include "Configuration.h"
\r
11 #include "DisplaySettings.h"
\r
12 #include "Meeting.h"
\r
14 #include "MeetingRoomCombo.h"
\r
15 #include "DigitalTimeDisplayWidget.h"
\r
16 #include "ScheduleWidget.h"
\r
17 #include "ToolBox.h"
\r
18 #include "MeetingInfoDialog.h"
\r
19 #include "BorderedBarWidget.h"
\r
23 WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *aConfiguration, QWidget *aParent ) :
\r
24 ViewBase( ViewBase::NormalView, aParent ), iConfiguration( aConfiguration )
\r
27 // *****************************************
\r
28 // Construct all the needed widgets
\r
29 QFont importantTextFont;
\r
30 importantTextFont.setBold( true );
\r
31 importantTextFont.setPointSize( 20 );
\r
33 QFont regularTextFont;
\r
34 regularTextFont.setBold( true );
\r
35 regularTextFont.setPointSize( 12 );
\r
38 clockFont.setStyleHint( QFont::Helvetica );
\r
39 clockFont.setBold( true );
\r
40 clockFont.setPixelSize( 36 );
\r
42 QFont statusBarFont;
\r
43 statusBarFont.setStyleHint( QFont::Helvetica );
\r
44 statusBarFont.setPixelSize( 12 );
\r
47 buttonFont.setStyleHint( QFont::Helvetica );
\r
48 buttonFont.setBold( true );
\r
49 buttonFont.setPixelSize( 18 );
\r
51 iSettingsButton = new QPushButton;
\r
52 iSettingsButton->setIcon( QPixmap( ":button_settings" ) );
\r
53 iSettingsButton->setFixedWidth( 36 );
\r
54 connect( iSettingsButton, SIGNAL( clicked() ), this, SIGNAL( settingsButtonClicked() ) );
\r
56 iCurrentDayLabel = ToolBox::createLabel( aCurrentDateTime.toString( iConfiguration->displaySettings()->dateFormat() ), regularTextFont );
\r
57 iCurrentWeekLabel = ToolBox::createLabel( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ), regularTextFont );
\r
59 iTimeDisplay = new BorderedBarWidget( this );
\r
60 iTimeDisplay->setFaceColor( Qt::darkGray );
\r
61 iTimeDisplay->setBackgroundColor( Qt::white);
\r
62 iTimeDisplay->setBorderWidth( 6 );
\r
63 iTimeDisplay->setFixedWidth( 170 );
\r
64 iTimeDisplay->setFixedHeight( 50 );
\r
65 iTimeDisplay->setFont( clockFont );
\r
67 iRoomsCombo = new MeetingRoomCombo( iConfiguration->rooms(), this );
\r
68 iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() );
\r
69 connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );
\r
71 iStatusBar = new BorderedBarWidget( this );
\r
72 iStatusBar->setFaceColor( Qt::darkGray );
\r
73 iStatusBar->setBackgroundColor( Qt::white );
\r
74 iStatusBar->setBorderWidth( 4 );
\r
75 iStatusBar->setFont(statusBarFont);
\r
76 iStatusBar->setFixedHeight( 28 );
\r
77 QPixmap pixmap(":ixonos_logo");
\r
78 iStatusBar->setPixmap( pixmap );
\r
79 iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign );
\r
81 iSchedule = new ScheduleWidget( aCurrentDateTime, iConfiguration->displaySettings(), this );
\r
82 connect( iSchedule, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );
\r
83 connect( iSchedule, SIGNAL( meetingActivated( Meeting* ) ), this, SIGNAL( meetingActivated( Meeting* ) ) );
\r
85 iPreviousWeekButton = new QPushButton( this );
\r
86 iPreviousWeekButton->setText( tr( "<" ) );
\r
87 iPreviousWeekButton->setFixedWidth( 50 );
\r
88 iPreviousWeekButton->setFixedHeight( 100 );
\r
89 iPreviousWeekButton->setFont( buttonFont );
\r
90 connect( iPreviousWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showPreviousWeek() ) );
\r
92 iCurrentWeekButton = new QPushButton( this );
\r
93 iCurrentWeekButton->setFixedWidth( 100 );
\r
94 iCurrentWeekButton->setFixedHeight( 46 );
\r
95 iCurrentWeekButton->setText( tr( "Today" ) );
\r
96 iCurrentWeekButton->setFont( buttonFont );
\r
98 connect( iCurrentWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showCurrentWeek() ) );
\r
100 iNextWeekButton = new QPushButton( this );
\r
101 iNextWeekButton->setFixedWidth( 50 );
\r
102 iNextWeekButton->setFixedHeight( 100 );
\r
103 iNextWeekButton->setText( tr( ">" ) );
\r
104 iNextWeekButton->setFont( buttonFont );
\r
105 connect( iNextWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showNextWeek() ) );
\r
107 // **********************************
\r
108 // Create the view's layout
\r
109 QVBoxLayout *leftLayout = new QVBoxLayout;
\r
110 QVBoxLayout *centerLayout = new QVBoxLayout;
\r
111 QVBoxLayout *rightLayout = new QVBoxLayout;
\r
113 leftLayout->addWidget( iPreviousWeekButton );
\r
114 rightLayout->addWidget( iNextWeekButton );
\r
116 QHBoxLayout *tableLayout = new QHBoxLayout;
\r
117 tableLayout->addWidget( iSchedule );
\r
119 QGridLayout *naviLayout = new QGridLayout;
\r
120 naviLayout->addWidget( iCurrentWeekButton, 0, 0, Qt::AlignLeft );
\r
121 naviLayout->addWidget( iTimeDisplay, 0, 1, Qt::AlignCenter );
\r
122 naviLayout->addWidget( iRoomsCombo, 0, 2, Qt::AlignRight );
\r
124 // QVBoxLayout *dateLayout = new QVBoxLayout;
\r
125 // dateLayout->addWidget( iCurrentDayLabel );
\r
126 // dateLayout->addWidget( iCurrentWeekLabel );
\r
127 // bottomLayout->addLayout( dateLayout );
\r
128 // bottomLayout->addWidget( iSettingsButton );
\r
130 centerLayout->addLayout( naviLayout );
\r
131 centerLayout->addLayout( tableLayout );
\r
132 centerLayout->addWidget( iStatusBar );
\r
134 QHBoxLayout *mainLayout = new QHBoxLayout;
\r
135 mainLayout->addLayout( leftLayout );
\r
136 mainLayout->addLayout( centerLayout );
\r
137 mainLayout->addLayout( rightLayout );
\r
138 setLayout( mainLayout );
\r
140 // Set child observing
\r
141 observeChild( iRoomsCombo );
\r
142 observeChild( iStatusBar );
\r
143 observeChild( iTimeDisplay );
\r
144 observeChild( iCurrentDayLabel );
\r
145 observeChild( iCurrentWeekLabel );
\r
146 observeChild( iPreviousWeekButton );
\r
147 observeChild( iCurrentWeekButton );
\r
148 observeChild( iNextWeekButton );
\r
149 observeChild( iSettingsButton );
\r
152 palette.setColor( QPalette::Window, Qt::white );
\r
153 palette.setColor( QPalette::Foreground, Qt::darkGray );
\r
154 setPalette( palette );
\r
156 setAutoFillBackground( true );
\r
158 // ******************************************
\r
159 // Handle all the signal connections
\r
160 // TODO : this solution if interaction monitoring is not elegant enough
\r
161 // connect( iPreviousWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );
\r
162 // connect( iCurrentWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );
\r
163 // connect( iNextWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );
\r
164 // connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) );
\r
165 // connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) );
\r
166 // TODO: connect RoomCombo signals to change meetings data.
\r
167 connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );
\r
168 connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( refresh() ) );
\r
171 WeeklyViewWidget::~WeeklyViewWidget()
\r
175 delete iRoomsCombo;
\r
178 if ( iTimeDisplay )
\r
180 delete iTimeDisplay;
\r
194 if ( iCurrentDayLabel )
\r
196 delete iCurrentDayLabel;
\r
197 iCurrentDayLabel = 0;
\r
199 if ( iCurrentWeekLabel )
\r
201 delete iCurrentWeekLabel;
\r
202 iCurrentWeekLabel = 0;
\r
204 if ( iPreviousWeekButton )
\r
206 delete iPreviousWeekButton;
\r
207 iPreviousWeekButton = 0;
\r
209 if ( iCurrentWeekButton )
\r
211 delete iCurrentWeekButton;
\r
212 iCurrentWeekButton = 0;
\r
214 if ( iNextWeekButton )
\r
216 delete iNextWeekButton;
\r
217 iNextWeekButton = 0;
\r
219 if ( iSettingsButton )
\r
221 delete iSettingsButton;
\r
222 iSettingsButton = 0;
\r
226 Room* WeeklyViewWidget::currentRoom()
\r
228 return iRoomsCombo->currentRoom();
\r
231 void WeeklyViewWidget::setConnectionStatus( QDateTime aCurrentTime, bool aConnected,
\r
232 QTime aLastUpdated, QString aError )
\r
234 iCurrentDayLabel->setText( aCurrentTime.date().toString( iConfiguration->displaySettings()->dateFormat() ) );
\r
235 iCurrentWeekLabel->setText( tr( "Wk %1" ).arg( aCurrentTime.date().weekNumber() ) );
\r
236 iSchedule->setCurrentDateTime( aCurrentTime );
\r
238 iTimeDisplay->setText( aCurrentTime.toString( iConfiguration->displaySettings()->timeFormat() ) );
\r
239 if ( aLastUpdated.isNull() )
\r
240 iStatusBar->setText( tr("Disconnected") , BorderedBarWidget::LeftAlign );
\r
241 else if ( !aConnected )
\r
243 iStatusBar->setText( tr("Disconnected")
\r
244 .arg(aLastUpdated.toString(iConfiguration->displaySettings()->timeFormat()))
\r
245 , BorderedBarWidget::LeftAlign );
\r
249 iStatusBar->setText( tr("Connected - Last update %1")
\r
250 .arg(aLastUpdated.toString(iConfiguration->displaySettings()->timeFormat())) ,
\r
251 BorderedBarWidget::LeftAlign );
\r
253 showError( aError );
\r
256 void WeeklyViewWidget::showError( QString aError )
\r
258 iStatusBar->setText( aError );
\r
261 QDate WeeklyViewWidget::beginnigOfShownWeek()
\r
263 return iSchedule->beginningOfShownWeek();
\r
266 void WeeklyViewWidget::refreshMeetings( const QList<Meeting*> &aMeetings )
\r
268 qDebug() << "WeeklyViewWidget::refreshMeetings()";
\r
269 iSchedule->refreshMeetings( aMeetings );
\r
272 void WeeklyViewWidget::showCurrentWeek()
\r
274 iSchedule->showCurrentWeek();
\r
277 void WeeklyViewWidget::setDefaultRoom()
\r
279 iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() );
\r
282 void WeeklyViewWidget::connectionEstablished()
\r
284 ViewBase::connectionEstablished();
\r
287 void WeeklyViewWidget::connectionLost()
\r
289 ViewBase::connectionLost();
\r