All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Signals | Public Member Functions
Qtilities::CoreGui::TreeFileItem Class Reference

The TreeFileItem class is an item in a tree which can be used to easily represent files. More...

#include <TreeFileItem.h>

Inheritance diagram for Qtilities::CoreGui::TreeFileItem:
Inheritance graph
[legend]

List of all members.

Public Types

enum  PathDisplay { DisplayFileName, DisplayFilePath, DisplayActualFilePath }
 This enumeration provides the possible ways that tree file items can be displayed. More...

Signals

void filePathChanged (const QString &new_file_path)
 Signal which is emitted when the file path of this tree file item changes.
- Signals inherited from Qtilities::CoreGui::TreeItemBase
void modificationStateChanged (bool is_modified) const
 Implement this function as a signal when implementing the object.

Public Member Functions

virtual QString absoluteToRelativeFilePath () const
 See QtilitiesFileInfo::absoluteToRelativeFilePath().
virtual QString absoluteToRelativePath () const
 See QtilitiesFileInfo::absoluteToRelativePath().
virtual QString actualFilePath () const
 See QtilitiesFileInfo::actualFilePath().
virtual QString actualPath () const
 See QtilitiesFileInfo::actualPath().
QString baseName () const
 See QFileInfo::baseName().
QString completeBaseName () const
 See QFileInfo::completeBaseName().
QString completeSuffix () const
 See QFileInfo::completeSuffix().
bool eventFilter (QObject *object, QEvent *event)
 Event filter which catches qti_prop_NAME property changes on this object.
virtual bool exists () const
 Returns true if the file exists, false otherwise. Note that the file path used to check is actualFilePath().
virtual
IExportable::ExportResultFlags 
exportXml (QDomDocument *doc, QDomElement *object_node) const
 Allows exporting to an XML document. A reference to the QDomElement to which the object's information must be added is provided, along with a reference to the QDomDocument.
QtilitiesFileInfo fileInfo () const
 Extended access to file info object.
QString fileName () const
 See QFileInfo::fileName().
virtual QString filePath () const
 See QFileInfo::filePath().
bool hasRelativeToPath () const
 See QtilitiesFileInfo::hasRelativeToPath().
virtual
IExportable::ExportResultFlags 
importXml (QDomDocument *doc, QDomElement *object_node, QList< QPointer< QObject > > &import_list)
 Allows importing and reconstruction of data from information provided in a XML document. A reference to the QDomElement which contains the object's information is provided, along with a reference to the QDomDocument.
InstanceFactoryInfo instanceFactoryInfo () const
 The instance factory information which must be used when the exported object is reconstructed during an import.
bool isAbsolute () const
 See QFileInfo::isAbsolute().
bool isRelative () const
 See QFileInfo::isRelative().
virtual QString path () const
 See QFileInfo::path().
PathDisplay pathDisplay () const
 Gets the PathDisplay used for this tree file item.
virtual QString relativeToPath () const
 See QtilitiesFileInfo::relativeToPath().
virtual void setFile (const QString &file_path, const QString &relative_to_path=QString(), bool broadcast=true)
 Sets the file path of this tree file item and only update the internal QFileInfo when the change was validated by any subject filters.
virtual void setFileForce (const QString &file_path, const QString &relative_to_path=QString(), bool broadcast=true)
 Sets the file path of this tree file item and update the internal QFileInfo without waiting for the change to be validated.
void setFileName (const QString &new_file_name)
 Reimplementation of QtilitiesFileInfo::setFileName() which sets the modification state to true if needed.
virtual void setFilePath (const QString &new_file_path)
 See QFileInfo::setFilePath();.
void setPathDisplay (PathDisplay path_display)
 Sets the PathDisplay used for this tree file item.
void setRelativeToPath (const QString &path)
 See QtilitiesFileInfo::setRelativeToPath().
QString suffix () const
 See QFileInfo::suffix().
