forked from MrBesen/lolautoaccept
43 lines
1.0 KiB
C++
43 lines
1.0 KiB
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() {
|
|
if(ui->championList->count() == 1) {
|
|
return (ChampRow*) ui->championList->takeItem(0);
|
|
}
|
|
int row = ui->championList->currentRow();
|
|
return (ChampRow*) ui->championList->takeItem(row);
|
|
}
|
|
|
|
void ChampionSearch::searchChanged(QString str) {
|
|
qInfo() << "champion search: " << str;
|
|
|
|
const std::vector<const DataDragon::ChampData*> champs = dd->getMatchingChamp(str);
|
|
qInfo() << "found " << champs.size() << " champs";
|
|
|
|
clear();
|
|
|
|
for(auto cd : champs) {
|
|
dd->getImageAsnyc(cd->id, [this, cd](QPixmap img) {
|
|
auto cr = new ChampRow();
|
|
cr->setChamp(*cd, img);
|
|
ui->championList->addItem(cr);
|
|
});
|
|
}
|
|
}
|
|
|
|
void ChampionSearch::clear() {
|
|
while(ui->championList->count()) {
|
|
delete ui->championList->takeItem(0);
|
|
}
|
|
} |