Qt Virtual Chart Table (QVCT)
CDeviceCreateView.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 <QComboBox>
21 #include <QDialogButtonBox>
22 #include <QFormLayout>
23 #include <QHBoxLayout>
24 #include <QLabel>
25 #include <QLineEdit>
26 #include <QList>
27 #include <QMap>
28 #include <QVBoxLayout>
29 
30 // QVCT
33 
34 
35 //------------------------------------------------------------------------------
36 // CONSTRUCTORS / DESTRUCTOR
37 //------------------------------------------------------------------------------
38 
40  : QDialog( 0 )
41  , ppoDevice( _ppoDevice )
42  , pqLineEditName( 0 )
43  , pqComboBoxDriver( 0 )
44 {
45  QDialog::setWindowTitle( tr("Create Device")+"..." );
46  *ppoDevice = 0;
48 }
49 
51 {
52  // Create layout
53  QVBoxLayout* __pqVBoxLayout = new QVBoxLayout();
54 
55  // Add form
56  QHBoxLayout* __pqHBoxLayout = new QHBoxLayout();
57  // ... icon
58  QLabel* __pqLabelIcon = new QLabel();
59  __pqLabelIcon->setPixmap( QPixmap( ":icons/32x32/device.png" ) );
60  __pqHBoxLayout->addWidget( __pqLabelIcon, 0 );
61  // ... form
62  QFormLayout* __pqFormLayout = new QFormLayout();
63  // ... name
64  pqLineEditName = new QLineEdit();
65  __pqFormLayout->addRow( tr("Name")+":", pqLineEditName );
66  // ... driver
67  pqComboBoxDriver = new QComboBox();
68  QList<QString> __qListDriverName = CDeviceDriver::names().values();
69  int __iCount = __qListDriverName.count();
70  for( int __i = 0; __i < __iCount; __i++ ) pqComboBoxDriver->addItem( __qListDriverName.at( __i ) );
71  __pqFormLayout->addRow( tr("Driver")+":", pqComboBoxDriver );
72  // ... [end]
73  __pqHBoxLayout->addLayout( __pqFormLayout, 1 );
74  __pqVBoxLayout->addLayout( __pqHBoxLayout );
75 
76  // Add buttons
77  QDialogButtonBox* __pqDialogButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel|QDialogButtonBox::Ok, Qt::Horizontal );
78  QDialog::connect( __pqDialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()) );
79  QDialog::connect( __pqDialogButtonBox, SIGNAL(rejected()), this, SLOT(reject()) );
80  __pqVBoxLayout->addWidget( __pqDialogButtonBox );
81 
82  // Set the layout
83  QDialog::setLayout( __pqVBoxLayout );
84 
85 }
86 
87 
88 //------------------------------------------------------------------------------
89 // METHODS: QDialog (override)
90 //------------------------------------------------------------------------------
91 
93 {
95  QDialog::accept();
96 }
QLineEdit * pqLineEditName
[UI:LineEdit] Device name
CDeviceCreateView(CDevice **_ppoDevice)
CDevice ** ppoDevice
[out] Created device
QComboBox * pqComboBoxDriver
[UI:ComboBox] Device driver
void constructLayout()
Constructs the layout of the user-interface.
virtual void accept()
[override] QDialog::accept()
static EDriver fromName(const QString &_rqsName)
Returns the device driver ID corresponding to the given human-readable name.
static const QMap< EDriver, QString > & names()
Returns the list of supported human-readable device driver names.
static CDevice * createDevice(const QString &_rqsDeviceName, EDriver _eDriver)
Create a new device based on the specified driver.
Generic navigation device (GPS, speedometer, compass, etc.)
Definition: CDevice.hpp:43