-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCountryDialog.cpp
100 lines (76 loc) · 2.47 KB
/
CountryDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
Stratofier Stratux AHRS Display
(c) 2018 Allen K. Lair, Sky Fun
*/
#include <QScroller>
#include <QListWidget>
#include <QSettings>
#include "CountryDialog.h"
extern QSettings *g_pSet;
CountryDialog::CountryDialog( QWidget *pParent, CanvasConstants *pC )
: QDialog( pParent, Qt::Dialog | Qt::FramelessWindowHint ),
m_pC( pC )
{
setupUi( this );
QScroller::grabGesture( m_pAirportList, QScroller::LeftMouseButtonGesture );
QScroller::grabGesture( m_pAirspaceList, QScroller::LeftMouseButtonGesture );
populateCountriesAirports();
populateCountriesAirspaces();
m_pOKButton->setMinimumHeight( 100 );
connect( m_pOKButton, SIGNAL( clicked() ), this, SLOT( ok() ) );
}
CountryDialog::~CountryDialog()
{
}
void CountryDialog::populateCountriesAirports()
{
QVariantList countries = g_pSet->value( "CountryAirports", QVariantList() ).toList();
QVariant country;
QListWidgetItem *pCountryItem;
foreach( country, countries )
{
pCountryItem = m_pAirportList->item( country.toInt() );
if( pCountryItem != nullptr )
pCountryItem->setSelected( true );
}
}
void CountryDialog::populateCountriesAirspaces()
{
QVariantList countries = g_pSet->value( "CountryAirspaces", QVariantList() ).toList();
QVariant country;
QListWidgetItem *pCountryItem;
foreach( country, countries )
{
pCountryItem = m_pAirspaceList->item( country.toInt() );
if( pCountryItem != nullptr )
pCountryItem->setSelected( true );
}
}
void CountryDialog::ok()
{
QListWidgetItem *pCountry;
int iC;
for( iC = 0; iC < m_pAirportList->count(); iC++ )
{
pCountry = m_pAirportList->item( iC );
if( pCountry != nullptr )
{
if( pCountry->isSelected() )
m_countryListAirports.append( static_cast<Canvas::CountryCodeAirports>( iC ) );
else
m_deleteCountryListAirports.append( static_cast<Canvas::CountryCodeAirports>( iC ) );
}
}
for( iC = 0; iC < m_pAirspaceList->count(); iC++ )
{
pCountry = m_pAirspaceList->item( iC );
if( pCountry != nullptr )
{
if( pCountry->isSelected() )
m_countryListAirspaces.append( static_cast<Canvas::CountryCodeAirspace>( iC ) );
else
m_deleteCountryListAirspaces.append( static_cast<Canvas::CountryCodeAirspace>( iC ) );
}
}
accept();
}