|
Canorus
0.0
|
File import/export base class. More...
#include <file.h>

Public Member Functions | |
| CAFile () | |
| virtual | ~CAFile () |
| const int | status () |
| const int | progress () |
| virtual const QString | readableStatus ()=0 |
| void | setStreamFromFile (const QString filename) |
| void | setStreamToFile (const QString filename) |
| void | setStreamFromDevice (QIODevice *device) |
| void | setStreamToDevice (QIODevice *device) |
| void | setStreamToString () |
| QString | getStreamAsString () |
Protected Member Functions | |
| void | setStatus (const int status) |
| void | setProgress (const int progress) |
| QTextStream * | stream () |
| virtual void | setStream (QTextStream *stream) |
| QFile * | file () |
| void | setFile (QFile *file) |
Private Attributes | |
| int | _status |
| int | _progress |
| QTextStream * | _stream |
| QFile * | _file |
| bool | _deleteStream |
File import/export base class.
Copyright (c) 2007, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.
Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE.GPL for details.
This class brings tools for manipulating with files and streams (most notably import and export). Classes CAImport and CAExport inherit this class and implement specific methods for import and export.
All file operations are done in a separate thread. While the file operations are in progress user can poll the status by calling status(), progress() and readableStatus() for human-readable status defined by the filter. Waiting for the thread to be finished can be implemented by calling QThread::wait() or by catching the signals emitted by children import and export classes.
| CAFile::CAFile | ( | ) |
References _deleteStream, setFile(), setProgress(), setStatus(), and setStream().

|
virtual |
Destructor. Also destroys the created stream and file, if set.
References _deleteStream, file(), and stream().

|
inlineprotected |
References _file.
Referenced by CAMidiImport::closeFile(), CACanorusMLExport::exportResources(), CACanImport::importDocumentImpl(), CACanorusMLImport::importResource(), CAPDFExport::pdfFinished(), CAPDFExport::runTypesetter(), CASVGExport::runTypesetter(), setFile(), setStreamFromFile(), setStreamToFile(), CASVGExport::svgFinished(), and ~CAFile().

| QString CAFile::getStreamAsString | ( | ) |
This function is provided for convenience when QTextStream/QIODevice API is not available (eg. when writing external Python plugins).
It returns the exported value as UTF-8 encoded string. To use this function first initialize the export filter using setStreamToString().
References stream().

|
inline |
References _progress.
Referenced by CAMainWinProgressCtl::on_updateTimer_timeout(), and setProgress().

|
pure virtual |
Implemented in CAMusicXmlImport, CAMidiImport, CALilyPondImport, CAImport, and CAExport.
Referenced by CAMainWinProgressCtl::on_updateTimer_timeout().

|
inlineprotected |
Referenced by CAFile(), setStreamFromFile(), and setStreamToFile().


|
inlineprotected |
References _progress, and progress().
Referenced by CAFile(), CACanorusMLExport::exportDocumentImpl(), and CAMidiImport::writeMidiFileEventsToScore_New().


|
inlineprotected |
References _status, and status().
Referenced by CAFile(), CAExport::exportDocument(), CAExport::exportDocumentImpl(), CACanExport::exportDocumentImpl(), CAExport::exportFunctionMarkContext(), CAExport::exportFunctionMarkContextImpl(), CAExport::exportLyricsContext(), CAExport::exportLyricsContextImpl(), CAExport::exportSheet(), CAExport::exportSheetImpl(), CAExport::exportStaff(), CAExport::exportStaffImpl(), CAExport::exportVoice(), CAExport::exportVoiceImpl(), CAMidiImport::fixAccidentals(), CAImport::importDocument(), CACanImport::importDocumentImpl(), CAImport::importDocumentImpl(), CAMusicXmlImport::importDocumentImpl(), CAImport::importFunctionMarkContext(), CAImport::importFunctionMarkContextImpl(), CAImport::importLyricsContext(), CAImport::importLyricsContextImpl(), CAMidiImport::importMidiEvents(), CAImport::importSheet(), CAImport::importSheetImpl(), CAMidiImport::importSheetImplPmidiParser(), CAImport::importStaff(), CAImport::importStaffImpl(), CAImport::importVoice(), CAImport::importVoiceImpl(), CAPDFExport::pdfFinished(), CAExport::run(), CAImport::run(), CASVGExport::svgFinished(), and CAMidiImport::writeMidiFileEventsToScore_New().


|
inlineprotectedvirtual |
References _stream, and stream().
Referenced by CAExport::CAExport(), CAFile(), CAImport::CAImport(), setStreamFromDevice(), setStreamFromFile(), setStreamToDevice(), and setStreamToFile().


| void CAFile::setStreamFromDevice | ( | QIODevice * | device | ) |
Creates and sets the stream from the given device. Read-only if the device is not already open.
References _deleteStream, setStream(), and stream().

| void CAFile::setStreamFromFile | ( | const QString | filename | ) |
Creates and sets the stream from the file named filename. Stream is Read-only. This method is usually called from the main window when opening a document. This method is also very important for python developers as they cannot directly access QTextStream class, so they call this wrapper instead with a simple string as parameter.
References _deleteStream, file(), setFile(), setStream(), and stream().
Referenced by CAImport::setStreamFromFile().


| void CAFile::setStreamToDevice | ( | QIODevice * | device | ) |
Creates and sets the stream from the given device. Read-write if the given device is not already open.
References _deleteStream, setStream(), and stream().
Referenced by CATypesetCtl::exportDocument(), CACanExport::exportDocumentImpl(), CATypesetCtl::exportSheet(), and setStreamToString().


| void CAFile::setStreamToFile | ( | const QString | filename | ) |
Creates and sets the stream from the file named filename. Stream is Read-Write. This method is usually called from the main window when saving the document. This method is also very important for python developers as they cannot directly access QTextStream class, so they call this wrapper instead with a simple string as parameter.
References _deleteStream, file(), setFile(), setStream(), and stream().
Referenced by CAExport::setStreamToFile().


| void CAFile::setStreamToString | ( | ) |
Creates and sets a new virtual IO device usually used for exporting document to a string when QTextStream/QIODevice API is not available (eg. when writing external Python plugins).
References setStreamToDevice().

|
inline |
References _status.
Referenced by CAExport::exportDocument(), CAExport::readableStatus(), CAImport::readableStatus(), CALilyPondImport::readableStatus(), CAMidiImport::readableStatus(), CAMusicXmlImport::readableStatus(), CAExport::run(), CAImport::run(), CAMainWin::saveDocument(), and setStatus().

|
inlineprotected |
References _stream.
Referenced by CAExport::CAExport(), CAImport::CAImport(), CAExport::exportDocument(), CACanExport::exportDocumentImpl(), getStreamAsString(), CACanImport::importDocumentImpl(), CACanorusMLImport::importDocumentImpl(), CAMusicXmlImport::importDocumentImpl(), CALilyPondImport::importSheetImpl(), CAImport::in(), CALilyPondImport::in(), CAMidiImport::in(), CAExport::out(), CAMXLImport::readContainerInfo(), CAExport::run(), CAImport::run(), setStream(), setStreamFromDevice(), setStreamFromFile(), setStreamToDevice(), setStreamToFile(), CAMXLImport::setTxtStream(), ~CAFile(), and CAImport::~CAImport().

|
private |
Referenced by CAFile(), setStreamFromDevice(), setStreamFromFile(), setStreamToDevice(), setStreamToFile(), and ~CAFile().
|
private |
Referenced by progress(), and setProgress().
|
private |
Referenced by setStatus(), and status().
|
private |
Referenced by setStream(), and stream().