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

Class Index

kmail'KMLineEdit (./kdenetwork/kmail/kmcomposewin.h:107)

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. */
   void cursorAtEnd();

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

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

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


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

kmail'KMLineEdit::KMLineEdit() (./kdenetwork/kmail/kmcomposewin.cpp:1920)

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

  installEventFilter(this);

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


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

kmail'KMLineEdit::~KMLineEdit() (./kdenetwork/kmail/kmcomposewin.cpp:1932)

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


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

kmail'KMLineEdit::eventFilter() (./kdenetwork/kmail/kmcomposewin.cpp:1939)

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

kmail'KMLineEdit::cursorAtEnd() (./kdenetwork/kmail/kmcomposewin.cpp:2004)

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


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

kmail'KMLineEdit::copy() (./kdenetwork/kmail/kmcomposewin.cpp:2012)

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

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

kmail'KMLineEdit::cut() (./kdenetwork/kmail/kmcomposewin.cpp:2019)

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

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

kmail'KMLineEdit::paste() (./kdenetwork/kmail/kmcomposewin.cpp:2031)

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

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

kmail'KMLineEdit::markAll() (./kdenetwork/kmail/kmcomposewin.cpp:2038)

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

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

kmail'KMLineEdit::slotCompletion() (./kdenetwork/kmail/kmcomposewin.cpp:2044)

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 (QString 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();
}

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