LMMS
Loading...
Searching...
No Matches
juce::FileListTreeItem Class Reference
Inheritance diagram for juce::FileListTreeItem:
juce::TreeViewItem juce::TimeSliceClient juce::AsyncUpdater juce::ChangeListener

Public Member Functions

 FileListTreeItem (FileTreeComponent &treeComp, DirectoryContentsList *parentContents, int indexInContents, const File &f, TimeSliceThread &t)
 ~FileListTreeItem () override
bool mightContainSubItems () override
String getUniqueName () const override
int getItemHeight () const override
var getDragSourceDescription () override
void itemOpennessChanged (bool isNowOpen) override
void removeSubContentsList ()
void setSubContentsList (DirectoryContentsList *newList, const bool canDeleteList)
bool selectFile (const File &target)
void changeListenerCallback (ChangeBroadcaster *) override
void rebuildItemsFromContentList ()
void paintItem (Graphics &g, int width, int height) override
String getAccessibilityName () override
void itemClicked (const MouseEvent &e) override
void itemDoubleClicked (const MouseEvent &e) override
void itemSelectionChanged (bool) override
int useTimeSlice () override
void handleAsyncUpdate () override
Public Member Functions inherited from juce::TreeViewItem
 TreeViewItem ()
virtual ~TreeViewItem ()
int getNumSubItems () const noexcept
TreeViewItemgetSubItem (int index) const noexcept
void clearSubItems ()
void addSubItem (TreeViewItem *newItem, int insertPosition=-1)
template<class ElementComparator>
void addSubItemSorted (ElementComparator &comparator, TreeViewItem *newItem)
void removeSubItem (int index, bool deleteItem=true)
template<class ElementComparator>
void sortSubItems (ElementComparator &comparator)
TreeViewgetOwnerView () const noexcept
TreeViewItemgetParentItem () const noexcept
bool isOpen () const noexcept
void setOpen (bool shouldBeOpen)
Openness getOpenness () const noexcept
void setOpenness (Openness newOpenness)
bool isSelected () const noexcept
void setSelected (bool shouldBeSelected, bool deselectOtherItemsFirst, NotificationType shouldNotify=sendNotification)
Rectangle< intgetItemPosition (bool relativeToTreeViewTopLeft) const noexcept
void treeHasChanged () const noexcept
void repaintItem () const
int getRowNumberInTree () const noexcept
bool areAllParentsOpen () const noexcept
void setLinesDrawnForSubItems (bool shouldDrawLines) noexcept
virtual int getItemWidth () const
virtual bool canBeSelected () const
virtual std::unique_ptr< ComponentcreateItemComponent ()
virtual void paintOpenCloseButton (Graphics &, const Rectangle< float > &area, Colour backgroundColour, bool isMouseOver)
virtual void paintHorizontalConnectingLine (Graphics &, const Line< float > &line)
virtual void paintVerticalConnectingLine (Graphics &, const Line< float > &line)
virtual bool customComponentUsesTreeViewMouseHandler () const
virtual void ownerViewChanged (TreeView *newOwner)
virtual String getTooltip ()
virtual bool isInterestedInFileDrag (const StringArray &files)
virtual void filesDropped (const StringArray &files, int insertIndex)
virtual bool isInterestedInDragSource (const DragAndDropTarget::SourceDetails &dragSourceDetails)
virtual void itemDropped (const DragAndDropTarget::SourceDetails &dragSourceDetails, int insertIndex)
void setDrawsInLeftMargin (bool canDrawInLeftMargin) noexcept
void setDrawsInRightMargin (bool canDrawInRightMargin) noexcept
std::unique_ptr< XmlElementgetOpennessState () const
void restoreOpennessState (const XmlElement &xml)
int getIndexInParent () const noexcept
bool isLastOfSiblings () const noexcept
String getItemIdentifierString () const

Public Attributes

const File file

Private Member Functions

void updateIcon (const bool onlyUpdateIfCached)
Private Member Functions inherited from juce::TimeSliceClient
virtual ~TimeSliceClient ()=default
Private Member Functions inherited from juce::AsyncUpdater
 AsyncUpdater ()
virtual ~AsyncUpdater ()
void triggerAsyncUpdate ()
void cancelPendingUpdate () noexcept
void handleUpdateNowIfNeeded ()
bool isUpdatePending () const noexcept
Private Member Functions inherited from juce::ChangeListener
virtual ~ChangeListener ()=default

Private Attributes

