JX Application Framework
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
JDirInfo Class Reference

#include <JDirInfo.h>

Inheritance diagram for JDirInfo:
[legend]

Classes

class  ContentsChanged
 
class  ContentsWillBeUpdated
 
class  PathChanged
 
class  PermissionsChanged
 
class  SettingsChanged
 

Public Member Functions

 JDirInfo (const JDirInfo &source)
 
 JDirInfo (const JDirInfo &source, const JString &dirName)
 
 ~JDirInfo () override
 
JDirInfooperator= (const JDirInfo &source)
 
void CopySettings (const JDirInfo &source)
 
bool DirectoryExists () const
 
const JStringGetDirectory () const
 
bool IsWritable () const
 
JError GoUp ()
 
JError GoDown (const JString &dirName)
 
void GoToClosest (const JString &dirName)
 
JError GoTo (const JString &dirName)
 
void ChangeSort (const std::function< std::weak_ordering(JDirEntry *const &, JDirEntry *const &)> f, const JListT::SortOrder order)
 
bool FilesVisible () const
 
void ShowFiles (const bool show)
 
bool DirsVisible () const
 
void ShowDirs (const bool show)
 
bool HiddenVisible () const
 
void ShowHidden (const bool show)
 
bool VCSDirsVisible () const
 
void ShowVCSDirs (const bool show)
 
bool OthersVisible () const
 
void ShowOthers (const bool show)
 
bool HasWildcardFilter () const
 
void SetWildcardFilter (const JString &filterStr, const bool negate=false, const bool caseSensitive=false)
 
void SetWildcardFilter (JRegex *filter, const bool dirInfoOwnsRegex, const bool negate=false)
 
void ClearWildcardFilter ()
 
bool WillApplyWildcardFilterToDirs () const
 
void ShouldApplyWildcardFilterToDirs (const bool apply=true)
 
bool HasDirEntryFilter () const
 
void SetDirEntryFilter (const std::function< bool(const JDirEntry &)> f)
 
void ClearDirEntryFilter ()
 
bool HasContentFilter () const
 
JError SetContentFilter (const JString &regexStr)
 
void ClearContentFilter ()
 
void ResetCSFFilters ()
 
void ChangeProgressDisplay (JProgressDisplay *pg)
 
void UseDefaultProgressDisplay ()
 
bool WillSwitchToValidDirectory () const
 
void ShouldSwitchToValidDirectory (const bool switchIfInvalid=true)
 
bool Update (const bool force=false)
 
bool ForceUpdate ()
 
JSize GetEntryCount () const
 
const JDirEntryGetEntry (const JIndex index) const
 
bool FindEntry (const JString &name, JIndex *index) const
 
bool ClosestMatch (const JString &prefixStr, JIndex *index) const
 
JDirEntry ** begin () const
 
JDirEntry ** end () const
 
- Public Member Functions inherited from JContainer
 JContainer ()
 
 JContainer (const JContainer &source)
 
JContaineroperator= (const JContainer &source)
 
- Public Member Functions inherited from JCollection
 JCollection ()
 
 JCollection (const JCollection &source)
 
 ~JCollection () override
 
JCollectionoperator= (const JCollection &source)
 
JSize GetItemCount () const
 
bool IsEmpty () const
 
bool IndexValid (const JIndex index) const
 
JIndex GetIndexFromEnd (const JIndex index) const
 
JString ToString () const override
 
- Public Member Functions inherited from JBroadcaster
 JBroadcaster ()
 
virtual ~JBroadcaster ()
 
JBroadcasteroperator= (const JBroadcaster &source)
 
bool HasSenders () const
 
JSize GetSenderCount () const
 
bool HasRecipients () const
 
JSize GetRecipientCount () const
 
template<class T >
void ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f)
 

Static Public Member Functions

static bool Create (const JString &dirName, JDirInfo **obj)
 
static bool Create (const JDirInfo &source, const JString &dirName, JDirInfo **obj)
 
static bool OKToCreate (const JString &dirName)
 
static bool BuildRegexFromWildcardFilter (const JString &filterStr, JString *regexStr)
 
static bool Empty (const JString &dirName)
 

Static Public Attributes

static const JUtf8BytekContentsWillBeUpdated = "ContentsWillBeUpdated::JDirInfo"
 
static const JUtf8BytekContentsChanged = "ContentsChanged::JDirInfo"
 
static const JUtf8BytekPathChanged = "PathChanged::JDirInfo"
 
static const JUtf8BytekPermissionsChanged = "PermissionsChanged::JDirInfo"
 
static const JUtf8BytekSettingsChanged = "SettingsChanged::JDirInfo"
 

Protected Member Functions

 JDirInfo (const JString &dirName)
 
virtual bool IsVisible (const JDirEntry &entry) const
 
bool MatchesNameFilter (const JDirEntry &entry) const
 
