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