/** * KMap::GeoCoordinates are declared as Q_MOVABLE_TYPE, here we test whether the class still * works with Qt's container classes. */ void TestGeoCoordinates::testMovable() { GeoCoordinates::List startList; startList << GeoCoordinates() << GeoCoordinates(5.0, 10.0) << GeoCoordinates(5.0, 10.0, 15.0); GeoCoordinates::List copiedList = startList; // force a deep copy to occur copiedList << GeoCoordinates(); QCOMPARE(copiedList.at(0), GeoCoordinates()); QCOMPARE(copiedList.at(1), GeoCoordinates(5.0, 10.0)); QCOMPARE(copiedList.at(2), GeoCoordinates(5.0, 10.0, 15.0)); // optional code for benchmarks, but I could not detect any difference // with and without Q_MOVABLE_TYPE here, looks like QList does not gain // any speed from Q_MOVABLE_TYPE // QBENCHMARK // { // const int benchSize = 100; // GeoCoordinates::List benchList; // for (int i=0; i<benchSize; ++i) // { // for (int j=0; j<benchSize; ++j) // { // benchList << GeoCoordinates(double(i)/50.0, double(j)/50.0); // } // } // // // QBENCHMARK // { // for (int i=0; i<benchSize*10; ++i) // { // GeoCoordinates::List benchListCopied = benchList; // // // force a deep copy to occur: // benchListCopied[0] = GeoCoordinates(); // benchListCopied << GeoCoordinates(); // } // } // } }
MainWindow::MainWindow(QCommandLineParser* const cmdLineArgs, QWidget* const parent) : QMainWindow(parent), d(new Private()) { // initialize Exiv2 before doing any multitasking MetaEngine::initializeExiv2(); d->treeWidget = new MyTreeWidget(this); d->treeWidget->setColumnCount(2); d->treeWidget->setHeaderLabels(QStringList()<<i18n("Filename")<<i18n("Coordinates")); d->treeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); d->displayMarkersModel = d->treeWidget->model(); d->selectionModel = d->treeWidget->selectionModel(); d->markerModelHelper = new MarkerModelHelper(d->displayMarkersModel, d->selectionModel); d->trackModelHelper = new MyTrackModelHelper(d->treeWidget->model()); ItemMarkerTiler* const mm = new ItemMarkerTiler(d->markerModelHelper, this); resize(512, 512); setWindowTitle(i18n("GeoIface demo")); setWindowIcon(QIcon::fromTheme(QString::fromLatin1("folder-html"))); setObjectName(QLatin1String("Demo-GeoIface" )); d->cmdLineArgs = cmdLineArgs; d->imageLoadingBunchTimer = new QTimer(this); d->imageLoadingBunchTimer->setSingleShot(false); connect(d->imageLoadingBunchTimer, SIGNAL(timeout()), this, SLOT(slotImageLoadingBunchReady())); // create a status bar: statusBar(); createMenus(); d->splitter = new QSplitter(Qt::Vertical, this); setCentralWidget(d->splitter); d->mapWidget = new MapWidget(d->splitter); d->mapWidget->setGroupedModel(mm); d->mapWidget->setActive(true); d->mapWidget->setDragDropHandler(new MyDragDropHandler(d->displayMarkersModel, d->mapWidget)); d->mapWidget->setVisibleMouseModes(GeoIface::MouseModePan|GeoIface::MouseModeZoomIntoGroup|GeoIface::MouseModeSelectThumbnail); d->mapWidget->setAvailableMouseModes(GeoIface::MouseModePan|GeoIface::MouseModeZoomIntoGroup|GeoIface::MouseModeSelectThumbnail); // d->mapWidget->setTrackModel(d->trackModelHelper); connect(d->markerModelHelper, SIGNAL(signalMarkersMoved(QList<QPersistentModelIndex>)), this, SLOT(slotMarkersMoved(QList<QPersistentModelIndex>))); // d->mapWidget->resize(d->mapWidget->width(), 200); d->splitter->addWidget(d->mapWidget); d->splitter->setCollapsible(0, false); d->splitter->setSizes(QList<int>()<<200); d->splitter->setStretchFactor(0, 10); QWidget* const dummyWidget = new QWidget(this); QVBoxLayout* const vbox = new QVBoxLayout(dummyWidget); vbox->addWidget(d->mapWidget->getControlWidget()); vbox->addWidget(d->treeWidget); d->progressBar = new QProgressBar(); d->progressBar->setFormat(i18n("Loading images -")); d->splitter->addWidget(dummyWidget); readSettings(); GeoCoordinates::List markerList; // ice cafe markerList<<GeoCoordinates::fromGeoUrl(QLatin1String("geo:51.0913031421,6.88878178596,44" )); // bar markerList<<GeoCoordinates::fromGeoUrl(QLatin1String("geo:51.06711205,6.90020261667,43" )); // Marienburg castle markerList<<GeoCoordinates::fromGeoUrl(QLatin1String("geo:51.087647318,6.88282728201,44" )); // head of monster markerList<<GeoCoordinates::fromGeoUrl(QLatin1String("geo:51.0889433167,6.88000331667,39.6" )); // Langenfeld markerList<<GeoCoordinates::fromGeoUrl(QLatin1String("geo:51.1100157609,6.94911003113,51" )); // Sagrada Familia in Spain markerList<<GeoCoordinates::fromGeoUrl(QLatin1String("geo:41.4036480511,2.1743756533,46" )); if (cmdLineArgs->isSet(QString::fromLatin1("demopoints_single")) || cmdLineArgs->isSet(QString::fromLatin1("demopoints_group"))) { for (int i = 0; i < markerList.count(); ++i) { QTreeWidgetItem* const treeItem = new QTreeWidgetItem(); treeItem->setText(0, QString::fromLatin1("item %1").arg(i)); treeItem->setText(1, markerList.at(i).geoUrl()); d->treeWidget->addTopLevelItem(treeItem); } } }