bool MatchesDirEntryFilter (const JDirEntry &entry) const
 
bool MatchesContentFilter (const JDirEntry &entry) const
 
- Protected Member Functions inherited from JContainer
void InstallCollection (JCollection *list)
 
const JCollectionGetList () const
 
void Receive (JBroadcaster *sender, const Message &message) override
 
- Protected Member Functions inherited from JCollection
void ItemAdded ()
 
void ItemRemoved ()
 
void SetItemCount (const JSize newItemCount)
 
- Protected Member Functions inherited from JBroadcaster
 JBroadcaster (const JBroadcaster &source)
 
void ListenTo (const JBroadcaster *sender)
 
void StopListening (const JBroadcaster *sender)
 
void ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember)
 
void StopListening (const JBroadcaster *sender, const std::type_info &messageType)
 
template<class T >
void Send (JBroadcaster *recipient, const T &message)
 
template<class T >
void Broadcast (const T &message)
 
void SendWithFeedback (JBroadcaster *recipient, Message *message)
 
void BroadcastWithFeedback (Message *message)
 
virtual void ReceiveWithFeedback (JBroadcaster *sender, Message *message)
 
virtual void ReceiveGoingAway (JBroadcaster *sender)
 

Detailed Description

Class that contains information about everything in a given directory.

Derived classes can override IsVisible() to perform extra filtering
of the list of files.  Note that since this class has a constructor
function, derived classes must also enforce their own constructor
functions.

If the contents will merely change due to filtering or updating,
instead of changing directories, we broadcast ContentsWillBeUpdated
before changing anything.  This gives others a chance to save state
that can be restored after ContentsChanged.  Note that PathChanged
cancels the effect of ContentsWillBeUpdated.

The content filter is applied in BuildInfo() because it is so
expensive and is not likely to change very often since it should not
be under user control.

Constructor & Destructor Documentation

◆ JDirInfo() [1/3]

JDirInfo::JDirInfo ( const JDirInfo source)

◆ JDirInfo() [2/3]

JDirInfo::JDirInfo ( const JDirInfo source,
const JString dirName 
)

◆ ~JDirInfo()

JDirInfo::~JDirInfo ( )
override

◆ JDirInfo() [3/3]

JDirInfo::JDirInfo ( const JString dirName)
protected

Member Function Documentation

◆ begin()

JDirEntry ** JDirInfo::begin ( ) const
inline

◆ BuildRegexFromWildcardFilter()

bool JDirInfo::BuildRegexFromWildcardFilter ( const JString filterStr,
JString regexStr 
)
static

◆ ChangeProgressDisplay()

void JDirInfo::ChangeProgressDisplay ( JProgressDisplay pg)

We take ownership of the object and will delete it when appropriate.

◆ ChangeSort()

void JDirInfo::ChangeSort ( const std::function< std::weak_ordering(JDirEntry *const &, JDirEntry *const &)>  f,
const JListT::SortOrder  order 
)

◆ ClearContentFilter()

void JDirInfo::ClearContentFilter ( )

◆ ClearDirEntryFilter()

void JDirInfo::ClearDirEntryFilter ( )

◆ ClearWildcardFilter()

void JDirInfo::ClearWildcardFilter ( )

◆ ClosestMatch()

bool JDirInfo::ClosestMatch ( const JString prefixStr,
JIndex index 
) const

Returns the index of the closest match for the given name prefix.

◆ CopySettings()

void JDirInfo::CopySettings ( const JDirInfo source)

◆ Create() [1/2]

bool JDirInfo::Create ( const JDirInfo source,
const JString dirName,
JDirInfo **  obj 
)
static

◆ Create() [2/2]

bool JDirInfo::Create ( const JString dirName,
JDirInfo **  obj 
)
static

By forcing everyone to use this function, we avoid having to worry about BuildInfo() succeeding within the class itself.

Note that this prevents one from creating derived classes unless one creates a similar constructor function that checks OKToCreate().

◆ DirectoryExists()

bool JDirInfo::DirectoryExists ( ) const
inline

◆ DirsVisible()

bool JDirInfo::DirsVisible ( ) const
inline

◆ Empty()

bool JDirInfo::Empty ( const JString dirName)
static

Returns true if the directory doesn't exist or exists and is empty.

Not called IsEmpty(), because that would conflict with our base class, JCollection.

◆ end()

JDirEntry ** JDirInfo::end ( ) const
inline

◆ FilesVisible()

bool JDirInfo::FilesVisible ( ) const
inline

◆ FindEntry()

bool JDirInfo::FindEntry ( const JString name,
JIndex index 
) const

Returns true if an entry with the given name exists.

◆ ForceUpdate()

bool JDirInfo::ForceUpdate ( )

Returns true if the update was successful. Otherwise, returns false to indicate that path is no longer valid.

◆ GetDirectory()

const JString & JDirInfo::GetDirectory ( ) const
inline

