Updraft
1.0
Open source glider flight visualisation tool.
|
Handles file types, opening of files. More...
#include <filetypemanager.h>
Classes | |
class | FileOpenOption |
Represents a single option to open a file. More... | |
Public Member Functions | |
void | registerFiletype (const FileRegistration ®istration) |
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< FileRegistration > | registered |
The list of known and registered files. | |
QString | lastFileOpenDir |
The last opened file's directory. | |
Friends | |
class | FileOpenDialog |
Handles file types, opening of files.
Dispatches file opens to plugins.
void Updraft::Core::FileTypeManager::getOpenOptions | ( | QString | path, |
QStandardItemModel * | model | ||
) | const [private] |
Fill the output model with possible ways of opening this file.
path | File to open. | |
[out] | model | Model 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.
[out] | newPath | contains destination path, if the function is successful This parameter is optional. |
importDirectory | a target subdirectory of application data dir. If importDirectory is empty, file will be copied to application data directory. | |
srcPath | a path to file which is to be imported. |
Gets the directory from which the last file was opened.
bool Updraft::Core::FileTypeManager::openFile | ( | const QString & | path, |
bool | showDialog = true |
||
) | const |
Open a file at given path.
path | Path to the file to open. |
showDialog | If this is false, then all found options for opeing the file are used and no gui elements are displayed. |
void Updraft::Core::FileTypeManager::openFileDialog | ( | const QString & | caption | ) |
Display a file open dialog, and open the selected files.
caption | Title 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.
path | Path to the file to open. | |
[out] | model | Model that contains the options for opening the file. Only items that are checked are |
model | Model with FileOpenOption instances. This is a little fragile -- if the model contains something else than FileOpenOption bad things will happen. |
void Updraft::Core::FileTypeManager::registerFiletype | ( | const FileRegistration & | registration | ) |
Register a file that can be opened by a plugin.
One file can be opened in many ways. Each registration describes one way.
void Updraft::Core::FileTypeManager::setLastDirectory | ( | const QDir & | dir | ) |
Sets the directory from which the last file was opened.
dir | The last opened file's directory |
friend class FileOpenDialog [friend] |
QString Updraft::Core::FileTypeManager::lastFileOpenDir [private] |
The last opened file's directory.
QList<FileRegistration> Updraft::Core::FileTypeManager::registered [private] |
The list of known and registered files.