Skip to content

Commit

Permalink
preferences: Copy friend name and notes to field when selected, for e…
Browse files Browse the repository at this point in the history
…asier editing
  • Loading branch information
CelticMinstrel committed Feb 18, 2016
1 parent 0537fc2 commit b238c42
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/gui/dialogs/preferences_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,18 @@ void tpreferences::add_friend_list_entry(const bool is_friend,
setup_friends_list(window);
}

void tpreferences::edit_friend_list_entry(tlistbox& friends,
ttext_box& textbox)
{
const int sel = friends.get_selected_row();
if(sel < 0) {
return;
}
std::map<std::string, preferences::acquaintance>::const_iterator who = get_acquaintances().begin();
std::advance(who, sel);
textbox.set_value(who->second.get_nick() + " " + who->second.get_notes());
}

void tpreferences::remove_friend_list_entry(tlistbox& friends_list,
ttext_box& textbox, twindow& window)
{
Expand Down Expand Up @@ -638,6 +650,12 @@ void tpreferences::initialize_members(twindow& window)
boost::ref(textbox),
boost::ref(window)));

friend_list.set_callback_value_change(boost::bind(
&tpreferences::edit_friend_list_entry,
this,
boost::ref(friend_list),
boost::ref(textbox)));

friend_list.select_row(0);

/** ALERTS **/
Expand Down
2 changes: 2 additions & 0 deletions src/gui/dialogs/preferences_dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class tpreferences : public tdialog
void add_friend_list_entry(const bool is_friend,
ttext_box& textbox, twindow& window);

void edit_friend_list_entry(tlistbox& friends, ttext_box& textbox);

void remove_friend_list_entry(tlistbox& friends_list,
ttext_box& textbox, twindow& window);

Expand Down

0 comments on commit b238c42

Please sign in to comment.