Qt Virtual Chart Table (QVCT)
CVesselContainerEditView.cpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 // QT
20 #include <QDialogButtonBox>
21 #include <QFormLayout>
22 #include <QHBoxLayout>
23 #include <QLabel>
24 #include <QLineEdit>
25 #include <QTextEdit>
26 #include <QVBoxLayout>
27 
28 // QVCT
32 
33 
34 //------------------------------------------------------------------------------
35 // CONSTRUCTORS / DESTRUCTOR
36 //------------------------------------------------------------------------------
37 
39  : COverlayObjectEditView( _poVesselContainer )
40 {
42 }
43 
45 {
46  // Create layout
47  QVBoxLayout* __pqVBoxLayout = new QVBoxLayout();
48 
49  // Add header
50  QFont __qFontHeader;
51  __qFontHeader.setPixelSize( 16 );
52  __qFontHeader.setBold( true );
53  QHBoxLayout* __pqHBoxLayoutHeader = new QHBoxLayout();
54  QLabel* __pqLabelIcon = new QLabel();
55  __pqLabelIcon->setPixmap( QPixmap( ":icons/32x32/vessel.png" ) );
56  __pqHBoxLayoutHeader->addWidget( __pqLabelIcon, 0, Qt::AlignTop );
57  QLabel* __pqLabelEdit = new QLabel( tr("Edit")+"..." );
58  __pqLabelEdit->setFont( __qFontHeader );
59  __pqHBoxLayoutHeader->addWidget( __pqLabelEdit, 1 );
60  // ... [end]
61  __pqVBoxLayout->addLayout( __pqHBoxLayoutHeader );
62 
63  // Add data
64  CVesselContainer* __poVesselContainer = (CVesselContainer*)poOverlayObject;
65  QFormLayout* __pqFormLayout = new QFormLayout();
66 
67  // ... name
68  pqLineEditName = new QLineEdit();
69  pqLineEditName->setToolTip( tr("Name") );
70  pqLineEditName->setText( __poVesselContainer->getName() );
71  __pqFormLayout->addRow( tr("Name")+":", pqLineEditName );
72 
73  // ... type
74  pqLineEditType = new QLineEdit();
75  pqLineEditType->setToolTip( tr("Type") );
76  pqLineEditType->setText( __poVesselContainer->getType() );
77  __pqFormLayout->addRow( tr("Type")+":", pqLineEditType );
78 
79  // ... description
80  pqTextEditDescription = new QTextEdit();
81  pqTextEditDescription->setToolTip( tr("Description") );
82  pqTextEditDescription->setAcceptRichText( false );
83  pqTextEditDescription->setPlainText( __poVesselContainer->getDescription() );
84  __pqFormLayout->addRow( tr("Description")+":", pqTextEditDescription );
85 
86  // ... comment
87  pqTextEditComment = new QTextEdit();
88  pqTextEditComment->setToolTip( tr("Comment") );
89  pqTextEditComment->setAcceptRichText( false );
90  pqTextEditComment->setPlainText( __poVesselContainer->getComment() );
91  __pqFormLayout->addRow( tr("Comment")+":", pqTextEditComment );
92 
93  // ... url
94  pqLineEditUrl = new QLineEdit();
95  pqLineEditUrl->setToolTip( tr("URL") );
96  pqLineEditUrl->setText( __poVesselContainer->getUrl() );
97  __pqFormLayout->addRow( tr("URL")+":", pqLineEditUrl );
98 
99  // ... [end]
100  __pqVBoxLayout->addLayout( __pqFormLayout );
101 
102  // Add buttons
103  QDialogButtonBox* __pqDialogButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel|QDialogButtonBox::Save, Qt::Horizontal );
104  QDialog::connect( __pqDialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()) );
105  QDialog::connect( __pqDialogButtonBox, SIGNAL(rejected()), this, SLOT(reject()) );
106  __pqVBoxLayout->addWidget( __pqDialogButtonBox );
107 
108  // Set the layout
109  COverlayObjectEditView::setLayout( __pqVBoxLayout );
110 
111 }
112 
113 
114 //------------------------------------------------------------------------------
115 // METHODS: QDialog (override)
116 //------------------------------------------------------------------------------
117 
119 {
120  CVesselContainer* __poVesselContainer = (CVesselContainer*)poOverlayObject;
121 
122  // Set data
123  // ... name
124  __poVesselContainer->setText( CVesselOverlay::NAME, pqLineEditName->text() ); // NOTE: Container's name will be updated via QTreeWidget::containerChanged()
125  // ... type
126  __poVesselContainer->setType( pqLineEditType->text() );
127  // ... description
128  __poVesselContainer->setDescription( pqTextEditDescription->toPlainText() );
129  // ... comment
130  __poVesselContainer->setComment( pqTextEditComment->toPlainText() );
131  // ... url
132  __poVesselContainer->setUrl( pqLineEditUrl->text() );
133 
134  // Done
135  QDialog::accept();
136 }
[UI] Generic overlay object's edit view
const COverlayObject * poOverlayObject
Overlay object being edited.
QString getName() const
Returns this object's name.
QLineEdit * pqLineEditUrl
[UI:LineEdit] URL
QTextEdit * pqTextEditComment
[UI:TextEdit] Comment
void constructLayout()
Constructs the layout of the user-interface.
CVesselContainerEditView(CVesselContainer *_poVesselContainer)
QTextEdit * pqTextEditDescription
[UI:TextEdit] Description
QLineEdit * pqLineEditType
[UI:LineEdit] Type
QLineEdit * pqLineEditName
[UI:LineEdit] Name
[UI] Vessel overlay container / flotilla
QString getUrl() const
Returns this flotilla's URL.
QString getComment() const
Returns this flotilla's comment.
void setType(const QString &_rqsType)
Sets this flotilla's type.
QString getType() const
Returns this flotilla's type.
void setComment(const QString &_rqsComment)
Sets this flotilla's comment.
void setDescription(const QString &_rqsDescription)
Sets this flotilla's description.
void setUrl(const QString &_rqsUrl)
Sets this flotilla's URL.
QString getDescription() const
Returns this flotilla's description.
@ NAME
Vessel name.