SymbolEditor
1.3.0
|
Manages the library of symbols. More...
#include <SymbolLibrary.h>
Public Member Functions | |
SymbolLibrary (SymbolListWidget *listWidget=0) | |
~SymbolLibrary () | |
void | clear () |
Symbol | symbol (qint16 index) |
Symbol | takeSymbol (qint16 index) |
qint16 | setSymbol (qint16 index, const Symbol &symbol) |
QString | name () const |
void | setName (const QString &name) |
QList< qint16 > | indexes () const |
QUndoStack * | undoStack () |
Private Member Functions | |
void | generateItems () |
Private Attributes | |
QUndoStack | m_undoStack |
QString | m_name |
SymbolListWidget * | m_listWidget |
qint16 | m_nextIndex |
QMap< qint16, Symbol > | m_symbols |
Static Private Attributes | |
static const qint32 | version = 101 |
Friends | |
QDataStream & | operator<< (QDataStream &stream, const SymbolLibrary &library) |
QDataStream & | operator>> (QDataStream &stream, SymbolLibrary &library) |
Manages the library of symbols.
The symbol library holds all the symbols that have been added to it or loaded from a file. The symbols are indexed and the index is incremented for each symbol added starting from 1. When a SymbolListWidget is assigned to the SymbolLibrary each of the symbols is added to the SymbolListWidget which will create a QListWidgetItem which is assigned the QIcon that is generated from the QPainterPath associated with the index.
Definition at line 46 of file SymbolLibrary.h.
|
explicit |
Construct a SymbolLibrary. Set the index to 1. The index will be set when a file is loaded and will be incremented when new symbols have been added. It will be saved with the file for the next time it is loaded.
Definition at line 70 of file SymbolLibrary.cpp.
SymbolLibrary::~SymbolLibrary | ( | ) |
Destructor
Definition at line 80 of file SymbolLibrary.cpp.
void SymbolLibrary::clear | ( | ) |
Clear the file of symbols. Clears the undo stack, deletes all the QListWidgetItems and clears the symbol map. The index is reset to 1.
Definition at line 91 of file SymbolLibrary.cpp.
|
private |
Generate all the items in the library. This will be called when a library file is loaded to generate all the new QListWidgetItems for the symbols in the library and generate an icon for it. A list of sorted QMap keys is retrieved to allow adding items in the correct order.
Definition at line 225 of file SymbolLibrary.cpp.
QList< qint16 > SymbolLibrary::indexes | ( | ) | const |
Get a sorted list of symbol indexes
Definition at line 199 of file SymbolLibrary.cpp.
QString SymbolLibrary::name | ( | ) | const |
Get the name of the symbol library.
Definition at line 177 of file SymbolLibrary.cpp.
void SymbolLibrary::setName | ( | const QString & | name | ) |
Set the name of the symbol library.
name | the name to be set |
Definition at line 188 of file SymbolLibrary.cpp.
qint16 SymbolLibrary::setSymbol | ( | qint16 | index, |
const Symbol & | symbol | ||
) |
Update the Symbol for an index in the library. If the index supplied is 0, a new index will be taken from the m_nextIndex value which is then incremented. This value will be returned. When a LibraryListWidget has been linked to the SymbolLibrary the symbol is added to the LibraryListWidget.
index | a qint16 representing the index |
symbol | a const reference to a Symbol |
Definition at line 158 of file SymbolLibrary.cpp.
Symbol SymbolLibrary::symbol | ( | qint16 | index | ) |
Get the path associated with an index. If the index is not in the library it returns a default constructed Symbol.
index | a qint16 representing the index to find |
Definition at line 114 of file SymbolLibrary.cpp.
Symbol SymbolLibrary::takeSymbol | ( | qint16 | index | ) |
Take a symbol from the library. Remove a symbol identified by it's index and return it. The QListWidgetItem associated with the symbol is also removed and deleted. If the index is not in the library it returns a default constructed symbol.
index | the index of the Symbol to be removed |
Definition at line 130 of file SymbolLibrary.cpp.
QUndoStack * SymbolLibrary::undoStack | ( | ) |
Get a pointer to the symbol library undo stack.
Definition at line 212 of file SymbolLibrary.cpp.
|
friend |
Stream out the file. Symbol files are indicated with a magic string of KXStitchSymbols. The stream version is set to maintain consistency with the streamed objects. Write the version, current index and the map of symbols.
stream | a reference to a QDataStream |
library | a const reference to a SymbolLibrary |
Definition at line 246 of file SymbolLibrary.cpp.
|
friend |
Stream in the file. Initially clear the current contents. Symbol files are indicated with a magic string of KXStitchSymbols. The stream version is set to maintain consistency with the streamed objects. Read and check the magic string. If this is not a symbol file throw an exception. Read in the version. Read the data for the specified version. The stream is checked for errors and an exception is thrown if there was an error.
stream | a reference to a QDataStream |
library | a reference to a SymbolLibrary |
Definition at line 287 of file SymbolLibrary.cpp.
|
private |
pointer to a QListWidget containing the QListWidgetItems for the QIcons, this may be null for an imported file
Definition at line 77 of file SymbolLibrary.h.
|
private |
name of the symbol library
Definition at line 75 of file SymbolLibrary.h.
|
private |
index for the next symbol added
Definition at line 79 of file SymbolLibrary.h.
|
private |
map of the Symbol to indexes
Definition at line 80 of file SymbolLibrary.h.
|
private |
holds the commands that have made changes to this library
Definition at line 73 of file SymbolLibrary.h.
|
staticprivate |
stream version of this file
Definition at line 71 of file SymbolLibrary.h.