void TTable::RemoveRows(const TIntV& RemoveV){ for(TInt i = 0; i < RemoveV.Len(); i++){RemoveRow(RemoveV[i]);} }
void ListView1::SetDataCDList() { while (CountRows()>0) RemoveRow(0); while (CountColumns()>0) { BColumn *col=ColumnAt(0); //SetColumnVisible(col, true); RemoveColumn(col); /* switch(col->LogicalFieldNum()) { case TRACKNUMBER_FIELD: { ((Application1 *)be_app)->CM->SetInt16(TRACKNUMBERCOLUMN_WIDTH, (int16)col->Width()); break; } case TRACKNAME_FIELD: { ((Application1 *)be_app)->CM->SetInt16(TRACKNAMECOLUMN_WIDTH, (int16)col->Width()); break; } case LENGTH_FIELD: { ((Application1 *)be_app)->CM->SetInt16(LENGTHCOLUMN_WIDTH, (int16)col->Width()); break; } case BYTES_FIELD: { ((Application1 *)be_app)->CM->SetInt16(BYTESCOLUMN_WIDTH, (int16)col->Width()); break; } case INDEX_FIELD: { ((Application1 *)be_app)->CM->SetInt16(INDEXCOLUMN_WIDTH, (int16)col->Width()); break; } case CDTEXT_FIELD: { ((Application1 *)be_app)->CM->SetInt16(CDTEXTCOLUMN_WIDTH, (int16)col->Width()); break; } default: { break; } } */ delete col; } SetSortingEnabled(true); AddColumn(new BBitmapColumn(_T("Icon"), // "FILEICONCOLUMN_TITLE" 18.0,18.0,18.0, B_ALIGN_CENTER), ICON_FIELD); AddColumn(new BFileColumn(_T("File name"), // "FILENAMECOLUMN_TITLE" 200.0, 60.0, 900.0,0), FILENAME_FIELD); AddColumn(new BSizeColumn(_T("Size"), // "SIZECOLUMN_TITLE" 50.0, 20.0, 120.0,B_ALIGN_RIGHT), SIZE_FIELD); ColumnAt(FILENAME_FIELD)->SetEditFlags(B_EDIT_EXIT_RETURN); ColumnAt(FILENAME_FIELD)->SetColumnFlags(ColumnAt(FILENAME_FIELD)->GetColumnFlags() | B_ALLOW_COLUMN_EDIT); ColumnAt(ICON_FIELD)->SetColumnFlags(B_ALLOW_COLUMN_NONE); ColumnAt(ICON_FIELD)->SetShowHeading(false); SetSortColumn(ColumnAt(FILENAME_FIELD), false, true); for (int32 i=0; i<CountColumns(); i++) { SetColumnVisible(ColumnAt(i), true); } for (int32 i=0; i<CountColumns(); i++) { SetColumnVisible(ColumnAt(i), false); } for (int32 i=0; i<CountColumns(); i++) { SetColumnVisible(ColumnAt(i), true); } }
void nsTreeContentView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aChild, int32_t aIndexInContainer, nsIContent* aPreviousSibling) { NS_ASSERTION(aChild, "null ptr"); // Make sure this notification concerns us. // First check the tag to see if it's one that we care about. nsIAtom *tag = aChild->Tag(); // We don't consider non-XUL nodes. if (!aChild->IsXUL() || !aContainer->IsXUL()) return; if (tag != nsGkAtoms::treeitem && tag != nsGkAtoms::treeseparator && tag != nsGkAtoms::treechildren && tag != nsGkAtoms::treerow && tag != nsGkAtoms::treecell) { return; } // If we have a legal tag, go up to the tree/select and make sure // that it's ours. for (nsIContent* element = aContainer; element != mBody; element = element->GetParent()) { if (!element) return; // this is not for us nsIAtom *parentTag = element->Tag(); if (element->IsXUL() && parentTag == nsGkAtoms::tree) return; // this is not for us } // Lots of codepaths under here that do all sorts of stuff, so be safe. nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this); if (tag == nsGkAtoms::treechildren) { int32_t index = FindContent(aContainer); if (index >= 0) { Row* row = mRows[index]; row->SetEmpty(true); int32_t count = RemoveSubtree(index); // Invalidate also the row to update twisty. if (mBoxObject) { mBoxObject->InvalidateRow(index); mBoxObject->RowCountChanged(index + 1, -count); } } } else if (tag == nsGkAtoms::treeitem || tag == nsGkAtoms::treeseparator ) { int32_t index = FindContent(aChild); if (index >= 0) { int32_t count = RemoveRow(index); if (mBoxObject) mBoxObject->RowCountChanged(index, -count); } } else if (tag == nsGkAtoms::treerow) { int32_t index = FindContent(aContainer); if (index >= 0 && mBoxObject) mBoxObject->InvalidateRow(index); } else if (tag == nsGkAtoms::treecell) { nsCOMPtr<nsIContent> parent = aContainer->GetParent(); if (parent) { int32_t index = FindContent(parent); if (index >= 0 && mBoxObject) mBoxObject->InvalidateRow(index); } } }
void nsTreeContentView::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, int32_t aModType) { // Lots of codepaths under here that do all sorts of stuff, so be safe. nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this); // Make sure this notification concerns us. // First check the tag to see if it's one that we care about. nsIAtom* tag = aElement->Tag(); if (mBoxObject && (aElement == mRoot || aElement == mBody)) { mBoxObject->ClearStyleAndImageCaches(); mBoxObject->Invalidate(); } // We don't consider non-XUL nodes. nsIContent* parent = nullptr; if (!aElement->IsXUL() || ((parent = aElement->GetParent()) && !parent->IsXUL())) { return; } if (tag != nsGkAtoms::treecol && tag != nsGkAtoms::treeitem && tag != nsGkAtoms::treeseparator && tag != nsGkAtoms::treerow && tag != nsGkAtoms::treecell) { return; } // If we have a legal tag, go up to the tree/select and make sure // that it's ours. for (nsIContent* element = aElement; element != mBody; element = element->GetParent()) { if (!element) return; // this is not for us nsIAtom *parentTag = element->Tag(); if (element->IsXUL() && parentTag == nsGkAtoms::tree) return; // this is not for us } // Handle changes of the hidden attribute. if (aAttribute == nsGkAtoms::hidden && (tag == nsGkAtoms::treeitem || tag == nsGkAtoms::treeseparator)) { bool hidden = aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden, nsGkAtoms::_true, eCaseMatters); int32_t index = FindContent(aElement); if (hidden && index >= 0) { // Hide this row along with its children. int32_t count = RemoveRow(index); if (mBoxObject) mBoxObject->RowCountChanged(index, -count); } else if (!hidden && index < 0) { // Show this row along with its children. nsCOMPtr<nsIContent> parent = aElement->GetParent(); if (parent) { InsertRowFor(parent, aElement); } } return; } if (tag == nsGkAtoms::treecol) { if (aAttribute == nsGkAtoms::properties) { if (mBoxObject) { nsCOMPtr<nsITreeColumns> cols; mBoxObject->GetColumns(getter_AddRefs(cols)); if (cols) { nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aElement); nsCOMPtr<nsITreeColumn> col; cols->GetColumnFor(element, getter_AddRefs(col)); mBoxObject->InvalidateColumn(col); } } } } else if (tag == nsGkAtoms::treeitem) { int32_t index = FindContent(aElement); if (index >= 0) { Row* row = mRows[index]; if (aAttribute == nsGkAtoms::container) { bool isContainer = aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::container, nsGkAtoms::_true, eCaseMatters); row->SetContainer(isContainer); if (mBoxObject) mBoxObject->InvalidateRow(index); } else if (aAttribute == nsGkAtoms::open) { bool isOpen = aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::open, nsGkAtoms::_true, eCaseMatters); bool wasOpen = row->IsOpen(); if (! isOpen && wasOpen) CloseContainer(index); else if (isOpen && ! wasOpen) OpenContainer(index); } else if (aAttribute == nsGkAtoms::empty) { bool isEmpty = aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::empty, nsGkAtoms::_true, eCaseMatters); row->SetEmpty(isEmpty); if (mBoxObject) mBoxObject->InvalidateRow(index); } } } else if (tag == nsGkAtoms::treeseparator) { int32_t index = FindContent(aElement); if (index >= 0) { if (aAttribute == nsGkAtoms::properties && mBoxObject) { mBoxObject->InvalidateRow(index); } } } else if (tag == nsGkAtoms::treerow) { if (aAttribute == nsGkAtoms::properties) { nsCOMPtr<nsIContent> parent = aElement->GetParent(); if (parent) { int32_t index = FindContent(parent); if (index >= 0 && mBoxObject) { mBoxObject->InvalidateRow(index); } } } } else if (tag == nsGkAtoms::treecell) { if (aAttribute == nsGkAtoms::ref || aAttribute == nsGkAtoms::properties || aAttribute == nsGkAtoms::mode || aAttribute == nsGkAtoms::src || aAttribute == nsGkAtoms::value || aAttribute == nsGkAtoms::label) { nsIContent* parent = aElement->GetParent(); if (parent) { nsCOMPtr<nsIContent> grandParent = parent->GetParent(); if (grandParent && grandParent->IsXUL()) { int32_t index = FindContent(grandParent); if (index >= 0 && mBoxObject) { // XXX Should we make an effort to invalidate only cell ? mBoxObject->InvalidateRow(index); } } } } } }
void TeamsListView::MessageReceived(BMessage* message) { switch (message->what) { case MSG_SELECTED_INTERFACE_CHANGED: { TargetHostInterface* interface; if (message->FindPointer("interface", reinterpret_cast<void**>( &interface)) == B_OK) { _SetInterface(interface); } break; } case MSG_TEAM_ADDED: { TeamInfo* info; team_id team; if (message->FindInt32("team", &team) != B_OK) break; TargetHost* host = fInterface->GetTargetHost(); AutoLocker<TargetHost> hostLocker(host); info = host->TeamInfoByID(team); if (info == NULL) break; TeamRow* row = new TeamRow(info); AddRow(row); break; } case MSG_TEAM_REMOVED: { team_id team; if (message->FindInt32("team", &team) != B_OK) break; TeamRow* row = FindTeamRow(team); if (row != NULL) { RemoveRow(row); delete row; } break; } case MSG_TEAM_RENAMED: { TeamInfo* info; team_id team; if (message->FindInt32("team", &team) != B_OK) break; TargetHost* host = fInterface->GetTargetHost(); AutoLocker<TargetHost> hostLocker(host); info = host->TeamInfoByID(team); if (info == NULL) break; TeamRow* row = FindTeamRow(info->TeamID()); if (row != NULL && row->NeedsUpdate(info)) UpdateRow(row); break; } default: Inherited::MessageReceived(message); } }
void JXTreeListWidget::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsTreeList && message.Is(JTreeList::kNodeInserted)) { const JTreeList::NodeInserted* info = dynamic_cast<const JTreeList::NodeInserted*>(&message); assert( info != NULL ); InsertRows(info->GetIndex(), 1); NeedsAdjustToTree(); } else if (sender == itsTreeList && message.Is(JTreeList::kNodeRemoved)) { const JTreeList::NodeRemoved* info = dynamic_cast<const JTreeList::NodeRemoved*>(&message); assert( info != NULL ); RemoveRow(info->GetIndex()); NeedsAdjustToTree(); } else if (sender == itsTreeList && message.Is(JTreeList::kNodeChanged)) { const JTreeList::NodeChanged* info = dynamic_cast<const JTreeList::NodeChanged*>(&message); assert( info != NULL ); TableRefreshRow(info->GetIndex()); NeedsAdjustToTree(); } else if (sender == itsTreeList && (message.Is(JTreeList::kNodeOpened) || message.Is(JTreeList::kNodeClosed))) { const JTreeList::NodeMessage* info = dynamic_cast<const JTreeList::NodeMessage*>(&message); assert( info != NULL ); TableRefreshRow(info->GetIndex()); } else if (sender == itsTreeList->GetTree() && message.Is(JTree::kPrepareForNodeMove)) { HandlePrepareForNodeMove(); } else if (sender == itsTreeList->GetTree() && message.Is(JTree::kNodeMoveFinished)) { HandleNodeMoveFinished(); } else { if (sender == this && message.Is(kColsInserted)) { const ColsInserted* info = dynamic_cast<const ColsInserted*>(&message); assert( info != NULL ); info->AdjustIndex(&itsToggleOpenColIndex); info->AdjustIndex(&itsNodeColIndex); info->AdjustIndex(&itsElasticColIndex); NeedsAdjustToTree(); } else if (sender == this && message.Is(kColsRemoved)) { const ColsRemoved* info = dynamic_cast<const ColsRemoved*>(&message); assert( info != NULL ); JBoolean ok = info->AdjustIndex(&itsToggleOpenColIndex); assert( ok ); ok = info->AdjustIndex(&itsNodeColIndex); assert( ok ); info->AdjustIndex(&itsElasticColIndex); // ok to let it go to zero NeedsAdjustToTree(); } else if (sender == this && message.Is(kColMoved)) { const ColMoved* info = dynamic_cast<const ColMoved*>(&message); assert( info != NULL ); info->AdjustIndex(&itsToggleOpenColIndex); info->AdjustIndex(&itsNodeColIndex); info->AdjustIndex(&itsElasticColIndex); itsMinColWidths->MoveElementToIndex(info->GetOrigIndex(), info->GetNewIndex()); } JXStyleTable::Receive(sender, message); } }