ViewBase added and major changes to use the new architecture
[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         QFont normalFont;
37         normalFont.setPointSize( 11 );
38
39         QFont boldFont;
40         boldFont.setPointSize( 11 );
41         boldFont.setBold( true );
42
43         QLabel *subjectLabel = ToolBox::createLabel( tr( "Subject:" ), boldFont );
44         QLabel *subjectContent = ToolBox::createLabel( aMeeting->subject(), normalFont );
45
46         QLabel *descriptionLabel = ToolBox::createLabel( tr( "Description:" ), boldFont );
47         QTextEdit *descriptionContent = new QTextEdit( "" );
48         descriptionContent->setHtml( aMeeting->description() );
49         descriptionContent->setReadOnly( true );
50         descriptionContent->setFont( normalFont );
51
52         QLabel *organizerLabel = NULL;
53         QLabel *organizerContent = NULL;
54         
55         QString roomAddr = aMeeting->room().address();
56         QString organizer = aMeeting->organizer();
57         if( !organizer.contains( roomAddr ) )
58         {
59                 organizerLabel = ToolBox::createLabel( tr( "Organizer:" ), boldFont );
60                 organizerContent = ToolBox::createLabel( aMeeting->organizer(), normalFont );
61         }
62         QLabel *startsAtLabel = ToolBox::createLabel( tr( "Starts at:" ), boldFont );
63         QLabel *startsAtContent = ToolBox::createLabel( aMeeting->startsAt().toString( tr( "d MMMM yyyy hh:mm" ) ), normalFont );
64
65         QLabel *endsAtLabel = ToolBox::createLabel( tr( "Ends at:" ), boldFont );
66         QLabel *endsAtContent = ToolBox::createLabel( aMeeting->endsAt().toString( tr( "d MMMM yyyy hh:mm" ) ), normalFont );
67
68         QPushButton *button = new QPushButton;
69         button->setText( tr( "OK" ) );
70         connect( button, SIGNAL( clicked() ), this, SLOT( close() ) );
71
72         QHBoxLayout *buttonLayout = new QHBoxLayout;
73         buttonLayout->addStretch();
74         buttonLayout->addWidget( button );
75         buttonLayout->addStretch();
76
77         QVBoxLayout *layout = new QVBoxLayout;
78         layout->addWidget( subjectLabel );
79         layout->addWidget( subjectContent );
80         layout->addSpacing( 5 );
81         layout->addWidget( descriptionLabel );
82         layout->addWidget( descriptionContent );
83         layout->addSpacing( 5 );
84         if( organizerLabel )
85                 layout->addWidget( organizerLabel );
86         if( organizerContent )
87                 layout->addWidget( organizerContent );
88         layout->addSpacing( 5 );
89         layout->addWidget( startsAtLabel );
90         layout->addWidget( startsAtContent );
91         layout->addSpacing( 5 );
92         layout->addWidget( endsAtLabel );
93         layout->addWidget( endsAtContent );
94         layout->addSpacing( 5 );
95         layout->addStretch();
96         layout->addLayout( buttonLayout );
97         setLayout( layout );
98 }