ExportModeFlags supportedFormats () const
 Provides information about the export format(s) supported by your implementation of IExportable.
 TreeFileItem (const QString &file_path=QString(), const QString &relative_to_path=QString(), PathDisplay path_display=DisplayFileName, QObject *parent=0)
 Constructs a TreeFileItem object.
- Public Member Functions inherited from Qtilities::CoreGui::TreeItemBase
virtual QtilitiesCategory getCategory (TreeNode *tree_node) const
 Gets the category of the tree item in the specified tree node.
virtual QtilitiesCategory getCategory (int observer_id=-1) const
 Gets the category of the tree item in the context specified by the given observer ID.
virtual QString getCategoryString (const QString &sep="::", int observer_id=-1) const
 Gets the category in a string format where different hierarchies of the category is split using sep.
virtual bool hasCategory () const
 Checks if the item has a category.
virtual bool isModified () const
 Indicates the modification state of the object.
QObject * objectBase ()
 Returns the QObject* base of the interface.
const QObject * objectBase () const
 Returns a const QObject* base of the interface.
virtual bool removeCategory (int observer_id=-1)
virtual bool setCategory (const QtilitiesCategory &category, TreeNode *tree_node)
virtual bool setCategory (const QtilitiesCategory &category, int observer_id=-1)
virtual bool setCategoryString (const QString &category_string, const QString &sep="::")
 TreeItemBase (const QString &name=QString(), QObject *parent=0)
 Constructs the base of a tree item.
- Public Member Functions inherited from Qtilities::CoreGui::AbstractTreeItem
Qt::AlignmentFlag getAlignment () const
 Gets the alignement of the tree item.
QColor getBackgroundColor () const
 Gets the background color of the tree item.
QBrush getBackgroundRole () const
 Gets the background role of the tree item.
QFont getFont () const
 Gets the font of the tree item.
QColor getForegroundColor () const
 Gets the foreground color of the tree item.
QBrush getForegroundRole () const
 Gets the foreground role of the tree item.
QIcon getIcon () const
 Gets the icon of the tree item.
QString getName (TreeNode *parent=0) const
 Function to get the name of this tree item.
QSize getSizeHint () const
 Gets the size hint of the tree item.
QString getStatusTip () const
 Gets the status tip of the tree item.
QString getToolTip () const
 Gets the tool tip of the tree item.
QString getWhatsThis () const
 Gets the what's this text of the tree item.
bool hasAlignment () const
 Checks if the item has a font.
bool hasBackgroundRole () const
 Checks if the item has a background role.
bool hasFont () const
 Checks if the item has a font.
bool hasForegroundRole () const
 Checks if the item has a foreground role.
bool hasIcon () const
 Checks if the item has an icon.
bool hasSizeHint () const
 Checks if the item has a size hint.
bool hasStatusTip () const
 Checks if the item has status tip text.
bool hasToolTip () const
 Checks if the item has a tool tip.
bool hasWhatsThis () const
 Checks if the item has what's this text.
void setAlignment (const Qt::AlignmentFlag &alignment)
 Sets the alignment of the tree item.
void setBackgroundColor (const QColor &color)
 Sets the background color of the tree item.
void setBackgroundRole (const QBrush &background_role)
 Sets the background role of the tree item.
void setFont (const QFont &font)
 Sets the font of the tree item.
void setForegroundColor (const QColor &color)
 Sets the foreground color of the tree item.
void setForegroundRole (const QBrush &foreground_role)
 Sets the foreground role of the tree item.
void setIcon (const QIcon &icon)
 Sets the icon of the tree item.
bool setName (const QString &new_name, Observer *parent=0)
 Function to set the name of this tree item.
void setSizeHint (const QSize &size)
 Sets the size hint of the tree item.
void setStatusTip (const QString &status_tip)
 Sets the status tip of the tree item.
void setToolTip (const QString &tooltip)
 Sets the tool tip of the tree item.
