40 lines
952 B
C++
40 lines
952 B
C++
#include "championsearch.h"
|
|
#include "ui_championsearch.h"
|
|
|
|
#include <Log.h>
|
|
|
|
ChampionSearch::ChampionSearch(DataDragon* dd, QWidget *parent) : QDialog(parent), ui(new Ui::ChampionSearch), dd(dd) {
|
|
ui->setupUi(this);
|
|
}
|
|
|
|
ChampionSearch::~ChampionSearch() {
|
|
delete ui;
|
|
}
|
|
|
|
ChampRow* ChampionSearch::getSearchResult() {
|
|
int row = ui->championList->currentRow();
|
|
return (ChampRow*) ui->championList->takeItem(row);
|
|
}
|
|
|
|
void ChampionSearch::searchChanged(QString str) {
|
|
Log::info << "champion search: " << str.toStdString();
|
|
|
|
auto champs = dd->getMatchingChamp(str.toStdString());
|
|
Log::info << "found " << champs.size() << " champs";
|
|
|
|
clear();
|
|
|
|
for(auto it : champs) {
|
|
dd->getImageAsnyc(it->id, [this, it](QPixmap img) {
|
|
auto cr = new ChampRow();
|
|
cr->setChamp(it->name, it->key, img);
|
|
ui->championList->addItem(cr);
|
|
});
|
|
}
|
|
}
|
|
|
|
void ChampionSearch::clear() {
|
|
while(ui->championList->count()) {
|
|
delete ui->championList->takeItem(0);
|
|
}
|
|
} |