All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Signals | Public Member Functions
Qtilities::Core::FileSetInfo Class Reference

The FileSetInfo class provides information about a set of files. More...

#include <FileSetInfo.h>

Inheritance diagram for Qtilities::Core::FileSetInfo:
Inheritance graph
[legend]

List of all members.

Signals

void fileChanged (const QString &path)
 Emitted when the contents of a file changed.
void setChanged ()
 Emitted when the file set changed.

Public Member Functions

bool addFile (const QString &file_path)
 Adds a file to the set by providing a file path.
bool addFile (QtilitiesFileInfo file_info)
 Adds a file to the set by providing a QtilitiesFileInfo object describing the file.
bool allFilesExists () const
 Function which checks if all files in this set exists.
void clear ()
 Removes all files from this file set hash.
int count () const
 Returns the number of files in this file set.
void disableFileWatching ()
 Disables file watching on this file set.
void enableFileWatching ()
 Enables file watching on this file file set.
IExportable::ExportResultFlags exportBinary (QDataStream &stream) const
 Allows exporting to a QDataStream.
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.
QStringList filePaths () const
 Gets a list of all files in this set as a QStringList containing the actual paths of all files.
QList< QtilitiesFileInfofiles () const
 Gets a list of all files in this set as a list of QtilitiesFileInfo objects.
int fileSetHash (bool update_previous_hash_storage=true) const
 Returns a hash code for the contents of all files in the set.
int fileSetHashPrevious () const
 Returns the last hash code calculated for the contents of all files in the set.
bool fileWatchingEnabled () const
 Indicates if file watching is enabled on this file set.
bool hasFile (const QString &file_path) const
 Checks if the specified file is part of this set.
IExportable::ExportResultFlags importBinary (QDataStream &stream, QList< QPointer< QObject > > &import_list)
 Allows importing and reconstruction of the object state from information provided in a QDataStream.
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 isEmpty () const
 Indicates if this file set is empty (thus it contains not files).
QObject * objectBase ()
 Returns the QObject* base of the interface.
const QObject * objectBase () const
 Returns a const QObject* base of the interface.
bool removeFile (const QString &file_path)
 Removes a file from the set by providing a file path.
bool removeFile (QtilitiesFileInfo file_info)
 Removes a file from the set by providing a QtilitiesFileInfo object describing the file.
void setFileSetHash (int hash)
 Sets the hash code for the contents of all files in the set.
void setFileWatchingEnabled (bool enabled)
 Function to enable/disable file watching.
ExportModeFlags supportedFormats () const
 Provides information about the export format(s) supported by your implementation of IExportable.
void updateRelativeToPaths (const QString &search_string, const QString &replace_string, ITask *task)
 Updates all paths starting with the search string to start with replace string.
- 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 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.
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.
- 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.

Additional Inherited Members

- Public Types inherited from Qtilities::Core::Interfaces::IExportable
enum  ExportMode { None = 0, Binary = 1, XML = 2 }
 Possible export modes that an implementation of IExportable can support. More...
enum  Result {
  Complete = 0, Incomplete = 1, Failed = 2, FailedContinue = 4,
  VersionTooNew = 8, VersionTooOld = 16, VersionSupported = 32, SuccessResult = Complete | Incomplete | VersionSupported,
  FailedResult = Failed | FailedContinue | VersionTooNew | VersionTooOld
}
 The possible results of an export/import operation. More...
- Static Public Member Functions inherited from Qtilities::Core::Interfaces::IExportable
template<typename T >
static T * duplicateInstance (IExportable *obj, QString *error_msg=0, int properties_to_copy=0, ExportResultFlags *result_flags=0)
 Provides an easy to use template based implementation of IExportable::duplicate().
static QString exportModeToString (ExportMode export_mode)
 Function which returns a string associated with a specific ExportMode.
static ExportMode stringToExportMode (const QString &export_mode_string)
 Function which returns the ExportMode associated with a string.
static Result validateQtilitiesExportVersion (Qtilities::ExportVersion export_version, ITask *task=0)
 Checks the exportVersion() against the supported Qtilities export versions for the current Qtilities version.
static Result validateQtilitiesImportVersion (Qtilities::ExportVersion import_version, ITask *task=0)
 Checks the exportVersion() against the supported Qtilities import versions for the current Qtilities version.

Detailed Description

The FileSetInfo class provides information about a set of files.

The FileSetInfo class is an easy to use class which provides information about a set of files. Files can be added through addFile() and removed through removeFile(). You can get a list of all files in the set through files(), and check for a specific file through hasFile().

FileSetInfo provides the following funcationality on the files which are part of the set:

This class was added in Qtilities v1.2.


Member Function Documentation

bool FileSetInfo::addFile ( const QString &  file_path)

Adds a file to the set by providing a file path.

*This function will add the specified file to the set and return true if successfull. If the file *is already in the set it won't be added again and false will be returned.

Returns:
True when added successfully, false otherwise.
See also:
removeFile(), hasFile(), files(), fileChanged(), setChanged()
bool FileSetInfo::addFile ( QtilitiesFileInfo  file_info)

Adds a file to the set by providing a QtilitiesFileInfo object describing the file.

