_selectionModel(0)
{
ui.setupUi(this);
- connect(ui.inputEdit, SIGNAL(returnPressed()), this, SLOT(enterPressed()));
+ connect(ui.inputEdit, SIGNAL(sendText(QString)), this, SLOT(sendText(QString)));
connect(ui.ownNick, SIGNAL(activated(QString)), this, SLOT(changeNick(QString)));
connect(this, SIGNAL(userInput(BufferInfo, QString)), Client::instance(), SIGNAL(sendInput(BufferInfo, QString)));
setFocusProxy(ui.inputEdit);
emit userInput(currentBufferInfo, QString("/nick %1").arg(newNick));
}
-void InputWidget::enterPressed() {
- QStringList lines = ui.inputEdit->text().split('\n', QString::SkipEmptyParts);
- foreach(QString msg, lines) {
- if(msg.isEmpty()) continue;
- emit userInput(currentBufferInfo, msg);
- }
- ui.inputEdit->clear();
+void InputWidget::sendText(QString text) {
+ emit userInput(currentBufferInfo, text);
}
-
// virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
private slots:
- void enterPressed();
+ void sendText(QString text);
void changeNick(const QString &newNick) const;
void setNetwork(const Network *network);
InputLine::InputLine(QWidget *parent)
: QLineEdit(parent),
- idx(0)
+ idx(0),
+ tabCompleter(new TabCompleter(this))
{
- connect(this, SIGNAL(returnPressed()), this, SLOT(enter()));
- tabComplete = new TabCompleter(this);
-
+
#ifdef Q_WS_MAC
bindModifier = Qt::ControlModifier | Qt::AltModifier;
jumpModifier = Qt::ControlModifier;
bindModifier = Qt::ControlModifier;
jumpModifier = Qt::AltModifier;
#endif
+
+ connect(this, SIGNAL(returnPressed()), this, SLOT(on_returnPressed()));
+ connect(this, SIGNAL(textChanged(QString)), this, SLOT(on_textChanged(QString)));
+
}
InputLine::~InputLine() {
}
if(event->key() == Qt::Key_Tab) { // Tabcomplete
- tabComplete->complete();
+ tabCompleter->complete();
event->accept();
} else {
- tabComplete->reset();
+ tabCompleter->reset();
if(event->key() == Qt::Key_Up) {
if(idx > 0) { idx--; setText(history[idx]); }
event->accept();
}
}
-bool InputLine::event(QEvent *e) {
- if(e->type() == QEvent::KeyPress) {
- keyPressEvent(static_cast<QKeyEvent*>(e));
- return true;
- }
- return QLineEdit::event(e);
-}
-
-void InputLine::enter() {
+void InputLine::on_returnPressed() {
history << text();
idx = history.count();
+ emit sendText(text());
+ clear();
}
-void InputLine::updateNickList(QStringList l) {
- nickList = l;
- emit nickListUpdated(l);
+void InputLine::on_textChanged(QString newText) {
+ if(newText.contains('\n')) {
+ clear();
+ QString line = newText.section('\n', 0, 0);
+ QString remainder = newText.section('\n', 1);
+ insert(line);
+ emit returnPressed();
+ insert(remainder);
+ }
}
class InputLine : public QLineEdit {
Q_OBJECT
- public:
- InputLine(QWidget *parent = 0);
- ~InputLine();
+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;
+protected:
+ // virtual bool event(QEvent *);
+ virtual void keyPressEvent(QKeyEvent * event);
+
+private slots:
+ void on_returnPressed();
+ void on_textChanged(QString newText);
+
+signals:
+ void sendText(QString text);
+
+private:
+ QStringList history;
+ qint32 idx;
+ TabCompleter *tabCompleter;
+
+ int bindModifier;
+ int jumpModifier;
};
#endif
{ using namespace Global;
quasselVersion = "0.2.0-pre";
- quasselDate = "2008-02-05";
- quasselBuild = 469;
+ quasselDate = "2008-02-06";
+ quasselBuild = 472;
//! Minimum client build number the core needs
clientBuildNeeded = 464;