SymbolEditor
1.3.0
|
An extension to the KListWidget to view and select Symbols. More...
#include <SymbolListWidget.h>
Public Member Functions | |
SymbolListWidget (QWidget *parent) | |
~SymbolListWidget () | |
void | setIconSize (int size) |
void | loadFromLibrary (SymbolLibrary *library) |
void | addSymbol (qint16 index, const Symbol &symbol) |
void | removeSymbol (qint16 index) |
Static Public Member Functions | |
static QIcon | createIcon (const Symbol &symbol, int size) |
Protected Member Functions | |
virtual QStringList | mimeTypes () const |
virtual Qt::DropActions | supportedDropActions () const |
virtual QMimeData * | mimeData (const QList< QListWidgetItem * > items) const |
virtual bool | dropMimeData (int index, const QMimeData *mimeData, Qt::DropAction action) |
Private Member Functions | |
QListWidgetItem * | createItem (qint16 index) |
void | updateIcons () |
Private Attributes | |
int | m_size |
SymbolLibrary * | m_library |
qint16 | m_lastIndex |
QMap< qint16, QListWidgetItem * > | m_items |
An extension to the KListWidget to view and select Symbols.
This widget is an extension to the KListWidget that can be populated from a SymbolLibrary to display the contained Symbols and allow selection of one of the Symbols for further processing.
Additional Symbols can be added individually and all Symbols will be sorted in the view by their index value.
Symbols can be removed by their index value.
Definition at line 43 of file SymbolListWidget.h.
|
explicit |
Constructor.
Definition at line 46 of file SymbolListWidget.cpp.
SymbolListWidget::~SymbolListWidget | ( | ) |
Destructor.
Definition at line 60 of file SymbolListWidget.cpp.
void SymbolListWidget::addSymbol | ( | qint16 | index, |
const Symbol & | symbol | ||
) |
Add an individual Symbol to the view.
Definition at line 107 of file SymbolListWidget.cpp.
|
static |
Create a QIcon for the supplied Symbol.
symbol | a const reference to a Symbol |
size | a size for the icon |
Definition at line 173 of file SymbolListWidget.cpp.
|
private |
If an item for the index currently exists return it otherwised create an item to be inserted into the KListWidget. The item created has a data entry added representing the index. The items are inserted so that the Symbols are sorted by their index.
index | an index in the SymbolLibrary |
Definition at line 138 of file SymbolListWidget.cpp.
|
protectedvirtual |
Called when KListWidgetItems are dragged from one KListWidget to another.
index | the position index of the dropped item |
mimeData | a pointer to the serialised data from the source |
action | the requested drop action, only copying will be implemented |
true
if the action is handled, false
otherwise Definition at line 250 of file SymbolListWidget.cpp.
void SymbolListWidget::loadFromLibrary | ( | SymbolLibrary * | library | ) |
Populate the KListWidget with the QListWidgetItems for each Symbol in the SymbolLibrary. An icon is created for each Symbol.
library | a pointer to the SymbolLibrary containing the Symbols |
Definition at line 87 of file SymbolListWidget.cpp.
|
protectedvirtual |
Called when dragging items from one KListWidget to another to provide the serialised data.
items | a QList of pointers to the QListWidgetItems to provide data for |
Definition at line 223 of file SymbolListWidget.cpp.
|
protectedvirtual |
Provide a list of mimetypes that this widget provides when dragging from it.
Definition at line 202 of file SymbolListWidget.cpp.
void SymbolListWidget::removeSymbol | ( | qint16 | index | ) |
Remove a symbol item from the view.
index | the index of the item to remove |
Definition at line 119 of file SymbolListWidget.cpp.
void SymbolListWidget::setIconSize | ( | int | size | ) |
Set the size of the icons to be used. The base QListWidget has the icon size and grid size set to this value. If there are existing items in the KListWidget, they are updated with new icons.
size | the size in pixels |
Definition at line 72 of file SymbolListWidget.cpp.
|
protectedvirtual |
Definition at line 210 of file SymbolListWidget.cpp.
|
private |
Generate the icons for all the QListWidgetItems stored in m_items.
Definition at line 266 of file SymbolListWidget.cpp.
|
private |
map of index to QListWidgetItem
Definition at line 71 of file SymbolListWidget.h.
|
private |
the last index in the list
Definition at line 69 of file SymbolListWidget.h.
|
private |
pointer to the library the items belong to
Definition at line 67 of file SymbolListWidget.h.
|
private |
size of icons generated in the view
Definition at line 66 of file SymbolListWidget.h.