qmlFrontend/hwengine.cpp
branchqmlfrontend
changeset 10616 20a2d5e6930a
parent 10612 eb3c1a289a23
child 10819 57e21f7621b0
equal deleted inserted replaced
10614:4afb4c4bf495 10616:20a2d5e6930a
    23     resetGameConfig_t * flibResetGameConfig;
    23     resetGameConfig_t * flibResetGameConfig;
    24     getThemesList_t *flibGetThemesList;
    24     getThemesList_t *flibGetThemesList;
    25     freeThemesList_t *flibFreeThemesList;
    25     freeThemesList_t *flibFreeThemesList;
    26     getThemeIcon_t *flibGetThemeIcon;
    26     getThemeIcon_t *flibGetThemeIcon;
    27     getScriptsList_t *flibGetScriptsList;
    27     getScriptsList_t *flibGetScriptsList;
       
    28     getSchemesList_t *flibGetSchemesList;
    28     getTeamsList_t *flibGetTeamsList;
    29     getTeamsList_t *flibGetTeamsList;
    29     tryAddTeam_t * flibTryAddTeam;
    30     tryAddTeam_t * flibTryAddTeam;
    30     tryRemoveTeam_t * flibTryRemoveTeam;
    31     tryRemoveTeam_t * flibTryRemoveTeam;
    31     changeTeamColor_t * flibChangeTeamColor;
    32     changeTeamColor_t * flibChangeTeamColor;
    32 }
    33 }
    60     flibGetThemesList = (getThemesList_t*) hwlib.resolve("getThemesList");
    61     flibGetThemesList = (getThemesList_t*) hwlib.resolve("getThemesList");
    61     flibFreeThemesList = (freeThemesList_t*) hwlib.resolve("freeThemesList");
    62     flibFreeThemesList = (freeThemesList_t*) hwlib.resolve("freeThemesList");
    62     flibGetThemeIcon = (getThemeIcon_t*) hwlib.resolve("getThemeIcon");
    63     flibGetThemeIcon = (getThemeIcon_t*) hwlib.resolve("getThemeIcon");
    63 
    64 
    64     flibGetScriptsList = (getScriptsList_t*) hwlib.resolve("getScriptsList");
    65     flibGetScriptsList = (getScriptsList_t*) hwlib.resolve("getScriptsList");
       
    66     flibGetSchemesList = (getSchemesList_t*) hwlib.resolve("getSchemesList");
    65 
    67 
    66     flibResetGameConfig = (resetGameConfig_t*) hwlib.resolve("resetGameConfig");
    68     flibResetGameConfig = (resetGameConfig_t*) hwlib.resolve("resetGameConfig");
    67     flibGetTeamsList = (getTeamsList_t*) hwlib.resolve("getTeamsList");
    69     flibGetTeamsList = (getTeamsList_t*) hwlib.resolve("getTeamsList");
    68     flibTryAddTeam = (tryAddTeam_t*) hwlib.resolve("tryAddTeam");
    70     flibTryAddTeam = (tryAddTeam_t*) hwlib.resolve("tryAddTeam");
    69     flibTryRemoveTeam = (tryRemoveTeam_t*) hwlib.resolve("tryRemoveTeam");
    71     flibTryRemoveTeam = (tryRemoveTeam_t*) hwlib.resolve("tryRemoveTeam");
   169 void HWEngine::fillModels()
   171 void HWEngine::fillModels()
   170 {
   172 {
   171     QStringList resultModel;
   173     QStringList resultModel;
   172 
   174 
   173     char ** themes = flibGetThemesList();
   175     char ** themes = flibGetThemesList();
   174     for (char **i = themes; *i != NULL; i++) {
   176     for (char **i = themes; *i != NULL; i++)
   175         QString theme = QString::fromUtf8(*i);
   177         resultModel << QString::fromUtf8(*i);
   176 
       
   177         resultModel << theme;
       
   178     }
       
   179     flibFreeThemesList(themes);
   178     flibFreeThemesList(themes);
   180 
   179 
   181     m_engine->rootContext()->setContextProperty("themesModel", QVariant::fromValue(resultModel));
   180     m_engine->rootContext()->setContextProperty("themesModel", QVariant::fromValue(resultModel));
   182 
   181 
       
   182     // scripts model
   183     resultModel.clear();
   183     resultModel.clear();
   184     char ** scripts = flibGetScriptsList();
   184     for (char **i = flibGetScriptsList(); *i != NULL; i++)
   185 
   185         resultModel << QString::fromUtf8(*i);
   186     for (char **i = scripts; *i != NULL; i++) {
       
   187         QString script = QString::fromUtf8(*i);
       
   188 
       
   189         resultModel << script;
       
   190     }
       
   191 
   186 
   192     m_engine->rootContext()->setContextProperty("scriptsModel", QVariant::fromValue(resultModel));
   187     m_engine->rootContext()->setContextProperty("scriptsModel", QVariant::fromValue(resultModel));
       
   188 
       
   189     // schemes model
       
   190     resultModel.clear();
       
   191     for (char **i = flibGetSchemesList(); *i != NULL; i++)
       
   192         resultModel << QString::fromUtf8(*i);
       
   193 
       
   194     m_engine->rootContext()->setContextProperty("schemesModel", QVariant::fromValue(resultModel));
   193 }
   195 }
   194 
   196 
   195 void HWEngine::getTeamsList()
   197 void HWEngine::getTeamsList()
   196 {
   198 {
   197     char ** teams = flibGetTeamsList();
   199     char ** teams = flibGetTeamsList();