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

Class Index

kjots'MyMultiEdit (./kdeutils/kjots/KJotsMain.h:65)

class MyMultiEdit : public QMultiLineEdit
{
  Q_OBJECT  
public:
  MyMultiEdit (QWidget* parent=0, const char* name=0);
  ~MyMultiEdit () {}

protected slots:
  void openUrl();

protected:
  virtual void keyPressEvent (QKeyEvent* e);
  virtual void mousePressEvent (QMouseEvent *e);

  CPopupMenu *web_menu;
};


/////////////////////////////////////////////////////////////////////////////

kjots'MyMultiEdit::MyMultiEdit() (./kdeutils/kjots/KJotsMain.cpp:110)

MyMultiEdit::MyMultiEdit (QWidget* parent, const char* name)
  : QMultiLineEdit(parent, name)
{
  web_menu = new CPopupMenu;
  web_menu->insertItem(i18n("Open URL"), this, SLOT(openUrl()) );
}


kjots'MyMultiEdit::keyPressEvent() (./kdeutils/kjots/KJotsMain.cpp:117)

void MyMultiEdit::keyPressEvent( QKeyEvent *e )
{
  if( e->key() == Key_Tab )
    {
      int line, col;
      cursorPosition(&line, &col);
      QMultiLineEdit::insertAt("\t", line, col);
      return;
    }
  QMultiLineEdit::keyPressEvent(e);
  return;
}


kjots'MyMultiEdit::mousePressEvent() (./kdeutils/kjots/KJotsMain.cpp:130)

void MyMultiEdit::mousePressEvent( QMouseEvent *e )
{
  if( e->button() == RightButton )
    {
      if( hasMarkedText() )
	{
	  QString marked = markedText();
	  if( marked.left(7) == "http://" || marked.left(6) == "ftp://" )
	    {
	      web_menu->popup(QCursor::pos());
	      web_menu->grabMouse();
	    }
	}
      return;
    }
  QMultiLineEdit::mousePressEvent(e);
  return;
}


kjots'MyMultiEdit::openUrl() (./kdeutils/kjots/KJotsMain.cpp:149)

void MyMultiEdit::openUrl()
{
  QString command;
  int pos;
  if( hasMarkedText() )
    {
      QString marked = markedText();
      if( marked.left(7) == "http://" )
	{
	  command = exec_http;
	
	  if( (pos = exec_http.find("%u")) == -1 )
	    {
	      command += " " + marked + " &";
	    }
	  else
	    {
	      command.remove(pos, 2);
	      command = command.insert(pos, marked);
	      command += " &";
	    }
	  system((const char *) command);
	  //debug("exec: %s", (const char *) command );
	}
      else if( marked.left(6) == "ftp://" )
	{
	  command = exec_ftp;
	
	  if( (pos = exec_ftp.find("%u")) == -1 )
	    {
	      command += " " + marked + " &";
	    }
	  else
	    {
	      command.remove(pos, 2);
	      command = command.insert(pos, marked);
	      command += " &";
	    }
	  system((const char *) command);
	  //debug("exec: %s", (const char *) command );
	}
    }
}

//----------------------------------------------------------------------
// MYBUTTONGROUP
//----------------------------------------------------------------------