Got the new stuff working, last commit before final pull push
[qtmeetings] / src / UserInterface / Views / MeetingInfoDialog.cpp
1 #include "MeetingInfoDialog.h"
2 #include "ToolBox.h"
3 #include "Meeting.h"
4 #include "Room.h"
5 #include <QLabel>
6 #include <QVBoxLayout>
7 #include <QPushButton>
8 #include <QTextEdit>
9 #include <QDebug>
10
11 MeetingInfoDialog::MeetingInfoDialog( Meeting *aMeeting, QWidget *aParent ) :
12                 QDialog( aParent )
13 {
14         setWindowTitle( tr( "Details" ) );
15
16         if ( aMeeting != 0 )
17         {
18                 createDialogView( aMeeting );
19         }
20
21         setMinimumWidth( MeetingInfoDialog::width );
22         setMinimumHeight( MeetingInfoDialog::height );
23 }
24
25 MeetingInfoDialog::~MeetingInfoDialog()
26 {
27 }
28
29 void MeetingInfoDialog::setMeeting(Meeting *aMeeting)
30 {
31         createDialogView( aMeeting );
32 }
33
34 void MeetingInfoDialog::createDialogView(Meeting *aMeeting)
35 {
36         qDebug() << "[MeetingInfoDialog::createDialogView] <Invoked>";
37         
38         QFont normalFont;
39         normalFont.setPointSize( 11 );
40
41         QFont boldFont;
42         boldFont.setPointSize( 11 );
43         boldFont.setBold( true );
44
45         QLabel *subjectLabel = ToolBox::createLabel( tr( "Subject:" ), boldFont );
46         QLabel *subjectContent = ToolBox::createLabel( aMeeting->subject(), normalFont );
47
48         QLabel *descriptionLabel = ToolBox::createLabel( tr( "Description:" ), boldFont );
49         QTextEdit *descriptionContent = new QTextEdit( "" );
50         descriptionContent->setHtml( aMeeting->description() );
51         descriptionContent->setReadOnly( true );
52         descriptionContent->setFont( normalFont );
53
54         QLabel *organizerLabel = NULL;
55         QLabel *organizerContent = NULL;
56         
57         QString roomAddr = aMeeting->room().address();
58         QString organizer = aMeeting->organizer();
59         if( !organizer.contains( roomAddr ) )
60         {
61                 organizerLabel = ToolBox::createLabel( tr( "Organizer:" ), boldFont );
62                 organizerContent = ToolBox::createLabel( aMeeting->organizer(), normalFont );
63         }
64         QLabel *startsAtLabel = ToolBox::createLabel( tr( "Starts at:" ), boldFont );
65         QLabel *startsAtContent = ToolBox::createLabel( aMeeting->startsAt().toString( tr( "d MMMM yyyy hh:mm" ) ), normalFont );
66
67         QLabel *endsAtLabel = ToolBox::createLabel( tr( "Ends at:" ), boldFont );
68         QLabel *endsAtContent = ToolBox::createLabel( aMeeting->endsAt().toString( tr( "d MMMM yyyy hh:mm" ) ), normalFont );
69
70         QPushButton *button = new QPushButton;
71         button->setText( tr( "OK" ) );
72         connect( button, SIGNAL( clicked() ), this, SLOT( close() ) );
73
74         QHBoxLayout *buttonLayout = new QHBoxLayout;
75         buttonLayout->addStretch();
76         buttonLayout->addWidget( button );
77         buttonLayout->addStretch();
78
79         QVBoxLayout *layout = new QVBoxLayout;
80         layout->addWidget( subjectLabel );
81         layout->addWidget( subjectContent );
82         layout->addSpacing( 5 );
83         layout->addWidget( descriptionLabel );
84         layout->addWidget( descriptionContent );
85         layout->addSpacing( 5 );
86         if( organizerLabel )
87                 layout->addWidget( organizerLabel );
88         if( organizerContent )
89                 layout->addWidget( organizerContent );
90         layout->addSpacing( 5 );
91         layout->addWidget( startsAtLabel );
92         layout->addWidget( startsAtContent );
93         layout->addSpacing( 5 );
94         layout->addWidget( endsAtLabel );
95         layout->addWidget( endsAtContent );
96         layout->addSpacing( 5 );
97         layout->addStretch();
98         layout->addLayout( buttonLayout );
99         setLayout( layout );
100         
101         qDebug() << "[MeetingInfoDialog::createDialogView] <Finished>";
102 }