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
80 iSchedule = new ScheduleWidget( aCurrentDateTime, iConfiguration->displaySettings(), this );
\r
81 connect( iSchedule, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );
\r
82 connect( iSchedule, SIGNAL( meetingActivated( Meeting* ) ), this, SIGNAL( meetingActivated( Meeting* ) ) );
\r
84 iPreviousWeekButton = new QPushButton( this );
\r
85 iPreviousWeekButton->setText( tr( "<" ) );
\r
86 iPreviousWeekButton->setFixedWidth( 50 );
\r
87 iPreviousWeekButton->setFixedHeight( 100 );
\r
88 iPreviousWeekButton->setFont( buttonFont );
\r
89 connect( iPreviousWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showPreviousWeek() ) );
\r
91 iCurrentWeekButton = new QPushButton( this );
\r
92 iCurrentWeekButton->setFixedWidth( 100 );
\r
93 iCurrentWeekButton->setFixedHeight( 46 );
\r
94 iCurrentWeekButton->setText( tr( "Today" ) );
\r
95 iCurrentWeekButton->setFont( buttonFont );
\r
97 connect( iCurrentWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showCurrentWeek() ) );
\r
99 iNextWeekButton = new QPushButton( this );
\r
100 iNextWeekButton->setFixedWidth( 50 );
\r
101 iNextWeekButton->setFixedHeight( 100 );
\r
102 iNextWeekButton->setText( tr( ">" ) );
\r
103 iNextWeekButton->setFont( buttonFont );
\r
104 connect( iNextWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showNextWeek() ) );
\r
106 // **********************************
\r
107 // Create the view's layout
\r
108 QVBoxLayout *leftLayout = new QVBoxLayout;
\r
109 QVBoxLayout *centerLayout = new QVBoxLayout;
\r
110 QVBoxLayout *rightLayout = new QVBoxLayout;
\r
112 leftLayout->addWidget( iPreviousWeekButton );
\r
113 rightLayout->addWidget( iNextWeekButton );
\r
115 QHBoxLayout *tableLayout = new QHBoxLayout;
\r
116 tableLayout->addWidget( iSchedule );
\r
118 QGridLayout *naviLayout = new QGridLayout;
\r
119 naviLayout->addWidget( iCurrentWeekButton, 0, 0, Qt::AlignLeft );
\r
120 naviLayout->addWidget( iTimeDisplay, 0, 1, Qt::AlignCenter );
\r
121 naviLayout->addWidget( iRoomsCombo, 0, 2, Qt::AlignRight );
\r
123 // QVBoxLayout *dateLayout = new QVBoxLayout;
\r
124 // dateLayout->addWidget( iCurrentDayLabel );
\r
125 // dateLayout->addWidget( iCurrentWeekLabel );
\r
126 // bottomLayout->addLayout( dateLayout );
\r
127 // bottomLayout->addWidget( iSettingsButton );
\r
129 centerLayout->addLayout( naviLayout );
\r
130 centerLayout->addLayout( tableLayout );
\r
131 centerLayout->addWidget( iStatusBar );
\r
133 QHBoxLayout *mainLayout = new QHBoxLayout;
\r
134 mainLayout->addLayout( leftLayout );
\r
135 mainLayout->addLayout( centerLayout );
\r
136 mainLayout->addLayout( rightLayout );
\r
137 setLayout( mainLayout );
\r
139 // Set child observing
\r
140 observeChild( iRoomsCombo );
\r
141 observeChild( iStatusBar );
\r
142 observeChild( iTimeDisplay );
\r
143 observeChild( iCurrentDayLabel );
\r
144 observeChild( iCurrentWeekLabel );
\r
145 observeChild( iPreviousWeekButton );
\r
146 observeChild( iCurrentWeekButton );
\r
147 observeChild( iNextWeekButton );
\r
148 observeChild( iSettingsButton );
\r
151 palette.setColor( QPalette::Window, Qt::white );
\r
152 palette.setColor( QPalette::Foreground, Qt::darkGray );
\r
153 setPalette( palette );
\r
155 setAutoFillBackground( true );
\r
157 // ******************************************
\r
158 // Handle all the signal connections
\r
159 // TODO : this solution if interaction monitoring is not elegant enough
\r
160 // connect( iPreviousWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );
\r
161 // connect( iCurrentWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );
\r
162 // connect( iNextWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );
\r
163 // connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) );
\r
164 // connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) );
\r
165 // TODO: connect RoomCombo signals to change meetings data.
\r
166 connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );
\r
167 connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( refresh() ) );
\r
170 WeeklyViewWidget::~WeeklyViewWidget()
\r
174 delete iRoomsCombo;
\r
177 if ( iTimeDisplay )
\r
179 delete iTimeDisplay;
\r
193 if ( iCurrentDayLabel )
\r
195 delete iCurrentDayLabel;
\r
196 iCurrentDayLabel = 0;
\r
198 if ( iCurrentWeekLabel )
\r
200 delete iCurrentWeekLabel;
\r
201 iCurrentWeekLabel = 0;
\r
203 if ( iPreviousWeekButton )
\r
205 delete iPreviousWeekButton;
\r
206 iPreviousWeekButton = 0;
\r
208 if ( iCurrentWeekButton )
\r
210 delete iCurrentWeekButton;
\r
211 iCurrentWeekButton = 0;
\r
213 if ( iNextWeekButton )
\r
215 delete iNextWeekButton;
\r
216 iNextWeekButton = 0;
\r
218 if ( iSettingsButton )
\r
220 delete iSettingsButton;
\r
221 iSettingsButton = 0;
\r
225 Room* WeeklyViewWidget::currentRoom()
\r
227 return iRoomsCombo->currentRoom();
\r
230 void WeeklyViewWidget::setCurrentDateTime( QDateTime aCurrentDateTime )
\r
232 iCurrentDayLabel->setText( aCurrentDateTime.date().toString( iConfiguration->displaySettings()->dateFormat() ) );
\r
234 iCurrentWeekLabel->setText( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ) );
\r
236 iTimeDisplay->setText( aCurrentDateTime.toString( iConfiguration->displaySettings()->timeFormat() ) );
\r
238 iSchedule->setCurrentDateTime( aCurrentDateTime );
\r
241 QDate WeeklyViewWidget::beginnigOfShownWeek()
\r
243 return iSchedule->beginningOfShownWeek();
\r
246 void WeeklyViewWidget::refreshMeetings( const QList<Meeting*> &aMeetings )
\r
248 qDebug() << "WeeklyViewWidget::refreshMeetings()";
\r
249 iSchedule->refreshMeetings( aMeetings );
\r
252 void WeeklyViewWidget::showCurrentWeek()
\r
254 iSchedule->showCurrentWeek();
\r
257 void WeeklyViewWidget::setDefaultRoom()
\r
259 iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() );
\r
262 void WeeklyViewWidget::connectionEstablished()
\r
264 ViewBase::connectionEstablished();
\r
265 qDebug() << "WeeklyViewWidget::connectionEstablished";
\r
266 iStatusBar->setText( tr("Connected"), BorderedBarWidget::LeftAlign );
\r
269 void WeeklyViewWidget::connectionLost()
\r
271 ViewBase::connectionLost();
\r
272 iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign );
\r