implement server config remove button

This commit is contained in:
Yannik Schmidt
2020-09-07 19:25:01 +02:00
parent 29be79f278
commit 1839b4b28e
5 changed files with 44 additions and 4 deletions

View File

@@ -0,0 +1 @@
#include "pushbuttonwithposition.h"

17
pushbuttonwithposition.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef PUSHBUTTONWITHPOSITION_H
#define PUSHBUTTONWITHPOSITION_H
#include <QPushButton>
class PushButtonWithPosition : public QPushButton
{
public:
PushButtonWithPosition(int row, QString text) : QPushButton(text){
this->row = row;
}
int row;
};
#endif // PUSHBUTTONWITHPOSITION_H

View File

@@ -9,6 +9,7 @@
#include "multivalueinputdialog.h" #include "multivalueinputdialog.h"
#include "urls.h" #include "urls.h"
#include "pushbuttonwithposition.h"
ServerConfig::ServerConfig(QWidget *parent, QSettings *settings) : QMainWindow(parent) { ServerConfig::ServerConfig(QWidget *parent, QSettings *settings) : QMainWindow(parent) {
@@ -78,6 +79,19 @@ ServerConfig::ServerConfig(QWidget *parent, QSettings *settings) : QMainWindow(p
this->setCentralWidget(mainWidget); this->setCentralWidget(mainWidget);
} }
void ServerConfig::removePP(){
PushButtonWithPosition* pButton = static_cast<PushButtonWithPosition*>(sender());
auto key = ppTable->item(pButton->row, 0);
auto repl = ppTable->item(pButton->row, 1);
sc->submitPostProcessorChange(key->text(), repl->text(), true);
}
void ServerConfig::removeContext(){
PushButtonWithPosition* pButton = static_cast<PushButtonWithPosition*>(sender());
auto label = contextTable->item(pButton->row, 0);
sc->submitSpeechContextPhraseChange(label->text(), true);
}
void ServerConfig::addNewPP(){ void ServerConfig::addNewPP(){
QStringList *sl = new QStringList(); QStringList *sl = new QStringList();
@@ -185,7 +199,9 @@ void ServerConfig::finishedRequest(QNetworkReply *reply){
contextTable->setItem(i, 0, new QTableWidgetItem(phrases.at(i).toString())); contextTable->setItem(i, 0, new QTableWidgetItem(phrases.at(i).toString()));
auto *deleteButtonLayout = new QGridLayout(); auto *deleteButtonLayout = new QGridLayout();
auto *deleteCell = new QWidget(); auto *deleteCell = new QWidget();
auto *deleteButton = new QPushButton("Entfernen"); auto *deleteButton = new PushButtonWithPosition(i, "Entfernen");
connect(deleteButton, SIGNAL (released()), this, SLOT (removeContext()));
deleteButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); deleteButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
deleteButtonLayout->addWidget(deleteButton); deleteButtonLayout->addWidget(deleteButton);
deleteButtonLayout->setContentsMargins(0,0,0,0); deleteButtonLayout->setContentsMargins(0,0,0,0);
@@ -201,7 +217,9 @@ void ServerConfig::finishedRequest(QNetworkReply *reply){
ppTable->setItem(i, 1, new QTableWidgetItem(keywordMap[key].toString())); ppTable->setItem(i, 1, new QTableWidgetItem(keywordMap[key].toString()));
auto *deleteButtonLayout = new QGridLayout(); auto *deleteButtonLayout = new QGridLayout();
auto *deleteCell = new QWidget(); auto *deleteCell = new QWidget();
auto *deleteButton = new QPushButton("Entfernen"); auto *deleteButton = new PushButtonWithPosition(i, "Entfernen");
connect(deleteButton, SIGNAL (released()), this, SLOT (removePP()));
deleteButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); deleteButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
deleteButtonLayout->addWidget(deleteButton); deleteButtonLayout->addWidget(deleteButton);
deleteButtonLayout->setContentsMargins(0,0,0,0); deleteButtonLayout->setContentsMargins(0,0,0,0);

View File

@@ -23,6 +23,8 @@ private slots:
void finishedRequest(QNetworkReply*); void finishedRequest(QNetworkReply*);
void addNewPP(); void addNewPP();
void addNewContext(); void addNewContext();
void removePP();
void removeContext();
private: private:
QGridLayout* mainLayout; QGridLayout* mainLayout;
QSettings* mySettings; QSettings* mySettings;

View File

@@ -39,7 +39,8 @@ SOURCES += \
about.cpp \ about.cpp \
serverconnection.cpp \ serverconnection.cpp \
serverconfig.cpp \ serverconfig.cpp \
multivalueinputdialog.cpp multivalueinputdialog.cpp \
pushbuttonwithposition.cpp
HEADERS += \ HEADERS += \
mainwindow.h \ mainwindow.h \
@@ -50,7 +51,8 @@ HEADERS += \
serverconnection.h \ serverconnection.h \
serverconfig.h \ serverconfig.h \
urls.h \ urls.h \
multivalueinputdialog.h multivalueinputdialog.h \
pushbuttonwithposition.h
FORMS += \ FORMS += \
mainwindow.ui \ mainwindow.ui \