Skip to content

Commit 89e74f1

Browse files
committed
Release 0.2.0
1 parent b1c4433 commit 89e74f1

16 files changed

+829
-90
lines changed

DataService.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ void DataService::Init()
106106
if (m_oid == 0)
107107
m_oid = 1000; // 1000 = Anonymous
108108

109+
// Get QTH
110+
rc = sqlite3_prepare(m_database, "SELECT value1 FROM config WHERE key = 'QTH';", -1, &statement, 0);
111+
if (rc == SQLITE_OK)
112+
{
113+
rc = sqlite3_step(statement);
114+
if (rc == SQLITE_ROW)
115+
{
116+
if (sqlite3_column_bytes(statement, 0) > 0)
117+
m_qth = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement, 0)));
118+
}
119+
sqlite3_finalize(statement);
120+
}
121+
109122
m_typeSettings[0].hex_color(getConfig("ColorUnknown"), 0xd94545);
110123
m_typeSettings[1].hex_color(getConfig("ColorTimesignal"), 0xcccccc);
111124
m_typeSettings[2].hex_color(getConfig("ColorMorse"), 0xb12eb3);
@@ -585,4 +598,24 @@ void DataService::SetVfoOffset(int offset) {
585598

586599
bool DataService::UpdateAvailable() {
587600
return version::version != m_remoteAdapter.GetNewestVersion();
588-
}
601+
}
602+
603+
std::string DataService::GetQTH()
604+
{
605+
return m_qth;
606+
}
607+
608+
void DataService::SetQTH(std::string qth)
609+
{
610+
m_qth = util::uppercase(qth);
611+
sqlite3_stmt* statement;
612+
int rc = sqlite3_prepare(m_database, "INSERT OR REPLACE INTO config (key, value1) VALUES ('QTH', ?);", -1, &statement, 0);
613+
if (rc == SQLITE_OK)
614+
{
615+
616+
sqlite3_bind_text(statement, 1, m_qth.c_str(), m_qth.size(), NULL);
617+
sqlite3_step(statement);
618+
sqlite3_finalize(statement);
619+
}
620+
}
621+

DataService.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ class DataService
4141
int GetVfoOffset();
4242
void SetVfoOffset(int offset);
4343

44+
std::string GetQTH();
45+
void SetQTH(std::string qth);
46+
4447
bool UpdateAvailable();
4548

4649
private:
4750
int m_oid;
4851
int m_vfoOffset;
52+
std::string m_qth;
4953
marker::marker_t m_selectedMarker;
5054
settings::types_t m_typeSettings;
5155
std::function<void()> m_dataChangedCallback;

SDRunoPlugin_CloudMarkers.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
<ClCompile Include="Ui\EditWindow.cpp" />
174174
<ClCompile Include="Ui\sdrbutton.cpp" />
175175
<ClCompile Include="Ui\sdrwindow.cpp" />
176+
<ClCompile Include="Ui\CountryWindow.cpp" />
176177
<ClCompile Include="Ui\SettingsWindow.cpp" />
177178
<ClCompile Include="Ui\SyncWindow.cpp" />
178179
<ClCompile Include="Ui\MainWindow.cpp" />
@@ -183,6 +184,7 @@
183184
<ItemGroup>
184185
<ClInclude Include="AnnotatorService.h" />
185186
<ClInclude Include="common.h" />
187+
<ClInclude Include="countries.h" />
186188
<ClInclude Include="remote_dev.h" />
187189
<ClInclude Include="remote_prod.h" />
188190
<ClInclude Include="Plugin.h" />
@@ -192,6 +194,7 @@
192194
<ClInclude Include="Ui\EditWindow.h" />
193195
<ClInclude Include="Ui\sdrbutton.h" />
194196
<ClInclude Include="Ui\sdrwindow.h" />
197+
<ClInclude Include="Ui\CountryWindow.h" />
195198
<ClInclude Include="Ui\SettingsWindow.h" />
196199
<ClInclude Include="Ui\SyncWindow.h" />
197200
<ClInclude Include="Ui\MainWindow.h" />

SDRunoPlugin_CloudMarkers.vcxproj.filters

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
<ClCompile Include="Ui\MainWindow.cpp">
7373
<Filter>Quelldateien\Ui</Filter>
7474
</ClCompile>
75+
<ClCompile Include="Ui\CountryWindow.cpp">
76+
<Filter>Quelldateien\Ui</Filter>
77+
</ClCompile>
7578
</ItemGroup>
7679
<ItemGroup>
7780
<ClInclude Include="Plugin.h">
@@ -128,6 +131,12 @@
128131
<ClInclude Include="Ui\MainWindow.h">
129132
<Filter>Headerdateien\Ui</Filter>
130133
</ClInclude>
134+
<ClInclude Include="Ui\CountryWindow.h">
135+
<Filter>Headerdateien\Ui</Filter>
136+
</ClInclude>
137+
<ClInclude Include="countries.h">
138+
<Filter>Headerdateien</Filter>
139+
</ClInclude>
131140
</ItemGroup>
132141
<ItemGroup>
133142
<ResourceCompile Include="Resource.rc">

