File indexing completed on 2024-06-16 07:42:24

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef _K3B_CUT_COMBOBOX_H_
0007 #define _K3B_CUT_COMBOBOX_H_
0008 
0009 #include "k3b_export.h"
0010 #include <KComboBox>
0011 #include <QPixmap>
0012 #include <QResizeEvent>
0013 class QResizeEvent;
0014 
0015 
0016 namespace K3b {
0017     /**
0018      * Cuts it's text.
0019      * Since it rebuilds the complete list of strings every time
0020      * a new string is added or one gets removed it is not a good
0021      * idea to use this for dynamic lists.
0022      *
0023      * Be aware that currently only insertItem works.
0024      * none of the insertStrList or insertStringList methods are implemented
0025      * yet and also the removeItem methods does not work.
0026      */
0027     class LIBK3B_EXPORT CutComboBox : public KComboBox
0028     {
0029         Q_OBJECT
0030 
0031     public:
0032         explicit CutComboBox( QWidget* parent = 0 );
0033         explicit CutComboBox( int method, QWidget* parent = 0 );
0034         virtual ~CutComboBox();
0035 
0036         enum Method {
0037             CUT,
0038             SQUEEZE
0039         };
0040 
0041         /**
0042          * The method to shorten the text
0043          * default: CUT
0044          */
0045         void setMethod( int );
0046 
0047         /** reimplemented */
0048         QSize sizeHint() const;
0049 
0050         /** reimplemented */
0051         QSize minimumSizeHint() const;
0052 
0053         /** reimplemented */
0054         virtual void setCurrentText( const QString& );
0055 
0056         void    insertStringList( const QStringList &, int index=-1 );
0057         void    insertStrList( const char **, int numStrings=-1, int index=-1);
0058 
0059         void    insertItem( const QString &text, int index=-1 );
0060         void    insertItem( const QPixmap &pixmap, int index=-1 );
0061         void    insertItem( const QPixmap &pixmap, const QString &text, int index=-1 );
0062 
0063         void    removeItem( int index );
0064 
0065         void    changeItem( const QString &text, int index );
0066         void    changeItem( const QPixmap &pixmap, const QString &text, int index );
0067 
0068         QString text( int ) const;
0069         QString currentText() const;
0070 
0071         void clear();
0072 
0073     protected:
0074         void resizeEvent( QResizeEvent* e );
0075         void cutText();
0076 
0077     private:
0078         class Private;
0079         Private* d;
0080     };
0081 }
0082 
0083 #endif