summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorGilbert Gonzales <gilbert@lindenlab.com>2012-08-01 17:36:46 -0700
committerGilbert Gonzales <gilbert@lindenlab.com>2012-08-01 17:36:46 -0700
commit1d6957ce09f92df6c0766162de1a84547f40e3bd (patch)
tree34b15b0722b838702d1185b96b239a46a7fcc7c9 /indra/llui
parentc6d981a8430f02a5a78afbeece9afeb7b2f108c8 (diff)
parent898ec6cd362cd92ceef8dca8faf3fb8ed119b1be (diff)
merge of latest changes
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llfolderview.cpp12
-rw-r--r--indra/llui/llfolderview.h3
-rw-r--r--indra/llui/llfolderviewitem.cpp134
-rw-r--r--indra/llui/llfolderviewitem.h31
-rw-r--r--indra/llui/llfolderviewmodel.cpp8
-rw-r--r--indra/llui/llfolderviewmodel.h99
-rw-r--r--indra/llui/lluictrlfactory.cpp5
-rw-r--r--indra/llui/lluictrlfactory.h5
8 files changed, 163 insertions, 134 deletions
diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp
index bc286c1868..0c1ed2aab9 100644
--- a/indra/llui/llfolderview.cpp
+++ b/indra/llui/llfolderview.cpp
@@ -274,7 +274,7 @@ BOOL LLFolderView::canFocusChildren() const
return FALSE;
}
-BOOL LLFolderView::addFolder( LLFolderViewFolder* folder)
+void LLFolderView::addFolder( LLFolderViewFolder* folder)
{
LLFolderViewFolder::addFolder(folder);
@@ -288,8 +288,6 @@ BOOL LLFolderView::addFolder( LLFolderViewFolder* folder)
//{
// mFolders.insert(mFolders.begin(), folder);
//}
-
- return TRUE;
}
void LLFolderView::closeAllFolders()
@@ -1766,14 +1764,14 @@ void LLFolderView::update()
// until that inventory is loaded up.
LLFastTimer t2(FTM_INVENTORY);
- if (getFolderViewModel()->getFilter()->isModified() && getFolderViewModel()->getFilter()->isNotDefault())
+ if (getFolderViewModel()->getFilter().isModified() && getFolderViewModel()->getFilter().isNotDefault())
{
mNeedsAutoSelect = TRUE;
}
- getFolderViewModel()->getFilter()->clearModified();
+ getFolderViewModel()->getFilter().clearModified();
// filter to determine visibility before arranging
- filter(*(getFolderViewModel()->getFilter()));
+ filter(getFolderViewModel()->getFilter());
// automatically show matching items, and select first one if we had a selection
if (mNeedsAutoSelect)
@@ -1791,7 +1789,7 @@ void LLFolderView::update()
// Open filtered folders for folder views with mAutoSelectOverride=TRUE.
// Used by LLPlacesFolderView.
- if (getFolderViewModel()->getFilter()->showAllResults())
+ if (getFolderViewModel()->getFilter().showAllResults())
{
// these are named variables to get around gcc not binding non-const references to rvalues
// and functor application is inherently non-const to allow for stateful functors
diff --git a/indra/llui/llfolderview.h b/indra/llui/llfolderview.h
index ba37a11bbe..05beff9bd8 100644
--- a/indra/llui/llfolderview.h
+++ b/indra/llui/llfolderview.h
@@ -121,7 +121,7 @@ public:
void closeAllFolders();
void openTopLevelFolders();
- virtual BOOL addFolder( LLFolderViewFolder* folder);
+ virtual void addFolder( LLFolderViewFolder* folder);
// Find width and height of this object and its children. Also
// makes sure that this view and its children are the right size.
@@ -217,6 +217,7 @@ public:
BOOL getShowSingleSelection() { return mShowSingleSelection; }
F32 getSelectionFadeElapsedTime() { return mMultiSelectionFadeTimer.getElapsedTimeF32(); }
bool getUseEllipses() { return mUseEllipses; }
+ S32 getSelectedCount() { return (S32)mSelectedItems.size(); }
void update(); // needs to be called periodically (e.g. once per frame)
diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp
index 2f17fa7c35..480332ae70 100644
--- a/indra/llui/llfolderviewitem.cpp
+++ b/indra/llui/llfolderviewitem.cpp
@@ -89,7 +89,8 @@ LLFolderViewItem::Params::Params()
selection_image("selection_image"),
item_height("item_height"),
item_top_pad("item_top_pad"),
- creation_date()
+ creation_date(),
+ allow_open("allow_open", true)
{}
// Default constructor
@@ -105,14 +106,13 @@ LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
mHasVisibleChildren(FALSE),
mIndentation(0),
mItemHeight(p.item_height),
- //TODO RN: create interface for string highlighting
- //mStringMatchOffset(std::string::npos),
mControlLabelRotation(0.f),
mDragAndDropTarget(FALSE),
mLabel(p.name),
mRoot(p.root),
mViewModelItem(p.listener),
- mIsMouseOverTitle(false)
+ mIsMouseOverTitle(false),
+ mAllowOpen(p.allow_open)
{
if (mViewModelItem)
{
@@ -219,11 +219,11 @@ void LLFolderViewItem::refresh()
mIconOpen = vmi.getIconOpen();
mIconOverlay = vmi.getIconOverlay();
- if (mRoot->useLabelSuffix())
- {
+ if (mRoot->useLabelSuffix())
+ {
mLabelStyle = vmi.getLabelStyle();
mLabelSuffix = vmi.getLabelSuffix();
-}
+ }
//TODO RN: make sure this logic still fires
//std::string searchable_label(mLabel);
@@ -253,7 +253,7 @@ void LLFolderViewItem::arrangeAndSet(BOOL set_selection,
LLFolderView* root = getRoot();
if (getParentFolder())
{
- getParentFolder()->requestArrange();
+ getParentFolder()->requestArrange();
}
if(set_selection)
{
@@ -273,9 +273,9 @@ std::set<LLFolderViewItem*> LLFolderViewItem::getSelectionList() const
}
// addToFolder() returns TRUE if it succeeds. FALSE otherwise
-BOOL LLFolderViewItem::addToFolder(LLFolderViewFolder* folder)
+void LLFolderViewItem::addToFolder(LLFolderViewFolder* folder)
{
- return folder->addItem(this);
+ folder->addItem(this);
}
@@ -404,8 +404,11 @@ void LLFolderViewItem::buildContextMenu(LLMenuGL& menu, U32 flags)
void LLFolderViewItem::openItem( void )
{
+ if (mAllowOpen)
+ {
getViewModelItem()->openItem();
}
+}
void LLFolderViewItem::rename(const std::string& new_name)
{
@@ -413,12 +416,12 @@ void LLFolderViewItem::rename(const std::string& new_name)
{
getViewModelItem()->renameItem(new_name);
- if(mParentFolder)
- {
- mParentFolder->requestSort();
- }
- }
+ //if(mParentFolder)
+ //{
+ // mParentFolder->requestSort();
+ //}
}
+}
const std::string& LLFolderViewItem::getName( void ) const
{
@@ -517,7 +520,7 @@ BOOL LLFolderViewItem::handleHover( S32 x, S32 y, MASK mask )
BOOL LLFolderViewItem::handleDoubleClick( S32 x, S32 y, MASK mask )
{
- getViewModelItem()->openItem();
+ openItem();
return TRUE;
}
@@ -744,15 +747,29 @@ void LLFolderViewItem::draw()
return;
}
+ std::string::size_type filter_string_length = mViewModelItem->hasFilterStringMatch() ? mViewModelItem->getFilterStringSize() : 0;
+ F32 right_x = 0;
+ F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD;
+ F32 text_left = (F32)(ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + mIndentation);
+ std::string combined_string = mLabel + mLabelSuffix;
+
+ if (filter_string_length > 0)
+ {
+ S32 left = llround(text_left) + font->getWidth(combined_string, 0, mViewModelItem->getFilterStringOffset()) - 2;
+ S32 right = left + font->getWidth(combined_string, mViewModelItem->getFilterStringOffset(), filter_string_length) + 2;
+ S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD);
+ S32 top = getRect().getHeight() - TOP_PAD;
+
+ LLUIImage* box_image = default_params.selection_image;
+ LLRect box_rect(left, top, right, bottom);
+ box_image->draw(box_rect, sFilterBGColor);
+ }
+
LLColor4 color = (mIsSelected && filled) ? sHighlightFgColor : sFgColor;
//TODO RN: implement this in terms of getColor()
//if (highlight_link) color = sLinkColor;
//if (gInventory.isObjectDescendentOf(getViewModelItem()->getUUID(), gInventory.getLibraryRootFolderID())) color = sLibraryColor;
- F32 right_x = 0;
- F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD;
- F32 text_left = (F32)(ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + mIndentation);
-
//--------------------------------------------------------------------------------//
// Draw the actual label text
//
@@ -773,29 +790,14 @@ void LLFolderViewItem::draw()
//--------------------------------------------------------------------------------//
// Highlight string match
//
- //TODO RN: expose interface for highlighting
- //if (mStringMatchOffset != std::string::npos)
- //{
- // // don't draw backgrounds for zero-length strings
- // S32 filter_string_length = getRoot()->getFilterSubString().size();
- // if (filter_string_length > 0)
- // {
- // std::string combined_string = mLabel + mLabelSuffix;
- // S32 left = llround(text_left) + font->getWidth(combined_string, 0, mStringMatchOffset) - 1;
- // S32 right = left + font->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2;
- // S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD);
- // S32 top = getRect().getHeight() - TOP_PAD;
- //
- // LLUIImage* box_image = default_params.selection_image;
- // LLRect box_rect(left, top, right, bottom);
- // box_image->draw(box_rect, sFilterBGColor);
- // F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mStringMatchOffset);
- // F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD;
- // font->renderUTF8( combined_string, mStringMatchOffset, match_string_left, yy,
- // sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
- // filter_string_length, S32_MAX, &right_x, FALSE );
- // }
- //}
+ if (filter_string_length > 0)
+ {
+ F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mViewModelItem->getFilterStringOffset());
+ F32 yy = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD - (F32)TOP_PAD;
+ font->renderUTF8( combined_string, mViewModelItem->getFilterStringOffset(), match_string_left, yy,
+ sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
+ filter_string_length, S32_MAX, &right_x, FALSE );
+ }
}
const LLFolderViewModelInterface* LLFolderViewItem::getFolderViewModel( void ) const
@@ -834,9 +836,9 @@ LLFolderViewFolder::~LLFolderViewFolder( void )
}
// addToFolder() returns TRUE if it succeeds. FALSE otherwise
-BOOL LLFolderViewFolder::addToFolder(LLFolderViewFolder* folder)
+void LLFolderViewFolder::addToFolder(LLFolderViewFolder* folder)
{
- return folder->addFolder(this);
+ folder->addFolder(this);
}
static LLFastTimer::DeclareTimer FTM_ARRANGE("Arrange");
@@ -1003,11 +1005,6 @@ BOOL LLFolderViewFolder::needsArrange()
return mLastArrangeGeneration < getRoot()->getArrangeGeneration();
}
-void LLFolderViewFolder::requestSort()
-{
- getViewModelItem()->requestSort();
-}
-
//TODO RN: get height resetting working
//void LLFolderViewFolder::setPassedFilter(BOOL passed, BOOL passed_folder, S32 filter_generation)
//{
@@ -1412,7 +1409,6 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item )
}
//item has been removed, need to update filter
getViewModelItem()->removeChild(item->getViewModelItem());
- getViewModelItem()->dirtyFilter();
//because an item is going away regardless of filter status, force rearrange
requestArrange();
removeChild(item);
@@ -1478,7 +1474,7 @@ BOOL LLFolderViewFolder::isRemovable()
}
// this is an internal method used for adding items to folders.
-BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item)
+void LLFolderViewFolder::addItem(LLFolderViewItem* item)
{
if (item->getParentFolder())
{
@@ -1491,7 +1487,6 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item)
item->setRect(LLRect(0, 0, getRect().getWidth(), 0));
item->setVisible(FALSE);
- addChild(item);
// TODO RN - port creation date management to new code location
#if 0
@@ -1499,10 +1494,7 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item)
setCreationDate(llmax<time_t>(mCreationDate, item->getCreationDate()));
#endif
- // Handle sorting
- requestArrange();
- requestSort();
-
+ addChild(item);
getViewModelItem()->addChild(item->getViewModelItem());
// TODO RN - port creation date management to new code location
#if 0
@@ -1528,14 +1520,10 @@ BOOL LLFolderViewFolder::addItem(LLFolderViewItem* item)
// parentp = parentp->getParentFolder();
//}
-
- item->getViewModelItem()->dirtyFilter();
-
- return TRUE;
}
// this is an internal method used for adding items to folders.
-BOOL LLFolderViewFolder::addFolder(LLFolderViewFolder* folder)
+void LLFolderViewFolder::addFolder(LLFolderViewFolder* folder)
{
if (folder->mParentFolder)
{
@@ -1546,30 +1534,26 @@ BOOL LLFolderViewFolder::addFolder(LLFolderViewFolder* folder)
folder->setOrigin(0, 0);
folder->reshape(getRect().getWidth(), 0);
folder->setVisible(FALSE);
- addChild( folder );
// rearrange all descendants too, as our indentation level might have changed
- folder->requestArrange();
- requestSort();
+ //folder->requestArrange();
+ //requestSort();
+ addChild( folder );
getViewModelItem()->addChild(folder->getViewModelItem());
- //After addChild since addChild assigns parent to bubble up to when calling dirtyFilter
- folder->getViewModelItem()->dirtyFilter();
-
- return TRUE;
}
void LLFolderViewFolder::requestArrange()
{
//if ( mLastArrangeGeneration != -1)
{
- mLastArrangeGeneration = -1;
- // flag all items up to root
- if (mParentFolder)
- {
- mParentFolder->requestArrange();
- }
+ mLastArrangeGeneration = -1;
+ // flag all items up to root
+ if (mParentFolder)
+ {
+ mParentFolder->requestArrange();
}
}
+}
void LLFolderViewFolder::toggleOpen()
{
diff --git a/indra/llui/llfolderviewitem.h b/indra/llui/llfolderviewitem.h
index 50d3e0580e..4eda02f13f 100644
--- a/indra/llui/llfolderviewitem.h
+++ b/indra/llui/llfolderviewitem.h
@@ -61,6 +61,7 @@ public:
item_top_pad;
Optional<time_t> creation_date;
+ Optional<bool> allow_open;
Params();
};
@@ -92,30 +93,29 @@ protected:
bool mLabelWidthDirty;
LLFolderViewFolder* mParentFolder;
LLFolderViewModelItem* mViewModelItem;
- BOOL mIsCurSelection;
- BOOL mSelectPending;
LLFontGL::StyleFlags mLabelStyle;
std::string mLabelSuffix;
LLUIImagePtr mIcon;
LLUIImagePtr mIconOpen;
LLUIImagePtr mIconOverlay;
- BOOL mHasVisibleChildren;
S32 mIndentation;
S32 mItemHeight;
S32 mDragStartX,
mDragStartY;
- //TODO RN: create interface for string highlighting
- //std::string::size_type mStringMatchOffset;
F32 mControlLabelRotation;
LLFolderView* mRoot;
- BOOL mDragAndDropTarget;
+ bool mHasVisibleChildren;
+ bool mIsCurSelection;
+ bool mDragAndDropTarget;
bool mIsMouseOverTitle;
+ bool mAllowOpen;
+ bool mSelectPending;
// this is an internal method used for adding items to folders. A
// no-op at this level, but reimplemented in derived classes.
- virtual BOOL addItem(LLFolderViewItem*) { return FALSE; }
- virtual BOOL addFolder(LLFolderViewFolder*) { return FALSE; }
+ virtual void addItem(LLFolderViewItem*) { }
+ virtual void addFolder(LLFolderViewFolder*) { }
static LLFontGL* getLabelFontForStyle(U8 style);
@@ -129,7 +129,7 @@ public:
virtual ~LLFolderViewItem( void );
// addToFolder() returns TRUE if it succeeds. FALSE otherwise
- virtual BOOL addToFolder(LLFolderViewFolder* folder);
+ virtual void addToFolder(LLFolderViewFolder* folder);
// Finds width and height of this object and it's children. Also
// makes sure that this view and it's children are the right size.
@@ -295,7 +295,7 @@ public:
LLFolderViewItem* getPreviousFromChild( LLFolderViewItem*, BOOL include_children = TRUE );
// addToFolder() returns TRUE if it succeeds. FALSE otherwise
- virtual BOOL addToFolder(LLFolderViewFolder* folder);
+ virtual void addToFolder(LLFolderViewFolder* folder);
// Finds width and height of this object and it's children. Also
// makes sure that this view and it's children are the right size.
@@ -354,8 +354,6 @@ public:
// Called when a child is refreshed.
virtual void requestArrange();
- virtual void requestSort();
-
// internal method which doesn't update the entire view. This
// method was written because the list iterators destroy the state
// of other iterations, thus, we can't arrange while iterating
@@ -379,8 +377,6 @@ public:
void applyFunctorToChildren(LLFolderViewFunctor& functor);
virtual void openItem( void );
- virtual BOOL addItem(LLFolderViewItem* item);
- virtual BOOL addFolder( LLFolderViewFolder* folder);
// LLView functionality
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
@@ -410,7 +406,12 @@ public:
LLFolderViewFolder* getCommonAncestor(LLFolderViewItem* item_a, LLFolderViewItem* item_b, bool& reverse);
void gatherChildRangeExclusive(LLFolderViewItem* start, LLFolderViewItem* end, bool reverse, std::vector<LLFolderViewItem*>& items);
-public:
+ // internal functions for tracking folders and items separately
+ // use addToFolder() virtual method to ensure folders are always added to mFolders
+ // and not mItems
+ void addItem(LLFolderViewItem* item);
+ void addFolder( LLFolderViewFolder* folder);
+
//WARNING: do not call directly...use the appropriate LLFolderViewModel-derived class instead
template<typename SORT_FUNC> void sortFolders(const SORT_FUNC& func) { mFolders.sort(func); }
template<typename SORT_FUNC> void sortItems(const SORT_FUNC& func) { mItems.sort(func); }
diff --git a/indra/llui/llfolderviewmodel.cpp b/indra/llui/llfolderviewmodel.cpp
index dc6e4d754b..6aa4a63edc 100644
--- a/indra/llui/llfolderviewmodel.cpp
+++ b/indra/llui/llfolderviewmodel.cpp
@@ -36,18 +36,18 @@ bool LLFolderViewModelCommon::needsSort(LLFolderViewModelItem* item)
std::string LLFolderViewModelCommon::getStatusText()
{
- if (!contentsReady() || mFolderView->getViewModelItem()->getLastFilterGeneration() < getFilter()->getCurrentGeneration())
+ if (!contentsReady() || mFolderView->getViewModelItem()->getLastFilterGeneration() < getFilter().getCurrentGeneration())
{
return LLTrans::getString("Searching");
}
else
{
- return getFilter()->getEmptyLookupMessage();
+ return getFilter().getEmptyLookupMessage();
}
}
void LLFolderViewModelCommon::filter()
{
- getFilter()->setFilterCount(llclamp(LLUI::sSettingGroups["config"]->getS32("FilterItemsPerFrame"), 1, 5000));
- mFolderView->getViewModelItem()->filter(*getFilter());
+ getFilter().setFilterCount(llclamp(LLUI::sSettingGroups["config"]->getS32("FilterItemsPerFrame"), 1, 5000));
+ mFolderView->getViewModelItem()->filter(getFilter());
}
diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h
index acdec53602..c4d98657e2 100644
--- a/indra/llui/llfolderviewmodel.h
+++ b/indra/llui/llfolderviewmodel.h
@@ -73,6 +73,8 @@ public:
virtual bool showAllResults() const = 0;
+ virtual std::string::size_type getStringMatchOffset(LLFolderViewModelItem* item) const = 0;
+ virtual std::string::size_type getFilterStringSize() const = 0;
// +-------------------------------------------------------------------+
// + Status
// +-------------------------------------------------------------------+
@@ -107,6 +109,24 @@ public:
virtual S32 getFirstRequiredGeneration() const = 0;
};
+class LLFolderViewModelInterface
+{
+public:
+ virtual ~LLFolderViewModelInterface() {}
+ virtual void requestSortAll() = 0;
+
+ virtual void sort(class LLFolderViewFolder*) = 0;
+ virtual void filter() = 0;
+
+ virtual bool contentsReady() = 0;
+ virtual void setFolderView(LLFolderView* folder_view) = 0;
+ virtual LLFolderViewFilter& getFilter() = 0;
+ virtual const LLFolderViewFilter& getFilter() const = 0;
+ virtual std::string getStatusText() = 0;
+
+ virtual bool startDrag(std::vector<LLFolderViewModelItem*>& items) = 0;
+};
+
// This is am abstract base class that users of the folderview classes
// would use to bridge the folder view with the underlying data
class LLFolderViewModelItem
@@ -155,8 +175,11 @@ public:
virtual void filter( LLFolderViewFilter& filter) = 0;
virtual bool passedFilter(S32 filter_generation = -1) = 0;
virtual bool descendantsPassedFilter(S32 filter_generation = -1) = 0;
- virtual void setPassedFilter(bool passed, bool passed_folder, S32 filter_generation) = 0;
+ virtual void setPassedFilter(bool passed, bool passed_folder, S32 filter_generation, std::string::size_type string_offset = std::string::npos, std::string::size_type string_size = 0) = 0;
virtual void dirtyFilter() = 0;
+ virtual bool hasFilterStringMatch() = 0;
+ virtual std::string::size_type getFilterStringOffset() = 0;
+ virtual std::string::size_type getFilterStringSize() = 0;
virtual S32 getLastFilterGeneration() const = 0;
@@ -188,15 +211,17 @@ protected:
class LLFolderViewModelItemCommon : public LLFolderViewModelItem
{
public:
- LLFolderViewModelItemCommon()
+ LLFolderViewModelItemCommon(LLFolderViewModelInterface& root_view_model)
: mSortVersion(-1),
mPassedFilter(true),
mPassedFolderFilter(true),
- mPrevPassedAllFilters(false),
+ mStringMatchOffsetFilter(std::string::npos),
+ mStringFilterSize(0),
mFolderViewItem(NULL),
mLastFilterGeneration(-1),
mMostFilteredDescendantGeneration(-1),
- mParent(NULL)
+ mParent(NULL),
+ mRootViewModel(root_view_model)
{
std::for_each(mChildren.begin(), mChildren.end(), DeletePointer());
}
@@ -216,24 +241,67 @@ public:
mParent->dirtyFilter();
}
}
+ bool hasFilterStringMatch() { return mStringMatchOffsetFilter != std::string::npos; }
+ std::string::size_type getFilterStringOffset() { return mStringMatchOffsetFilter; }
+ std::string::size_type getFilterStringSize() { return mStringFilterSize; }
+
virtual void addChild(LLFolderViewModelItem* child)
{
mChildren.push_back(child);
child->setParent(this);
+ dirtyFilter();
+ requestSort();
}
virtual void removeChild(LLFolderViewModelItem* child)
{
mChildren.remove(child);
child->setParent(NULL);
+ dirtyFilter();
+ }
+
+ void setPassedFilter(bool passed, bool passed_folder, S32 filter_generation, std::string::size_type string_offset = std::string::npos, std::string::size_type string_size = 0)
+ {
+ mPassedFilter = passed;
+ mPassedFolderFilter = passed_folder;
+ mLastFilterGeneration = filter_generation;
+ mStringMatchOffsetFilter = string_offset;
+ mStringFilterSize = string_size;
+ }
+
+ virtual bool potentiallyVisible()
+ {
+ return passedFilter() // we've passed the filter
+ || getLastFilterGeneration() < mRootViewModel.getFilter().getFirstSuccessGeneration() // or we don't know yet
+ || descendantsPassedFilter();
+ }
+
+ virtual bool passedFilter(S32 filter_generation = -1)
+ {
+ if (filter_generation < 0)
+ filter_generation = mRootViewModel.getFilter().getFirstSuccessGeneration();
+
+ bool passed_folder_filter = mPassedFolderFilter && mLastFilterGeneration >= filter_generation;
+ bool passed_filter = mPassedFilter && mLastFilterGeneration >= filter_generation;
+ return passed_folder_filter
+ && (descendantsPassedFilter(filter_generation)
+ || passed_filter);
}
+ virtual bool descendantsPassedFilter(S32 filter_generation = -1)
+ {
+ if (filter_generation < 0) filter_generation = mRootViewModel.getFilter().getFirstSuccessGeneration();
+ return mMostFilteredDescendantGeneration >= filter_generation;
+ }
+
+
protected:
virtual void setParent(LLFolderViewModelItem* parent) { mParent = parent; }
S32 mSortVersion;
bool mPassedFilter;
bool mPassedFolderFilter;
- bool mPrevPassedAllFilters;
+ std::string::size_type mStringMatchOffsetFilter;
+ std::string::size_type mStringFilterSize;
S32 mLastFilterGeneration;
S32 mMostFilteredDescendantGeneration;
@@ -242,28 +310,13 @@ protected:
typedef std::list<LLFolderViewModelItem*> child_list_t;
child_list_t mChildren;
LLFolderViewModelItem* mParent;
+ LLFolderViewModelInterface& mRootViewModel;
void setFolderViewItem(LLFolderViewItem* folder_view_item) { mFolderViewItem = folder_view_item;}
LLFolderViewItem* mFolderViewItem;
};
-class LLFolderViewModelInterface
-{
-public:
- virtual ~LLFolderViewModelInterface() {}
- virtual void requestSortAll() = 0;
-
- virtual void sort(class LLFolderViewFolder*) = 0;
- virtual void filter() = 0;
- virtual bool contentsReady() = 0;
- virtual void setFolderView(LLFolderView* folder_view) = 0;
- virtual LLFolderViewFilter* getFilter() = 0;
- virtual const LLFolderViewFilter* getFilter() const = 0;
- virtual std::string getStatusText() = 0;
-
- virtual bool startDrag(std::vector<LLFolderViewModelItem*>& items) = 0;
-};
class LLFolderViewModelCommon : public LLFolderViewModelInterface
{
@@ -307,8 +360,8 @@ public:
virtual const SortType& getSorter() const { return mSorter; }
virtual void setSorter(const SortType& sorter) { mSorter = sorter; requestSortAll(); }
- virtual FilterType* getFilter() { return &mFilter; }
- virtual const FilterType* getFilter() const { return &mFilter; }
+ virtual FilterType& getFilter() { return mFilter; }
+ virtual const FilterType& getFilter() const { return mFilter; }
virtual void setFilter(const FilterType& filter) { mFilter = filter; }
// TODO RN: remove this and put all filtering logic in view model
diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp
index f64f33bc5e..91a6b3259c 100644
--- a/indra/llui/lluictrlfactory.cpp
+++ b/indra/llui/lluictrlfactory.cpp
@@ -304,9 +304,4 @@ void LLUICtrlFactory::registerWidget(const std::type_info* widget_type, const st
//LLDefaultParamBlockRegistry::instance().defaultRegistrar().add(widget_type, &get_empty_param_block<T>);
}
-//static
-const std::string* LLUICtrlFactory::getWidgetName(const std::type_info* widget_type)
-{
- return LLWidgetNameRegistry::instance().getValue(widget_type);
-}
diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h
index b441cb0c9d..9f18be2371 100644
--- a/indra/llui/lluictrlfactory.h
+++ b/indra/llui/lluictrlfactory.h
@@ -105,7 +105,7 @@ private:
ParamDefaults()
{
// look up template file for this param block...
- const std::string* param_block_tag = getWidgetName(&typeid(PARAM_BLOCK));
+ const std::string* param_block_tag = LLWidgetNameRegistry::instance().getValue(&typeid(PARAM_BLOCK));
if (param_block_tag)
{ // ...and if it exists, back fill values using the most specific template first
PARAM_BLOCK params;
@@ -139,7 +139,6 @@ public:
template<typename T>
static const typename T::Params& getDefaultParams()
{
- //#pragma message("Generating ParamDefaults")
return ParamDefaults<typename T::Params, 0>::instance().get();
}
@@ -303,8 +302,6 @@ private:
}
- static const std::string* getWidgetName(const std::type_info* widget_type);
-
// this exists to get around dependency on llview
static void setCtrlParent(LLView* view, LLView* parent, S32 tab_group);