void setWhatsThis (const QString &whats_this)
 Sets the what's this text of the tree item.
- Public Member Functions inherited from Qtilities::Core::Interfaces::IModificationNotifier
virtual void setModificationState (bool new_state, NotificationTargets notification_targets=NotifyListeners, bool force_notifications=false)=0
 Sets the modification state of the object. Returns true if it was successfull.
- Public Member Functions inherited from Qtilities::Core::Interfaces::IObjectBase
QString objectOriginID () const
 Allows interfaces to provide some sort of source identification.
void setObjectOriginID (const QString &object_origin_id)
 Allows setting of the object source ID of this interface implementation.
- Public Member Functions inherited from Qtilities::Core::Interfaces::IExportable
quint32 applicationExportVersion () const
 Returns the application export version currently used by all your application's classes.
virtual void clearExportTask ()
 Clears the export task.
IExportableduplicate (QString *error_msg=0, int properties_to_copy=0, ExportResultFlags *result_flags=0) const
 Function which will create a duplicate (copy) of this object.
virtual ExportResultFlags exportBinary (QDataStream &stream) const
 Allows exporting to a QDataStream.
virtual ITaskexportTask () const
 Gets the task which must be used to log import/export information to.
Qtilities::ExportVersion exportVersion () const
 Returns the export version currently used by all Qtilities classes.
virtual ExportResultFlags importBinary (QDataStream &stream, QList< QPointer< QObject > > &import_list)
 Allows importing and reconstruction of the object state from information provided in a QDataStream.
bool isExportable () const
 Gets if this object must be part of it's parents' exports.
virtual void setApplicationExportVersion (quint32 version)
 Sets the application export version currently used by all your application's classes.
virtual void setExportTask (ITask *task)
 Sets the task which must be used to log import/export information to.
virtual void setExportVersion (Qtilities::ExportVersion version)
 Returns the export version currently used by all Qtilities classes.
virtual void setIsExportable (bool new_is_exportable)
 Sets if this object must be part of it's parents' exports.

Detailed Description

The TreeFileItem class is an item in a tree which can be used to easily represent files.

The TreeFileItem tree item is derived from TreeItem can provided functionality to represent a file in a tree. This functionality includes:

Note:
This class is meant to be used where the tree item will only be attached to a single observer context since setFile() does not update any qti_prop_ALIAS_MAP. You can however reimplement setFile() and setFileForce() in order to implement this functionality if needed.

This class was added in Qtilities v0.2.


Member Enumeration Documentation

This enumeration provides the possible ways that tree file items can be displayed.

The default is DisplayFileName.

Enumerator:
DisplayFileName 

Display fileName().

DisplayFilePath 

Display filePath().

DisplayActualFilePath 

Display actualFilePath().


Constructor & Destructor Documentation

Qtilities::CoreGui::TreeFileItem::TreeFileItem ( const QString &  file_path = QString(),
const QString &  relative_to_path = QString(),
PathDisplay  path_display = DisplayFileName,
QObject *  parent = 0 
)

Constructs a TreeFileItem object.

Parameters:
file_pathThe file path of the file.
relative_to_pathThe relative to path for the file. See Qtilities::Core::QtilitiesFileInfo::relativeToPath() for more information.
path_displayThe preferred way that this file item must be displayed.
parentThe parent of the item.

Member Function Documentation

Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::CoreGui::TreeFileItem::exportXml ( QDomDocument *  doc,
QDomElement *  object_node 
) const
virtual

Allows exporting to an XML document. A reference to the QDomElement to which the object's information must be added is provided, along with a reference to the QDomDocument.

See Serializing Qtilities Data Types Overview for more information about the expected output format.

Reimplemented from Qtilities::Core::Interfaces::IExportable.

void Qtilities::CoreGui::TreeFileItem::filePathChanged ( const QString &  new_file_path)
signal

Signal which is emitted when the file path of this tree file item changes.

