From a5bbd674dfd88016636b9f2e3eebafdadc2a2b7c Mon Sep 17 00:00:00 2001 From: Markus Wuebben Date: Fri, 11 Jul 1997 11:47:25 +0000 Subject: [PATCH] Added insertFile() function svn path=/trunk/kdenetwork/kmail/; revision=377 --- kmcomposewin.cpp | 25 +++++++++++++++++++++++++ kmcomposewin.h | 1 + 2 files changed, 26 insertions(+) diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index 15a967dc1..3f07fd6ec 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -459,6 +459,30 @@ void KMComposeView::detachFile(int index, int col) } +void KMComposeView::insertFile() +{ + QString iFileString; + QString textString; + QFile *iFileName; + char buf[255]; + int col, line; + QFileDialog *d=new QFileDialog(".","*",this,NULL,TRUE); + d->setCaption("Insert File"); + if (d->exec()) + {iFileString = d->selectedFile(); + iFileName = new QFile(iFileString); + iFileName->open(IO_ReadOnly); + iFileName->at(0); + while(iFileName->readLine(buf,254) != 0) + textString.append(buf); + iFileName->close(); + editor->getCursorPosition(&line,&col); + editor->insertAt(textString,line,col); + editor->update(); + editor->repaint(); + } +} + void KMComposeView::toDo() { KMsgBox::message(this,"Ouch", @@ -680,6 +704,7 @@ void KMComposeWin::setupMenuBar() QPopupMenu *mmenu = new QPopupMenu(); mmenu->insertItem("Recip&ients...",composeView,SLOT(toDo()),ALT+Key_I); + mmenu->insertItem("Insert &File", composeView,SLOT(insertFile()),ALT+Key_F); mmenu->insertSeparator(); QPopupMenu *menv = new QPopupMenu(); menv->insertItem("High"); diff --git a/kmcomposewin.h b/kmcomposewin.h index 42f8fad6c..bc826eba4 100644 --- a/kmcomposewin.h +++ b/kmcomposewin.h @@ -77,6 +77,7 @@ private slots: void replyMessage(); void replyAll(); void detachFile(int,int); + void insertFile(); protected: virtual void resizeEvent(QResizeEvent *); };