Qt Virtual Chart Table (QVCT)
CVesselPointDeviceEditView.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 <QGridLayout>
22 #include <QLabel>
23 #include <QCheckBox>
24 #include <QVBoxLayout>
25 
26 // QVCT
29 
30 
31 //------------------------------------------------------------------------------
32 // CONSTRUCTORS / DESTRUCTOR
33 //------------------------------------------------------------------------------
34 
36  : COverlayObjectEditView( _poVesselPointDevice )
37 {
39 }
40 
42 {
43  // Create layout
44  QVBoxLayout* __pqVBoxLayout = new QVBoxLayout();
45 
46  // Add header
47  QFont __qFontHeader;
48  __qFontHeader.setPixelSize( 16 );
49  __qFontHeader.setBold( true );
50  QHBoxLayout* __pqHBoxLayoutHeader = new QHBoxLayout();
51  QLabel* __pqLabelIcon = new QLabel();
52  __pqLabelIcon->setPixmap( QPixmap( ":icons/32x32/vessel_device.png" ) );
53  __pqHBoxLayoutHeader->addWidget( __pqLabelIcon, 0, Qt::AlignTop );
54  QLabel* __pqLabelEdit = new QLabel( tr("Edit")+"..." );
55  __pqLabelEdit->setFont( __qFontHeader );
56  __pqHBoxLayoutHeader->addWidget( __pqLabelEdit, 1 );
57  // ... [end]
58  __pqVBoxLayout->addLayout( __pqHBoxLayoutHeader );
59 
60  // Add data
61  CVesselPointDevice* __poVesselPointDevice = (CVesselPointDevice*)poOverlayObject;
62  QGridLayout* __pqGridLayout = new QGridLayout();
63  int __iRow = -1;
64 
65  // ... name
66  __iRow++;
67  __pqGridLayout->addWidget( new QLabel( tr("Device/Source")+":" ), __iRow, 0 );
68  poTextName = new COverlayText();
69  poTextName->setToolTip( tr("Device name (matching one of the defined devices)") );
70  poTextName->setText( __poVesselPointDevice->getName() );
71  __pqGridLayout->addWidget( poTextName, __iRow, 1, Qt::AlignHCenter );
73  poTextSourceName->setToolTip( tr("Source name/filter (exactly matching the device provided source name)") );
74  poTextSourceName->setText( __poVesselPointDevice->getSourceName() );
75  __pqGridLayout->addWidget( poTextSourceName, __iRow, 3, Qt::AlignHCenter );
76 
77  // ... separator
78  __iRow++;
79  __pqGridLayout->addWidget( new QLabel( "<B>"+tr("Synchronize/Update")+"</B>" ), __iRow, 2, Qt::AlignHCenter );
80 
81  // ... position & time (header)
82  __iRow++;
83  __pqGridLayout->addWidget( new QLabel( "<I>"+tr("Position")+"</I>" ), __iRow, 1, Qt::AlignHCenter );
84  __pqGridLayout->addWidget( new QLabel( "<I>"+tr("Elevation")+"</I>" ), __iRow, 2, Qt::AlignHCenter );
85  __pqGridLayout->addWidget( new QLabel( "<I>"+tr("Time")+"</I>" ), __iRow, 3, Qt::AlignHCenter );
86 
87  // ... position & time (data)
88  __iRow++;
89  __pqGridLayout->addWidget( new QLabel( tr("Position & Time")+":" ), __iRow, 0 );
90  pqCheckBoxPosition = new QCheckBox();
91  pqCheckBoxPosition->setToolTip( tr("Whether to use this device to update the vessel position (longitude/latitude)") );
92  pqCheckBoxPosition->setCheckState( __poVesselPointDevice->isSynchronizedPosition() ? Qt::Checked : Qt::Unchecked );
93  __pqGridLayout->addWidget( pqCheckBoxPosition, __iRow, 1, Qt::AlignHCenter );
94  pqCheckBoxElevation = new QCheckBox();
95  pqCheckBoxElevation->setToolTip( tr("Whether to use this device to update the vessel elevation") );
96  pqCheckBoxElevation->setCheckState( __poVesselPointDevice->isSynchronizedElevation() ? Qt::Checked : Qt::Unchecked );
97  __pqGridLayout->addWidget( pqCheckBoxElevation, __iRow, 2, Qt::AlignHCenter );
98  pqCheckBoxTime = new QCheckBox();
99  pqCheckBoxTime->setToolTip( tr("Whether to use this device to update the vessel time") );
100  pqCheckBoxTime->setCheckState( __poVesselPointDevice->isSynchronizedTime() ? Qt::Checked : Qt::Unchecked );
101  __pqGridLayout->addWidget( pqCheckBoxTime, __iRow, 3, Qt::AlignHCenter );
102 
103  // ... course (header)
104  __iRow++;
105  __pqGridLayout->addWidget( new QLabel( "<I>"+tr("Bearing")+"</I>" ), __iRow, 1, Qt::AlignHCenter );
106  __pqGridLayout->addWidget( new QLabel( "<I>"+tr("Speed (horizontal)")+"</I>" ), __iRow, 2, Qt::AlignHCenter );
107  __pqGridLayout->addWidget( new QLabel( "<I>"+tr("Speed (vertical)")+"</I>" ), __iRow, 3, Qt::AlignHCenter );
108 
109  // ... ground course
110  __iRow++;
111  __pqGridLayout->addWidget( new QLabel( tr("Ground Course")+":" ), __iRow, 0 );
112  pqCheckBoxGroundBearing = new QCheckBox();
113  pqCheckBoxGroundBearing->setToolTip( tr("Whether to use this device to update the vessel ground (true) bearing") );
114  pqCheckBoxGroundBearing->setCheckState( __poVesselPointDevice->isSynchronizedGroundBearing() ? Qt::Checked : Qt::Unchecked );
115  __pqGridLayout->addWidget( pqCheckBoxGroundBearing, __iRow, 1, Qt::AlignHCenter );
116  pqCheckBoxGroundSpeed = new QCheckBox();
117  pqCheckBoxGroundSpeed->setToolTip( tr("Whether to use this device to update the vessel ground (true) horizontal speed") );
118  pqCheckBoxGroundSpeed->setCheckState( __poVesselPointDevice->isSynchronizedGroundSpeed() ? Qt::Checked : Qt::Unchecked );
119  __pqGridLayout->addWidget( pqCheckBoxGroundSpeed, __iRow, 2, Qt::AlignHCenter );
120  pqCheckBoxGroundSpeedVertical = new QCheckBox();
121  pqCheckBoxGroundSpeedVertical->setToolTip( tr("Whether to use this device to update the vessel ground (true) vertical speed") );
122  pqCheckBoxGroundSpeedVertical->setCheckState( __poVesselPointDevice->isSynchronizedGroundSpeedVertical() ? Qt::Checked : Qt::Unchecked );
123  __pqGridLayout->addWidget( pqCheckBoxGroundSpeedVertical, __iRow, 3, Qt::AlignHCenter );
124 
125  // ... apparent course
126  __iRow++;
127  __pqGridLayout->addWidget( new QLabel( tr("Apparent Course")+":" ), __iRow, 0 );
128  pqCheckBoxApparentBearing = new QCheckBox();
129  pqCheckBoxApparentBearing->setToolTip( tr("Whether to use this device to update the vessel apparent (relative) bearing") );
130  pqCheckBoxApparentBearing->setCheckState( __poVesselPointDevice->isSynchronizedApparentBearing() ? Qt::Checked : Qt::Unchecked );
131  __pqGridLayout->addWidget( pqCheckBoxApparentBearing, __iRow, 1, Qt::AlignHCenter );
132  pqCheckBoxApparentSpeed = new QCheckBox();
133  pqCheckBoxApparentSpeed->setToolTip( tr("Whether to use this device to update the vessel apparent (relative) horizontal speed") );
134  pqCheckBoxApparentSpeed->setCheckState( __poVesselPointDevice->isSynchronizedApparentSpeed() ? Qt::Checked : Qt::Unchecked );
135  __pqGridLayout->addWidget( pqCheckBoxApparentSpeed, __iRow, 2, Qt::AlignHCenter );
136  pqCheckBoxApparentSpeedVertical = new QCheckBox();
137  pqCheckBoxApparentSpeedVertical->setToolTip( tr("Whether to use this device to update the vessel apparent (relative) vertical speed") );
138  pqCheckBoxApparentSpeedVertical->setCheckState( __poVesselPointDevice->isSynchronizedApparentSpeedVertical() ? Qt::Checked : Qt::Unchecked );
139  __pqGridLayout->addWidget( pqCheckBoxApparentSpeedVertical, __iRow, 3, Qt::AlignHCenter );
140 
141  // ... other (header)
142  __iRow++;
143  __pqGridLayout->addWidget( new QLabel( "<I>"+tr("Additional Text")+"</I>" ), __iRow, 1, Qt::AlignHCenter );
144 
145  // ... other
146  __iRow++;
147  __pqGridLayout->addWidget( new QLabel( tr("Other")+":" ), __iRow, 0 );
148  pqCheckBoxText = new QCheckBox();
149  pqCheckBoxText->setToolTip( tr("Whether to use this device to update the vessel additional textual information") );
150  pqCheckBoxText->setCheckState( __poVesselPointDevice->isSynchronizedText() ? Qt::Checked : Qt::Unchecked );
151  __pqGridLayout->addWidget( pqCheckBoxText, __iRow, 1, Qt::AlignHCenter );
152 
153  // ... [end]
154  __pqVBoxLayout->addLayout( __pqGridLayout );
155 
156  // Add buttons
157  QDialogButtonBox* __pqDialogButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel|QDialogButtonBox::Save, Qt::Horizontal );
158  QDialog::connect( __pqDialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()) );
159  QDialog::connect( __pqDialogButtonBox, SIGNAL(rejected()), this, SLOT(reject()) );
160  __pqVBoxLayout->addWidget( __pqDialogButtonBox );
161 
162  // Set the layout
163  COverlayObjectEditView::setLayout( __pqVBoxLayout );
164 
165 }
166 
167 
168 //------------------------------------------------------------------------------
169 // METHODS: QDialog (override)
170 //------------------------------------------------------------------------------
171 
173 {
174  CVesselPointDevice* __poVesselPointDevice = (CVesselPointDevice*)poOverlayObject;
175 
176  // Set data
177  __poVesselPointDevice->setSynchronized( pqCheckBoxPosition->checkState() == Qt::Checked,
178  pqCheckBoxElevation->checkState() == Qt::Checked,
179  pqCheckBoxTime->checkState() == Qt::Checked,
180  pqCheckBoxGroundBearing->checkState() == Qt::Checked,
181  pqCheckBoxGroundSpeed->checkState() == Qt::Checked,
182  pqCheckBoxGroundSpeedVertical->checkState() == Qt::Checked,
183  pqCheckBoxApparentBearing->checkState() == Qt::Checked,
184  pqCheckBoxApparentSpeed->checkState() == Qt::Checked,
185  pqCheckBoxApparentSpeedVertical->checkState() == Qt::Checked,
186  pqCheckBoxText->checkState() == Qt::Checked );
187 
188  // Done
189  QDialog::accept();
190 }
QString getSourceName() const
Returns the source name.
[UI] Generic overlay object's edit view
const COverlayObject * poOverlayObject
Overlay object being edited.
QString getName() const
Returns this object's name.
[UI] Overlay-specific text label
void setText(const QString &_rqsText)
[override] QLabel::setText( const QString& )
QCheckBox * pqCheckBoxApparentSpeedVertical
[UI:CheckBox] Synchronize apparent vertical speed
COverlayText * poTextName
[UI:Label] Name
QCheckBox * pqCheckBoxElevation
[UI:CheckBox] Synchronize elevation
QCheckBox * pqCheckBoxGroundBearing
[UI:CheckBox] Synchronize ground bearing
QCheckBox * pqCheckBoxPosition
[UI:CheckBox] Synchronize position
QCheckBox * pqCheckBoxText
[UI:CheckBox] Synchronize additional textual data string
QCheckBox * pqCheckBoxTime
[UI:CheckBox] Synchronize time
QCheckBox * pqCheckBoxGroundSpeedVertical
[UI:CheckBox] Synchronize ground vertical speed
QCheckBox * pqCheckBoxApparentBearing
[UI:CheckBox] Synchronize apparent bearing
QCheckBox * pqCheckBoxGroundSpeed
[UI:CheckBox] Synchronize ground horizontal speed
CVesselPointDeviceEditView(CVesselPointDevice *_poVesselPointDevice)
COverlayText * poTextSourceName
[UI:Label] Source name
void constructLayout()
Constructs the layout of the user-interface.
QCheckBox * pqCheckBoxApparentSpeed
[UI:CheckBox] Synchronize apparent horizontal speed
[UI] Vessel device
bool isSynchronizedElevation()
Returns whether this device/source is used to synchronize the vessel's elevation.
bool isSynchronizedApparentBearing()
Returns whether this device/source is used to synchronize the vessel's apparent bearing.
bool isSynchronizedGroundBearing()
Returns whether this device/source is used to synchronize the vessel's ground bearing.
bool isSynchronizedPosition()
Returns whether this device/source is used to synchronize the vessel's position.
void setSynchronized(bool _bSynchronizePosition, bool _bSynchronizeElevation, bool _bSynchronizeTime, bool _bSynchronizeGroundBearing, bool _bSynchronizeGroundSpeed, bool _bSynchronizeGroundSpeedVertical, bool _bSynchronizeApparentBearing, bool _bSynchronizeApparentSpeed, bool _bSynchronizeApparentSpeedVertical, bool _bSynchronizeText)
Sets the synchronizazion flags.
bool isSynchronizedGroundSpeed()
Returns whether this device/source is used to synchronize the vessel's ground horizontal speed.
bool isSynchronizedTime()
Returns whether this device/source is used to synchronize the vessel's time.
bool isSynchronizedApparentSpeed()
Returns whether this device/source is used to synchronize the vessel's apparent horizontal speed.
bool isSynchronizedGroundSpeedVertical()
Returns whether this device/source is used to synchronize the vessel's ground vertical speed.
bool isSynchronizedText()
Returns whether this device/source is used to synchronize the vessel's additional textual data string...
bool isSynchronizedApparentSpeedVertical()
Returns whether this device/source is used to synchronize the vessel's apparent vertical speed.