[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfenumlistwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfenumlistwidget.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfenumlistwidget.h 667 2011-07-24 15:44:22Z phfaist $ */
23 
24 
25 #ifndef KLF_ENUMLISTWIDGET_H
26 #define KLF_ENUMLISTWIDGET_H
27 
28 #include <QWidget>
29 #include <QLabel>
30 
31 #include <klfdefs.h>
32 
33 
34 class KLF_EXPORT KLFEnumListWidget : public QLabel
35 {
36  Q_OBJECT
37 public:
38  KLFEnumListWidget(QWidget *parent);
39  virtual ~KLFEnumListWidget();
40 
41  inline int itemCount() const { return pItems.size(); }
42 
43  QString itemAt(int i) const;
44  QVariant itemDataAt(int i) const;
45 
46  QStringList itemList() const;
47  QVariantList itemDataList() const;
48 
49 signals:
50  void itemActivated(const QString& s, const QVariant& data);
51  void itemActivated(int i, const QString& s, const QVariant& data);
52 
53 public slots:
54  void addItem(const QString& s, const QVariant& data = QVariant()) { insertItem(-1, s, data); }
55 
56  void removeItem(int i);
57  void insertItem(int i, const QString& s, const QVariant& data = QVariant()) ;
58 
59  void setItems(const QStringList& slist, const QVariantList& datalist = QVariantList());
60 
61 protected:
62  virtual void updateLabelText();
63 
64  struct Item {
65  Item(const QString& s_ = QString(), const QVariant& d_ = QVariant()) : s(s_), data(d_) { }
68  };
69 
71 
72 private slots:
73 
74  void labelActionLink(const QString& link);
75 
76 private:
77  inline int simple_wrapped_item_index(int i) const { return (i >= 0) ? i : pItems.size() + i; }
78 };
79 
80 
81 
82 
83 
84 #endif
Item(const QString &s_=QString(), const QVariant &d_=QVariant())
Base declarations for klatexformula and some utilities.
int size() const
void addItem(const QString &s, const QVariant &data=QVariant())
#define KLF_EXPORT
Definition: klfdefs.h:41
QList< Item > pItems

Generated by doxygen 1.8.13