Qt Virtual Chart Table (QVCT)
CVesselContainerDeviceEditView.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 <QLabel>
23 #include <QSpinBox>
24 #include <QVBoxLayout>
25 
26 // QVCT
29 
30 
31 //------------------------------------------------------------------------------
32 // CONSTRUCTORS / DESTRUCTOR
33 //------------------------------------------------------------------------------
34 
36  : COverlayObjectEditView( _poVesselContainerDevice )
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  CVesselContainerDevice* __poVesselContainerDevice = (CVesselContainerDevice*)poOverlayObject;
62  QFormLayout* __pqFormLayout = new QFormLayout();
63  // ... name
64  poTextName = new COverlayText();
65  poTextName->setToolTip( tr("Device name (matching one of the defined devices)") );
66  poTextName->setText( __poVesselContainerDevice->getName() );
67  __pqFormLayout->addRow( tr("Name")+":", poTextName );
68  // ... (vessels) time-to-live
69  pqSpinBoxTTL = new QSpinBox();
70  pqSpinBoxTTL->setRange( 5, 86400 );
71  pqSpinBoxTTL->setToolTip( tr("Vessels Time-To-Live (after which vessels are automatically deleted if no corresponding data are received), in seconds [s]") );
72  pqSpinBoxTTL->setValue( __poVesselContainerDevice->getTTL() );
73  __pqFormLayout->addRow( tr("TTL")+":", pqSpinBoxTTL );
74  // ... [end]
75  __pqVBoxLayout->addLayout( __pqFormLayout );
76 
77  // Add buttons
78  QDialogButtonBox* __pqDialogButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel|QDialogButtonBox::Save, Qt::Horizontal );
79  QDialog::connect( __pqDialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()) );
80  QDialog::connect( __pqDialogButtonBox, SIGNAL(rejected()), this, SLOT(reject()) );
81  __pqVBoxLayout->addWidget( __pqDialogButtonBox );
82 
83  // Set the layout
84  COverlayObjectEditView::setLayout( __pqVBoxLayout );
85 
86 }
87 
88 
89 //------------------------------------------------------------------------------
90 // METHODS: QDialog (override)
91 //------------------------------------------------------------------------------
92 
94 {
95  CVesselContainerDevice* __poVesselContainerDevice = (CVesselContainerDevice*)poOverlayObject;
96 
97  // Set data
98  __poVesselContainerDevice->setTTL( pqSpinBoxTTL->value() );
99 
100  // Done
101  QDialog::accept();
102 }
[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& )
void constructLayout()
Constructs the layout of the user-interface.
CVesselContainerDeviceEditView(CVesselContainerDevice *_poVesselContainerDevice)
QSpinBox * pqSpinBoxTTL
[UI:SpinBox] (Vessels) Time-to-live
int getTTL() const
Returns the (vessels) time-to-live.
void setTTL(int _iTTL)
Sets the (vessels) time-to-live (seconds)