It is not complete so far (it lacks save/load and refresh code), but it already has tests.
QMaemo5HomescreenAdaptor *adaptor = new QMaemo5HomescreenAdaptor (&w);
adaptor->setSettingsAvailable (true);
-
+
w.show ();
return app.exec ();
--- /dev/null
+#include <QtCore>
+
+#include "regions.hpp"
+
+
+RegionsTable::RegionsTable ()
+{
+ // Load saved table, if failed, initialize default table of regions
+ makeDefaultTable ();
+}
+
+
+void RegionsTable::makeDefaultTable ()
+{
+ _map.clear ();
+ _map.insert ("1", RegionInfo ("1", "Moscow"));
+ _map.insert ("10174", RegionInfo ("10174", "St. Petersburg"));
+ _map.insert ("20544", RegionInfo ("20544", "Kiev"));
+ _map.insert ("11162", RegionInfo ("11162", "Ekaterinburg"));
+}
+
+
+const RegionInfo *RegionsTable::lookup (const QString &id) const
+{
+ QMap<QString, RegionInfo>::const_iterator it = _map.find (id);
+
+ if (it == _map.end ())
+ return NULL;
+ else
+ return &*it;
+}
--- /dev/null
+#ifndef __REGIONS_H__
+#define __REGIONS_H__
+
+#include <QtCore>
+
+
+class RegionInfo
+{
+private:
+ QString _id;
+ QString _name;
+
+public:
+ RegionInfo (const QString &id, const QString &name)
+ : _id (id),
+ _name (name)
+ {};
+
+ QString id () const
+ { return _id; };
+
+ QString name () const
+ { return _name; };
+};
+
+
+// Map between region ID and it's information
+class RegionsTable
+{
+private:
+ QMap<QString, RegionInfo> _map;
+
+ void makeDefaultTable ();
+
+public:
+ RegionsTable ();
+
+ const RegionInfo *lookup (const QString &id) const;
+};
+
+#endif // __REGIONS_H__
--- /dev/null
+#include <stdio.h>
+#include <QtCore>
+
+#include <regions.hpp>
+
+
+int main()
+{
+ RegionsTable table;
+ const RegionInfo *ri;
+
+ ri = table.lookup ("1");
+ if (ri)
+ printf ("Region 1 is %s\n", ri->name ().toUtf8 ().constData ());
+ else
+ printf ("Region 1 is not found\n");
+
+ return 0;
+}
+
--- /dev/null
+TEMPLATE = app
+
+SOURCES += main.cpp
+
+include (../../yandex-traffic-core.pri)
--- /dev/null
+TEMPLATE = subdirs
+SUBDIRS = regions
--- /dev/null
+HEADERS += $$PWD/regions.hpp
+SOURCES += $$PWD/regions.cpp
+
+INCLUDEPATH += $$PWD
\ No newline at end of file
SOURCES += main.cpp
HEADERS += mainwidget.hpp
+include (ynadex-traffic-core.pri)
+
desktop.path = /usr/share/applications/hildon-home
desktop.files = yandex-traffic-widget.desktop