SymbolEditor  1.3.0
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
SymbolListWidget Class Reference

An extension to the KListWidget to view and select Symbols. More...

#include <SymbolListWidget.h>

Inheritance diagram for SymbolListWidget:
Collaboration diagram for SymbolListWidget:

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
 
SymbolLibrarym_library
 
qint16 m_lastIndex
 
QMap< qint16, QListWidgetItem * > m_items
 

Detailed Description

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.

Constructor & Destructor Documentation

SymbolListWidget::SymbolListWidget ( QWidget *  parent)
explicit

Constructor.

Definition at line 46 of file SymbolListWidget.cpp.

Here is the call graph for this function:

SymbolListWidget::~SymbolListWidget ( )

Destructor.

Definition at line 60 of file SymbolListWidget.cpp.

Member Function Documentation

void SymbolListWidget::addSymbol ( qint16  index,
const Symbol symbol 
)

Add an individual Symbol to the view.

Parameters
indexthe index of the Symbol
symbola const reference to the Symbol to add

Definition at line 107 of file SymbolListWidget.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QIcon SymbolListWidget::createIcon ( const Symbol symbol,
int  size 
)
static

Create a QIcon for the supplied Symbol.

Parameters
symbola const reference to a Symbol
sizea size for the icon
Returns
a QIcon

Definition at line 173 of file SymbolListWidget.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QListWidgetItem * SymbolListWidget::createItem ( qint16  index)
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.

Parameters
indexan index in the SymbolLibrary
Returns
a pointer to the QListWidgetItem created

Definition at line 138 of file SymbolListWidget.cpp.

Here is the caller graph for this function:

bool SymbolListWidget::dropMimeData ( int  index,
const QMimeData *  mimeData,
Qt::DropAction  action 
)
protectedvirtual

Called when KListWidgetItems are dragged from one KListWidget to another.

Parameters
indexthe position index of the dropped item
mimeDataa pointer to the serialised data from the source
actionthe requested drop action, only copying will be implemented
Returns
true if the action is handled, false otherwise

Definition at line 250 of file SymbolListWidget.cpp.

Here is the call graph for this function:

void SymbolListWidget::loadFromLibrary ( SymbolLibrary library)

Populate the KListWidget with the QListWidgetItems for each Symbol in the SymbolLibrary. An icon is created for each Symbol.

Parameters
librarya pointer to the SymbolLibrary containing the Symbols

Definition at line 87 of file SymbolListWidget.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QMimeData * SymbolListWidget::mimeData ( const QList< QListWidgetItem * >  items) const
protectedvirtual

Called when dragging items from one KListWidget to another to provide the serialised data.

Parameters
itemsa QList of pointers to the QListWidgetItems to provide data for
Returns
a pointer to the QMimeData created

Definition at line 223 of file SymbolListWidget.cpp.

Here is the call graph for this function:

QStringList SymbolListWidget::mimeTypes ( ) const
protectedvirtual

Provide a list of mimetypes that this widget provides when dragging from it.

Returns
a QStringList containing the mimetype strings

Definition at line 202 of file SymbolListWidget.cpp.

void SymbolListWidget::removeSymbol ( qint16  index)

Remove a symbol item from the view.

Parameters
indexthe index of the item to remove

Definition at line 119 of file SymbolListWidget.cpp.

Here is the caller graph for this function:

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.

Parameters
sizethe size in pixels

Definition at line 72 of file SymbolListWidget.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Qt::DropActions SymbolListWidget::supportedDropActions ( ) const
protectedvirtual

Definition at line 210 of file SymbolListWidget.cpp.

void SymbolListWidget::updateIcons ( )
private

Generate the icons for all the QListWidgetItems stored in m_items.

Definition at line 266 of file SymbolListWidget.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

QMap<qint16, QListWidgetItem*> SymbolListWidget::m_items
private

map of index to QListWidgetItem

Definition at line 71 of file SymbolListWidget.h.

qint16 SymbolListWidget::m_lastIndex
private

the last index in the list

Definition at line 69 of file SymbolListWidget.h.

SymbolLibrary* SymbolListWidget::m_library
private

pointer to the library the items belong to

Definition at line 67 of file SymbolListWidget.h.

int SymbolListWidget::m_size
private

size of icons generated in the view

Definition at line 66 of file SymbolListWidget.h.


The documentation for this class was generated from the following files: