diff options
Diffstat (limited to 'indra/llui/llscrolllistctrl.cpp')
-rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 72 |
1 files changed, 31 insertions, 41 deletions
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 1d9564d107..e711a6ed1b 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -196,7 +196,6 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p) mHighlightedItem(-1), mBorder(NULL), mSortCallback(NULL), - mCommentTextView(NULL), mNumDynamicWidthColumns(0), mTotalStaticColumnWidth(0), mTotalColumnPadding(0), @@ -288,13 +287,6 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p) addColumn(*row_it); } - for (LLInitParam::ParamIterator<LLScrollListItem::Params>::const_iterator row_it = p.contents.rows.begin(); - row_it != p.contents.rows.end(); - ++row_it) - { - addRow(*row_it); - } - LLTextBox::Params text_p; text_p.name("comment_text"); text_p.border_visible(false); @@ -302,7 +294,15 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p) text_p.follows.flags(FOLLOWS_ALL); // word wrap was added accroding to the EXT-6841 text_p.wrap(true); - addChild(LLUICtrlFactory::create<LLTextBox>(text_p)); + mCommentText = LLUICtrlFactory::create<LLTextBox>(text_p); + addChild(mCommentText); + + for (LLInitParam::ParamIterator<LLScrollListItem::Params>::const_iterator row_it = p.contents.rows.begin(); + row_it != p.contents.rows.end(); + ++row_it) + { + addRow(*row_it); + } } S32 LLScrollListCtrl::getSearchColumn() @@ -541,12 +541,7 @@ void LLScrollListCtrl::updateLayout() getRect().getWidth() - 2 * mBorderThickness, getRect().getHeight() - (2 * mBorderThickness ) - heading_size ); - if (mCommentTextView == NULL) - { - mCommentTextView = getChildView("comment_text"); - } - - mCommentTextView->setShape(mItemListRect); + mCommentText->setShape(mItemListRect); // how many lines of content in a single "page" S32 page_lines = getLinesPerPage(); @@ -664,7 +659,7 @@ S32 LLScrollListCtrl::calcMaxContentWidth() if (mColumnWidthsDirty) { // update max content width for this column, by looking at all items - column->mMaxContentWidth = column->mHeader ? LLFontGL::getFontSansSerifSmall()->getWidth(column->mLabel) + mColumnPadding + HEADING_TEXT_PADDING : 0; + column->mMaxContentWidth = column->mHeader ? LLFontGL::getFontSansSerifSmall()->getWidth(column->mLabel.getWString().c_str()) + mColumnPadding + HEADING_TEXT_PADDING : 0; item_list::iterator iter; for (iter = mItemList.begin(); iter != mItemList.end(); iter++) { @@ -1244,7 +1239,7 @@ void LLScrollListCtrl::deselectAllItems(bool no_commit_on_change) void LLScrollListCtrl::setCommentText(const std::string& comment_text) { - getChild<LLTextBox>("comment_text")->setValue(comment_text); + mCommentText->setValue(comment_text); } LLScrollListItem* LLScrollListCtrl::addSeparator(EAddPosition pos) @@ -1479,10 +1474,9 @@ const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const item = getFirstSelected(); if (item) { - auto col = item->getColumn(column); - if(col) + if (LLScrollListCell* cell = item->getColumn(column)) { - return col->getValue().asString(); + return cell->getValue().asString(); } } @@ -1728,7 +1722,7 @@ void LLScrollListCtrl::draw() updateColumns(); - getChildView("comment_text")->setVisible(mItemList.empty()); + mCommentText->setVisible(mItemList.empty()); drawItems(); @@ -2720,7 +2714,8 @@ struct SameSortColumn bool LLScrollListCtrl::setSort(S32 column_idx, bool ascending) { LLScrollListColumn* sort_column = getColumn(column_idx); - if (!sort_column) return false; + if (!sort_column) + return false; sort_column->mSortDirection = ascending ? LLScrollListColumn::ASCENDING : LLScrollListColumn::DESCENDING; @@ -2733,32 +2728,28 @@ bool LLScrollListCtrl::setSort(S32 column_idx, bool ascending) mSortColumns.push_back(new_sort_column); return true; } - else - { - // grab current sort column - sort_column_t cur_sort_column = mSortColumns.back(); - // remove any existing sort criterion referencing this column - // and add the new one - mSortColumns.erase(remove_if(mSortColumns.begin(), mSortColumns.end(), SameSortColumn(column_idx)), mSortColumns.end()); - mSortColumns.push_back(new_sort_column); + // grab current sort column + sort_column_t cur_sort_column = mSortColumns.back(); - // did the sort criteria change? - return (cur_sort_column != new_sort_column); - } + // remove any existing sort criterion referencing this column + // and add the new one + mSortColumns.erase(remove_if(mSortColumns.begin(), mSortColumns.end(), SameSortColumn(column_idx)), mSortColumns.end()); + mSortColumns.push_back(new_sort_column); + + // did the sort criteria change? + return cur_sort_column != new_sort_column; } S32 LLScrollListCtrl::getLinesPerPage() { - //if mPageLines is NOT provided display all item if (mPageLines) { return mPageLines; } - else - { - return mLineHeight ? mItemListRect.getHeight() / mLineHeight : getItemCount(); - } + + // If mPageLines is NOT provided then display all items + return mLineHeight ? mItemListRect.getHeight() / mLineHeight : getItemCount(); } @@ -2774,7 +2765,7 @@ void LLScrollListCtrl::sortByColumn(const std::string& name, bool ascending) column_map_t::iterator itor = mColumns.find(name); if (itor != mColumns.end()) { - sortByColumnIndex((*itor).second->mIndex, ascending); + sortByColumnIndex(itor->second->mIndex, ascending); } } @@ -3093,8 +3084,7 @@ std::string LLScrollListCtrl::getSortColumnName() { LLScrollListColumn* column = mSortColumns.empty() ? NULL : mColumnsIndexed[mSortColumns.back().first]; - if (column) return column->mName; - else return ""; + return column ? column->mName : LLStringUtil::null; } bool LLScrollListCtrl::hasSortOrder() const |