MainWindow::MainWindow(const StatePtr & state ): QMainWindow(), m_state(state), m_br(this, state) { m_map = new MarbleMap(this, m_state); m_map->setMapThemeId("earth/openstreetmap/openstreetmap.dgml"); m_nodesTableModel = new GraphNodesTableModel(this, m_state); m_edgesTableModel = new GraphEdgesTableModel(this, m_state); m_nodesTableView = new QTableView(this); m_nodesTableView->setModel(m_nodesTableModel); m_edgesTableView = new QTableView(this); m_edgesTableView->setModel(m_edgesTableModel); m_nodesTableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeMode::Stretch); m_edgesTableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeMode::Stretch); QHBoxLayout * cfgLayout = new QHBoxLayout(this); m_routerSelection = new QComboBox(this); m_routerSelection->addItem("Hop distance", QVariant(Router::HOP_DISTANCE)); m_routerSelection->addItem("Dijkstra std::set distance", QVariant(Router::DIJKSTRA_SET_DISTANCE)); m_routerSelection->addItem("Dijkstra std::set time", QVariant(Router::DIJKSTRA_SET_TIME)); m_routerSelection->addItem("Dijkstra std::priority_queue distance", QVariant(Router::DIJKSTRA_PRIO_QUEUE_DISTANCE)); m_routerSelection->addItem("Dijkstra std::priority_queue time", QVariant(Router::DIJKSTRA_PRIO_QUEUE_TIME)); m_accessType = new QComboBox(this); m_accessType->addItem("Foot", Graph::Edge::AT_FOOT); m_accessType->addItem("Bike", Graph::Edge::AT_BIKE); m_accessType->addItem("Car", Graph::Edge::AT_CAR); cfgLayout->addWidget(m_routerSelection); cfgLayout->addWidget(m_accessType); QWidget * cfgWidget = new QWidget(this); cfgWidget->setLayout(cfgLayout); m_statsLabel = new QLabel(this); QHBoxLayout * cfgStatsLayout = new QHBoxLayout(this); cfgStatsLayout->addWidget(cfgWidget); cfgStatsLayout->addWidget(m_statsLabel); QWidget * cfgStatsWidget = new QWidget(this); cfgStatsWidget->setLayout(cfgStatsLayout); QVBoxLayout * leftLayout = new QVBoxLayout(this); leftLayout->addWidget(m_nodesTableView, 5); leftLayout->addWidget(m_edgesTableView, 5); leftLayout->addWidget(cfgStatsWidget, 1); QWidget * leftLayoutWidget = new QWidget(this); leftLayoutWidget->setLayout(leftLayout); QHBoxLayout * mainLayout = new QHBoxLayout(this); mainLayout->addWidget(leftLayoutWidget, 2); mainLayout->addWidget(m_map, 3); connect(m_nodesTableView, SIGNAL(doubleClicked(QModelIndex)), m_nodesTableModel, SLOT(doubleClicked(QModelIndex))); connect(m_nodesTableView->horizontalHeader(), SIGNAL(sectionClicked(int)), m_nodesTableModel, SLOT(headerClicked(int))); connect(m_edgesTableView, SIGNAL(doubleClicked(QModelIndex)), m_edgesTableModel, SLOT(doubleClicked(QModelIndex))); connect(m_edgesTableView->horizontalHeader(), SIGNAL(sectionClicked(int)), m_edgesTableModel, SLOT(headerClicked(int))); connect(m_nodesTableModel, SIGNAL(startEdgeClicked(uint32_t)), this, SLOT(scrollToNodeEdges(uint32_t))); connect(m_nodesTableModel, SIGNAL(toggleNodeClicked(uint32_t)), this, SLOT(toggleNode(uint32_t))); connect(m_nodesTableModel, SIGNAL(clearShownNodesClicked()), this, SLOT(clearShownNodes())); connect(m_nodesTableModel, SIGNAL(nodeCoordinateClicked(uint32_t)), m_map, SLOT(zoomToNode(uint32_t))); connect(this, SIGNAL(shownNodesChanged()), m_nodesTableModel, SLOT(resetData())); connect(m_edgesTableModel, SIGNAL(sourceNodeClicked(uint32_t)), this, SLOT(scrollToNode(uint32_t))); connect(m_edgesTableModel, SIGNAL(targetNodeClicked(uint32_t)), this, SLOT(scrollToNode(uint32_t))); connect(m_edgesTableModel, SIGNAL(toggleEdgeClicked(uint32_t)), this, SLOT(toggleEdge(uint32_t))); connect(m_edgesTableModel, SIGNAL(clearShownEdgesClicked()), this, SLOT(clearShownEdges())); connect(this, SIGNAL(shownEdgesChanged()), m_edgesTableModel, SLOT(resetData())); connect(m_routerSelection, SIGNAL(currentIndexChanged(int)), this, SLOT(routerConfigChanged())); connect(m_accessType, SIGNAL(currentIndexChanged(int)), this, SLOT(routerConfigChanged())); //connect background router connect(&m_br, SIGNAL(routeCalculated(Graph::Route,double)), this, SLOT(routeCalculated(Graph::Route,double))); //connect marble map connect(m_map, SIGNAL(calculateRoute(double,double,double,double)), this, SLOT(calculateRoute(double,double,double,double))); connect(this, SIGNAL(routeCalculated(Graph::Route)), m_map, SLOT(displayRoute(Graph::Route))); connect(this, SIGNAL(shownEdgesChanged()), m_map, SLOT(shownEdgesChanged())); connect(this, SIGNAL(shownNodesChanged()), m_map, SLOT(shownNodesChanged())); //set the router, will also correctly initalize it m_routerSelection->setCurrentIndex(0); m_accessType->setCurrentIndex(0); routerConfigChanged(); QWidget * centralWidget = new QWidget(this); centralWidget->setLayout(mainLayout); setCentralWidget(centralWidget); }
int main(int argc, char *argv[] ) { QApplication app(argc, argv); QCoreApplication::setOrganizationName("ZouBa"); QCoreApplication::setOrganizationDomain("zouba.yi.org"); QCoreApplication::setApplicationName("ZouBa"); Locations* locations = Locations::GetInstance(); Locations *other_locations = Locations::GetInstance(); if (locations->size() == 0) { locations->addEditLocation(new Location("2558542", "6676458", "Home")); locations->addEditLocation(new Location("2540835", "6672773", "Work")); } #ifdef Q_WS_MAEMO_5 SearchDisplay *mainWindow = new SearchDisplay(); //layout->addWidget(win); #else //DesktopWindow* mainWindow = new DesktopWindow(); SearchDisplay *mainWindow = new SearchDisplay(); #endif mainWindow->show(); if (locations == other_locations) qDebug() << "Same instance"; else qDebug() << "!!NOT SAME INSTANCE!!"; #ifdef BUILD_TWO_GUIS #ifdef Q_WS_MAEMO_5 QMainWindow *oldMainWindow = new QMainWindow; UiClass *ui = new UiClass;; ui->setupUi(oldMainWindow); UiController *uiController = new UiController( ui ); Route *route = new Route(); //#ifdef Q_WS_MAEMO_5 GpsController *gpsController = new GpsController(); //#endif QObject::connect( route, SIGNAL( routeReady( QList<RouteData> ) ), uiController, SLOT( displayRoute( QList<RouteData> ) ) ); /*QObject::connect( gpsController, SIGNAL( gpsLocationChanged( Location* ) ), uiController, SLOT() );*/ QObject::connect( uiController, SIGNAL(fromChanged(Location*)), route, SLOT(setFromLocation(Location*))); QObject::connect( uiController, SIGNAL(toChanged(Location*)), route, SLOT(setToLocation(Location*))); QObject::connect( uiController, SIGNAL(routeSearchRequested()), route, SLOT(searchRoute())); QObject::connect( route, SIGNAL(busy(bool)), ui, SLOT(setBusy(bool))); //#ifdef Q_WS_MAEMO_5 QObject::connect( ui->m_UseGpsAction, SIGNAL(toggled(bool)), gpsController, SLOT(useGPS(bool))); //#endif oldMainWindow->show(); #endif // Q_WS_MAEMO_5 #endif // BUILD_TWO_GUIS //Locations::destroyLocations(); return app.exec(); }