コード例 #1
0
ファイル: adamantshopplugin.cpp プロジェクト: Novynn/Adamant
void AdamantShopPlugin::loadShops(const QStringList &currentLeagues) {
    _shops.clear();

    QStringList leagues = currentLeagues;

    // NOTE(rory): Load leagues
    auto list = shopsPath().entryInfoList({"*.shop"});
    for (QFileInfo info : list) {
        if (leagues.contains(info.baseName())) continue;
        leagues.append(info.baseName());
    }

    // NOTE(rory):
    for (const QString& league : leagues) {
        if (_shops.contains(league)) continue;
        bool disabled = !currentLeagues.contains(league);

        auto shop = loadShop(shopsPath().absoluteFilePath(QString("%1.shop").arg(league)));

        if (!shop)  {
            shop = new Shop(league);
            shop->setUnused();
        }
        shop->setDisabled(disabled);

        _shops.insert(shop->league(), shop);
        _viewer->addShop(shop);
    }
}
コード例 #2
0
ファイル: logindialog.cpp プロジェクト: Kashbel/acquisition
void LoginDialog::OnMainPageFinished() {
    QNetworkReply *reply = qobject_cast<QNetworkReply *>(QObject::sender());
    QString html(reply->readAll());
    QRegExp regexp("/account/view-profile/(.*)\"");
    regexp.setMinimal(true);
    int pos = regexp.indexIn(html);
    if (pos == -1) {
        DisplayError("Failed to find account name.");
        return;
    }
    QString account = regexp.cap(1);
    QLOG_DEBUG() << "Logged in as:" << account;

    std::string league(ui->leagueComboBox->currentText().toStdString());
    app_->InitLogin(std::move(login_manager_), league, account.toStdString());
    mw = new MainWindow(std::move(app_));
    mw->setWindowTitle(QString("Acquisition - %1").arg(league.c_str()));
    mw->show();
    close();
}