void LandmarkFilterDialog::categoryRemoved(const QList<QLandmarkCategoryId> &categoryIds)
{
    if (categoryIds.contains(oldCategoryId)) {
        filterAllCheckBox->setCheckState(Qt::Checked);
        setupFetchRequest();
        emit doFetchAll();
    }
}
QTM_USE_NAMESPACE

LandmarkBrowser::LandmarkBrowser(QWidget *parent, Qt::WindowFlags flags)
    :currentLandmarkOffset(0),
     currentCategoryOffset(0),
     limit(20), filterDialog(0),
     landmarkFetch(0), landmarkImport(0), landmarkExport(0), landmarkRemove(0),
     landmarkSave(0), categoryFetch(0), categoryRemove(0),progress(0),
     manager(0)


{
    setupUi(this);

    categoryTable->removeColumn(2);
    categoryTable->hideColumn(1);
    categoryTable->setHorizontalHeaderItem(0, new QTableWidgetItem("Name"));

    manager = new QLandmarkManager(this);
    if (manager->error() == QLandmarkManager::InvalidManagerError) {
        QMessageBox::warning(this,"Warning", "Manager is invalid closing application, please view any warnings "
                             "on the the console", QMessageBox::Ok, QMessageBox::NoButton);
        QTimer::singleShot(0, this,SLOT(close()));
        return;
    }


    landmarkFetch = new QLandmarkFetchRequest(manager, this);
    QObject::connect(landmarkFetch, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)),
                this,SLOT(fetchHandler(QLandmarkAbstractRequest::State)));

    landmarkImport = new QLandmarkImportRequest(manager, this);
    connect(landmarkImport, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)),
                this,SLOT(fetchHandler(QLandmarkAbstractRequest::State)));

    landmarkExport = new QLandmarkExportRequest(manager, this);
    QObject::connect(landmarkExport, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)),
                this,SLOT(fetchHandler(QLandmarkAbstractRequest::State)));

    landmarkRemove = new QLandmarkRemoveRequest(manager, this);
    landmarkSave = new QLandmarkSaveRequest(manager, this);
    categoryRemove = new QLandmarkCategoryRemoveRequest(manager, this);

     categoryFetch = new QLandmarkCategoryFetchRequest(manager, this);
     QObject::connect(categoryFetch, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)),
                      this,SLOT(fetchHandler(QLandmarkAbstractRequest::State)));

    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    categoryTable->setSelectionBehavior(QAbstractItemView::SelectRows);

    table->setHorizontalHeaderItem(0, new QTableWidgetItem("Lat"));
    table->setHorizontalHeaderItem(1, new QTableWidgetItem("Long"));
    table->setHorizontalHeaderItem(2, new QTableWidgetItem("Name"));

    prevLandmarkButton->setEnabled(false);

    filterDialog = new LandmarkFilterDialog(landmarkFetch, manager, this);
    connect(filterDialog,SIGNAL(doFetchAll()), this, SLOT(doFetchAll()));

    progress = new QProgressDialog (tr("Please wait..."),tr("Cancel"),0,0, this);
    progress->setWindowTitle(tr("Loading Landmarks"));
    QObject::connect(progress,SIGNAL(canceled()), this, SLOT(cancel()));

    landmarkFetch->setLimit(limit);
    landmarkFetch->setOffset(currentLandmarkOffset);
    landmarkFetch->setSorting(QLandmarkNameSort());
    if (!landmarkFetch->start() && landmarkFetch->error() == QLandmarkManager::InvalidManagerError) {
        QMessageBox::warning(this,"Warning", "Manager is invalid closing application", QMessageBox::Ok, QMessageBox::NoButton);
        QTimer::singleShot(0, this,SLOT(close()));
        return;
    }

    categoryFetch->setLimit(limit);
    categoryFetch->setOffset(currentCategoryOffset);
    categoryFetch->start();

    progress->show();

    #ifdef Q_OS_SYMBIAN
        gpxRadioButton->setEnabled(false);
        gpxRadioButton->setVisible(false);
    #endif

        connect(manager, SIGNAL(landmarksAdded(QList<QLandmarkId>)),this,SLOT(landmarksAdded(QList<QLandmarkId>)));
        connect(manager,SIGNAL(landmarksChanged(QList<QLandmarkId>)), this, SLOT(landmarksChanged()));
        connect(manager, SIGNAL(landmarksRemoved(QList<QLandmarkId>)),this,SLOT(landmarksRemoved()));

        connect(manager, SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)), this, SLOT(categoriesAdded()));
        connect(manager, SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)), this,SLOT(categoriesChanged()));
        connect(manager, SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)), this,SLOT(categoriesRemoved()));

        connect(manager, SIGNAL(dataChanged()),this, SLOT(dataChanged()));
}