X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Finputline.h;h=6bbfee2fbfa980e511915204a168ac54e8a1077b;hp=936e1bda99c0807f982f237d4d90149b269075f2;hb=e049ffc61b5e260a49d73102a74c3821af827e77;hpb=fa6d3f8fad021a2a6f6d6228987c85997532e683 diff --git a/src/uisupport/inputline.h b/src/uisupport/inputline.h index 936e1bda..6bbfee2f 100644 --- a/src/uisupport/inputline.h +++ b/src/uisupport/inputline.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,42 +18,75 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _INPUTLINE_H_ -#define _INPUTLINE_H_ +#ifndef INPUTLINE_H_ +#define INPUTLINE_H_ -#include +#include +#include +#include + +#ifdef HAVE_KDE +#include +#endif class TabCompleter; -class InputLine : public QLineEdit { +class InputLine : public +#ifdef HAVE_KDE + KTextEdit +#else + QTextEdit +#endif +{ Q_OBJECT - public: - InputLine(QWidget *parent = 0); - ~InputLine(); - - protected: - virtual bool event(QEvent *); - virtual void keyPressEvent(QKeyEvent * event); - - private slots: - void enter(); - - public slots: - void updateNickList(QStringList); - - signals: - void nickListUpdated(QStringList); - - private: - qint32 idx; - QStringList history; - QStringList nickList; - - TabCompleter *tabComplete; - - int bindModifier; - int jumpModifier; +public: + InputLine(QWidget *parent = 0); + ~InputLine(); + + void setCustomFont(const QFont &); // should be used instead setFont(), so we can set our size correctly + + // Compatibility methods with the rest of the classes which still expect this to be a QLineEdit + inline QString text() { return toPlainText(); } + inline int cursorPosition() { return textCursor().position(); } + inline void insert(const QString &newText) { insertPlainText(newText); } + inline void backspace() { keyPressEvent(new QKeyEvent(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier)); } + inline bool hasSelectedText() { return textCursor().hasSelection(); } + + virtual QSize sizeHint() const; + virtual QSize minimumSizeHint() const; + +protected: + virtual void keyPressEvent(QKeyEvent * event); + virtual bool eventFilter(QObject *watched, QEvent *event); + +private slots: + void on_returnPressed(); + void on_textChanged(QString newText); + + // Needed to emulate the signal that QLineEdit has + inline void on_textChanged() { emit textChanged(toPlainText()); }; + + bool addToHistory(const QString &text, bool temporary = false); + +signals: + void sendText(QString text); + + // QTextEdit does not provide this signal, so we manually emit it in keyPressEvent() + void returnPressed(); + void textChanged(QString newText); + +private: + QStringList history; + QHash tempHistory; + qint32 idx; + TabCompleter *tabCompleter; + + int bindModifier; + int jumpModifier; + + void resetLine(); + void showHistoryEntry(); }; #endif