From 770a32c423594968ef47d0f2b67bc28aadaff110 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 25 Jul 2014 11:54:48 +0200 Subject: [PATCH] FIRE-8175: Add option to rename a contact set to the set configuration floater --- .../fsfloatercontactsetconfiguration.cpp | 41 +++++++++++++++++-- .../fsfloatercontactsetconfiguration.h | 18 +++++--- indra/newview/lggcontactsets.cpp | 16 ++++++++ indra/newview/lggcontactsets.h | 1 + .../floater_fs_contact_set_configuration.xml | 2 + .../skins/default/xui/de/notifications.xml | 3 ++ .../floater_fs_contact_set_configuration.xml | 23 +++++++++-- .../skins/default/xui/en/notifications.xml | 8 ++++ 8 files changed, 101 insertions(+), 11 deletions(-) diff --git a/indra/newview/fsfloatercontactsetconfiguration.cpp b/indra/newview/fsfloatercontactsetconfiguration.cpp index b6931650c4..b81653b1c9 100644 --- a/indra/newview/fsfloatercontactsetconfiguration.cpp +++ b/indra/newview/fsfloatercontactsetconfiguration.cpp @@ -30,6 +30,11 @@ #include "llviewerprecompiledheaders.h" #include "fsfloatercontactsetconfiguration.h" #include "lggcontactsets.h" +#include "llcheckboxctrl.h" +#include "llcolorswatch.h" +#include "lllineeditor.h" +#include "llbutton.h" +#include "llnotificationsutil.h" FSFloaterContactSetConfiguration::FSFloaterContactSetConfiguration(const LLSD& target_set) : LLFloater(target_set) @@ -39,9 +44,13 @@ FSFloaterContactSetConfiguration::FSFloaterContactSetConfiguration(const LLSD& t BOOL FSFloaterContactSetConfiguration::postBuild() { - LLStringUtil::format_map_t map; - map["NAME"] = mContactSet; - setTitle(getString("title", map)); + updateTitle(); + + mSetName = getChild("set_name_editor"); + mSetName->setText(mContactSet); + + mRenameButton = getChild("rename_btn"); + mRenameButton->setCommitCallback(boost::bind(&FSFloaterContactSetConfiguration::onRenameSet, this)); mSetSwatch = getChild("set_swatch"); if (mSetSwatch) @@ -84,3 +93,29 @@ void FSFloaterContactSetConfiguration::onCommitDefaultColor() { LGGContactSets::getInstance()->setDefaultColor(mGlobalSwatch->get()); } + +void FSFloaterContactSetConfiguration::onRenameSet() +{ + std::string new_name = mSetName->getText(); + + if (!new_name.empty() && LGGContactSets::getInstance()->renameSet(mContactSet, new_name)) + { + mKey = LLSD(new_name); + mContactSet = new_name; + updateTitle(); + } + else + { + LLSD substitutions; + substitutions["SET"] = mContactSet; + substitutions["NEW_NAME"] = new_name; + LLNotificationsUtil::add("RenameContactSetFailure", substitutions); + } +} + +void FSFloaterContactSetConfiguration::updateTitle() +{ + LLStringUtil::format_map_t map; + map["NAME"] = mContactSet; + setTitle(getString("title", map)); +} diff --git a/indra/newview/fsfloatercontactsetconfiguration.h b/indra/newview/fsfloatercontactsetconfiguration.h index d24400c28a..a3449c5d3f 100644 --- a/indra/newview/fsfloatercontactsetconfiguration.h +++ b/indra/newview/fsfloatercontactsetconfiguration.h @@ -31,8 +31,11 @@ #define FS_FLOATERCONTACTSETCONFIGURATION_H #include "llfloater.h" -#include "llcheckboxctrl.h" -#include "llcolorswatch.h" + +class LLColorSwatchCtrl; +class LLCheckBoxCtrl; +class LLLineEditor; +class LLButton; class FSFloaterContactSetConfiguration : public LLFloater { @@ -46,13 +49,18 @@ private: void onCommitSetColor(); void onCommitSetNotifications(); void onCommitDefaultColor(); + void onRenameSet(); + void updateTitle(); + // Wish there was something better to use for this... std::string mContactSet; - LLCheckBoxCtrl* mNotificationCheckBox; - LLColorSwatchCtrl* mSetSwatch; - LLColorSwatchCtrl* mGlobalSwatch; + LLCheckBoxCtrl* mNotificationCheckBox; + LLColorSwatchCtrl* mSetSwatch; + LLColorSwatchCtrl* mGlobalSwatch; + LLLineEditor* mSetName; + LLButton* mRenameButton; }; #endif //FS_FLOATERCONTACTSETCONFIGURATION_H diff --git a/indra/newview/lggcontactsets.cpp b/indra/newview/lggcontactsets.cpp index 0f0b8c8ed9..cd393e72ab 100644 --- a/indra/newview/lggcontactsets.cpp +++ b/indra/newview/lggcontactsets.cpp @@ -916,6 +916,22 @@ void LGGContactSets::addSet(const std::string& set_name) } } +bool LGGContactSets::renameSet(const std::string& set_name, const std::string& new_set_name) +{ + if (!isInternalSetName(set_name) && isValidSet(set_name) && + !isInternalSetName(new_set_name) && !isValidSet(new_set_name)) + { + ContactSet* set = getContactSet(set_name); + set->mName = new_set_name; + mContactSets.erase(set_name); + mContactSets[new_set_name] = set; + saveToDisk(); + mChangedSignal(UPDATED_LISTS); + return true; + } + return false; +} + void LGGContactSets::removeSet(const std::string& set_name) { contact_set_map_t::iterator found = mContactSets.find(set_name); diff --git a/indra/newview/lggcontactsets.h b/indra/newview/lggcontactsets.h index 8cf2ac6e4b..5b7434b862 100644 --- a/indra/newview/lggcontactsets.h +++ b/indra/newview/lggcontactsets.h @@ -80,6 +80,7 @@ public: bool hasFriendColorThatShouldShow(const LLUUID& friend_id, ELGGCSType type); void addSet(const std::string& set_name); + bool renameSet(const std::string& set_name, const std::string& new_set_name); void removeSet(const std::string& set_name); bool isValidSet(const std::string& set_name); diff --git a/indra/newview/skins/default/xui/de/floater_fs_contact_set_configuration.xml b/indra/newview/skins/default/xui/de/floater_fs_contact_set_configuration.xml index 049eb7f87a..8e8856c099 100644 --- a/indra/newview/skins/default/xui/de/floater_fs_contact_set_configuration.xml +++ b/indra/newview/skins/default/xui/de/floater_fs_contact_set_configuration.xml @@ -7,6 +7,8 @@ Kontakt-Set-Einstellungen: + +