From 8cf8f82d0b933dab43372fb0afdda58687ce6af6 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Wed, 23 Nov 2011 19:01:08 +0100 Subject: Added a modify button to the server dialog. This was righteously requested by Ablu as missing when dealing with one's own entries. Reviewed-by: Ablu --- src/gui/customserverdialog.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/gui/customserverdialog.cpp') diff --git a/src/gui/customserverdialog.cpp b/src/gui/customserverdialog.cpp index 304665d6..589440a2 100644 --- a/src/gui/customserverdialog.cpp +++ b/src/gui/customserverdialog.cpp @@ -44,9 +44,10 @@ std::string TypeListModel::getElementAt(int elementIndex) return "Unknown"; } -CustomServerDialog::CustomServerDialog(ServerDialog *parent): +CustomServerDialog::CustomServerDialog(ServerDialog *parent, int index): Window(_("Add a custom Server"), true, static_cast(parent)), - mServerDialog(parent) + mServerDialog(parent), + mIndex(index) { setWindowName("CustomServerDialog"); @@ -110,6 +111,18 @@ CustomServerDialog::CustomServerDialog(ServerDialog *parent): loadWindowState(); + // Add the entry's info when in modify mode. + if (index > -1) + { + const ServerInfo &serverInfo = mServerDialog->mServers[index]; + mNameField->setText(serverInfo.name); + mDescriptionField->setText(serverInfo.description); + mServerAddressField->setText(serverInfo.hostname); + mPortField->setText(toString(serverInfo.port)); + mTypeField->setSelected(serverInfo.type ? ServerInfo::MANASERV : + ServerInfo::TMWATHENA); + } + setVisible(true); mNameField->requestFocus(); @@ -169,7 +182,7 @@ void CustomServerDialog::action(const gcn::ActionEvent &event) serverInfo.save = true; //Add server - mServerDialog->saveCustomServers(serverInfo); + mServerDialog->saveCustomServers(serverInfo, mIndex); scheduleDelete(); } } -- cgit v1.2.3-70-g09d2