FileTreeComponentowner
DirectoryContentsListparentContentsList
int indexInContentsList
OptionalScopedPointer< DirectoryContentsListsubContentsList
bool isDirectory
TimeSliceThreadthread
CriticalSection iconUpdate
Image icon
String fileSize
String modTime

Additional Inherited Members

Public Types inherited from juce::TreeViewItem
enum class  Openness { opennessDefault , opennessClosed , opennessOpen }

Constructor & Destructor Documentation

◆ FileListTreeItem()

juce::FileListTreeItem::FileListTreeItem ( FileTreeComponent & treeComp,
DirectoryContentsList * parentContents,
int indexInContents,
const File & f,
TimeSliceThread & t )
inline

◆ ~FileListTreeItem()

juce::FileListTreeItem::~FileListTreeItem ( )
inlineoverride

Member Function Documentation

◆ changeListenerCallback()

void juce::FileListTreeItem::changeListenerCallback ( ChangeBroadcaster * source)
inlineoverridevirtual

Your subclass should implement this method to receive the callback.

Parameters
sourcethe ChangeBroadcaster that triggered the callback.

Implements juce::ChangeListener.

◆ getAccessibilityName()

String juce::FileListTreeItem::getAccessibilityName ( )
inlineoverridevirtual

Use this to set the name for this item that will be read out by accessibility clients.

The default implementation will return the tooltip string from getTooltip() if it is not empty, otherwise it will return a description of the nested level and row number of the item.

See also
AccessibilityHandler

Reimplemented from juce::TreeViewItem.

◆ getDragSourceDescription()

var juce::FileListTreeItem::getDragSourceDescription ( )
inlineoverridevirtual

To allow items from your TreeView to be dragged-and-dropped, implement this method.

If this returns a non-null variant then when the user drags an item, the TreeView will try to find a DragAndDropContainer in its parent hierarchy, and will use it to trigger a drag-and-drop operation, using this string as the source description, with the TreeView itself as the source component.

If you need more complex drag-and-drop behaviour, you can use custom components for the items, and use those to trigger the drag.

To accept drag-and-drop in your tree, see isInterestedInDragSource(), isInterestedInFileDrag(), etc.

See also
DragAndDropContainer::startDragging

Reimplemented from juce::TreeViewItem.

◆ getItemHeight()

int juce::FileListTreeItem::getItemHeight ( ) const
inlineoverridevirtual

Must return the height required by this item.

This is the height in pixels that the item will take up. Items in the tree can be different heights, but if they change height, you should call treeHasChanged() to update the tree.

Reimplemented from juce::TreeViewItem.

◆ getUniqueName()

String juce::FileListTreeItem::getUniqueName ( ) const
inlineoverridevirtual

Returns a string to uniquely identify this item.

If you're planning on using the TreeView::getOpennessState() method, then these strings will be used to identify which nodes are open. The string should be unique amongst the item's sibling items, but it's ok for there to be duplicates at other levels of the tree.

If you're not going to store the state, then it's ok not to bother implementing this method.

Reimplemented from juce::TreeViewItem.

◆ handleAsyncUpdate()

void juce::FileListTreeItem::handleAsyncUpdate ( )
inlineoverridevirtual

Called back to do whatever your class needs to do.

This method is called by the message thread at the next convenient time after the triggerAsyncUpdate() method has been called.

Implements juce::AsyncUpdater.

◆ itemClicked()

void juce::FileListTreeItem::itemClicked ( const MouseEvent & )
inlineoverridevirtual

Called when the user clicks on this item.

If you're using createItemComponent() to create a custom component for the item, the mouse-clicks might not make it through to the TreeView, but this is how you find out about clicks when just drawing each item individually.

The associated mouse-event details are passed in, so you can find out about which button, where it was, etc.

See also
itemDoubleClicked

Reimplemented from juce::TreeViewItem.

◆ itemDoubleClicked()

void juce::FileListTreeItem::itemDoubleClicked ( const MouseEvent & )
inlineoverridevirtual

Called when the user double-clicks on this item.

If you're using createItemComponent() to create a custom component for the item, the mouse-clicks might not make it through to the TreeView, but this is how you find out about clicks when just drawing each item individually.

The associated mouse-event details are passed in, so you can find out about which button, where it was, etc.

If not overridden, the base class method here will open or close the item as if the 'plus' button had been clicked.

See also
itemClicked

Reimplemented from juce::TreeViewItem.

◆ itemOpennessChanged()

