forked from teamnwah/openmw-tes3coop
Add addServer by address method
This commit is contained in:
parent
ecf82a5df7
commit
a86739f080
2 changed files with 11 additions and 12 deletions
|
@ -48,6 +48,14 @@ MainWindow::~MainWindow()
|
||||||
delete mGameInvoker;
|
delete mGameInvoker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::addServer(QString addr)
|
||||||
|
{
|
||||||
|
favorites->insertRow(0);
|
||||||
|
QModelIndex mi = favorites->index(0, ServerData::ADDR);
|
||||||
|
favorites->setData(mi, addr, Qt::EditRole);
|
||||||
|
NetController::get()->updateInfo(favorites, mi);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::addServer()
|
void MainWindow::addServer()
|
||||||
{
|
{
|
||||||
int id = tblServerBrowser->selectionModel()->currentIndex().row();
|
int id = tblServerBrowser->selectionModel()->currentIndex().row();
|
||||||
|
@ -64,12 +72,7 @@ void MainWindow::addServerByIP()
|
||||||
bool ok;
|
bool ok;
|
||||||
QString text = QInputDialog::getText(this, tr("Add Server by address"), tr("Address:"), QLineEdit::Normal, "", &ok);
|
QString text = QInputDialog::getText(this, tr("Add Server by address"), tr("Address:"), QLineEdit::Normal, "", &ok);
|
||||||
if(ok && !text.isEmpty())
|
if(ok && !text.isEmpty())
|
||||||
{
|
addServer(text);
|
||||||
favorites->insertRow(0);
|
|
||||||
QModelIndex mi = favorites->index(0, ServerData::ADDR);
|
|
||||||
favorites->setData(mi, text, Qt::EditRole);
|
|
||||||
NetController::get()->updateInfo(favorites, mi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::deleteServer()
|
void MainWindow::deleteServer()
|
||||||
|
@ -178,12 +181,7 @@ void MainWindow::loadFavorites()
|
||||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(file.readAll()));
|
QJsonDocument jsonDoc(QJsonDocument::fromJson(file.readAll()));
|
||||||
|
|
||||||
for(auto server : jsonDoc.array())
|
for(auto server : jsonDoc.array())
|
||||||
{
|
addServer(server.toString());
|
||||||
favorites->insertRows(0, 1);
|
|
||||||
QModelIndex mi = favorites->index(0, ServerData::ADDR);
|
|
||||||
favorites->setData(mi, server.toString(), Qt::EditRole);
|
|
||||||
NetController::get()->updateInfo(favorites, mi);
|
|
||||||
}
|
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@ public:
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent * event) Q_DECL_OVERRIDE;
|
void closeEvent(QCloseEvent * event) Q_DECL_OVERRIDE;
|
||||||
|
void addServer(QString addr);
|
||||||
public slots:
|
public slots:
|
||||||
bool refresh();
|
bool refresh();
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
Loading…
Reference in a new issue