void testFilterBox() {
        QLandmarkBoxFilter boxFilter(QGeoCoordinate(20,30),QGeoCoordinate(10,40));

        //landmark is in box
        QLandmark lm;
        lm.setCoordinate(QGeoCoordinate(15,35));
        QVERIFY(MockEngine::testFilter(boxFilter,lm));

        //landmark is outside box
        lm.setCoordinate(QGeoCoordinate(50,50));
        QVERIFY(!MockEngine::testFilter(boxFilter,lm));

        //test landmark inside box when box crosses dateline
        QGeoBoundingBox box;
        box.setTopLeft(QGeoCoordinate(20,170));
        box.setBottomRight(QGeoCoordinate(10,-170));
        boxFilter.setBoundingBox(box);

        lm.setCoordinate(QGeoCoordinate(15,-175));
        QVERIFY(MockEngine::testFilter(boxFilter, lm));

        lm.setCoordinate(QGeoCoordinate(15, 175));
        QVERIFY(MockEngine::testFilter(boxFilter, lm));


        //test landmark outside box when box crosses dateline
        lm.setCoordinate(QGeoCoordinate(15, 160));
        QVERIFY(!MockEngine::testFilter(boxFilter, lm));

        lm.setCoordinate(QGeoCoordinate(15, -160));
        QVERIFY(!MockEngine::testFilter(boxFilter, lm));
    }
bool LandmarkFilterDialog::setupFetchRequest()
{
    if (filterAllCheckBox->checkState() == Qt::Checked) {
        fetchRequest->setFilter(QLandmarkFilter());
        fetchRequest->setSorting(QLandmarkNameSort());
    } else {
        QLandmarkIntersectionFilter filter;
        QLandmarkSortOrder sortOrder = QLandmarkNameSort();

        if (filterNameCheckBox->checkState() == Qt::Checked) {
            QLandmarkNameFilter nameFilter;
            nameFilter.setName(nameLineEdit->text());
            if (startsWithRadioButton->isChecked())
                nameFilter.setMatchFlags(QLandmarkFilter::MatchStartsWith);
            else
                nameFilter.setMatchFlags(QLandmarkFilter::MatchContains);
            filter.append(nameFilter);
        }

        if (filterCategoryCheckBox->checkState() == Qt::Checked) {
            QLandmarkCategoryFilter categoryFilter;
            if (categoryComboBox->count() > 0) {
                oldCategoryId = categoryComboBox->itemData(categoryComboBox->currentIndex())
                            .value<QLandmarkCategoryId>();
                categoryFilter.setCategoryId(oldCategoryId);
            }
            filter.append(categoryFilter);
        }

        if (filterBoxCheckBox->checkState() == Qt::Checked) {

            if (!isValidLatitude(boxTopLeftLatitudeLineEdit->text())) {
                QMessageBox::warning(this,"Warning", "Top left latitude is invalid.  Must be between -90 and 90 (not inclusive)", QMessageBox::Ok, QMessageBox::NoButton);
                return false;
            }
            else if (!isValidLongitude(boxTopLeftLongitudeLineEdit->text())) {
                QMessageBox::warning(this,"Warning", "Top left longitude is invalid. Must be between -180 and 180 (inclusive) ", QMessageBox::Ok, QMessageBox::NoButton);
                return false;
            }
            else if (!isValidLatitude(boxBottomRightLatitudeLineEdit->text())) {
                QMessageBox::warning(this,"Warning", "Bottom right latitude is invalid. (Must be between -90 and 90 (not inclusive)", QMessageBox::Ok, QMessageBox::NoButton);
                return false;
            }
            else if (!isValidLongitude(boxBottomRightLongitudeLineEdit->text())) {
                QMessageBox::warning(this,"Warning", "Bottom right longitude is invalid. (Must be between -180 and 180 (inclusive)", QMessageBox::Ok, QMessageBox::NoButton);
                return false;
            }

            QGeoCoordinate topLeft;
            topLeft.setLatitude(boxTopLeftLatitudeLineEdit->text().toDouble());
            topLeft.setLongitude(boxTopLeftLongitudeLineEdit->text().toDouble());
            QGeoCoordinate bottomRight;
            bottomRight.setLatitude(boxBottomRightLatitudeLineEdit->text().toDouble());
            bottomRight.setLongitude(boxBottomRightLongitudeLineEdit->text().toDouble());

            QGeoBoundingBox box;
            box.setTopLeft(topLeft);
            box.setBottomRight(bottomRight);
            QLandmarkBoxFilter boxFilter;
            boxFilter.setBoundingBox(box);
            filter.append(boxFilter);
        }

        if (filterProximityCheckBox->checkState() == Qt::Checked) {
            if (!isValidLatitude(proximityLatitudeLineEdit->text())) {
                QMessageBox::warning(this,"Warning", "Proximity latitude is invalid.  It must be between -90 and 90 (not inclusive)", QMessageBox::Ok, QMessageBox::NoButton);
                return false;
            } else if (!isValidLongitude(proximityLongitudeLineEdit->text())) {
                QMessageBox::warning(this,"Warning", "Proximity longitude is invalid. It must be between -180 and 180 (inclusive) ", QMessageBox::Ok, QMessageBox::NoButton);
                return false;
            }
            bool ok;
            qreal radius = radiusLineEdit->text().toDouble(&ok);
            if (!ok) {
                QMessageBox::warning(this,"Warning", "Proximity radius is invalid. It must be a number", QMessageBox::Ok, QMessageBox::NoButton);
                return false;
            }

            QLandmarkProximityFilter proximityFilter;
            QGeoCoordinate center;
            center.setLatitude(proximityLatitudeLineEdit->text().toDouble());
            center.setLongitude(proximityLongitudeLineEdit->text().toDouble());
            proximityFilter.setCenter(center);
            proximityFilter.setRadius(radiusLineEdit->text().toDouble());
            filter.append(proximityFilter);
            sortOrder = QLandmarkSortOrder();
        }

        fetchRequest->setFilter(filter);
        fetchRequest->setSorting(sortOrder);
    }
    return true;
}