summaryrefslogtreecommitdiff
path: root/src/gui/serverdialog.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-11-23 19:01:08 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-01-10 20:32:02 +0100
commit8cf8f82d0b933dab43372fb0afdda58687ce6af6 (patch)
tree740af7cb3f148b60839d1304791bdb0046161a53 /src/gui/serverdialog.cpp
parent98be39a094cc20f513da1847c553513682e4eeae (diff)
downloadmana-client-8cf8f82d0b933dab43372fb0afdda58687ce6af6.tar.gz
mana-client-8cf8f82d0b933dab43372fb0afdda58687ce6af6.tar.bz2
mana-client-8cf8f82d0b933dab43372fb0afdda58687ce6af6.tar.xz
mana-client-8cf8f82d0b933dab43372fb0afdda58687ce6af6.zip
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
Diffstat (limited to 'src/gui/serverdialog.cpp')
-rw-r--r--src/gui/serverdialog.cpp53
1 files changed, 41 insertions, 12 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index d580d4d3..0e97dd0d 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -207,19 +207,21 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
mQuitButton = new Button(_("Quit"), "quit", this);
mConnectButton = new Button(_("Connect"), "connect", this);
- mManualEntryButton = new Button(_("Custom Server"), "addEntry", this);
+ mManualEntryButton = new Button(_("Add custom Server..."), "addEntry", this);
+ mModifyButton = new Button(_("Modify..."), "modify", this);
mDeleteButton = new Button(_("Delete"), "remove", this);
mServersList->setActionEventId("connect");
mServersList->addSelectionListener(this);
usedScroll->setVerticalScrollAmount(0);
- place(0, 0, usedScroll, 5, 5).setPadding(3);
+ place(0, 0, usedScroll, 6, 5).setPadding(3);
place(0, 5, mDescription, 5);
place(0, 6, mManualEntryButton);
- place(1, 6, mDeleteButton);
- place(3, 6, mQuitButton);
- place(4, 6, mConnectButton);
+ place(1, 6, mModifyButton);
+ place(2, 6, mDeleteButton);
+ place(4, 6, mQuitButton);
+ place(5, 6, mConnectButton);
// Make sure the list has enough height
getLayout().setRowHeight(3, 80);
@@ -290,6 +292,7 @@ void ServerDialog::action(const gcn::ActionEvent &event)
mConnectButton->setEnabled(false);
mDeleteButton->setEnabled(false);
mManualEntryButton->setEnabled(false);
+ mModifyButton->setEnabled(false);
const ServerInfo &serverInfo = mServersListModel->getServer(index);
mServerInfo->hostname = serverInfo.hostname;
@@ -314,6 +317,21 @@ void ServerDialog::action(const gcn::ActionEvent &event)
// Add a custom server: It will delete itself using guichan logic.
new CustomServerDialog(this);
}
+ else if (event.getId() == "modify")
+ {
+ int index = mServersList->getSelected();
+ // Check whether a server is selected.
+ if (index < 0)
+ {
+ OkDialog *dlg = new OkDialog(_("Error"),
+ _("Please select a custom server."));
+ dlg->addActionListener(this);
+ }
+ else
+ {
+ new CustomServerDialog(this, index);
+ }
+ }
else if (event.getId() == "remove")
{
int index = mServersList->getSelected();
@@ -344,6 +362,7 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &)
if (index == -1)
{
mDeleteButton->setEnabled(false);
+ mModifyButton->setEnabled(false);
return;
}
@@ -352,6 +371,7 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &)
mDescription->setCaption(myServer.description);
mDeleteButton->setEnabled(myServer.save);
+ mModifyButton->setEnabled(myServer.save);
}
void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
@@ -543,22 +563,29 @@ void ServerDialog::loadCustomServers()
}
}
-void ServerDialog::saveCustomServers(const ServerInfo &currentServer)
+void ServerDialog::saveCustomServers(const ServerInfo &currentServer, int index)
{
ServerInfos::iterator it, it_end = mServers.end();
// Make sure the current server is mentioned first
if (currentServer.isValid())
{
- for (it = mServers.begin(); it != it_end; ++it)
+ if (index > -1)
+ {
+ mServers[index] = currentServer;
+ }
+ else
{
- if (*it == currentServer)
+ for (it = mServers.begin(); it != it_end; ++it)
{
- mServers.erase(it);
- break;
+ if (*it == currentServer)
+ {
+ mServers.erase(it);
+ break;
+ }
}
+ mServers.insert(mServers.begin(), currentServer);
}
- mServers.insert(mServers.begin(), currentServer);
}
int savedServerCount = 0;
@@ -592,7 +619,9 @@ void ServerDialog::saveCustomServers(const ServerInfo &currentServer)
config.setValue("MostUsedServerName" + toString(savedServerCount), "");
// Restore the correct description
- mDescription->setCaption(mServers[0].description);
+ if (index < 0)
+ index = 0;
+ mDescription->setCaption(mServers[index].description);
}
int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status,