summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2013-05-02 16:24:09 -0700
committerMerov Linden <merov@lindenlab.com>2013-05-02 16:24:09 -0700
commita73305c41d058fc755b824e5a9243afe43b424e1 (patch)
treeb7bc60c021461604d6e425366c56e88a9ac8ed6e /indra
parent8764e84041c48d0facd3a2860d90f78c88714f7c (diff)
ACME-275 : WIP : Implemented filter(), still arrange() not done timely, tweaked test values to allow test of sort and filter
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llpanelpeople.cpp14
-rw-r--r--indra/newview/llpersonmodelcommon.cpp55
-rw-r--r--indra/newview/llpersonmodelcommon.h18
3 files changed, 72 insertions, 15 deletions
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index a9a024c9ed..9daf441ab3 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -1687,10 +1687,22 @@ void LLPanelPeople::showFacebookFriends(const LLSD& friends)
void LLPanelPeople::addTestParticipant()
{
+ std::string suffix("Aa");
+ std::string prefix("EastBayGuy");
for(int i = 0; i < 300; ++i)
{
LLPersonTabModel * person_folder_model = dynamic_cast<LLPersonTabModel *>(mPersonFolderView->mPersonFolderModelMap.begin()->second);
- addParticipantToModel(person_folder_model, LLUUID().generateNewID(), "EastBayGuy");
+ std::string name = prefix + " " + suffix;
+ addParticipantToModel(person_folder_model, LLUUID().generateNewID(), name);
+ // Next suffix : Aa, Ab, Ac ... Az, Ba, Bb, Bc ... Bz, Ca, Cb ...
+ suffix[1]+=1;
+ if (suffix[1]=='{')
+ {
+ suffix[1]='a';
+ suffix[0]+=1;
+ if (suffix[0]=='[')
+ suffix[0]='A';
+ }
}
}
diff --git a/indra/newview/llpersonmodelcommon.cpp b/indra/newview/llpersonmodelcommon.cpp
index 3e9ca9c3b9..9660432b80 100644
--- a/indra/newview/llpersonmodelcommon.cpp
+++ b/indra/newview/llpersonmodelcommon.cpp
@@ -31,21 +31,23 @@
#include "llevents.h"
#include "llsdutil.h"
+#include "llstring.h"
//
// LLPersonModelCommon
//
LLPersonModelCommon::LLPersonModelCommon(std::string display_name, LLFolderViewModelInterface& root_view_model) :
-LLFolderViewModelItemCommon(root_view_model),
- mName(display_name),
+ LLFolderViewModelItemCommon(root_view_model),
mID(LLUUID().generateNewID())
{
+ renameItem(display_name);
}
LLPersonModelCommon::LLPersonModelCommon(LLFolderViewModelInterface& root_view_model) :
-LLFolderViewModelItemCommon(root_view_model),
+ LLFolderViewModelItemCommon(root_view_model),
mName(""),
+ mSearchableName(""),
mID(LLUUID().generateNewID())
{
}
@@ -55,6 +57,14 @@ LLPersonModelCommon::~LLPersonModelCommon()
}
+BOOL LLPersonModelCommon::renameItem(const std::string& new_name)
+{
+ mName = new_name;
+ mSearchableName = new_name;
+ LLStringUtil::toUpper(mSearchableName);
+ return TRUE;
+}
+
void LLPersonModelCommon::postEvent(const std::string& event_type, LLPersonTabModel* folder, LLPersonModel* person)
{
LLUUID folder_id = folder->getID();
@@ -84,6 +94,39 @@ void LLPersonModelCommon::showProperties(void)
{
}
+bool LLPersonModelCommon::filter( LLFolderViewFilter& filter)
+{
+ // See LLFolderViewModelItemInventory::filter()
+/*
+ if (!filter.isModified())
+ {
+ llinfos << "Merov : LLPersonModelCommon::filter, exit, no modif" << llendl;
+ return true;
+ }
+*/
+ if (!mChildren.empty())
+ {
+ //llinfos << "Merov : LLPersonModelCommon::filter, filtering folder = " << getDisplayName() << llendl;
+ setPassedFilter(1, -1, filter.getStringMatchOffset(this), filter.getFilterStringSize());
+ for (child_list_t::iterator iter = mChildren.begin(), end_iter = mChildren.end();
+ iter != end_iter;
+ ++iter)
+ {
+ // LLFolderViewModelItem
+ LLPersonModelCommon* item = dynamic_cast<LLPersonModelCommon*>(*iter);
+ item->filter(filter);
+ }
+ }
+ else
+ {
+ const bool passed_filter = filter.check(this);
+ setPassedFilter(passed_filter, -1, filter.getStringMatchOffset(this), filter.getFilterStringSize());
+ }
+
+ filter.clearModified();
+ return true;
+}
+
//
// LLPersonTabModel
//
@@ -186,7 +229,7 @@ void LLPersonViewFilter::setFilterSubString(const std::string& string)
if (mFilterSubString != filter_sub_string_new)
{
// *TODO : Add logic to support more and less restrictive filtering
- mFilterModified = FILTER_RESTART;
+ setModified(FILTER_RESTART);
mFilterSubString = filter_sub_string_new;
}
}
@@ -198,9 +241,7 @@ bool LLPersonViewFilter::showAllResults() const
bool LLPersonViewFilter::check(const LLFolderViewModelItem* item)
{
- std::string::size_type string_offset = mFilterSubString.size() ? item->getSearchableName().find(mFilterSubString) : std::string::npos;
-
- return (mFilterSubString.size() == 0 || string_offset != std::string::npos);
+ return (mFilterSubString.size() ? (item->getSearchableName().find(mFilterSubString) != std::string::npos) : true);
}
std::string::size_type LLPersonViewFilter::getStringMatchOffset(LLFolderViewModelItem* item) const
diff --git a/indra/newview/llpersonmodelcommon.h b/indra/newview/llpersonmodelcommon.h
index 9e13a7d7d9..1e9117c2df 100644
--- a/indra/newview/llpersonmodelcommon.h
+++ b/indra/newview/llpersonmodelcommon.h
@@ -46,13 +46,14 @@ public:
// Stub those things we won't really be using in this conversation context
virtual const std::string& getName() const { return mName; }
virtual const std::string& getDisplayName() const { return mName; }
- virtual const std::string& getSearchableName() const { return mName; }
+ virtual const std::string& getSearchableName() const { return mSearchableName; }
+
virtual LLPointer<LLUIImage> getIcon() const { return NULL; }
virtual LLPointer<LLUIImage> getOpenIcon() const { return getIcon(); }
virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; }
virtual std::string getLabelSuffix() const { return LLStringUtil::null; }
virtual BOOL isItemRenameable() const { return TRUE; }
- virtual BOOL renameItem(const std::string& new_name) { mName = new_name; return TRUE; }
+ virtual BOOL renameItem(const std::string& new_name);
virtual BOOL isItemMovable( void ) const { return FALSE; }
virtual BOOL isItemRemovable( void ) const { return FALSE; }
virtual BOOL isItemInTrash( void) const { return FALSE; }
@@ -70,10 +71,12 @@ public:
virtual bool hasChildren() const { return FALSE; }
virtual bool potentiallyVisible() { return true; }
- virtual bool filter( LLFolderViewFilter& filter) { return false; }
+
+ virtual bool filter( LLFolderViewFilter& filter);
+
virtual bool descendantsPassedFilter(S32 filter_generation = -1) { return true; }
- virtual void setPassedFilter(bool passed, S32 filter_generation, std::string::size_type string_offset = std::string::npos, std::string::size_type string_size = 0) { }
- virtual bool passedFilter(S32 filter_generation = -1) { return true; }
+// virtual void setPassedFilter(bool passed, S32 filter_generation, std::string::size_type string_offset = std::string::npos, std::string::size_type string_size = 0) { }
+ virtual bool passedFilter(S32 filter_generation = -1) { return mPassedFilter; }
// The action callbacks
virtual void performAction(LLInventoryModel* model, std::string action);
@@ -97,7 +100,8 @@ public:
protected:
- std::string mName; // Name of the session or the participant
+ std::string mName; // Name of the person
+ std::string mSearchableName; // Name used in string matching for this person
LLUUID mID;
};
@@ -175,7 +179,7 @@ public:
// +-------------------------------------------------------------------+
// Note : we currently filter the whole person list at once, no need to count then.
void setFilterCount(S32 count) { }
- S32 getFilterCount() const { return 0; }
+ S32 getFilterCount() const { return 1; }
void decrementFilterCount() { }
// +-------------------------------------------------------------------+