*This function will add the specified file to the set and return true if successfull. If the file *is already in the set it won't be added again and false will be returned.

Returns:
True when added successfully, false otherwise.
See also:
removeFile(), hasFile(), files(), fileChanged(), setChanged()
void FileSetInfo::disableFileWatching ( )

Disables file watching on this file set.

disableFileWatching Enabled by default.

See also:
enableFileWatching(), fileWatchingEnabled(), setFileWatchingEnabled()
void FileSetInfo::enableFileWatching ( )

Enables file watching on this file file set.

enableFileWatching Enabled by default.

See also:
disableFileWatching(), fileWatchingEnabled(), setFileWatchingEnabled()
Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::Core::FileSetInfo::exportBinary ( QDataStream &  stream) const
virtual

Allows exporting to a QDataStream.

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

Parameters:
streamA reference to the QDataStream to which the object's information must be appended is provided.

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

Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::Core::FileSetInfo::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::Core::FileSetInfo::fileChanged ( const QString &  path)
signal

Emitted when the contents of a file changed.

fileChanged Emitted when the contents of any monitored file in the set is changed, renamed or removed.

Parameters:
pathThe path of the file that changed.

*Internally this class uses QFileSystemWatcher to monitor changes to file contents and this signal *is basically connected to the same signal on the internal file system watcher.

QStringList FileSetInfo::filePaths ( ) const

Gets a list of all files in this set as a QStringList containing the actual paths of all files.

Returns:
A QStringList file paths of all files in the list.
See also:
addFile(), removeFile(), hasFile(), filesLastSave()
QList< QtilitiesFileInfo > FileSetInfo::files ( ) const

Gets a list of all files in this set as a list of QtilitiesFileInfo objects.

Returns:
A QStringList file paths of all files in the list.
See also:
addFile(), removeFile(), hasFile(), filesLastSave()
int FileSetInfo::fileSetHash ( bool  update_previous_hash_storage = true) const

Returns a hash code for the contents of all files in the set.

*This function will generate an unique hash code generated from the contents of all files in the set.

Parameters:
update_previous_hash_storageWhen true, the internal storage storing the last calculated hash which is accessable through *fileSetHashPrevious() will be updated. When false, the new hash will only be returned and the internal storage won't be modified.
Returns:
The file set hash for the files in this set. If no files are in the set, this function will return -1.
See also:
fileSetHashPrevious()
int FileSetInfo::fileSetHashPrevious ( ) const

Returns the last hash code calculated for the contents of all files in the set.

*This function will return the last calculated hash code for the contents of all files in the set.

Note:
If the hash has never been calculated, this function will return -1.
See also:
fileSetHash()
bool FileSetInfo::fileWatchingEnabled ( ) const

Indicates if file watching is enabled on this file set.

fileWatchingEnabled Enabled by default.

See also:
disableFileWatching(), enableFileWatching(), setFileWatchingEnabled()
bool FileSetInfo::hasFile ( const QString &  file_path) const

Checks if the specified file is part of this set.

Returns:
True when the file is part of this set, false otherwise.
See also:
addFile(), removeFile(), files()
Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::Core::FileSetInfo::importBinary ( QDataStream &  stream,
QList< QPointer< QObject > > &  import_list 
)
virtual

Allows importing and reconstruction of the object state from information provided in a QDataStream.

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

Parameters:
streamThe QDataStream which contains the object's information.
import_listAll objects constructed during the import operation must be added to the import list. When the operation fails, all objects in this list will be deleted.

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

Qtilities::Core::Interfaces::IExportable::ExportResultFlags Qtilities::Core::FileSetInfo::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.

InstanceFactoryInfo FileSetInfo::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.

const QObject* Qtilities::Core::FileSetInfo::objectBase ( ) const
inlinevirtual

Returns a const QObject* base of the interface.

This function can be used in const methods, but make sure that you don't modify things that should stay const. An example where this is used is when we want to get a property on an object in a const method. This is a const operation.

Implements Qtilities::Core::Interfaces::IObjectBase.

bool FileSetInfo::removeFile ( const QString &  file_path)

Removes a file from the set by providing a file path.

*This function will remove the file from the set and return true if successfull.

Returns:
True when removed successfully, false otherwise.
See also:
addFile(), hasFile(), files()
bool FileSetInfo::removeFile ( QtilitiesFileInfo  file_info)

Removes a file from the set by providing a QtilitiesFileInfo object describing the file.

*This function will remove the file from the set and return true if successfull.

Returns:
True when removed successfully, false otherwise.
See also:
addFile(), hasFile(), files()
void Qtilities::Core::FileSetInfo::setChanged ( )
signal

Emitted when the file set changed.

fileChanged

*Emitted when the set changed (only monitored files are taken into account).

*This function will be emitted when:

  • The contents of any of the files in the set is changed, renamed or removed.
  • When files are added to or removed from the set.
void FileSetInfo::setFileWatchingEnabled ( bool  enabled)

Function to enable/disable file watching.

enableFileWatching Enabled by default.

See also:
disableFileWatching(), enableFileWatching(), fileWatchingEnabled()
Qtilities::Core::Interfaces::IExportable::ExportModeFlags Qtilities::Core::FileSetInfo::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é