SymbolEditor  1.3.0
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
SymbolListWidget.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2012 by Stephen Allewell *
3  * sallewell@users.sourceforge.net *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  ********************************************************************************/
10 
11 
18 #ifndef SymbolListWidget_H
19 #define SymbolListWidget_H
20 
21 
22 #include <KListWidget>
23 
24 
25 class QMimeData;
26 
27 class SymbolLibrary;
28 class Symbol;
29 
30 
43 class SymbolListWidget : public KListWidget
44 {
45 public:
46  explicit SymbolListWidget(QWidget *parent);
48 
49  void setIconSize(int size);
50  void loadFromLibrary(SymbolLibrary *library);
51  void addSymbol(qint16 index, const Symbol &symbol);
52  void removeSymbol(qint16 index);
53 
54  static QIcon createIcon(const Symbol &symbol, int size);
55 
56 protected:
57  virtual QStringList mimeTypes() const;
58  virtual Qt::DropActions supportedDropActions() const;
59  virtual QMimeData *mimeData(const QList<QListWidgetItem *> items) const;
60  virtual bool dropMimeData(int index, const QMimeData *mimeData, Qt::DropAction action);
61 
62 private:
63  QListWidgetItem *createItem(qint16 index);
64  void updateIcons();
65 
66  int m_size;
69  qint16 m_lastIndex;
71  QMap<qint16, QListWidgetItem*> m_items;
72 };
73 
74 
75 #endif