Qt Virtual Chart Table (QVCT)
CLandmarkContainerEditView.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 <QVBoxLayout>
26 
27 // QVCT
31 
32 
33 //------------------------------------------------------------------------------
34 // CONSTRUCTORS / DESTRUCTOR
35 //------------------------------------------------------------------------------
36 
38  : COverlayObjectEditView( _poLandmarkContainer )
39 {
41 }
42 
44 {
45  // Create layout
46  QVBoxLayout* __pqVBoxLayout = new QVBoxLayout();
47 
48  // Add header
49  QFont __qFontHeader;
50  __qFontHeader.setPixelSize( 16 );
51  __qFontHeader.setBold( true );
52  QHBoxLayout* __pqHBoxLayoutHeader = new QHBoxLayout();
53  QLabel* __pqLabelIcon = new QLabel();
54  __pqLabelIcon->setPixmap( QPixmap( ":icons/32x32/landmark.png" ) );
55  __pqHBoxLayoutHeader->addWidget( __pqLabelIcon, 0, Qt::AlignTop );
56  QLabel* __pqLabelEdit = new QLabel( tr("Edit")+"..." );
57  __pqLabelEdit->setFont( __qFontHeader );
58  __pqHBoxLayoutHeader->addWidget( __pqLabelEdit, 1 );
59  // ... [end]
60  __pqVBoxLayout->addLayout( __pqHBoxLayoutHeader );
61 
62  // Add data
63  CLandmarkContainer* __poLandmarkContainer = (CLandmarkContainer*)poOverlayObject;
64  QFormLayout* __pqFormLayout = new QFormLayout();
65 
66  // ... name
67  pqLineEditName = new QLineEdit();
68  pqLineEditName->setToolTip( tr("Name") );
69  pqLineEditName->setText( __poLandmarkContainer->getName() );
70  __pqFormLayout->addRow( tr("Name")+":", pqLineEditName );
71 
72  // ... [end]
73  __pqVBoxLayout->addLayout( __pqFormLayout );
74 
75  // Add buttons
76  QDialogButtonBox* __pqDialogButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel|QDialogButtonBox::Save, Qt::Horizontal );
77  QDialog::connect( __pqDialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()) );
78  QDialog::connect( __pqDialogButtonBox, SIGNAL(rejected()), this, SLOT(reject()) );
79  __pqVBoxLayout->addWidget( __pqDialogButtonBox );
80 
81  // Set the layout
82  COverlayObjectEditView::setLayout( __pqVBoxLayout );
83 
84 }
85 
86 
87 //------------------------------------------------------------------------------
88 // METHODS: QDialog (override)
89 //------------------------------------------------------------------------------
90 
92 {
93  CLandmarkContainer* __poLandmarkContainer = (CLandmarkContainer*)poOverlayObject;
94 
95  // Set data
96  // ... name
97  __poLandmarkContainer->setText( CLandmarkOverlay::NAME, pqLineEditName->text() ); // NOTE: Container's name will be updated via QTreeWidget::containerChanged()
98 
99  // Done
100  QDialog::accept();
101 }
QLineEdit * pqLineEditName
[UI:LineEdit] Name
void constructLayout()
Constructs the layout of the user-interface.
CLandmarkContainerEditView(CLandmarkContainer *_poLandmarkContainer)
[UI] Landmark overlay container
@ NAME
Landmark name.
[UI] Generic overlay object's edit view
const COverlayObject * poOverlayObject
Overlay object being edited.
QString getName() const
Returns this object's name.