Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / konqueror / src / konqcombo.h
blob513cce1932b6f3d02168d1912e7d82ea6ffc10a1
1 /* This file is part of the KDE project
2 Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef KONQ_COMBO_H
21 #define KONQ_COMBO_H
23 #include <khistorycombobox.h>
25 class QEvent;
26 class QKeyEvent;
27 class QPixmap;
28 class KCompletion;
29 class KConfig;
31 // we use KHistoryCombo _only_ for the up/down keyboard handling, otherwise
32 // KComboBox would do fine.
33 class KonqCombo : public KHistoryComboBox
35 Q_OBJECT
37 public:
38 explicit KonqCombo( QWidget *parent );
39 ~KonqCombo();
41 // initializes with the completion object and calls loadItems()
42 void init( KCompletion * );
44 // determines internally if it's temporary or final
45 void setURL( const QString& url );
47 void setTemporary( const QString& );
48 void setTemporary( const QString&, const QPixmap& );
49 void clearTemporary( bool makeCurrent = true );
50 void removeURL( const QString& url );
52 void insertPermanent( const QString& );
54 void updatePixmaps();
56 void loadItems();
57 void saveItems();
59 static void setConfig( KConfig * );
61 virtual void popup();
63 void setPageSecurity( int );
65 void insertItem( const QString &text, int index=-1, const QString& title=QString() );
66 void insertItem( const QPixmap &pixmap, const QString &text, int index=-1, const QString& title=QString() );
68 protected:
69 virtual void keyPressEvent( QKeyEvent * );
70 virtual bool eventFilter( QObject *, QEvent * );
71 virtual void mousePressEvent( QMouseEvent * );
72 virtual void mouseMoveEvent( QMouseEvent * );
73 void paintEvent( QPaintEvent * );
74 void selectWord(QKeyEvent *e);
76 Q_SIGNALS:
77 /**
78 Specialized signal that emits the state of the modifier
79 keys along with the actual activated text.
81 void activated( const QString &, int );
83 /**
84 User has clicked on the security lock in the combobar
86 void showPageSecurity();
88 private Q_SLOTS:
89 void slotCleared();
90 void slotSetIcon( int index );
91 void slotActivated( const QString& text );
93 private:
94 void updateItem( const QPixmap& pix, const QString&, int index, const QString& title );
95 void saveState();
96 void restoreState();
97 void applyPermanent();
98 QString temporaryItem() const { return itemText( temporary ); }
99 void removeDuplicates( int index );
100 bool hasSufficientContrast(const QColor &c1, const QColor &c2);
102 bool m_returnPressed;
103 bool m_permanent;
104 int m_cursorPos;
105 int m_currentIndex;
106 int m_modifier;
107 QString m_currentText;
108 QPoint m_dragStart;
109 int m_pageSecurity;
111 void getStyleOption(QStyleOptionComboBox* combo);
113 static KConfig *s_config;
114 static const int temporary; // the index of our temporary item
117 #endif // KONQ_COMBO_H