Esempio n. 1
0
void showGameDialog(){
    if(dialog == 0 && combo == 0){
        dialog = new QDialog;
        QGridLayout* layout = new QGridLayout(dialog);
        combo = new QComboBox(dialog);
        QPushButton* accept = new QPushButton("Accept", dialog);
        dialog->connect(accept, &QPushButton::clicked, dialog, &acceptFunc);
        QPushButton* cancel = new QPushButton("Cancel", dialog);
        dialog->connect(cancel, &QPushButton::clicked, dialog, &QDialog::close);
        layout->addWidget(combo, 0, 0, 1, 2);
        layout->addWidget(accept, 1, 0);
        layout->addWidget(cancel, 1, 1);
        dialog->setLayout(layout);
    }
    combo->clear();
    gameDirs = getSubDirectories("games/");
    QStringList games;
    for(std::string s : gameDirs){
        rapidjson::Document doc;
        if(readJsonFile("games/"+s+"/gameInfo.json", doc)){
            games << doc["name"].GetString();
        } else {
            games << s.c_str();
        }
    }
    combo->addItems(games);
    dialog->exec();
}
Esempio n. 2
0
void getAvailableItems(CollectionItemType type,
                       std::list<std::vector<std::string> > & list,
                       KIM::Log * const log)
{
  std::list<std::pair<std::string, std::string> > paths;
  searchPaths(type, &paths, log);

  std::list<std::pair<std::string, std::string> >::const_iterator itr;
  for (itr = paths.begin(); itr != paths.end(); ++itr)
  {
    std::list<std::string> items;
    getSubDirectories(itr->second, items);

    std::string collection = itr->first;
    std::list<std::string>::const_iterator itemItr;
    for (itemItr = items.begin(); itemItr != items.end(); ++itemItr)
    {
      std::vector<std::string> entry(5);
      entry[IE_COLLECTION] = collection;
      std::size_t split = itemItr->find_last_of("/");
      entry[IE_NAME] = itemItr->substr(split + 1);
      entry[IE_DIR] = itemItr->substr(0, split);

      std::string lib = entry[IE_DIR] + "/" + entry[IE_NAME]
                        + "/" KIM_SHARED_MODULE_PREFIX + KIM_PROJECT_NAME "-";
      switch (type)
      {
        case KIM_MODEL_DRIVERS: lib.append(KIM_MODEL_DRIVER_IDENTIFIER); break;
        case KIM_MODELS: lib.append(KIM_MODEL_IDENTIFIER); break;
        case KIM_SIMULATOR_MODELS:
          lib.append(KIM_SIMULATOR_MODEL_IDENTIFIER);
          break;
      }
      lib.append(KIM_SHARED_MODULE_SUFFIX);
      entry[IE_FULLPATH] = lib;

      KIM::SharedLibrary sharedLibrary(log);

      int error = sharedLibrary.Open(lib);

      if (!error)
      {
        std::string versionString;
        error = sharedLibrary.GetCompiledWithVersion(&versionString);
        if (error) { entry[IE_VER] = "unknown"; }
        else
        {
          entry[IE_VER] = versionString;
        }

        list.push_back(entry);
        sharedLibrary.Close();
      }
    }
  }

  list.sort(lessThan);
}