[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenetwork/ksirc
From:       Andrew Standley-Jones <asj () cban ! com>
Date:       2002-12-12 2:51:24
[Download RAW message or body]

CVS commit by asj: 

Updated text edit to allow more than 255 characters, and splits it up 
nicely for the irc server


  M +37 -7     ahistlineedit.cpp   1.44
  M +4 -0      ahistlineedit.h   1.20
  M +9 -11     toplevel.cpp   1.241


--- kdenetwork/ksirc/ahistlineedit.cpp  #1.43:1.44
@@ -48,4 +48,6 @@
 #include <qapplication.h>
 #include <qclipboard.h>
+#include <qpen.h>
+#include <qpainter.h>
 #include <kdebug.h>
 
@@ -53,4 +55,6 @@ aHistLineEdit::aHistLineEdit(QWidget *pa
   : QTextEdit(parent, name)
 {
+
+    m_drawrect = true;
     current = hist.append(QString::null); // Set the current as blank
     setWrapPolicy(QTextEdit::AtWordOrDocumentBoundary);
@@ -66,4 +70,6 @@ aHistLineEdit::aHistLineEdit(QWidget *pa
     slotMaybeResize(); // setup initial size.
 
+    setLineWidth(2);
+
 }
 
@@ -82,15 +88,22 @@ int aHistLineEdit::cursorPosition() cons
 void aHistLineEdit::slotMaybeResize()
 {
+/*
     if(QTextEdit::text().contains("\n")){
         setText(text());
         setCursorPosition(text().length());
     }
+*/
 
     if(text().length() > 255){
-        int p = cursorPosition();
-        QString s = text();
-        s.truncate(255);
-        setText(s);
-        setCursorPosition(p);
+        if(m_drawrect == false){
+            m_drawrect = true;
+            repaint();
+        }
+    }
+    else {
+        if(m_drawrect == true){
+            m_drawrect = false;
+            repaint();
+        }
     }
 
@@ -325,4 +338,21 @@ void aHistLineEdit::paste()
 {
     /* we ignore this, let the top level take it */
+}
+
+void aHistLineEdit::paintEvent ( QPaintEvent *p )
+{
+    QTextEdit::paintEvent(p);
+
+    if(m_drawrect == true){
+        QPainter paint(this);
+        QPen pen = paint.pen();
+        pen.setWidth(5);
+        pen.setStyle(Qt::SolidLine);
+        pen.setColor(palette().active().highlight());
+        paint.setPen(pen);
+        QRect r = frameRect();
+        paint.drawRect(r);
+    }
+
 }
 

--- kdenetwork/ksirc/ahistlineedit.h  #1.19:1.20
@@ -39,4 +39,6 @@ protected:
   virtual bool eventFilter( QObject *o, QEvent *e );
 
+  virtual void paintEvent ( QPaintEvent * );
+
 private:
   QStringList hist;
@@ -44,4 +46,6 @@ private:
   void ColourPickerPopUp();
   int m_height;
+
+  bool m_drawrect;
 
 };

--- kdenetwork/ksirc/toplevel.cpp  #1.240:1.241
@@ -866,14 +866,12 @@ bool KSircTopLevel::parse_input(const QS
 void KSircTopLevel::returnPressed()
 {
+    uint len;
   QString s = linee->text();
-//  if ( s.startsWith( "/j " ) || s.startsWith( "/join " ) ) {
-//    s.remove( 0, s.find( "#" ) );
-//    QStringList fragments = QStringList::split( ",", s );
-//    QStringList::ConstIterator it = fragments.begin();
-//    QStringList::ConstIterator end = fragments.end();
-//    for ( ; it != end; ++it )
-//      sirc_line_return( "/join " + *it );
-//  } else
-  sirc_line_return( s );
+
+    for(len = 0; len < s.length(); ){
+        int l = s.length() > 255 ? 255 : s.length();
+        sirc_line_return( s.mid(len, l) );
+        len += l;
+    }
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic