-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGlobalCitiesArray.h
More file actions
77 lines (55 loc) · 1.47 KB
/
GlobalCitiesArray.h
File metadata and controls
77 lines (55 loc) · 1.47 KB
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
#ifndef GLOBALCITIESARRAY_H
#define GLOBALCITIESARRAY_H
#include "dbhandler.h"
#include <QQueue>
#include <QStack>
class GlobalCities
{
public:
int count_of_cities;
QQueue<QString> cities_Queue;
QStack<QString> cities_Stack;
void initial()
{
QMessageBox msgBox;
count_of_cities=0;
cities_Queue.clear();
DbHandler dbHandler(DATABASE_PATH,DATABASE_CONNECTION_NAME);
if(dbHandler.open())
{
QSqlQuery query;
query.exec("SELECT Name FROM Cities WHERE IsActive=1");
while(query.next())
{
count_of_cities+=1;
cities_Queue.enqueue(query.value(0).toString());
}
//query.prepare("SELECT COUNT(*) FROM Cities WHERE IsActive=1");
//query.exec();
//query.first();
//count_of_cities = query.value(0).toInt();;
//msgBox.setText(QString::number(count_of_cities));
//msgBox.exec();
dbHandler.close();
}
else
{
msgBox.setText(FAILED_MESSAGE_DATABASE_OPENING);
msgBox.exec();
}
}
int getCitiesCount()
{
return count_of_cities;
}
QQueue<QString> getCitiesQueue()
{
return cities_Queue;
}
QStack<QString> getCitiesStack()
{
return cities_Stack;
}
};
//static QString cities_Array[count_of_cities];
#endif // GLOBALCITIESARRAY_H