Updraft  1.0
Open source glider flight visualisation tool.
Updraft::Core::FileTypeManager Class Reference

Handles file types, opening of files. More...

#include <filetypemanager.h>

List of all members.

Classes

class  FileOpenOption
 Represents a single option to open a file. More...

Public Member Functions

void registerFiletype (const FileRegistration &registration)
 Register a file that can be opened by a plugin.
bool openFile (const QString &path, bool showDialog=true) const
 Open a file at given path.
void openFileDialog (const QString &caption)
 Display a file open dialog, and open the selected files.
QDir lastDirectory ()
 Gets the directory from which the last file was opened.
void setLastDirectory (const QDir &dir)
 Sets the directory from which the last file was opened.

Private Member Functions

void getOpenOptions (QString path, QStandardItemModel *out) const
 Fill the output model with possible ways of opening this file.
bool importFile (QString *newPath, const QString &importDirectory, const QString &srcPath) const
 Copy a file to import directory.
bool openFileInternal (const QString &path, QStandardItemModel const *model) const
 Open a file at given path once its open options have been found and selected.

Private Attributes

QList< FileRegistrationregistered
 The list of known and registered files.
QString lastFileOpenDir
 The last opened file's directory.

Friends

class FileOpenDialog

Detailed Description

Handles file types, opening of files.

Dispatches file opens to plugins.


Member Function Documentation

void Updraft::Core::FileTypeManager::getOpenOptions ( QString  path,
QStandardItemModel *  model 
) const [private]

Fill the output model with possible ways of opening this file.

Parameters:
pathFile to open.
[out]modelModel that will contain the options. The model is cleared before, and each item is initially selected.
bool Updraft::Core::FileTypeManager::importFile ( QString *  newPath,
const QString &  importDirectory,
const QString &  srcPath 
) const [private]

Copy a file to import directory.

Parameters:
[out]newPathcontains destination path, if the function is successful This parameter is optional.
importDirectorya target subdirectory of application data dir. If importDirectory is empty, file will be copied to application data directory.
srcPatha path to file which is to be imported.
Returns:
True on success, otherwise returns false.

Gets the directory from which the last file was opened.

Returns:
The last opened file's directory.
bool Updraft::Core::FileTypeManager::openFile ( const QString &  path,
bool  showDialog = true 
) const

Open a file at given path.

Parameters:
pathPath to the file to open.
showDialogIf this is false, then all found options for opeing the file are used and no gui elements are displayed.
Returns:
true if opening was successful.
void Updraft::Core::FileTypeManager::openFileDialog ( const QString &  caption)

Display a file open dialog, and open the selected files.

Parameters:
captionTitle of the file open dialog.
bool Updraft::Core::FileTypeManager::openFileInternal ( const QString &  path,
QStandardItemModel const *  model 
) const [private]

Open a file at given path once its open options have been found and selected.

Parameters:
pathPath to the file to open.
[out]modelModel that contains the options for opening the file. Only items that are checked are
modelModel with FileOpenOption instances. This is a little fragile -- if the model contains something else than FileOpenOption bad things will happen.
Returns:
true if opening was successful.

Register a file that can be opened by a plugin.

One file can be opened in many ways. Each registration describes one way.

Sets the directory from which the last file was opened.

Parameters:
dirThe last opened file's directory

Friends And Related Function Documentation

friend class FileOpenDialog [friend]

Member Data Documentation

The last opened file's directory.

The list of known and registered files.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines