forked from MrBesen/lolautoaccept
restoring runepages
This commit is contained in:
parent
4aa35ff4e1
commit
67d5614be3
|
@ -206,6 +206,8 @@ public:
|
||||||
std::vector<RunePage> getAllRunePages();
|
std::vector<RunePage> getAllRunePages();
|
||||||
bool selectRunePage(uint64_t id);
|
bool selectRunePage(uint64_t id);
|
||||||
bool editRunePage(const RunePage& page);
|
bool editRunePage(const RunePage& page);
|
||||||
|
bool createRunePage(const RunePage& page);
|
||||||
|
bool deleteRunePage(uint64_t id);
|
||||||
|
|
||||||
std::vector<RuneAspekt> getAllRuneAspekts();
|
std::vector<RuneAspekt> getAllRuneAspekts();
|
||||||
std::vector<RuneStyle> getAllRuneStyles();
|
std::vector<RuneStyle> getAllRuneStyles();
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
POST,
|
POST,
|
||||||
PUT,
|
PUT,
|
||||||
PATCH,
|
PATCH,
|
||||||
// DELETE
|
DELETE
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WebException {
|
struct WebException {
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "runeaspekt.h"
|
||||||
|
#include "runestyle.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class RuneManager;
|
class RuneManager;
|
||||||
|
@ -26,12 +28,17 @@ private slots:
|
||||||
void loadRunes();
|
void loadRunes();
|
||||||
void setRunesEnabled(bool enabled);
|
void setRunesEnabled(bool enabled);
|
||||||
|
|
||||||
void clientRunePageRenamed(QListWidgetItem* item);
|
void saveRunePageClient(int id, QString name, const RunePage& rp);
|
||||||
|
|
||||||
void saveRunePageAA(int id, QString name, const RunePage& rp);
|
void saveRunePageAA(int id, QString name, const RunePage& rp);
|
||||||
|
|
||||||
|
void deleteRunepageClient(int id);
|
||||||
|
void deleteRunepageAA(int id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::RuneManager* ui;
|
Ui::RuneManager* ui;
|
||||||
std::shared_ptr<ClientAPI> client;
|
std::shared_ptr<ClientAPI> client;
|
||||||
Config* config = nullptr;
|
Config* config = nullptr;
|
||||||
|
|
||||||
|
std::vector<RuneAspekt> runeInfo;
|
||||||
|
std::vector<RuneStyle> runeStyles;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include "clientapi.h"
|
#include "clientapi.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "runeaspekt.h"
|
||||||
|
#include "runestyle.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class RunePageList;
|
class RunePageList;
|
||||||
|
@ -29,15 +31,31 @@ public:
|
||||||
void loadRunePages(const std::vector<ClientAPI::RunePage>& pages);
|
void loadRunePages(const std::vector<ClientAPI::RunePage>& pages);
|
||||||
void loadRunePages(const std::vector<std::shared_ptr<Config::RunePageConfig>>& pages);
|
void loadRunePages(const std::vector<std::shared_ptr<Config::RunePageConfig>>& pages);
|
||||||
|
|
||||||
|
void setRuneInfos(const std::vector<RuneAspekt>& runeInfo, const std::vector<RuneStyle>& runeStyles);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void runepageChanged(int id, QString name, const RunePage& rp);
|
void runepageChanged(int id, QString name, const RunePage& rp);
|
||||||
|
void runepageDeleted(int id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void dropEvent(QDropEvent* event) override;
|
virtual void dropEvent(QDropEvent* event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void itemChangedCallback(QListWidgetItem* item);
|
||||||
|
void openContextMenu(const QPoint&);
|
||||||
|
void deleteCurrentItem();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void clearItems();
|
||||||
void addRunepageItem(QString name, int id, const ::RunePage& rp, bool isCurrent = false);
|
void addRunepageItem(QString name, int id, const ::RunePage& rp, bool isCurrent = false);
|
||||||
|
|
||||||
|
QString getRuneDescription(const ::RunePage& runepage);
|
||||||
|
QString getRuneText(uint32_t id);
|
||||||
|
QString getRuneStyleByID(uint32_t id);
|
||||||
|
|
||||||
|
const std::vector<RuneAspekt>* runeInfo = nullptr;
|
||||||
|
const std::vector<RuneStyle>* runeStyles = nullptr;
|
||||||
|
|
||||||
Ui::RunePageList* ui;
|
Ui::RunePageList* ui;
|
||||||
QListWidget* other = nullptr;
|
QListWidget* other = nullptr;
|
||||||
bool isClient;
|
bool isClient;
|
||||||
|
|
|
@ -225,7 +225,7 @@ bool ClientAPI::selectRunePage(uint64_t id) {
|
||||||
if(doc.isEmpty()) return true; // ok
|
if(doc.isEmpty()) return true; // ok
|
||||||
|
|
||||||
// error
|
// error
|
||||||
Log::warn << "error selecting runepage: " << id << " " << doc.toJson().toStdString();
|
qWarning() << "error selecting runepage: " << id << " " << doc.toJson().toStdString();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -246,13 +246,51 @@ bool ClientAPI::editRunePage(const RunePage& page) {
|
||||||
|
|
||||||
QJsonDocument reqdoc(pagereq);
|
QJsonDocument reqdoc(pagereq);
|
||||||
const std::string requestdocstr = reqdoc.toJson(QJsonDocument::JsonFormat::Compact).toStdString();
|
const std::string requestdocstr = reqdoc.toJson(QJsonDocument::JsonFormat::Compact).toStdString();
|
||||||
Log::info << "requeststr: " << requestdocstr;
|
qInfo() << "requeststr: " << requestdocstr;
|
||||||
QJsonDocument doc = request("lol-perks/v1/pages/" + std::to_string(page.id), Method::PUT, requestdocstr);
|
QJsonDocument doc = request("lol-perks/v1/pages/" + std::to_string(page.id), Method::PUT, requestdocstr);
|
||||||
|
|
||||||
if(doc.isEmpty()) return true; // ok
|
if(doc.isEmpty()) return true; // ok
|
||||||
|
|
||||||
// error
|
// error
|
||||||
Log::warn << "error editing runepage: " << page.id << " " << doc.toJson().toStdString();
|
qWarning() << "error editing runepage: " << page.id << " " << doc.toJson().toStdString();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClientAPI::createRunePage(const RunePage& page) {
|
||||||
|
QJsonObject pagereq;
|
||||||
|
|
||||||
|
pagereq["name"] = QString::fromStdString(page.name);
|
||||||
|
pagereq["primaryStyleId"] = (int) page.runepage.primaryStyle;
|
||||||
|
pagereq["subStyleId"] = (int) page.runepage.secondaryStyle;
|
||||||
|
|
||||||
|
QJsonArray selected;
|
||||||
|
for(uint32_t sel : page.runepage.selectedAspects) {
|
||||||
|
selected.push_back((int) sel);
|
||||||
|
}
|
||||||
|
|
||||||
|
pagereq["selectedPerkIds"] = selected;
|
||||||
|
|
||||||
|
QJsonDocument reqdoc(pagereq);
|
||||||
|
const std::string requestdocstr = reqdoc.toJson(QJsonDocument::JsonFormat::Compact).toStdString();
|
||||||
|
qInfo() << "requeststr: " << requestdocstr;
|
||||||
|
QJsonDocument doc = request("lol-perks/v1/pages/", Method::POST, requestdocstr);
|
||||||
|
|
||||||
|
if(doc.isEmpty()) return true; // ok
|
||||||
|
|
||||||
|
// error
|
||||||
|
qWarning() << "error creating runepage: " << page.name << " " << doc.toJson().toStdString();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClientAPI::deleteRunePage(uint64_t id) {
|
||||||
|
QJsonDocument doc = request("lol-perks/v1/pages/" + std::to_string(id), Method::DELETE);
|
||||||
|
|
||||||
|
if(doc.isEmpty()) return true; // ok
|
||||||
|
|
||||||
|
// error
|
||||||
|
qWarning() << "error deleteing runepage: " << id << " " << doc.toJson().toStdString();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +299,7 @@ std::vector<RuneAspekt> ClientAPI::getAllRuneAspekts() {
|
||||||
QJsonDocument doc = request("lol-perks/v1/perks");
|
QJsonDocument doc = request("lol-perks/v1/perks");
|
||||||
|
|
||||||
if(!doc.isArray()) {
|
if(!doc.isArray()) {
|
||||||
Log::warn << __PRETTY_FUNCTION__ << " doc is not array";
|
qWarning() << __PRETTY_FUNCTION__ << " doc is not array";
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +318,7 @@ std::vector<RuneStyle> ClientAPI::getAllRuneStyles() {
|
||||||
QJsonDocument doc = request("lol-perks/v1/styles");
|
QJsonDocument doc = request("lol-perks/v1/styles");
|
||||||
|
|
||||||
if(!doc.isArray()) {
|
if(!doc.isArray()) {
|
||||||
Log::warn << __PRETTY_FUNCTION__ << " doc is not array";
|
qWarning() << __PRETTY_FUNCTION__ << " doc is not array";
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,8 +119,11 @@ QByteArray RestClient::requestRaw(const std::string& url, Method m, const std::s
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
|
||||||
headerlist = curl_slist_append(headerlist, "Content-Type: application/json");
|
headerlist = curl_slist_append(headerlist, "Content-Type: application/json");
|
||||||
break;
|
break;
|
||||||
//case Method::DELETE:
|
case Method::DELETE:
|
||||||
// curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE"); break;
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||||
|
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str());
|
||||||
|
headerlist = curl_slist_append(headerlist, "Content-Type: application/json");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
||||||
|
|
|
@ -15,6 +15,10 @@ RuneManager::RuneManager(QWidget* parent) : QWidget(parent), ui(new Ui::RuneMana
|
||||||
ui->listaaRunes->setOther(ui->listClientRunes);
|
ui->listaaRunes->setOther(ui->listClientRunes);
|
||||||
|
|
||||||
QObject::connect(ui->listaaRunes, &RunePageList::runepageChanged, this, &RuneManager::saveRunePageAA);
|
QObject::connect(ui->listaaRunes, &RunePageList::runepageChanged, this, &RuneManager::saveRunePageAA);
|
||||||
|
QObject::connect(ui->listClientRunes, &RunePageList::runepageChanged, this, &RuneManager::saveRunePageClient);
|
||||||
|
|
||||||
|
QObject::connect(ui->listaaRunes, &RunePageList::runepageDeleted, this, &RuneManager::deleteRunepageAA);
|
||||||
|
QObject::connect(ui->listClientRunes, &RunePageList::runepageDeleted, this, &RuneManager::deleteRunepageClient);
|
||||||
|
|
||||||
loadRunes();
|
loadRunes();
|
||||||
}
|
}
|
||||||
|
@ -29,6 +33,9 @@ void RuneManager::setConfig(Config& config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuneManager::loadRunes() {
|
void RuneManager::loadRunes() {
|
||||||
|
this->ui->btnRetry->setEnabled(false);
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
if(!client) {
|
if(!client) {
|
||||||
auto ca = ClientAccess::find();
|
auto ca = ClientAccess::find();
|
||||||
|
|
||||||
|
@ -38,12 +45,20 @@ void RuneManager::loadRunes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(client) {
|
if(client) {
|
||||||
|
// load meta data
|
||||||
|
runeInfo = client->getAllRuneAspekts();
|
||||||
|
runeStyles = client->getAllRuneStyles();
|
||||||
|
|
||||||
|
this->ui->listClientRunes->setRuneInfos(runeInfo, runeStyles);
|
||||||
|
this->ui->listaaRunes->setRuneInfos(runeInfo, runeStyles);
|
||||||
|
|
||||||
// load runepages
|
// load runepages
|
||||||
const std::vector<ClientAPI::RunePage> runePages = client->getAllRunePages();
|
const std::vector<ClientAPI::RunePage> runePages = client->getAllRunePages();
|
||||||
ui->listClientRunes->loadRunePages(runePages);
|
ui->listClientRunes->loadRunePages(runePages);
|
||||||
}
|
}
|
||||||
|
|
||||||
setRunesEnabled(!!client); // cast to bool
|
setRunesEnabled(!!client); // cast to bool
|
||||||
|
this->ui->btnRetry->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,24 +67,25 @@ void RuneManager::setRunesEnabled(bool enabled) {
|
||||||
this->ui->lblaaRunes->setEnabled(enabled);
|
this->ui->lblaaRunes->setEnabled(enabled);
|
||||||
this->ui->listClientRunes->setEnabled(enabled);
|
this->ui->listClientRunes->setEnabled(enabled);
|
||||||
this->ui->listaaRunes->setEnabled(enabled);
|
this->ui->listaaRunes->setEnabled(enabled);
|
||||||
this->ui->btnDelete->setEnabled(enabled);
|
|
||||||
|
|
||||||
this->ui->btnRetry->setEnabled(!enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RuneManager::clientRunePageRenamed(QListWidgetItem* item) {
|
void RuneManager::saveRunePageClient(int id, QString name, const RunePage& rp) {
|
||||||
uint32_t pageId = item->data(RunePageList::RoleId).toUInt();
|
|
||||||
const ::RunePage* page = (::RunePage*) item->data(RunePageList::RolePointer).toULongLong();
|
|
||||||
qDebug() << "edit page: " << pageId << "setname:" << item->text();
|
|
||||||
|
|
||||||
if(client) {
|
if(client) {
|
||||||
ClientAPI::RunePage newPage;
|
ClientAPI::RunePage newPage;
|
||||||
newPage.id = pageId;
|
newPage.name = name.toStdString();
|
||||||
newPage.name = item->text().toStdString();
|
newPage.runepage = rp;
|
||||||
newPage.runepage = *page;
|
newPage.id = id;
|
||||||
|
|
||||||
if(!client->editRunePage(newPage)) {
|
if(id == -1) {
|
||||||
// TODO: some error occured
|
// create new page
|
||||||
|
if(!client->createRunePage(newPage)) {
|
||||||
|
// TODO: some error occured
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// edit existing page
|
||||||
|
if(!client->editRunePage(newPage)) {
|
||||||
|
// TODO: some error occured
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +101,7 @@ void RuneManager::saveRunePageAA(int id, QString name, const RunePage& rp) {
|
||||||
} else {
|
} else {
|
||||||
if((int) pages.size() > id && id >= 0) {
|
if((int) pages.size() > id && id >= 0) {
|
||||||
pages.at(id)->runepage = rp;
|
pages.at(id)->runepage = rp;
|
||||||
|
pages.at(id)->name = name;
|
||||||
} else {
|
} else {
|
||||||
// unkown id
|
// unkown id
|
||||||
qWarning() << "unknown runepage id:" << id;
|
qWarning() << "unknown runepage id:" << id;
|
||||||
|
@ -96,3 +113,26 @@ void RuneManager::saveRunePageAA(int id, QString name, const RunePage& rp) {
|
||||||
// reload runes
|
// reload runes
|
||||||
ui->listaaRunes->loadRunePages(pages);
|
ui->listaaRunes->loadRunePages(pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RuneManager::deleteRunepageClient(int id) {
|
||||||
|
if(client) {
|
||||||
|
if(!client->deleteRunePage(id)) {
|
||||||
|
// TODO: some error occured
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RuneManager::deleteRunepageAA(int id) {
|
||||||
|
if(!config) return;
|
||||||
|
|
||||||
|
Config::RootConfig& rc = config->getConfig();
|
||||||
|
auto& pages = rc.runePages;
|
||||||
|
if((int) pages.size() > id && id >= 0) {
|
||||||
|
pages.erase(pages.begin() + id);
|
||||||
|
|
||||||
|
config->save();
|
||||||
|
} else {
|
||||||
|
// unkown id
|
||||||
|
qWarning() << "unknown runepage id:" << id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,10 +3,15 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
|
#include <QMenu>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
RunePageList::RunePageList(QWidget* parent) : QListWidget(parent), ui(new Ui::RunePageList) {
|
RunePageList::RunePageList(QWidget* parent) : QListWidget(parent), ui(new Ui::RunePageList) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
QObject::connect(this, &QListWidget::itemChanged, this, &RunePageList::itemChangedCallback);
|
||||||
|
QObject::connect(this, &QListWidget::customContextMenuRequested, this, &RunePageList::openContextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
RunePageList::~RunePageList() {
|
RunePageList::~RunePageList() {
|
||||||
|
@ -14,20 +19,25 @@ RunePageList::~RunePageList() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunePageList::loadRunePages(const std::vector<ClientAPI::RunePage>& pages) {
|
void RunePageList::loadRunePages(const std::vector<ClientAPI::RunePage>& pages) {
|
||||||
clear();
|
clearItems();
|
||||||
for(const ClientAPI::RunePage& rp : pages) {
|
for(const ClientAPI::RunePage& rp : pages) {
|
||||||
addRunepageItem(QString::fromStdString(rp.name), rp.id, rp.runepage, rp.isCurrent);
|
addRunepageItem(QString::fromStdString(rp.name), rp.id, rp.runepage, rp.isCurrent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunePageList::loadRunePages(const std::vector<std::shared_ptr<Config::RunePageConfig>>& pages) {
|
void RunePageList::loadRunePages(const std::vector<std::shared_ptr<Config::RunePageConfig>>& pages) {
|
||||||
clear();
|
clearItems();
|
||||||
for(size_t i = 0; i < pages.size(); ++i) {
|
for(size_t i = 0; i < pages.size(); ++i) {
|
||||||
std::shared_ptr<Config::RunePageConfig> rp = pages.at(i);
|
std::shared_ptr<Config::RunePageConfig> rp = pages.at(i);
|
||||||
addRunepageItem(rp->name, i, rp->runepage);
|
addRunepageItem(rp->name, i, rp->runepage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RunePageList::setRuneInfos(const std::vector<RuneAspekt>& runeInfo, const std::vector<RuneStyle>& runeStyles) {
|
||||||
|
this->runeInfo = &runeInfo;
|
||||||
|
this->runeStyles = &runeStyles;
|
||||||
|
}
|
||||||
|
|
||||||
void RunePageList::dropEvent(QDropEvent* event) {
|
void RunePageList::dropEvent(QDropEvent* event) {
|
||||||
qDebug() << "drop event";
|
qDebug() << "drop event";
|
||||||
if(event->source() == nullptr || event->source() != other) {
|
if(event->source() == nullptr || event->source() != other) {
|
||||||
|
@ -45,7 +55,7 @@ void RunePageList::dropEvent(QDropEvent* event) {
|
||||||
|
|
||||||
// compare rune pages for duplicates?
|
// compare rune pages for duplicates?
|
||||||
|
|
||||||
QListWidget::dropEvent(event);
|
// QListWidget::dropEvent(event);
|
||||||
|
|
||||||
// save change
|
// save change
|
||||||
QString name = item->text();
|
QString name = item->text();
|
||||||
|
@ -54,16 +64,99 @@ void RunePageList::dropEvent(QDropEvent* event) {
|
||||||
emit runepageChanged(-1, name, *oldPage);
|
emit runepageChanged(-1, name, *oldPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RunePageList::itemChangedCallback(QListWidgetItem* item) {
|
||||||
|
int pageId = item->data(RunePageList::RoleId).toUInt();
|
||||||
|
QString newName = item->text();
|
||||||
|
const ::RunePage* page = (::RunePage*) item->data(RunePageList::RolePointer).toULongLong();
|
||||||
|
emit runepageChanged(pageId, newName, *page);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunePageList::openContextMenu(const QPoint& pos) {
|
||||||
|
QPoint globalPos = mapToGlobal(pos);
|
||||||
|
|
||||||
|
QMenu menu;
|
||||||
|
menu.addAction(QIcon::fromTheme("edit-delete"), RunePageList::tr("Delete"), this, &RunePageList::deleteCurrentItem);
|
||||||
|
|
||||||
|
menu.exec(globalPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunePageList::deleteCurrentItem() {
|
||||||
|
QListWidgetItem* item = currentItem();
|
||||||
|
if (item) {
|
||||||
|
uint32_t id = item->data(RoleId).toUInt();
|
||||||
|
RunePage* page = (RunePage*) item->data(RolePointer).toULongLong();
|
||||||
|
removeItemWidget(item);
|
||||||
|
emit runepageDeleted(id);
|
||||||
|
|
||||||
|
delete item;
|
||||||
|
delete page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunePageList::clearItems() {
|
||||||
|
while(count()) {
|
||||||
|
QListWidgetItem* item = takeItem(0);
|
||||||
|
delete (RunePage*) item->data(RolePointer).toULongLong();
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
void RunePageList::addRunepageItem(QString name, int id, const ::RunePage& rp, bool isCurrent) {
|
void RunePageList::addRunepageItem(QString name, int id, const ::RunePage& rp, bool isCurrent) {
|
||||||
QListWidgetItem* item = new QListWidgetItem(name);
|
QListWidgetItem* item = new QListWidgetItem(name);
|
||||||
item->setData(RoleId, (uint) id);
|
item->setData(RoleId, (uint) id);
|
||||||
item->setData(RolePointer, (qulonglong) new ::RunePage(rp));
|
item->setData(RolePointer, (qulonglong) new ::RunePage(rp));
|
||||||
|
QString tooltipStr;
|
||||||
if(id != -1) {
|
if(id != -1) {
|
||||||
item->setToolTip(QString("id: %0").arg(id));
|
tooltipStr = QString("id: %0\n").arg(id);
|
||||||
}
|
}
|
||||||
|
tooltipStr += getRuneDescription(rp);
|
||||||
|
item->setToolTip(tooltipStr);
|
||||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||||
if(isCurrent) {
|
if(isCurrent) {
|
||||||
item->setSelected(true);
|
item->setSelected(true);
|
||||||
}
|
}
|
||||||
addItem(item);
|
addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RunePageList::getRuneDescription(const ::RunePage& runepage) {
|
||||||
|
QString outStr;
|
||||||
|
outStr.reserve(100);
|
||||||
|
QTextStream out(&outStr);
|
||||||
|
|
||||||
|
if(! (bool) runepage) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
out << getRuneStyleByID(runepage.primaryStyle) << ' ' << RunePageList::tr("with") << ' ' << getRuneStyleByID(runepage.secondaryStyle);
|
||||||
|
|
||||||
|
for(uint32_t rune : runepage.selectedAspects) {
|
||||||
|
out << '\n' << getRuneText(rune);
|
||||||
|
}
|
||||||
|
return outStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RunePageList::getRuneText(uint32_t id) {
|
||||||
|
if(runeInfo != nullptr) {
|
||||||
|
for(const RuneAspekt& ra : *runeInfo) {
|
||||||
|
if(ra.id == id) {
|
||||||
|
return QString::fromStdString(ra.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString("(%0)").arg(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RunePageList::getRuneStyleByID(uint32_t id) {
|
||||||
|
if(runeStyles != nullptr) {
|
||||||
|
auto it = std::find_if(runeStyles->begin(), runeStyles->end(), [id](const RuneStyle& rs) { return rs.id == id; });
|
||||||
|
|
||||||
|
if(it != runeStyles->end()) {
|
||||||
|
return QString::fromStdString(it->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString("(%0)").arg(id);
|
||||||
|
}
|
||||||
|
|
|
@ -11,8 +11,22 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="lblClientRunes">
|
||||||
|
<property name="text">
|
||||||
|
<string>Runes in the Client</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="RunePageList" name="listaaRunes">
|
<widget class="QLabel" name="lblaaRunes">
|
||||||
|
<property name="text">
|
||||||
|
<string>Runes in the Autoacceptor</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="RunePageList" name="listClientRunes">
|
||||||
<property name="dragEnabled">
|
<property name="dragEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -21,29 +35,8 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="lblClientRunes">
|
<widget class="RunePageList" name="listaaRunes">
|
||||||
<property name="text">
|
|
||||||
<string>Runes in the Client</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QPushButton" name="btnDelete">
|
|
||||||
<property name="text">
|
|
||||||
<string>Delete</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QLabel" name="lblaaRunes">
|
|
||||||
<property name="text">
|
|
||||||
<string>Runes in the Autoacceptor</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="RunePageList" name="listClientRunes">
|
|
||||||
<property name="dragEnabled">
|
<property name="dragEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -55,7 +48,25 @@
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="btnRetry">
|
<widget class="QPushButton" name="btnRetry">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Retry</string>
|
<string>Reload</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="reload"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QCheckBox" name="chkAutoCopy">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Runes from the client get copied to the autoacceptor automatically.
|
||||||
|
|
||||||
|
This Feature is in development.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string> Auto Copy Runes</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -86,25 +97,8 @@
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
|
||||||
<sender>listClientRunes</sender>
|
|
||||||
<signal>itemChanged(QListWidgetItem*)</signal>
|
|
||||||
<receiver>RuneManager</receiver>
|
|
||||||
<slot>clientRunePageRenamed(QListWidgetItem*)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>266</x>
|
|
||||||
<y>229</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>644</x>
|
|
||||||
<y>240</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
</connections>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>loadRunes()</slot>
|
<slot>loadRunes()</slot>
|
||||||
<slot>clientRunePageRenamed(QListWidgetItem*)</slot>
|
|
||||||
</slots>
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
<height>300</height>
|
<height>300</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
Loading…
Reference in New Issue