SymbolEditor
1.3.0
|
Manages the main window of the application. More...
#include <MainWindow.h>
Public Member Functions | |
MainWindow () | |
~MainWindow () | |
Protected Slots | |
void | fileOpen () |
void | fileOpen (const KUrl &url) |
void | save () |
void | saveAs () |
void | newSymbol () |
void | saveSymbol () |
void | saveSymbolAsNew () |
void | importLibrary () |
void | close () |
void | quit () |
void | undo () |
void | redo () |
void | undoTextChanged (const QString &text) |
void | redoTextChanged (const QString &text) |
void | cleanChanged (bool clean) |
void | currentChanged (int index) |
void | itemSelected (QListWidgetItem *item) |
void | listWidgetContextMenuRequested (const QPoint &pos) |
void | deleteSymbol () |
void | preferences () |
Protected Member Functions | |
virtual bool | queryClose () |
virtual bool | queryExit () |
Private Member Functions | |
bool | editorClean () |
bool | libraryClean () |
void | setupActions () |
void | setActionsFromSymbol (const Symbol &symbol) |
Private Attributes | |
KUrl | m_url |
KTabWidget * | m_tabWidget |
Editor * | m_editor |
SymbolListWidget * | m_listWidget |
SymbolLibrary * | m_symbolLibrary |
QListWidgetItem * | m_item |
QMenu * | m_menu |
QUndoGroup | m_undoGroup |
Manages the main window of the application.
The MainWindow class is based on the KXmlGuiWindow class which provides the basis for KDE applications. It creates instances of the Editor class and the QListWidget class that is used to show the existing symbols in the library.
It creates all the actions that are associated with the application connecting various signals to the relevant slots to allow the interaction between the gui elements.
Definition at line 48 of file MainWindow.h.
MainWindow::MainWindow | ( | ) |
Construct the MainWindow. Create an instance of a symbol file. Create the tab widget, editor, list widget and the symbol file. The tab widget is then set as the central widget and will contain the editor and list widgets. The Editor is added to a layout to allow it to be centralized in the main window. Set up the actions, add the two undo stacks to the undo group and connect any signal slots required. Set up the GUI from the applications rc file. The editor page is selected in the tab widget which should also initialise the undo redo buttons. The moveTo tool action is triggered to enable the moveTo tool as the initial one. Other actions are initialised from the current Editor symbol.
Definition at line 186 of file MainWindow.cpp.
MainWindow::~MainWindow | ( | ) |
Descructor for the MainWindow Delete the SymbolLibrary object. The other widgets that are created in the constructor are children of the MainWindow and will be destroyed when this is.
Definition at line 252 of file MainWindow.cpp.
|
protectedslot |
Update the caption based on the state of the undo stack.
clean | true if the symbol has not been changed, false otherwise |
Definition at line 650 of file MainWindow.cpp.
|
protectedslot |
Close the current library. Check if the current symbol and the symbol library need to be saved and then clear the library and the editor.
Definition at line 577 of file MainWindow.cpp.
|
protectedslot |
Change the tab selected. This is connected to the QTabWidget::currentChanged() slot and indicates that the current tab has changed. This allows the undo stack connections to be modified.
index | the index of the page |
Definition at line 671 of file MainWindow.cpp.
|
protectedslot |
Delete the symbol pointed to by m_item.
Definition at line 728 of file MainWindow.cpp.
|
private |
Check if it ok to close the currently edited symbol.
Definition at line 275 of file MainWindow.cpp.
|
protectedslot |
Open a file. Use the KFileDialog::getOpenUrl to get a KUrl to open which is then passed to filOpen(const KURl &).
Definition at line 350 of file MainWindow.cpp.
|
protectedslot |
If a valid url is supplied, try and download the file (in case it comes from a remote source) and then try and open it read only. Once opened create a QDataStream and try and read the contents. This is protected in a try-catch block to intercept any exceptions that may be thrown by the loading routines. If there were any errors, the symbol library will be cleared and a suitable error message will be displayed. The url of the file is set in the symbol file object only if there were no errors. This will avoid writing to a corrupt file or to a file that isn't a symbol file. The url is added to the recent file list.
Definition at line 370 of file MainWindow.cpp.
|
protectedslot |
Import a library of symbols into the current library. Get a url for the library file and try and download it in case it comes from a remote source. Open the file and read the contents into a new SymbolLibrary object. The read is protected by a try-catch block to intercept any exceptions thrown by the read routines. If there were no errors an ImportLibraryCommand is created and pushed onto the symbol library undo stack. This will copy all the symbols from the imported library into the current library. Any errors will display a suitable error message.
Definition at line 532 of file MainWindow.cpp.
|
protectedslot |
Edit an existing symbol from the symbol library. Check if the current symbol being edited has been changed. If yes, ask if it should be saved or discarded. Clear the contents of the editor and assign a copy of the item symbol to it to edit. The actions are updated to reflect the settings of the symbol being edited.
item | a pointer to a QListWidgetItem that was double clicked. |
Definition at line 690 of file MainWindow.cpp.
|
private |
Check if it is ok to close the library.
Definition at line 308 of file MainWindow.cpp.
|
protectedslot |
Display a context menu for the list widget. Options: Delete Symbol
pos | a const reference to a QPoint representing the cursor position |
Definition at line 712 of file MainWindow.cpp.
|
protectedslot |
Initialise a new symbol. Check if the current symbol has been saved or can be overwritten and then call clear on the editor which initializes the editor with an empty symbol. The actions are reset to those relevant to the new empty symbol. The moveTo action is triggered as this is the most likely to be used next.
Definition at line 483 of file MainWindow.cpp.
|
protectedslot |
Configure the application. Display the configuration dialog, creating it if necessary.
Definition at line 738 of file MainWindow.cpp.
|
protectedvirtual |
Test if it is ok to close this window. Check if the current symbol being edited has been changed and if the library has been changed.
Definition at line 264 of file MainWindow.cpp.
|
protectedvirtual |
Test if it is ok to close the application.
Definition at line 340 of file MainWindow.cpp.
|
protectedslot |
Quit the application. Closes this MainWindow.
Definition at line 591 of file MainWindow.cpp.
|
protectedslot |
Redo the last operation undone. Several undo stacks will be available. One for the library object and one for the editor. Changing the tab will update the actions depending on the contents of the relevant undo stack.
Definition at line 613 of file MainWindow.cpp.
|
protectedslot |
Update the redo action text to reflect the last operation available to redo. Several undo stacks will be available. One for the library object and one for the editor. Changing the tab will update the actions depending on the contents of the relevant undo stack.
text | the text string to describe the operation |
Definition at line 639 of file MainWindow.cpp.
|
protectedslot |
Save the library using its url, if this is Untitled than call saveAs to get a valid url. Open the file and write to the stream. This is protected in a try-catch block to intercept any exceptions thrown by the writing routines. If there were any exceptions thrown or the file could not be opened a suitable error message is shown.
Definition at line 425 of file MainWindow.cpp.
|
protectedslot |
Save the library using a different url. This is also called from save when the assigned url is Untitled. The new url is added to the recent files list.
Definition at line 456 of file MainWindow.cpp.
|
protectedslot |
Save the current symbol. Store the symbol currently in the editor into the symbol library object. If it is a new symbol the index will be 0, a new index will then be created. Otherwise the index will be the one from the library and storing it will overwrite the existing symbol.
Definition at line 499 of file MainWindow.cpp.
|
protectedslot |
Save the current symbol using a new index. Store the symbol currently in the editor into the symbol library object. Ignore the editors index, resetting it to 0 and a new index will then be created. Reassign this symbol back to the editor with a 0 index effectively creating a new symbol in the editor.
Definition at line 514 of file MainWindow.cpp.
|
private |
Set the actions status based on the settings in the specified Symbol.
symbol | a const reference to a Symbol |
Definition at line 999 of file MainWindow.cpp.
|
private |
Set up the applications actions. Create standard actions. Create other actions, setting the icon and data as required. Several actions are added to groups which are set as exclusive. All actions are added to the applications KActionCollection.
Definition at line 762 of file MainWindow.cpp.
|
protectedslot |
Undo the last operation. Several undo stacks will be available. One for the library object and one for the editor. Changing the tab will update the actions depending on the contents of the relevant undo stack.
Definition at line 602 of file MainWindow.cpp.
|
protectedslot |
Update the undo action text to reflect the last operation available to undo. Several undo stacks will be available. One for the library object and one for the editor. Changing the tab will update the actions depending on the contents of the relevant undo stack.
text | the text string to describe the operation |
Definition at line 626 of file MainWindow.cpp.
|
private |
pointer to the Editor
Definition at line 97 of file MainWindow.h.
|
private |
pointer to a QListWidgetItem in m_listWidget found for the context menu
Definition at line 102 of file MainWindow.h.
|
private |
pointer to the SymbolListWidget containing icons for the library symbols
Definition at line 98 of file MainWindow.h.
|
private |
pointer to a popup context menu
Definition at line 103 of file MainWindow.h.
|
private |
pointer to a SymbolLibrary
Definition at line 100 of file MainWindow.h.
|
private |
pointer to the KTabWidget containing the editor and library tabs
Definition at line 96 of file MainWindow.h.
|
private |
the QUndoGroup has the QUndoStacks for the Editor and the SymbolLibrary added to it
Definition at line 105 of file MainWindow.h.
|
private |
url of the loaded library
Definition at line 94 of file MainWindow.h.