kwave
18.07.70
|
#include <FileContext.h>
Classes | |
class | UsageGuard |
Public Slots | |
int | executeCommand (const QString &command) |
Signals | |
void | sigStatusBarMessage (const QString &message, unsigned int ms) |
void | sigZoomChanged (Kwave::FileContext *context, double zoom) |
void | sigMetaDataChanged (Kwave::MetaDataList meta_data) |
void | sigSelectionChanged (sample_index_t offset, sample_index_t length) |
void | sigUndoRedoInfo (const QString &undo, const QString &redo) |
void | sigVisibleRangeChanged (sample_index_t offset, sample_index_t visible, sample_index_t total) |
void | sigModified () |
void | destroyed (Kwave::FileContext *context) |
Public Member Functions | |
FileContext (Kwave::App &app) | |
virtual | ~FileContext () |
bool | init (Kwave::TopWidget *top_widget) |
bool | createMainWidget (const QSize &preferred_size) |
void | setParent (Kwave::TopWidget *top_widget) |
Kwave::App & | app () const |
QWidget * | mainWidget () const |
Kwave::SignalManager * | signalManager () const |
Kwave::PluginManager * | pluginManager () const |
Kwave::Zoomable * | zoomable () const |
bool | isEmpty () const |
bool | isActive () const |
bool | isInUse () const |
QString | signalName () const |
int | instanceNr () const |
QString | windowCaption (bool with_modified) const |
int | loadBatch (const QUrl &url) |
int | saveFile () |
int | saveFileAs (const QString &filename, bool selection=false) |
bool | closeFile () |
Protected Member Functions | |
void | use () |
void | release () |
Private Slots | |
void | contextSwitched (Kwave::FileContext *context) |
void | forwardZoomChanged (double zoom) |
void | updatePlaybackPos (sample_index_t offset) |
void | metaDataChanged (Kwave::MetaDataList meta_data) |
void | selectionChanged (sample_index_t offset, sample_index_t length) |
void | setUndoRedoInfo (const QString &undo, const QString &redo) |
void | visibleRangeChanged (sample_index_t offset, sample_index_t visible, sample_index_t total) |
void | modifiedChanged () |
void | processDelayedCommand () |
Private Member Functions | |
void | activated () |
void | statusBarMessage (const QString &msg, unsigned int ms) |
int | parseCommands (QTextStream &stream) |
void | enqueueCommand (unsigned int delay, const QString &command) |
int | revert () |
int | delegateCommand (const char *plugin, Kwave::Parser &parser, unsigned int param_count) |
Private Attributes | |
QAtomicInt | m_use_count |
Kwave::App & | m_application |
QPointer< Kwave::TopWidget > | m_top_widget |
QPointer< Kwave::MainWidget > | m_main_widget |
QPointer< Kwave::SignalManager > | m_signal_manager |
QPointer< Kwave::PluginManager > | m_plugin_manager |
bool | m_active |
double | m_last_zoom |
sample_index_t | m_last_playback_pos |
QString | m_last_status_message_text |
QElapsedTimer | m_last_status_message_timer |
unsigned int | m_last_status_message_ms |
QString | m_last_undo |
QString | m_last_redo |
int | m_instance_nr |
QTimer | m_delayed_command_timer |
QList< QPair< unsigned int, QString > > | m_delayed_command_queue |
Friends | |
class | App |
class | TopWidget |
class | UsageGuard |
Definition at line 55 of file FileContext.h.
|
explicit |
Constructor. Creates a new toplevel window, signal manager, plugin manager and so on.
app | reference to the Kwave application |
Definition at line 69 of file FileContext.cpp.
References Kwave::connect(), m_delayed_command_timer, and processDelayedCommand().
|
virtual |
Destructor
Definition at line 95 of file FileContext.cpp.
References m_main_widget, m_plugin_manager, m_signal_manager, and m_top_widget.
|
private |
should be called when this context got active, to update the status bar, toolbar etc.
Definition at line 619 of file FileContext.cpp.
References forwardZoomChanged(), m_last_playback_pos, m_last_redo, m_last_status_message_ms, m_last_status_message_text, m_last_status_message_timer, m_last_undo, m_last_zoom, m_main_widget, m_plugin_manager, m_signal_manager, sigMetaDataChanged(), sigModified(), sigStatusBarMessage(), sigUndoRedoInfo(), sigVisibleRangeChanged(), Kwave::toUint(), and updatePlaybackPos().
Referenced by contextSwitched().
|
inline |
returns a reference to the application instance
Definition at line 93 of file FileContext.h.
Referenced by Kwave::MainWidget::resizeEvent().
bool Kwave::FileContext::closeFile | ( | ) |
Closes the current file. If the file has been modified and the user wanted to cancel the close operation, the file will not get closed and the function returns with false.
Definition at line 1060 of file FileContext.cpp.
References Kwave::App::GUI_MDI, Kwave::App::GUI_SDI, Kwave::App::GUI_TAB, Kwave::App::guiType(), m_application, m_main_widget, m_plugin_manager, m_signal_manager, m_top_widget, saveFile(), and Kwave::MessageBox::warningYesNoCancel().
Referenced by Kwave::TopWidget::closeAllSubWindows(), Kwave::MainWidget::closeEvent(), executeCommand(), Kwave::TopWidget::loadFile(), and Kwave::TopWidget::newWindow().
|
privateslot |
called when the current file context has changed
context | the new file context (can be "this") |
Definition at line 605 of file FileContext.cpp.
References activated(), and m_active.
Referenced by setParent().
bool Kwave::FileContext::createMainWidget | ( | const QSize & | preferred_size | ) |
create a main widget, within the MDI area or toplevel widget in case of SDI interface
preferred_size | preferred size of the main widget |
Definition at line 127 of file FileContext.cpp.
References Kwave::connect(), executeCommand(), forwardZoomChanged(), m_main_widget, m_signal_manager, m_top_widget, sigVisibleRangeChanged(), sigZoomChanged(), and visibleRangeChanged().
Referenced by Kwave::TopWidget::init(), Kwave::TopWidget::insertContext(), and Kwave::TopWidget::newWindow().
|
private |
delegate a command to a plugin
plugin | name of a plugin to delegate the command to |
parser | the parser with the parts of the command |
param_count | required number of parameters |
Definition at line 296 of file FileContext.cpp.
References _, Kwave::Parser::command(), Kwave::Parser::count(), m_plugin_manager, and Kwave::Parser::remainingParams().
Referenced by executeCommand().
|
signal |
emitted when the context is about to be destroyed (in the context of it's destructor)
|
private |
enqueues a command for later execution
delay | milliseconds to wait before execution |
command | the command to execute |
Definition at line 795 of file FileContext.cpp.
References m_delayed_command_queue, m_delayed_command_timer, and use().
Referenced by executeCommand().
|
slot |
Execute a Kwave text command
command | a text command |
Definition at line 312 of file FileContext.cpp.
References _, CASE_COMMAND, closeFile(), Kwave::Parser::command(), Kwave::Parser::commandList(), Kwave::Parser::count(), DBG, delegateCommand(), enqueueCommand(), Kwave::CommandHandler::executeCommand(), Kwave::Parser::firstParam(), Kwave::Parser::hasMultipleCommands(), Kwave::Logger::Info, loadBatch(), Kwave::Logger::log(), m_delayed_command_queue, m_main_widget, m_plugin_manager, m_top_widget, name, Kwave::Parser::nextParam(), Kwave::Parser::remainingParams(), revert(), saveFile(), and saveFileAs().
Referenced by createMainWidget(), Kwave::TopWidget::forwardCommand(), init(), Kwave::TopWidget::loadFile(), parseCommands(), and processDelayedCommand().
|
privateslot |
emits a sigZoomChanged(this, zoom) when the zoom has changed in the m_main_widget
Definition at line 474 of file FileContext.cpp.
References m_last_zoom, and sigZoomChanged().
Referenced by activated(), and createMainWidget().
bool Kwave::FileContext::init | ( | Kwave::TopWidget * | top_widget | ) |
initializes the instance
top_widget | pointer to the toplevel widget |
Definition at line 160 of file FileContext.cpp.
References _, Kwave::connect(), Kwave::MessageBox::error(), executeCommand(), m_plugin_manager, m_signal_manager, m_top_widget, metaDataChanged(), modifiedChanged(), parseCommands(), selectionChanged(), setParent(), setUndoRedoInfo(), Kwave::Splash::showMessage(), sigMetaDataChanged(), sigModified(), sigUndoRedoInfo(), statusBarMessage(), and updatePlaybackPos().
Referenced by Kwave::TopWidget::newFileContext().
|
inline |
returns the instance of the loaded file or -1
Definition at line 136 of file FileContext.h.
Referenced by Kwave::TopWidget::openFiles().
|
inline |
Returns whether this context is active or not.
true | if the context is active |
false | if the context is inactive |
Definition at line 124 of file FileContext.h.
Referenced by metaDataChanged(), modifiedChanged(), Kwave::MainWidget::resizeEvent(), selectionChanged(), setUndoRedoInfo(), statusBarMessage(), and visibleRangeChanged().
|
inline |
Returns whether this context is empty (has a main widget) or not.
true | if the context is empty |
false | if the context has a main widget |
Definition at line 117 of file FileContext.h.
Referenced by Kwave::TopWidget::newWindow(), and Kwave::App::switchGuiType().
bool Kwave::FileContext::isInUse | ( | ) | const |
Returns true it this context has a signal (file is loaded) or the context is executing a script
Definition at line 823 of file FileContext.cpp.
References m_signal_manager, and m_use_count.
Referenced by Kwave::TopWidget::detachAllContexts().
int Kwave::FileContext::loadBatch | ( | const QUrl & | url | ) |
Loads a batch file into memory, parses and executes all commands in it.
url | URL of the macro (batch file) to be loaded |
Definition at line 863 of file FileContext.cpp.
References parseCommands().
Referenced by executeCommand(), Kwave::TopWidget::loadFile(), and Kwave::MainWidget::loadLabels().
QWidget * Kwave::FileContext::mainWidget | ( | ) | const |
returns a pointer to the main widget of this context
Definition at line 271 of file FileContext.cpp.
References m_main_widget.
Referenced by Kwave::TopWidget::init(), Kwave::TopWidget::insertContext(), and parseCommands().
|
privateslot |
Called when the meta data of the current signal has changed
meta_data | the new meta data, after the change |
Definition at line 521 of file FileContext.cpp.
References Kwave::App::GUI_SDI, Kwave::App::guiType(), isActive(), m_application, m_instance_nr, m_main_widget, name, Kwave::App::openFiles(), sigMetaDataChanged(), signalName(), and windowCaption().
Referenced by init().
|
privateslot |
called if the signal now or no longer is modified
Definition at line 592 of file FileContext.cpp.
References Kwave::App::GUI_SDI, Kwave::App::guiType(), isActive(), m_application, m_main_widget, sigModified(), and windowCaption().
Referenced by init().
|
private |
Parses a text stream line by line and executes each line as a command until all commands are done or the first one fails.
stream | a QTextStream to read from |
Definition at line 671 of file FileContext.cpp.
References _, CASE_COMMAND, Kwave::Parser::command(), DBG, executeCommand(), Kwave::Parser::firstParam(), Kwave::label_t::hits, m_plugin_manager, m_top_widget, mainWidget(), name, Kwave::label_t::pos, and Kwave::MessageBox::questionYesNo().
Referenced by init(), and loadBatch().
Kwave::PluginManager * Kwave::FileContext::pluginManager | ( | ) | const |
returns a pointer to the plugin manager of this context
Definition at line 284 of file FileContext.cpp.
References m_plugin_manager.
Referenced by Kwave::TopWidget::forwardCommand(), Kwave::MainWidget::MainWidget(), and Kwave::MainWidget::~MainWidget().
|
privateslot |
process the next delayed command from m_delayed_command_queue
Definition at line 808 of file FileContext.cpp.
References executeCommand(), m_delayed_command_queue, m_delayed_command_timer, and release().
Referenced by FileContext().
|
protected |
decrements the usage count of this context, and if it has reached zero this instance will be deleted (delayed)
Definition at line 117 of file FileContext.cpp.
References m_use_count.
Referenced by Kwave::TopWidget::detachAllContexts(), Kwave::TopWidget::insertContext(), Kwave::TopWidget::newWindow(), processDelayedCommand(), Kwave::TopWidget::subWindowDeleted(), and Kwave::App::switchGuiType().
|
private |
Discards all changes to the current file and loads it again.
Definition at line 883 of file FileContext.cpp.
References m_signal_manager, m_top_widget, signalName(), and Kwave::MessageBox::warningContinueCancel().
Referenced by executeCommand().
int Kwave::FileContext::saveFile | ( | ) |
Saves the current file.
Definition at line 901 of file FileContext.cpp.
References m_signal_manager, NEW_FILENAME, saveFileAs(), and signalName().
Referenced by closeFile(), and executeCommand().
int Kwave::FileContext::saveFileAs | ( | const QString & | filename, |
bool | selection = false |
||
) |
Opens a dialog for saving the current file.
filename | the name of the new file or empty string to open the File/SaveAs dialog |
selection | if set to true, only the current selection will be saved |
Definition at line 921 of file FileContext.cpp.
References _, Kwave::App::addRecentFile(), DBG, Kwave::CodecManager::encoder(), Kwave::CodecManager::encodingFilter(), Kwave::CodecBase::extensions(), Kwave::INF_FILENAME, Kwave::INF_MIMETYPE, m_application, m_plugin_manager, m_signal_manager, m_top_widget, Kwave::CodecManager::mimeTypeOf(), name, Kwave::FileDialog::SaveFile, Kwave::FileDialog::selectedUrl(), Kwave::FileInfo::set(), signalName(), and Kwave::MessageBox::warningYesNo().
Referenced by executeCommand(), and saveFile().
|
privateslot |
Called when the number of selected samples has changed.
offset | index of the first selected sample |
length | number of selected samples |
Definition at line 558 of file FileContext.cpp.
References isActive(), and sigSelectionChanged().
Referenced by init().
void Kwave::FileContext::setParent | ( | Kwave::TopWidget * | top_widget | ) |
migrate this context to a different toplevel widget
top_widget | pointer to the new toplevel widget |
Definition at line 235 of file FileContext.cpp.
References Kwave::connect(), contextSwitched(), m_active, m_main_widget, m_plugin_manager, m_signal_manager, and m_top_widget.
Referenced by Kwave::TopWidget::detachAllContexts(), init(), Kwave::TopWidget::insertContext(), and Kwave::App::switchGuiType().
|
privateslot |
Called when the undo or redo action has changed.
undo | description of the last undo action |
redo | description of the last redo action |
Definition at line 568 of file FileContext.cpp.
References isActive(), m_last_redo, m_last_undo, and sigUndoRedoInfo().
Referenced by init().
|
signal |
emitted when the meta data of the current signal has changed
meta_data | the new meta data, after the change |
Referenced by activated(), init(), and metaDataChanged().
|
signal |
Emitted if the signal changes from non-modified to modified state or vice-versa.
Referenced by activated(), init(), and modifiedChanged().
Kwave::SignalManager * Kwave::FileContext::signalManager | ( | ) | const |
returns a pointer to the signal manager of this context
Definition at line 277 of file FileContext.cpp.
References m_signal_manager.
Referenced by Kwave::MainWidget::addLabel(), Kwave::PlayerToolBar::contextSwitched(), Kwave::MainWidget::dropEvent(), Kwave::MainWidget::executeCommand(), Kwave::MainWidget::fixZoomAndOffset(), Kwave::MainWidget::fullZoom(), Kwave::MainWidget::horizontalScrollBarMoved(), Kwave::MainWidget::labelProperties(), Kwave::TopWidget::loadFile(), Kwave::MainWidget::loadLabels(), Kwave::MainWidget::MainWidget(), Kwave::MainWidget::ms2samples(), Kwave::TopWidget::newSignal(), Kwave::TopWidget::newWindow(), Kwave::MainWidget::refreshHorizontalScrollBar(), Kwave::MainWidget::saveLabels(), Kwave::TopWidget::selectionChanged(), Kwave::ZoomToolBar::selectZoom(), Kwave::ZoomToolBar::setZoomInfo(), Kwave::MainWidget::slotTrackInserted(), Kwave::TopWidget::updateMenu(), Kwave::ZoomToolBar::updateToolbar(), Kwave::TopWidget::updateToolbar(), Kwave::MainWidget::updateViewRange(), and Kwave::MainWidget::zoomSelection().
QString Kwave::FileContext::signalName | ( | ) | const |
returns the name of the signal
Definition at line 830 of file FileContext.cpp.
References m_signal_manager.
Referenced by metaDataChanged(), Kwave::TopWidget::openFiles(), revert(), saveFile(), saveFileAs(), Kwave::MainWidget::saveLabels(), Kwave::TopWidget::updateMenu(), and windowCaption().
|
signal |
emits a change in the selected range.
offset | index of the first selected items |
length | number of selected items |
Referenced by selectionChanged().
|
signal |
emitted when there is a status bar message to show
message | the status bar message, already localized |
ms | the time in milliseconds to show the message |
Referenced by activated(), and statusBarMessage().
|
signal |
Emitted if the state or description of undo/redo has changed. If undo or redo is unavailable the description will be zero.
Referenced by activated(), init(), and setUndoRedoInfo().
|
signal |
emitted when the visible range has changed
Referenced by activated(), createMainWidget(), and visibleRangeChanged().
|
signal |
emitted when the zoom factor of the corresponding main widget has changed
context | contains "this" |
zoom | new zoom factor |
Referenced by createMainWidget(), and forwardZoomChanged().
|
private |
Show a message in the status bar
msg | the status bar message, already localized |
ms | the time in milliseconds to show the message |
Definition at line 481 of file FileContext.cpp.
References isActive(), m_last_status_message_ms, m_last_status_message_text, m_last_status_message_timer, and sigStatusBarMessage().
Referenced by init(), and updatePlaybackPos().
|
privateslot |
Called when the playback position has changed
offset | the current playback position [samples] |
Definition at line 495 of file FileContext.cpp.
References m_last_playback_pos, m_main_widget, m_plugin_manager, m_signal_manager, Kwave::ms2string(), Kwave::samples2string(), Kwave::Zoomable::scrollTo(), statusBarMessage(), and zoomable().
Referenced by activated(), and init().
|
protected |
increments the usage count of this context, prevents it from being deleted
Definition at line 110 of file FileContext.cpp.
References m_use_count.
Referenced by enqueueCommand().
|
privateslot |
Called after changes of the currently visible view range
offset | index of the first visible sample |
visible | number of visible samples |
total | length of the whole signal |
Definition at line 581 of file FileContext.cpp.
References isActive(), and sigVisibleRangeChanged().
Referenced by createMainWidget().
QString Kwave::FileContext::windowCaption | ( | bool | with_modified | ) | const |
returns a string suitable as window caption
with_modified | if true, include the "modified" state |
Definition at line 836 of file FileContext.cpp.
References Kwave::App::GUI_SDI, Kwave::App::guiType(), m_application, m_instance_nr, m_signal_manager, name, and signalName().
Referenced by Kwave::TopWidget::executeCommand(), Kwave::TopWidget::insertContext(), metaDataChanged(), modifiedChanged(), Kwave::TopWidget::updateCaption(), and Kwave::TopWidget::updateMenu().
Kwave::Zoomable * Kwave::FileContext::zoomable | ( | ) | const |
Returns a pointer to a GUI element that receives zoom info (the MainWidget)
Definition at line 290 of file FileContext.cpp.
References m_main_widget.
Referenced by Kwave::ZoomToolBar::selectZoom(), Kwave::ZoomToolBar::setZoomInfo(), and updatePlaybackPos().
|
friend |
Definition at line 177 of file FileContext.h.
|
friend |
Definition at line 178 of file FileContext.h.
|
friend |
Definition at line 179 of file FileContext.h.
|
private |
if true, this context is active, otherwise it is inactive
Definition at line 407 of file FileContext.h.
Referenced by contextSwitched(), and setParent().
|
private |
reference to the global Kwave application object
Definition at line 392 of file FileContext.h.
Referenced by closeFile(), metaDataChanged(), modifiedChanged(), saveFileAs(), and windowCaption().
|
private |
queue for delayed execution of commands
Definition at line 437 of file FileContext.h.
Referenced by enqueueCommand(), executeCommand(), and processDelayedCommand().
|
private |
timer for delayed commands
Definition at line 434 of file FileContext.h.
Referenced by enqueueCommand(), FileContext(), and processDelayedCommand().
|
private |
instance of the loaded file or -1
Definition at line 431 of file FileContext.h.
Referenced by metaDataChanged(), and windowCaption().
|
private |
last playback position, only valid if playback is running
Definition at line 413 of file FileContext.h.
Referenced by activated(), and updatePlaybackPos().
|
private |
name of the last redo action
Definition at line 428 of file FileContext.h.
Referenced by activated(), and setUndoRedoInfo().
|
private |
number of milliseconds the status message should be shown
Definition at line 422 of file FileContext.h.
Referenced by activated(), and statusBarMessage().
|
private |
last status bar message
Definition at line 416 of file FileContext.h.
Referenced by activated(), and statusBarMessage().
|
private |
time when the last status message has been shown
Definition at line 419 of file FileContext.h.
Referenced by activated(), and statusBarMessage().
|
private |
name of the last undo action
Definition at line 425 of file FileContext.h.
Referenced by activated(), and setUndoRedoInfo().
|
private |
last zoom factor
Definition at line 410 of file FileContext.h.
Referenced by activated(), and forwardZoomChanged().
|
private |
instance of our main widget
Definition at line 398 of file FileContext.h.
Referenced by activated(), closeFile(), createMainWidget(), executeCommand(), mainWidget(), metaDataChanged(), modifiedChanged(), setParent(), updatePlaybackPos(), zoomable(), and ~FileContext().
|
private |
instance of our plugin manager
Definition at line 404 of file FileContext.h.
Referenced by activated(), closeFile(), delegateCommand(), executeCommand(), init(), parseCommands(), pluginManager(), saveFileAs(), setParent(), updatePlaybackPos(), and ~FileContext().
|
private |
instance of our signal manager
Definition at line 401 of file FileContext.h.
Referenced by activated(), closeFile(), createMainWidget(), init(), isInUse(), revert(), saveFile(), saveFileAs(), setParent(), signalManager(), signalName(), updatePlaybackPos(), windowCaption(), and ~FileContext().
|
private |
instance of our toplevel window
Definition at line 395 of file FileContext.h.
Referenced by closeFile(), createMainWidget(), executeCommand(), init(), parseCommands(), revert(), saveFileAs(), setParent(), and ~FileContext().
|
private |
usage counter [0...n]
Definition at line 389 of file FileContext.h.