◆ GetEntry()

const JDirEntry & JDirInfo::GetEntry ( const JIndex  index) const
inline

◆ GetEntryCount()

JSize JDirInfo::GetEntryCount ( ) const
inline

◆ GoDown()

JError JDirInfo::GoDown ( const JString dirName)

◆ GoTo()

JError JDirInfo::GoTo ( const JString dirName)

◆ GoToClosest()

void JDirInfo::GoToClosest ( const JString origDirName)

If the directory exists, go to it. Otherwise, go as far down the directory tree as possible towards the specified directory.

As an example, /usr/include/junk doesn't normally exist, so it will go to /usr/include instead.

◆ GoUp()

JError JDirInfo::GoUp ( )

◆ HasContentFilter()

bool JDirInfo::HasContentFilter ( ) const
inline

◆ HasDirEntryFilter()

bool JDirInfo::HasDirEntryFilter ( ) const
inline

◆ HasWildcardFilter()

bool JDirInfo::HasWildcardFilter ( ) const
inline

◆ HiddenVisible()

bool JDirInfo::HiddenVisible ( ) const
inline

◆ IsVisible()

bool JDirInfo::IsVisible ( const JDirEntry entry) const
protectedvirtual

◆ IsWritable()

bool JDirInfo::IsWritable ( ) const
inline

◆ MatchesContentFilter()

bool JDirInfo::MatchesContentFilter ( const JDirEntry entry) const
protected

◆ MatchesDirEntryFilter()

bool JDirInfo::MatchesDirEntryFilter ( const JDirEntry entry) const
protected

◆ MatchesNameFilter()

bool JDirInfo::MatchesNameFilter ( const JDirEntry entry) const
protected

◆ OKToCreate()

bool JDirInfo::OKToCreate ( const JString dirName)
static

◆ operator=()

JDirInfo & JDirInfo::operator= ( const JDirInfo source)

◆ OthersVisible()

bool JDirInfo::OthersVisible ( ) const
inline

◆ ResetCSFFilters()

void JDirInfo::ResetCSFFilters ( )

This does not clear the name filter because it is primarily useful for JChooseSaveFile, which doesn't want it changed.

◆ SetContentFilter()

JError JDirInfo::SetContentFilter ( const JString regexStr)

◆ SetDirEntryFilter()

void JDirInfo::SetDirEntryFilter ( const std::function< bool(const JDirEntry &)>  f)

◆ SetWildcardFilter() [1/2]

void JDirInfo::SetWildcardFilter ( const JString filterStr,
const bool  negate = false,
const bool  caseSensitive = false 
)

◆ SetWildcardFilter() [2/2]

void JDirInfo::SetWildcardFilter ( JRegex filter,
const bool  dirInfoOwnsRegex,
const bool  negate = false 
)

◆ ShouldApplyWildcardFilterToDirs()

void JDirInfo::ShouldApplyWildcardFilterToDirs ( const bool  apply = true)

◆ ShouldSwitchToValidDirectory()

void JDirInfo::ShouldSwitchToValidDirectory ( const bool  switchIfInvalid = true)
inline

◆ ShowDirs()

void JDirInfo::ShowDirs ( const bool  show)

◆ ShowFiles()

void JDirInfo::ShowFiles ( const bool  show)

◆ ShowHidden()

void JDirInfo::ShowHidden ( const bool  show)

◆ ShowOthers()

void JDirInfo::ShowOthers ( const bool  show)

◆ ShowVCSDirs()

void JDirInfo::ShowVCSDirs ( const bool  show)

◆ Update()

bool JDirInfo::Update ( const bool  force = false)

Returns true if anything needed to be updated.

◆ UseDefaultProgressDisplay()

void JDirInfo::UseDefaultProgressDisplay ( )

◆ VCSDirsVisible()

bool JDirInfo::VCSDirsVisible ( ) const
inline

◆ WillApplyWildcardFilterToDirs()

bool JDirInfo::WillApplyWildcardFilterToDirs ( ) const
inline

◆ WillSwitchToValidDirectory()

bool JDirInfo::WillSwitchToValidDirectory ( ) const
inline

Member Data Documentation

◆ kContentsChanged

const JUtf8Byte * JDirInfo::kContentsChanged = "ContentsChanged::JDirInfo"
static

◆ kContentsWillBeUpdated

const JUtf8Byte * JDirInfo::kContentsWillBeUpdated = "ContentsWillBeUpdated::JDirInfo"
static

◆ kPathChanged

const JUtf8Byte * JDirInfo::kPathChanged = "PathChanged::JDirInfo"
static

◆ kPermissionsChanged

const JUtf8Byte * JDirInfo::kPermissionsChanged = "PermissionsChanged::JDirInfo"
static

◆ kSettingsChanged

const JUtf8Byte * JDirInfo::kSettingsChanged = "SettingsChanged::JDirInfo"
static

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