started work on displaying map
authorpavelpa <pavelpa@localhost>
Mon, 18 Jan 2010 21:32:44 +0000 (21:32 +0000)
committerpavelpa <pavelpa@localhost>
Mon, 18 Jan 2010 21:32:44 +0000 (21:32 +0000)
 - implemented mapwindow
 - map is hard-coded for now
TODO: finish getting map path from the event

src/gui/gui.pro
src/gui/mainwindow.cpp
src/gui/mainwindow.h
src/gui/mapwindow.cpp [new file with mode: 0644]
src/gui/mapwindow.h [new file with mode: 0644]
src/gui/mapwindow.ui [new file with mode: 0644]
src/mvc/eventmodel.cpp
src/mvc/treeview.cpp
src/mvc/treeview.h

index 1139109..72cd959 100644 (file)
@@ -26,15 +26,18 @@ maemo {
 FORMS += mainwindow.ui \
          daynavigatorwidget.ui \
          about.ui \
-         eventdialog.ui
+         eventdialog.ui \
+         mapwindow.ui
 
 HEADERS += mainwindow.h \
            daynavigatorwidget.h \
-           eventdialog.h
+           eventdialog.h \
+           mapwindow.h
 
 SOURCES += mainwindow.cpp \
            daynavigatorwidget.cpp \
-           eventdialog.cpp
+           eventdialog.cpp \
+           mapwindow.cpp
 
 maemo {
     FORMS += alarmdialog.ui
index 5aac872..051fded 100644 (file)
@@ -15,6 +15,7 @@
 #include "ui_about.h"
 #include "eventdialog.h"
 #include "daynavigatorwidget.h"
+#include "mapwindow.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
@@ -63,9 +64,15 @@ MainWindow::MainWindow(QWidget *parent)
     actTreeView->setModel(new EventModel());
     actTreeView->setItemDelegate(new Delegate(actTreeView));
 
+    // event double clicked
     connect(dayTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &)));
     connect(favTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &)));
     connect(actTreeView, SIGNAL(doubleClicked(const QModelIndex &)), SLOT(itemDoubleClicked(const QModelIndex &)));
+    // request for map to be displayed
+    connect(dayTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
+    connect(favTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
+    connect(actTreeView, SIGNAL(requestForMap(const QModelIndex &)), SLOT(displayMap(const QModelIndex &)));
+
 
     // TESTING: load some 'fav' data
     if(Conference::getAll().count()) // no conference(s) in the DB
@@ -112,8 +119,6 @@ void MainWindow::importSchedule()
     QFile file("../schedule.en.xml");
     if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
     {
-        QString currPath = QDir::currentPath();
-        qDebug() << "current path: " << currPath;
         qDebug() << "can't open " << file.fileName();
         return;
     }
@@ -191,3 +196,10 @@ void MainWindow::itemDoubleClicked(const QModelIndex &aIndex)
     dialog.exec();
 }
 
+void MainWindow::displayMap(const QModelIndex &aIndex)
+{
+    QPixmap map(":/maps/rooms/janson.png");
+    MapWindow window(map,this);
+    window.exec();
+}
+
index d319576..6d7fcae 100644 (file)
@@ -23,6 +23,7 @@ private slots:
     /*void updateFavViewComplete();*/
     void updateActivitiesDayView(const QDate &aDate);
     void itemDoubleClicked(const QModelIndex &aIndex);
+    void displayMap(const QModelIndex &aIndex);
 private:
     SqlEngine *mSqlEngine;
     ScheduleXmlParser *mXmlParser;
diff --git a/src/gui/mapwindow.cpp b/src/gui/mapwindow.cpp
new file mode 100644 (file)
index 0000000..9141d20
--- /dev/null
@@ -0,0 +1,15 @@
+#include "mapwindow.h"
+
+MapWindow::MapWindow(const QPixmap &aImage, QWidget *aParent)
+    : QDialog(aParent)
+{
+    setupUi(this);
+    setMouseTracking(true); // to receive mouse events
+    map->setPixmap(aImage);
+}
+
+void MapWindow::mouseDoubleClickEvent(QMouseEvent *event)
+{
+    close();
+}
+
diff --git a/src/gui/mapwindow.h b/src/gui/mapwindow.h
new file mode 100644 (file)
index 0000000..7e5a8ff
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef MAPWINDOW_H
+#define MAPWINDOW_H
+
+#include <QDialog>
+#include <QPixmap>
+#include "ui_mapwindow.h"
+
+class MapWindow : public QDialog, Ui::MapWindow
+{
+public:
+    MapWindow(const QPixmap &aImage, QWidget *aParent = NULL);
+    ~MapWindow() {}
+protected:
+    virtual void mouseDoubleClickEvent(QMouseEvent *event);
+};
+
+#endif /* MAPWINDOW_H */
+
diff --git a/src/gui/mapwindow.ui b/src/gui/mapwindow.ui
new file mode 100644 (file)
index 0000000..38e5f3d
--- /dev/null
@@ -0,0 +1,32 @@
+<ui version="4.0" >
+ <class>MapWindow</class>
+ <widget class="QDialog" name="MapWindow" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>298</width>
+    <height>179</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Dialog</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout" >
+   <item row="0" column="0" >
+    <widget class="QLabel" name="map" >
+     <property name="text" >
+      <string>Map goes here</string>
+     </property>
+     <property name="alignment" >
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+  <zorder>map</zorder>
+  <zorder>toolButton</zorder>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index a9801f9..fb14a56 100644 (file)
@@ -61,7 +61,7 @@ void EventModel::createActivityGroups() {
         {
             mGroups.last().mChildCount = i - mGroups.last().mFirstEventIndex;
             mGroups << EventModel::Group(QString("activity %1").arg(activityId), 0);
-            int nextActivityId = activityId;
+            //int nextActivityId = activityId;
         }
         // add parent-child relation
         mParents[mEvents.at(i).id()] = mGroups.count() - 1;
@@ -150,7 +150,7 @@ void EventModel::clearModel()
         QModelIndex idx = index(i, 0);
         Group group = mGroups[i];
         beginRemoveRows(idx, 0, group.mChildCount - 1);
-        bool ok = removeRows(0, group.mChildCount, idx);
+        /*bool ok =*/ removeRows(0, group.mChildCount, idx);
         endRemoveRows();
         //qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok;
     }
index 4d1bc30..89a57fb 100644 (file)
@@ -79,6 +79,7 @@ void TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
             {
                 // handle Alarm Control clicked
                 qDebug() << "MAP CLICKED: " << qVariantValue<QString>(aIndex.data());
+                emit(requestForMap(aIndex));
             }
         break;
         case Delegate::ControlNone:
index fe8e0e2..8851ca5 100644 (file)
@@ -3,15 +3,17 @@
 
 #include <QTreeView>
 
-
 class TreeView : public QTreeView
 {
+    Q_OBJECT
 public:
     TreeView(QWidget *aParent = NULL);
     ~TreeView() {}
 private:
     void mouseReleaseEvent(QMouseEvent *aEvent);
     void testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint);
+signals:
+    void requestForMap(const QModelIndex &aIndex);
 };
 
 #endif /* TREEVIEW_H */