Source Code (Use browser search to find items of interest.)

Class Index

krn'KMLineEdit (./kdenetwork/krn/kmcomposewin.h:85)

class KMLineEdit : public QLineEdit
{
  Q_OBJECT

public:
  KMLineEdit(KMComposeWin* composer = NULL, QWidget *parent = NULL, 
	     const char *name = NULL);
  virtual ~KMLineEdit();

  /** Set cursor to end of line. */
  virtual void cursorAtEnd();

signals:
  /** Emitted when Ctrl-. (period) is pressed. */
  void completion();

public slots:
  virtual void copy();
  virtual void cut();
  virtual void paste();
  virtual void markAll();
  virtual void slotCompletion();

protected:
  virtual bool eventFilter(QObject*, QEvent*);
  KMComposeWin* mComposer;
protected:
};


//-----------------------------------------------------------------------------

krn'KMLineEdit::KMLineEdit() (./kdenetwork/krn/kmcomposewin.cpp:1798)

KMLineEdit::KMLineEdit(KMComposeWin* composer, QWidget *parent, 
		       const char *name): KMLineEditInherited(parent,name)
{
  mComposer = composer;

  installEventFilter(this);
  
  connect (this, SIGNAL(completion()), this, SLOT(slotCompletion()));
}


//-----------------------------------------------------------------------------

krn'KMLineEdit::~KMLineEdit() (./kdenetwork/krn/kmcomposewin.cpp:1810)

KMLineEdit::~KMLineEdit()
{
  removeEventFilter(this);
}


//-----------------------------------------------------------------------------

krn'KMLineEdit::eventFilter() (./kdenetwork/krn/kmcomposewin.cpp:1817)

bool KMLineEdit::eventFilter(QObject*, QEvent* e)
{

krn'KMLineEdit::cursorAtEnd() (./kdenetwork/krn/kmcomposewin.cpp:1889)

void KMLineEdit::cursorAtEnd()
{
  QKeyEvent ev( QEvent::KeyPress, Key_End, 0, 0 );
  QLineEdit::keyPressEvent( &ev );
}


//-----------------------------------------------------------------------------

krn'KMLineEdit::copy() (./kdenetwork/krn/kmcomposewin.cpp:1897)

void KMLineEdit::copy()
{
  QString t = markedText();
  QApplication::clipboard()->setText(t);
}

//-----------------------------------------------------------------------------

krn'KMLineEdit::cut() (./kdenetwork/krn/kmcomposewin.cpp:1904)

void KMLineEdit::cut()
{
  if(hasMarkedText())
  {
    QString t = markedText();
    QKeyEvent k(QEvent::KeyPress, Key_D, 0, ControlButton);
    keyPressEvent(&k);
    QApplication::clipboard()->setText(t);
  }
}

//-----------------------------------------------------------------------------

krn'KMLineEdit::paste() (./kdenetwork/krn/kmcomposewin.cpp:1916)

void KMLineEdit::paste()
{
  QKeyEvent k(QEvent::KeyPress, Key_V, 0, ControlButton);
  keyPressEvent(&k);
}

//-----------------------------------------------------------------------------

krn'KMLineEdit::markAll() (./kdenetwork/krn/kmcomposewin.cpp:1923)

void KMLineEdit::markAll()
{
  selectAll();
}

//-----------------------------------------------------------------------------

krn'KMLineEdit::slotCompletion() (./kdenetwork/krn/kmcomposewin.cpp:1929)

void KMLineEdit::slotCompletion()
{
  QString t;
  QString Name(name());

  if (Name == "subjectLine")
  {
    //mComposer->focusNextPrevEdit(this,TRUE); //IMHO, it is useless now (sven)

    return;
  }
  
  QPopupMenu pop;
  int n;
  
  KMAddrBook adb;
  adb.readConfig();

  if(adb.load() == IO_FatalError)
    return;

  QString s(text());
  QString prevAddr;
  n = s.findRev(',');
  if (n>=0)
  {
    prevAddr = s.left(n+1) + ' ';
    s = s.mid(n+1,255).stripWhiteSpace();
  }
  //s.append("*");
  //QRegExp regexp(s.data(), FALSE, TRUE);
  
  n=0;
  for (const char *a=adb.first(); a; a=adb.next())
  {
    //t.setStr(a);
    //if (t.contains(regexp))
    if (QString(a).find(s,0,false) >= 0)
    {
      pop.insertItem(a);
      n++;
    }
  }
  
  if (n > 1)
  {
    int id;
    pop.popup(parentWidget()->mapToGlobal(QPoint(x(), y()+height())));
    pop.setActiveItem(pop.idAt(0));
    id = pop.exec();
    
    if (id!=-1)
    {
      setText(prevAddr + pop.text(id));
      //mComposer->focusNextPrevEdit(this,TRUE);
    }
  }
  else if (n==1)
  {
    setText(prevAddr + pop.text(pop.idAt(0)));
    //mComposer->focusNextPrevEdit(this,TRUE);
  }

  setFocus();
  cursorAtEnd();
}

//-----------------------------------------------------------------------------