summaryrefslogtreecommitdiffstats
path: root/lib/widgets/qcomboview.h
blob: ecfa8ee29d007c66bd5a96d97f73343441170044 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/**********************************************************************
**
**
** Definition of QComboView class
**
** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
** Copyright (C) 2003 Alexander Dymo <cloudtemple@mksat.net>
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
**********************************************************************/

#ifndef TQCOMBOVIEW_H
#define TQCOMBOVIEW_H

#include "tqwidget.h"

#ifndef TQT_NO_COMBOBOX

/**
@file qcomboview.h
QComboView class.
*/

class TQStrList;
class TQStringList;
class TQLineEdit;
class TQValidator;
class TQListView;
class TQListViewItem;
class QComboViewData;

/**
QComboView - a combo with a TQListView as a popup widget.
This means that you can have a treeview inside of a combo. Otherwise it works
in the same way as TQComboBox and have similar API.
*/
class TQ_EXPORT QComboView : public TQWidget
{
    Q_OBJECT
  TQ_OBJECT
    Q_ENUMS( Policy )
    TQ_PROPERTY( bool editable READ editable WRITE setEditable )
//    TQ_PROPERTY( int count READ count )
    TQ_PROPERTY( TQString currentText READ currentText WRITE setCurrentText DESIGNABLE false )
//    TQ_PROPERTY( TQListView *currentItem READ currentItem WRITE setCurrentItem )
    TQ_PROPERTY( bool autoResize READ autoResize WRITE setAutoResize DESIGNABLE false )
    TQ_PROPERTY( int sizeLimit READ sizeLimit WRITE setSizeLimit )
//    TQ_PROPERTY( int maxCount READ maxCount WRITE setMaxCount )
    TQ_PROPERTY( Policy insertionPolicy READ insertionPolicy WRITE setInsertionPolicy )
    TQ_PROPERTY( bool autoCompletion READ autoCompletion WRITE setAutoCompletion )
    TQ_PROPERTY( bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled )
    TQ_OVERRIDE( bool autoMask DESIGNABLE true SCRIPTABLE true )

public:
//    QComboView( TQWidget* parent=0, const char* name=0 );
    QComboView( bool rw, TQWidget* parent=0, const char* name=0 );
    ~QComboView();

    int childCount() const;

    TQListViewItem *currentItem() const;
    virtual void setCurrentItem( TQListViewItem * );
    virtual void setCurrentActiveItem( TQListViewItem * );

    bool	autoResize()	const;
    virtual void setAutoResize( bool );
    TQSize	tqsizeHint() const;

    void	setPalette( const TQPalette & );
    void	setFont( const TQFont & );
    void	setEnabled( bool );

    virtual void setSizeLimit( int );
    int		sizeLimit() const;

/*    virtual void setMaxCount( int );
    int		maxCount() const;*/

    enum Policy { NoInsertion, AtTop, AtCurrent, AtBottom,
		  AfterCurrent, BeforeCurrent };

    virtual void setInsertionPolicy( Policy policy );
    Policy	insertionPolicy() const;

    virtual void setValidator( const TQValidator * );
    const TQValidator * validator() const;

    virtual void setListView( TQListView * );
    TQListView *	listView() const;

    virtual void setLineEdit( TQLineEdit *edit );
    TQLineEdit*	lineEdit() const;

    virtual void setAutoCompletion( bool );
    bool	autoCompletion() const;

    bool	eventFilter( TQObject *object, TQEvent *event );

    void	setDuplicatesEnabled( bool enable );
    bool	duplicatesEnabled() const;

    bool	editable() const;
    void	setEditable( bool );

    virtual void popup();

    TQString currentText() const;
    void setCurrentText( const TQString& );

public slots:
    virtual void clear();
    void	clearValidator();
    void	clearEdit();
    virtual void setEditText( const TQString &);

signals:
    void	activated( TQListViewItem * item );
    void	highlighted( TQListViewItem * item );
    void	activated( const TQString &);
    void	highlighted( const TQString &);
    void	textChanged( const TQString &);
    void    focusGranted();
    void    focusLost();

private slots:
    void	internalActivate( TQListViewItem * );
    void	internalHighlight( TQListViewItem * );
    void	internalClickTimeout();
    void	returnPressed();
    void checkState(TQListViewItem*);

protected:
    void	paintEvent( TQPaintEvent * );
    void	resizeEvent( TQResizeEvent * );
    void	mousePressEvent( TQMouseEvent * );
    void	mouseMoveEvent( TQMouseEvent * );
    void	mouseReleaseEvent( TQMouseEvent * );
    void	mouseDoubleClickEvent( TQMouseEvent * );
    void	keyPressEvent( TQKeyEvent *e );
    void	focusInEvent( TQFocusEvent *e );
    void	focusOutEvent( TQFocusEvent *e );
    void	wheelEvent( TQWheelEvent *e );
    void	styleChange( TQStyle& );

    void	updateMask();

private:
    virtual void setUpListView();
    void	setUpLineEdit();
    void	popDownListView();
    void	reIndex();
    void	currentChanged();
    TQListViewItem *completionIndex( const TQString &, TQListViewItem * ) const;

    QComboViewData	*d;

private:	// Disabled copy constructor and operator=
#if defined(TQ_DISABLE_COPY)
    QComboView( const QComboView & );
    QComboView &operator=( const QComboView & );
#endif
};


#endif // TQT_NO_COMBOBOX

#endif // TQCOMBOVIEW_H