navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
guiProxy.h
Go to the documentation of this file.
1 #ifndef NAVIT_GUI_QML_GUIPROXY_H
2 #define NAVIT_GUI_QML_GUIPROXY_H
3 
4 class NGQProxyGui : public NGQProxy {
5  Q_OBJECT;
6 
7  Q_PROPERTY(QString iconPath READ iconPath CONSTANT);
8 
9  Q_PROPERTY(QString commandFunction READ commandFunction CONSTANT);
10 
11  Q_PROPERTY(QString localeName READ localeName CONSTANT);
12  Q_PROPERTY(QString langName READ langName CONSTANT);
13  Q_PROPERTY(QString ctryName READ ctryName CONSTANT);
14 
15  Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthSignal STORED false);
16  Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightSignal STORED false);
17 
18 private:
19  QStringList returnPath;
20 
21 public:
22  NGQProxyGui(struct gui_priv* this_,QObject *parent) : NGQProxy(this_, parent) {
23  this->source=QString("");
24  }
25 
27  if (this->object->currentPoint!=NULL) {
28  delete this->object->currentPoint;
29  }
30  this->object->currentPoint = new NGQPoint(this->object,p,type,NULL);
31  this->object->guiWidget->rootContext()->setContextProperty("point",this->object->currentPoint);
32  }
34  if (this->object->currentPoint!=NULL) {
35  delete this->object->currentPoint;
36  }
37  this->object->currentPoint = new NGQPoint(this->object,c,type,NULL);
38  this->object->guiWidget->rootContext()->setContextProperty("point",this->object->currentPoint);
39  }
40  void setNewPoint(struct pcoord* pc,NGQPointTypes type) {
41  if (this->object->currentPoint!=NULL) {
42  delete this->object->currentPoint;
43  }
44  this->object->currentPoint = new NGQPoint(this->object,pc,type,NULL);
45  this->object->guiWidget->rootContext()->setContextProperty("point",this->object->currentPoint);
46  }
47  void processCommand(QString function) {
48  //QDeclarativeExpression commandJS(this->object->guiWidget->rootContext(),QString(),qobject_cast<QObject*>(this->object->guiWidget->rootObject()));
49  //commandJS.setSourceLocation("command.js",0);
50  //this->function=function;
51  //commandJS.eval(qobject_cast<QObject*>(this->object->guiWidget->rootObject()));
52  }
53 signals:
54  void widthSignal(int);
55  void heightSignal(int);
56 public slots:
57  void pushPage(QString page) {
58  returnPath.push_front(page);
59  }
60  QString popPage() {
61  if (!returnPath.empty()) {
62  if (returnPath.length()>1) {
63  returnPath.pop_front();
64  }
65  return returnPath.first();
66  }
67  return QString();
68  }
69  int lengthPage() {
70  return returnPath.length();
71  }
72  void backToMap() {
73  if (this->object->graphicsWidget) {
74  this->object->graphicsWidget->setFocus(Qt::ActiveWindowFocusReason);
75  this->object->switcherWidget->setCurrentWidget(this->object->graphicsWidget);
76  this->object->graphicsWidget->show();
77  }
78  }
79  void switchToMenu(struct point* p) {
80  if (!this->object->lazy) {
81  this->returnPath.clear();
82  this->object->guiWidget->setSource(QUrl::fromLocalFile(QString(this->object->source)+"/"+this->object->skin+"/main.qml"));
83  }
84  this->setNewPoint(p,MapPoint);
85  this->object->guiWidget->setFocus(Qt::ActiveWindowFocusReason);
86  this->object->switcherWidget->setCurrentWidget(this->object->guiWidget);
87 
88  }
89  //Properties
90  QString iconPath() {
91  return QString(this->object->icon_src);
92  }
93  int width() {
94  return this->object->w;
95  }
96  void setWidth(int w) {
97  this->object->w=w;
98  this->widthSignal(w);
99  }
100  int height() {
101  return this->object->h;
102  }
103  void setHeight(int h) {
104  this->object->h=h;
105  this->heightSignal(h);
106  }
107  QString commandFunction() {
108  return this->function;
109  }
110 
111  //Locale properties
112  QString localeName() {
113  return QString()+"LANG="+getenv("LANG");
114  }
115  QString langName() {
116 #ifdef HAVE_API_WIN32_BASE
117  char str[32];
118 
119  GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, str, sizeof(str));
120  return QString()+"LOCALE_SABBREVLANGNAME="+str;
121 #else
122  return QString();
123 #endif
124  }
125  QString ctryName() {
126 #ifdef HAVE_API_WIN32_BASE
127  char str[32];
128 
129  GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, str, sizeof(str));
130  return QString()+"LOCALE_SABBREVCTRYNAME="+str;
131 #else
132  return QString();
133 #endif
134  }
135 protected:
136  int getAttrFunc(enum attr_type type, struct attr* attr, struct attr_iter* iter) { return gui_get_attr(this->object->gui, type, attr, iter); }
137  int setAttrFunc(struct attr* attr) {return gui_set_attr(this->object->gui,attr); }
138 private:
139  QString source;
140  QString function;
141 };
142 
143 void __setNewPoint(struct gui_priv* this_,struct coord* c, NGQPointTypes type) {
144  this_->guiProxy->setNewPoint(c,type);
145 }
146 void __setNewPoint(struct gui_priv* this_,struct pcoord* pc, NGQPointTypes type) {
147  this_->guiProxy->setNewPoint(pc,type);
148 }
149 
150 #include "guiProxy.moc"
151 
152 #endif /* NAVIT_GUI_QML_GUIPROXY_H */
QString iconPath()
Definition: guiProxy.h:90
QWidget * graphicsWidget
Definition: gui_qml.cpp:63
NGQProxyGui(struct gui_priv *this_, QObject *parent)
Definition: guiProxy.h:22
attr_type
Definition: attr.h:34
unsigned char p[5]
Definition: mg.h:48
struct gui * gui
Definition: gui_qml.cpp:40
void setNewPoint(struct pcoord *pc, NGQPointTypes type)
Definition: guiProxy.h:40
void setHeight(int h)
Definition: guiProxy.h:103
void pushPage(QString page)
Definition: guiProxy.h:57
tuple iter
Definition: eval.py:8
Definition: gpx2navit_txt.h:51
Definition: ngqpoint.h:32
int lazy
Definition: gui_qml.cpp:55
void setNewPoint(struct point *p, NGQPointTypes type)
Definition: guiProxy.h:26
int gui_get_attr(struct gui *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: gui.c:63
void backToMap()
Definition: guiProxy.h:72
void setWidth(int w)
Definition: guiProxy.h:96
QDeclarativeView * guiWidget
Definition: gui_qml.cpp:64
int height()
Definition: guiProxy.h:100
void widthSignal(int)
char * source
Definition: gui_qml.cpp:50
QString source
Definition: guiProxy.h:139
QString popPage()
Definition: guiProxy.h:60
Definition: graphics_win32.h:52
int lengthPage()
Definition: guiProxy.h:69
QStringList returnPath
Definition: guiProxy.h:16
void processCommand(QString function)
Definition: guiProxy.h:47
Definition: config_.c:48
QString langName()
Definition: guiProxy.h:115
QString localeName()
Definition: guiProxy.h:112
QString ctryName()
Definition: guiProxy.h:125
void __setNewPoint(struct gui_priv *this_, struct coord *c, NGQPointTypes type)
Definition: guiProxy.h:143
Definition: attr.h:156
int setAttrFunc(struct attr *attr)
Definition: guiProxy.h:137
void setNewPoint(struct coord *c, NGQPointTypes type)
Definition: guiProxy.h:33
void switchToMenu(struct point *p)
Definition: guiProxy.h:79
char * icon_src
Definition: gui_qml.cpp:52
Definition: point.h:23
NGQPointTypes
Definition: ngqpoint.h:32
struct gui_priv * object
Definition: proxy.h:89
int getAttrFunc(enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: guiProxy.h:136
Definition: ngqpoint.h:34
char type[3]
Definition: garmin_img.c:130
Definition: coord.h:34
class NGQPoint * currentPoint
Definition: gui_qml.cpp:80
void heightSignal(int)
int width()
Definition: guiProxy.h:93
QString commandFunction()
Definition: guiProxy.h:107
Definition: coord.h:40
Definition: proxy.h:21
Definition: guiProxy.h:4
class NGQProxyGui * guiProxy
Definition: gui_qml.cpp:74
int gui_set_attr(struct gui *this_, struct attr *attr)
Definition: gui.c:80