Ui/CountryWindow.cpp

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#include "CountryWindow.h"
2+
#include "../countries.h";
3+
4+
#define WIDTH (400)
5+
#define HEIGHT (300)
6+
7+
#define TEXTHEIGHT (24)
8+
#define FULLWIDTH (WIDTH - 40)
9+
#define LEFT (20)
10+
#define ROW(x) (40 + ((x - 1) * 45))
11+
#define TEXTROW(x) (52 + ((x - 1) * 45))
12+
13+
CountryWindow::CountryWindow(nana::form* parent, DataService& dataService, std::string current) :
14+
sdrwindow(parent, "COUNTRIES", WIDTH, HEIGHT, dataService),
15+
m_ituCode(current)
16+
{
17+
}
18+
19+
nana::listbox::oresolver& operator<<(nana::listbox::oresolver& ores, const staticdata::country_t& country)
20+
{
21+
return ores << country.code << country.name;
22+
}
23+
24+
bool findSearchTextInCountry(const std::string& searchText, const staticdata::country_t country)
25+
{
26+
if (searchText.empty())
27+
return true;
28+
29+
auto it = std::search(
30+
country.name.begin(), country.name.end(),
31+
searchText.begin(), searchText.end(),
32+
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); }
33+
);
34+
return (it != country.name.end());
35+
}
36+
37+
void CountryWindow::createWidgets()
38+
{
39+
// Search
40+
m_lblSearchC = makeLabelTitle(LEFT, ROW(1), FULLWIDTH, "COUNTRY NAME");
41+
m_txtSearch = makeTextbox(LEFT, TEXTROW(1), FULLWIDTH, TEXTHEIGHT, false, "Start typing country name ...");
42+
43+
// Results
44+
m_lblResultsC = makeLabelTitle(LEFT, ROW(2), FULLWIDTH, "RESULTS");
45+
m_lstResults = makeListbox(LEFT, TEXTROW(2), FULLWIDTH, 150);
46+
m_lstResults->append_header("ITU", 60);
47+
m_lstResults->append_header("NAME", 260);
48+
49+
// Buttons
50+
m_btnOk = makeButton(20, 260, "OK", "Accept selected country");
51+
if (m_ituCode.empty())
52+
m_btnOk->enabled(false);
53+
54+
m_btnCancel = makeButton(84, 260, "CANCEL", "Cancel selection");
55+
56+
// Events
57+
m_lstResults->events().selected([&](const nana::arg_listbox& arg) {
58+
if (arg.item.selected()) {
59+
m_ituCode = arg.item.text(0);
60+
m_btnOk->enabled(true);
61+
}
62+
else
63+
{
64+
m_ituCode = "";
65+
m_btnOk->enabled(false);
66+
}
67+
});
68+
69+
m_lstResults->events().dbl_click([&] {
70+
if (!m_ituCode.empty())
71+
Close();
72+
});
73+
74+
m_btnOk->events().click([&] {
75+
Close();
76+
});
77+
78+
m_btnCancel->events().click([&] {
79+
m_ituCode = "";
80+
Close();
81+
});
82+
83+
m_txtSearch->events().text_changed([&] {
84+
updateList(m_txtSearch->caption());
85+
});
86+
87+
updateList("");
88+
}
89+
90+
std::string CountryWindow::GetITUCode()
91+
{
92+
return m_ituCode;
93+
}
94+
95+
void CountryWindow::updateList(std::string searchText)
96+
{
97+
m_lstResults->clear();
98+
auto list = m_lstResults->at(0);
99+
for (auto country : staticdata::countries) {
100+
if (findSearchTextInCountry(searchText, country)) {
101+
auto item = list.append(country);
102+
if (country.code == m_ituCode)
103+
item.select(true, true);
104+
}
105+
}
106+
}

Ui/CountryWindow.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
#include <nana/gui.hpp>
4+
#include <nana/gui/widgets/label.hpp>
5+
#include <nana/gui/widgets/textbox.hpp>
6+
#include <nana/gui/widgets/listbox.hpp>
7+
8+
#include "sdrwindow.h"
9+
10+
class CountryWindow : public sdrwindow
11+
{
12+
public:
13+
CountryWindow(nana::form* parent, DataService& dataService, std::string current);
14+
std::string GetITUCode();
15+
16+
private:
17+
std::string m_ituCode;
18+
19+
void createWidgets();
20+
void updateList(std::string searchText);
21+
22+
std::unique_ptr<nana::label> m_lblSearchC;
23+
std::unique_ptr<nana::textbox> m_txtSearch;
24+
std::unique_ptr<nana::label> m_lblResultsC;
25+
std::unique_ptr<nana::listbox> m_lstResults;
26+
std::unique_ptr<nana::sdrbutton> m_btnOk;
27+
std::unique_ptr<nana::sdrbutton> m_btnCancel;
28+
};
29+

0 commit comments

Comments
 (0)