Parameters:
new_file_pathEqual to the new filePath().
Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::CoreGui::TreeFileItem::importXml ( QDomDocument *  doc,
QDomElement *  object_node,
QList< QPointer< QObject > > &  import_list 
)
virtual

Allows importing and reconstruction of data from information provided in a XML document. A reference to the QDomElement which contains the object's information is provided, along with a reference to the QDomDocument.

See Serializing Qtilities Data Types Overview for more information about the expected output format.

Reimplemented from Qtilities::Core::Interfaces::IExportable.

Qtilities::Core::InstanceFactoryInfo Qtilities::CoreGui::TreeFileItem::instanceFactoryInfo ( ) const
virtual

The instance factory information which must be used when the exported object is reconstructed during an import.

For more information see The IExportable interface, what does it have to do with factories?.

Reimplemented from Qtilities::Core::Interfaces::IExportable.

void Qtilities::CoreGui::TreeFileItem::setFile ( const QString &  file_path,
const QString &  relative_to_path = QString(),
bool  broadcast = true 
)
virtual

Sets the file path of this tree file item and only update the internal QFileInfo when the change was validated by any subject filters.

Does the same as QFileInfo::setFile() except that it also sets the correct property on the object needed to display it in an ObserverWidget.

This function will check if there is a qti_prop_NAME property on this object and set it. If it does not exist it will just set objectName(). Note that this does not set the names in the qti_prop_ALIAS_MAP property if it exists.

Important: If the qti_prop_NAME property exists this function will set the property, but not the path on the internal QFileInfo. When a QtilitiesPropertyChangeEvent is recieved it will update the internal QFileInfo. This is usefull in cases where the name change can be rejected (for example when a NamingPolicyFilter detects a duplicate). Thus the internal QFileInfo will only be changed when the new paths are valid. The important thing to remember here is that in order for a QtilitiesPropertyChangeEvent to be delivered, the observer to which the TreeFileItem is attached needs to have delivery of QtilitiesPropertyChangeEvent events enabled.

An alternative is to call setFileForce() which will update the internal QFileInfo without waiting for a QtilitiesPropertyChangeEvent. Make sure you understand when to use setFileForce() since the internal QFileInfo can get out of sync with the object name if the object name property is rejected by any subject filters. However if you are sure that it won't be rejected, setFileForce() should be used instead of setFile().

Parameters:
file_pathThe new file path.
relative_to_pathThe relative to path to use.
broadcastIndicates if the file model must broadcast that it was changed. This also hold for the modification state status of the file model.
See also:
setFileForce()
void CoreGui::TreeFileItem::setFileForce ( const QString &  file_path,
const QString &  relative_to_path = QString(),
bool  broadcast = true 
)
virtual

Sets the file path of this tree file item and update the internal QFileInfo without waiting for the change to be validated.

Does the same as setFile() except that it updates the internal QFileInfo immediately.

This function will check if there is a qti_prop_NAME property on this object and set it. If it does not exist it will just set objectName(). Note that this does not set the names in the qti_prop_ALIAS_MAP property if it exists.

Important: See the documentation of setFile() in order to understand when to use setFile() and when to use setFileForce().

Parameters:
file_pathThe new file path.
relative_to_pathThe relative to path to use.
broadcastIndicates if the file model must broadcast that it was changed. This also hold for the modification state status of the file model.
See also:
setFile()

This function was added in Qtilities v1.1.

Qtilities::Core::Interfaces::IExportable::ExportModeFlags Qtilities::CoreGui::TreeFileItem::supportedFormats ( ) const
virtual

Provides information about the export format(s) supported by your implementation of IExportable.

Note:
It is important to note that you need to check the exportVersion() when you return the supported formats.

Reimplemented from Qtilities::Core::Interfaces::IExportable.



Qtilities : Reference Documentation Back to top Copyright © 2009-2013, Jaco Naudé