krita

squeezedcombobox.h

Go to the documentation of this file.
00001 /* ============================================================
00002  * Author: Tom Albers <tomalbers@kde.nl>
00003  * Date  : 2005-01-01
00004  * Description : 
00005  * 
00006  * Copyright 2005 by Tom Albers
00007  *
00008  * This program is free software; you can redistribute it
00009  * and/or modify it under the terms of the GNU General
00010  * Public License as published by the Free Software Foundation;
00011  * either version 2, or (at your option)
00012  * any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * 
00019  * ============================================================ */
00020 
00023 #ifndef SQUEEZEDCOMBOBOX_H
00024 #define SQUEEZEDCOMBOBOX_H
00025 
00026 class QTimer;
00027 
00028 // Qt includes.
00029 
00030 #include <qcombobox.h>
00031 #include <qtooltip.h>
00032 
00033 class SqueezedComboBox;
00034 
00044 class SqueezedComboBoxTip : public QToolTip
00045 {
00046 public:
00057     SqueezedComboBoxTip( QWidget *parent, SqueezedComboBox *name );
00058 
00059 protected:
00065     void maybeTip( const QPoint& pos );
00066 
00067 private:
00068     SqueezedComboBox*        m_originalWidget;
00069 };
00070 
00082 class SqueezedComboBox : public QComboBox
00083 {
00084     Q_OBJECT
00085 
00086 public:
00092     SqueezedComboBox(QWidget *parent = 0, const char *name = 0 );
00093 
00097     virtual ~SqueezedComboBox();
00098 
00099     bool contains(const QString & text) const;
00100 
00109     void insertSqueezedItem(const QString& newItem, int index);
00110 
00116     QString itemHighlighted( );
00117 
00121     virtual QSize sizeHint() const;
00122 
00123 private slots:
00124     void slotTimeOut();
00125     void slotUpdateToolTip( int index );
00126 
00127 private:
00128     void resizeEvent ( QResizeEvent * );
00129     QString squeezeText( const QString& original);
00130 
00131     QMap<int,QString>   m_originalItems;
00132     QTimer*             m_timer;
00133     SqueezedComboBoxTip*      m_tooltip;
00134 };
00135 
00136 #endif // SQUEEZEDCOMBOBOX_H
KDE Home | KDE Accessibility Home | Description of Access Keys