void juce::FileListTreeItem::itemOpennessChanged ( bool isNowOpen)
inlineoverridevirtual

Called when an item is opened or closed.

When setOpen() is called and the item has specified that it might have sub-items with the mightContainSubItems() method, this method is called to let the item create or manage its sub-items.

So when this is called with isNowOpen set to true (i.e. when the item is being opened), a subclass might choose to use clearSubItems() and addSubItem() to refresh its sub-item list.

When this is called with isNowOpen set to false, the subclass might want to use clearSubItems() to save on space, or it might choose to leave them, depending on the nature of the tree.

You could also use this callback as a trigger to start a background process which asynchronously creates sub-items and adds them, if that's more appropriate for the task in hand.

See also
mightContainSubItems

Reimplemented from juce::TreeViewItem.

◆ itemSelectionChanged()

void juce::FileListTreeItem::itemSelectionChanged ( bool isNowSelected)
inlineoverridevirtual

Called when the item is selected or deselected.

Use this if you want to do something special when the item's selectedness changes. By default it'll get repainted when this happens.

Reimplemented from juce::TreeViewItem.

◆ mightContainSubItems()

bool juce::FileListTreeItem::mightContainSubItems ( )
inlineoverridevirtual

Tells the tree whether this item can potentially be opened.

If your item could contain sub-items, this should return true; if it returns false then the tree will not try to open the item. This determines whether or not the item will be drawn with a 'plus' button next to it.

Implements juce::TreeViewItem.

◆ paintItem()

void juce::FileListTreeItem::paintItem ( Graphics & g,
int width,
int height )
inlineoverridevirtual

Draws the item's contents.

You can choose to either implement this method and draw each item, or you can use createItemComponent() to create a component that will represent the item.

If all you need in your tree is to be able to draw the items and detect when the user selects or double-clicks one of them, it's probably enough to use paintItem(), itemClicked() and itemDoubleClicked(). If you need more complicated interactions, you may need to use createItemComponent() instead.

Parameters
gthe graphics context to draw into
widththe width of the area available for drawing
heightthe height of the area available for drawing

Reimplemented from juce::TreeViewItem.

◆ rebuildItemsFromContentList()

void juce::FileListTreeItem::rebuildItemsFromContentList ( )
inline

◆ removeSubContentsList()

void juce::FileListTreeItem::removeSubContentsList ( )
inline

◆ selectFile()

bool juce::FileListTreeItem::selectFile ( const File & target)
inline

◆ setSubContentsList()

void juce::FileListTreeItem::setSubContentsList ( DirectoryContentsList * newList,
const bool canDeleteList )
inline

◆ updateIcon()

void juce::FileListTreeItem::updateIcon ( const bool onlyUpdateIfCached)
inlineprivate

◆ useTimeSlice()

int juce::FileListTreeItem::useTimeSlice ( )
inlineoverridevirtual

Called back by a TimeSliceThread.

When you register this class with it, a TimeSliceThread will repeatedly call this method.

The implementation of this method should use its time-slice to do something that's quick - never block for longer than absolutely necessary.

Returns
Your method should return the number of milliseconds which it would like to wait before being called again. Returning 0 will make the thread call again as soon as possible (after possibly servicing other busy clients). If you return a value below zero, your client will be removed from the list of clients, and won't be called again. The value you specify isn't a guarantee, and is only used as a hint by the thread - the actual time before the next callback may be more or less than specified. You can force the TimeSliceThread to wake up and poll again immediately by calling its notify() method.

Implements juce::TimeSliceClient.

Member Data Documentation

◆ file

const File juce::FileListTreeItem::file

◆ fileSize

String juce::FileListTreeItem::fileSize
private

◆ icon

Image juce::FileListTreeItem::icon
private

◆ iconUpdate

CriticalSection juce::FileListTreeItem::iconUpdate
private

◆ indexInContentsList

int juce::FileListTreeItem::indexInContentsList
private

◆ isDirectory

bool juce::FileListTreeItem::isDirectory
private

◆ modTime

String juce::FileListTreeItem::modTime
private

◆ owner

FileTreeComponent& juce::FileListTreeItem::owner
private

◆ parentContentsList

DirectoryContentsList* juce::FileListTreeItem::parentContentsList
private

◆ subContentsList

OptionalScopedPointer<DirectoryContentsList> juce::FileListTreeItem::subContentsList
private

◆ thread

TimeSliceThread& juce::FileListTreeItem::thread
private

The documentation for this class was generated from the following file: