1 //=========================================================
2 //  MusE
3 //  Linux Music Editor
4 //    $Id: lcombo.h,v 1.1.1.1.2.3 2009/07/01 22:14:56 spamatica Exp $
5 //  (C) Copyright 2000 Werner Schweer (ws@seh.de)
6 //
7 //  This program is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU General Public License
9 //  as published by the Free Software Foundation; version 2 of
10 //  the License, or (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 Free Software
19 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 //=========================================================
22 
23 #ifndef __LCOMBO_H__
24 #define __LCOMBO_H__
25 
26 #include <QWidget>
27 #include <QComboBox>
28 #include <QVariant>
29 
30 class QAbstractItemView;
31 class QString;
32 class QModelIndex;
33 
34 namespace MusEGui {
35 
36 //---------------------------------------------------------
37 //   LabelCombo
38 //---------------------------------------------------------
39 
40 class LabelCombo : public QWidget {
41       Q_OBJECT
42       QComboBox* box;
43 
44 
45    signals:
46       void activated(int);
47       void activated(const QModelIndex&);
48 
49    private slots:
50       void box_activated(int idx);
51 
52    public slots:
53       void clearFocus();
54       void setCurrentIndex(int i);
55       void setCurrentModelIndex(const QModelIndex& mdl_idx);
56 
57    public:
58       LabelCombo(const QString& label, QWidget* parent,
59          const char* name=0);
60       void addItem(const QString& txt, const QVariant & userData = QVariant());
61       void insertItem(int index, const QString& txt, const QVariant & userData = QVariant());
62 
63       QAbstractItemView *view() const;
64 
65       void setView(QAbstractItemView* v);
66       void setFocusPolicy ( Qt::FocusPolicy fp );
67 
68       QVariant itemData(int index, int role = Qt::UserRole) const;
69       int findData(
70         const QVariant &data, int role = Qt::UserRole,
71         Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const;
72       int maxVisibleItems() const;
73       void setMaxVisibleItems(int maxItems);
74       QComboBox::SizeAdjustPolicy sizeAdjustPolicy() const;
75       void setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy policy);
76 
77       int currentIndex() const;
78       QModelIndex currentModelIndex() const;
79       };
80 
81 } // namespace MusEGui
82 
83 #endif
84