Fix crash on logout
[kdenetwork.git] / ksirc / alistbox.h
blobc5bdda2ecd16a1c864ea4682c0150d7aeaf80626
1 #ifndef ALISTBOX_H
2 #define ALISTBOX_H
4 #include <q3listbox.h>
5 //Added by qt3to4:
6 #include <QPixmap>
7 #include <QDragMoveEvent>
8 #include <QDropEvent>
9 #include "ksopts.h"
11 class nickListItem : public Q3ListBoxItem
13 public:
14 nickListItem();
15 nickListItem(const nickListItem &old);
16 virtual ~nickListItem();
18 virtual int height ( const Q3ListBox * ) const;
19 virtual int width ( const Q3ListBox * ) const;
20 QString text () const { return string; }
21 const QPixmap* pixmap () const;
23 bool op() const { return is_op; }
24 bool voice() const { return is_voice; }
25 bool away() const { return is_away; }
26 bool ircOp() const { return is_ircop; }
28 void setOp(bool _op = FALSE);
29 void setVoice(bool _voice = FALSE);
30 void setAway(bool _away = FALSE);
31 void setIrcOp(bool _ircop = FALSE);
33 void setText(const QString &str) { string = str; }
35 QString nickPrefix() const;
37 void forceColour(const QColor *col);
39 nickListItem &operator= ( const nickListItem & nli );
41 protected:
42 virtual void paint ( QPainter * );
44 private:
45 bool is_op:1;
46 bool is_voice:1;
47 bool is_away:1;
48 bool is_ircop:1;
50 QString string;
51 const QColor *forcedCol;
54 class aListBox : public Q3ListBox
56 Q_OBJECT
58 public:
59 aListBox(QWidget *parent = 0, const char *name = 0);
61 virtual ~aListBox();
63 void clear();
65 void inSort ( nickListItem *);
66 void inSort ( QString text, bool top=FALSE);
68 nickListItem *item(int index);
70 bool isTop(int index);
72 int findNick(const QString &str);
74 void clearAdvOps();
76 bool needNickPrefix() const;
78 void setNickListDirty()
79 { m_nickListDirty = true; }
81 unsigned short int nickPrefixWidth() const
82 { return m_nickPrefixWidth; }
84 virtual void fontChange( const QFont &f );
86 static QString nickPrefixOp() { return QString::fromLatin1( "o" ); }
87 static QString nickPrefixVoice() { return QString::fromLatin1( "v" ); }
88 static QString nickPrefixAway() { return QString::fromLatin1( "a" ); }
89 static QString nickPrefixIrcOp() { return QString::fromLatin1( "O" ); }
91 signals:
92 void contextMenuRequested(int index);
93 void selectedNick(const QString&);
94 void urlsDropped( const QStringList& urls, const QString& nick );
95 void textDropped( const Q3ListBoxItem *item, const QString& text );
97 protected:
98 virtual int findSep();
99 virtual int searchFor(const QString &nick, bool &found, bool top);
100 virtual void dragMoveEvent( QDragMoveEvent * );
101 virtual void dropEvent( QDropEvent * );
103 private slots:
104 void reEmitContextMenuRequest( Q3ListBoxItem *item );
106 private:
107 void updateNeedNickPrefixFlag() const;
108 void updateNickPrefixWidth();
110 QPalette p_scroll;
111 mutable bool m_nickListDirty;
112 mutable bool m_needNickPrefix;
113 int m_nickPrefixWidth;
116 #endif