Example #1
0
void Private::setupGameSignals()
{
    QObject *root = m_view.rootObject();
    if ( root ) {
        m_parent->connect( root, SIGNAL(browseMapButtonClicked()),
                           m_parent, SLOT(browseMapButtonClicked()) );
        QObject *gameOptions = root->findChild<QObject*>(QStringLiteral("gameOptions"));

        m_parent->connect( gameOptions, SIGNAL(nextButtonClicked()),
                           m_parent, SLOT(createQuestion()) );
        m_parent->connect( gameOptions, SIGNAL(gameClosed()),
                           m_parent, SLOT(disableGames()) );

        // For "Identify the highlighted country" game
        m_parent->connect( gameOptions, SIGNAL(countryByShapeGameRequested()),
                           m_parent, SLOT(enableCountryShapeGame()) );
        m_parent->connect( m_countryByShape, SIGNAL(gameInitialized()),
                           m_parent, SLOT(createQuestion()) );

        // For "Identify the flag" game
        m_parent->connect( gameOptions, SIGNAL(countryByFlagGameRequested()),
                           m_parent, SLOT(enableCountryFlagGame()) );
        m_parent->connect( m_countryByFlag, SIGNAL(gameInitialized()),
                           m_parent, SLOT(createQuestion()) );

        // For "Click on that country" game
        m_parent->connect( gameOptions, SIGNAL(clickOnThatGameRequested()),
                           m_parent, SLOT(enableClickOnThatGame()) );
        m_parent->connect( m_clickOnThat, SIGNAL(gameInitialized()),
                           m_parent, SLOT(createQuestion()) );
        m_parent->connect( gameOptions, SIGNAL(answerDisplayButtonClicked()),
                           m_clickOnThat, SLOT(highlightCorrectAnswer()) );
    }
}
Example #2
0
void CountryByFlag::initiateGame()
{
    /**
     * First remove the GeoDataDocument, which displays
     * country names, from map.
     */

    if ( !d->m_countryNames ) {
        const GeoDataTreeModel *const treeModel = d->m_marbleWidget->model()->treeModel();
        for ( int i = 0; i < treeModel->rowCount(); ++i ) {
            QVariant const data = treeModel->data ( treeModel->index ( i, 0 ), MarblePlacemarkModel::ObjectPointerRole );
            GeoDataObject *object = qvariant_cast<GeoDataObject*>( data );
            Q_ASSERT_X( object, "CountryByFlag::initiateGame",
                        "failed to get valid data from treeModel for GeoDataObject" );
            if ( object->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
                GeoDataDocument *doc = static_cast<GeoDataDocument*>( object );
                QFileInfo fileInfo( doc->fileName() );
                if ( fileInfo.fileName() == QString("boundaryplacemarks.cache") ) {
                    d->m_countryNames = doc;
                    break;
                }
            }
        }
    }

    if ( d->m_countryNames ) {
        d->m_countryNames->setVisible( false );
        d->m_marbleWidget->model()->treeModel()->updateFeature( d->m_countryNames );
        d->m_marbleWidget->centerOn( 23.0, 42.0 );
        d->m_marbleWidget->setDistance( 7500 );
        d->m_marbleWidget->setHighlightEnabled( false );
        emit gameInitialized();
    }
}
Example #3
0
void CountryByShape::initiateGame()
{
    if ( !d->m_countryNames ) {
        const GeoDataTreeModel *const treeModel = d->m_marbleWidget->model()->treeModel();
        for ( int i = 0; i < treeModel->rowCount(); ++i ) {
            QVariant const data = treeModel->data ( treeModel->index ( i, 0 ), MarblePlacemarkModel::ObjectPointerRole );
            GeoDataObject *object = qvariant_cast<GeoDataObject*>( data );
            Q_ASSERT_X( object, "CountryByShape::initiateGame",
                        "failed to get valid data from treeModel for GeoDataObject" );
            if ( object->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
                GeoDataDocument *doc = static_cast<GeoDataDocument*>( object );
                QFileInfo fileInfo( doc->fileName() );
                if (fileInfo.fileName() == QLatin1String("boundaryplacemarks.cache")) {
                    d->m_countryNames = doc;
                    break;
                }
            }
        }
    }

    if ( !d->m_countryBoundaries ) {
        const GeoDataTreeModel *const treeModel = d->m_marbleWidget->model()->treeModel();
        for ( int i = 0; i < treeModel->rowCount(); ++i ) {
            QVariant const data = treeModel->data ( treeModel->index ( i, 0 ), MarblePlacemarkModel::ObjectPointerRole );
            GeoDataObject *object = qvariant_cast<GeoDataObject*>( data );
            Q_ASSERT_X( object, "MainWindow::initiateGame",
                        "failed to get valid data from treeModel for GeoDataObject" );
            if ( object->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
                GeoDataDocument *const doc = static_cast<GeoDataDocument*>( object );
                QFileInfo fileInfo( doc->fileName() );
                if (fileInfo.fileName() == QLatin1String("ne_50m_admin_0_countries.pn2")) {
                    d->m_countryBoundaries = doc;
                    break;
                }
            }
        }
    }

    d->m_marbleWidget->setHighlightEnabled( true );

    if ( d->m_countryBoundaries &&
         d->m_countryNames )
    {
        d->m_countryNames->setVisible( false );
        d->m_marbleWidget->model()->treeModel()->updateFeature( d->m_countryNames );
        emit gameInitialized();
    }
}