diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2009-10-04 13:23:47 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2009-10-04 13:23:47 +0200 |
commit | 7b6ddb687ceb1faf1b100929c501ab403e3e63de (patch) | |
tree | 82ea5890bb700799540bdb39f1ae066a6431f3b6 /src/gui/serverdialog.cpp | |
parent | 69217e82e8631bbb2183a1322d0985a495c52f5e (diff) | |
download | mana-7b6ddb687ceb1faf1b100929c501ab403e3e63de.tar.gz mana-7b6ddb687ceb1faf1b100929c501ab403e3e63de.tar.bz2 mana-7b6ddb687ceb1faf1b100929c501ab403e3e63de.tar.xz mana-7b6ddb687ceb1faf1b100929c501ab403e3e63de.zip |
Made sure the server information updates when dragging the server list
It was only updating on click events, due to using ActionListener
instead of SelectionListener.
Diffstat (limited to 'src/gui/serverdialog.cpp')
-rw-r--r-- | src/gui/serverdialog.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index bbc2d3f9..d126c312 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -82,7 +82,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo): mMostUsedServersListModel = new ServersListModel; ServerInfo currentServer; std::string currentConfig = ""; - for (int i=0; i<=MAX_SERVERLIST; i++) + for (int i = 0; i <= MAX_SERVERLIST; i++) { currentServer.clear(); @@ -90,15 +90,15 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo): currentServer.hostname = config.getValue(currentConfig, ""); currentConfig = "MostUsedServerPort" + toString(i); - currentServer.port = (short)atoi(config.getValue(currentConfig, "").c_str()); - if (!currentServer.hostname.empty() || currentServer.port != 0) + currentServer.port = (short) config.getValue(currentConfig, 0); + if (!currentServer.hostname.empty() && currentServer.port != 0) { mMostUsedServersListModel->addElement(currentServer); } } - mMostUsedServersDropDown = new ListBox(mMostUsedServersListModel); - ScrollArea *usedScroll = new ScrollArea(mMostUsedServersDropDown); + mMostUsedServersList = new ListBox(mMostUsedServersListModel); + ScrollArea *usedScroll = new ScrollArea(mMostUsedServersList); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mQuitButton = new Button(_("Quit"), "quit", this); @@ -106,13 +106,12 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo): mServerNameField->setActionEventId("connect"); mPortField->setActionEventId("connect"); - mMostUsedServersDropDown->setActionEventId("changeSelection"); mServerNameField->addActionListener(this); mPortField->addActionListener(this); - mMostUsedServersDropDown->addActionListener(this); + mMostUsedServersList->addSelectionListener(this); - mMostUsedServersDropDown->setSelected(0); + mMostUsedServersList->setSelected(0); place(0, 0, serverLabel); place(0, 1, portLabel); @@ -146,22 +145,13 @@ ServerDialog::~ServerDialog() delete mMostUsedServersListModel; } -void -ServerDialog::action(const gcn::ActionEvent &event) +void ServerDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "ok") { // Give focus back to the server dialog. mServerNameField->requestFocus(); } - else if (event.getId() == "changeSelection") - { - // Change the textField Values according to new selection - ServerInfo myServer = mMostUsedServersListModel->getServer - (mMostUsedServersDropDown->getSelected()); - mServerNameField->setText(myServer.hostname); - mPortField->setText(toString(myServer.port)); - } else if (event.getId() == "connect") { // Check login @@ -213,3 +203,12 @@ ServerDialog::action(const gcn::ActionEvent &event) state = STATE_FORCE_QUIT; } } + +void ServerDialog::valueChanged(const gcn::SelectionEvent &event) +{ + // Update the server and post fields according to the new selection + const ServerInfo myServer = mMostUsedServersListModel->getServer + (mMostUsedServersList->getSelected()); + mServerNameField->setText(myServer.hostname); + mPortField->setText(toString(myServer.port)); +} |