pasting multiple lines at once into the InputLine is now treated correctly
authorMarcus Eggenberger <egs@quassel-irc.org>
Wed, 6 Feb 2008 12:22:18 +0000 (12:22 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Wed, 6 Feb 2008 12:22:18 +0000 (12:22 +0000)
src/qtui/inputwidget.cpp
src/qtui/inputwidget.h
src/uisupport/inputline.cpp
src/uisupport/inputline.h
version.inc

index e329b04..5f31670 100644 (file)
@@ -30,7 +30,7 @@ InputWidget::InputWidget(QWidget *parent)
     _selectionModel(0)
 {
   ui.setupUi(this);
     _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);
   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);
@@ -144,12 +144,6 @@ void InputWidget::changeNick(const QString &newNick) const {
   emit userInput(currentBufferInfo, QString("/nick %1").arg(newNick));
 }
 
   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);
 }
 }
-
index 697f654..485ac67 100644 (file)
@@ -56,7 +56,7 @@ protected slots:
 //   virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
 
 private slots:
 //   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);
   void changeNick(const QString &newNick) const;
 
   void setNetwork(const Network *network);
index 05f9755..7d863fe 100644 (file)
 
 InputLine::InputLine(QWidget *parent)
   : QLineEdit(parent),
 
 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;
 #ifdef Q_WS_MAC
   bindModifier = Qt::ControlModifier | Qt::AltModifier;
   jumpModifier = Qt::ControlModifier;
@@ -36,6 +35,10 @@ InputLine::InputLine(QWidget *parent)
   bindModifier = Qt::ControlModifier;
   jumpModifier = Qt::AltModifier;
 #endif
   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() {
 }
 
 InputLine::~InputLine() {
@@ -49,10 +52,10 @@ void InputLine::keyPressEvent(QKeyEvent * event) {
   }
   
   if(event->key() == Qt::Key_Tab) { // Tabcomplete
   }
   
   if(event->key() == Qt::Key_Tab) { // Tabcomplete
-    tabComplete->complete();
+    tabCompleter->complete();
     event->accept();
   } else {
     event->accept();
   } else {
-    tabComplete->reset();
+    tabCompleter->reset();
     if(event->key() == Qt::Key_Up) {
       if(idx > 0) { idx--; setText(history[idx]); }
       event->accept();
     if(event->key() == Qt::Key_Up) {
       if(idx > 0) { idx--; setText(history[idx]); }
       event->accept();
@@ -70,20 +73,20 @@ void InputLine::keyPressEvent(QKeyEvent * event) {
   }
 }
 
   }
 }
 
-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();
   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);
+  }
 }
 }
index 936e1bd..3294be1 100644 (file)
@@ -28,32 +28,28 @@ class TabCompleter;
 class InputLine : public QLineEdit {
   Q_OBJECT
 
 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
 };
 
 #endif
index b2db73c..533e953 100644 (file)
@@ -4,8 +4,8 @@
 { using namespace Global;
 
   quasselVersion = "0.2.0-pre";
 { 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;
 
   //! Minimum client build number the core needs
   clientBuildNeeded = 464;