// markus: added half of dnd support in kmcomposer

improved reader layout

svn path=/trunk/kdenetwork/kmail/; revision=943
wilder-work
cvs 29 years ago
parent c89a6636b3
commit 5dbaf93db7
  1. 178
      kmcomposewin.cpp
  2. 5
      kmcomposewin.h
  3. 23
      kmreaderwin.cpp

@ -5,6 +5,8 @@
#include "kmcomposewin.moc" #include "kmcomposewin.moc"
#include "kmmainwin.h" #include "kmmainwin.h"
#include "kmmessage.h" #include "kmmessage.h"
#include "kmglobal.h"
#include "kmsender.h"
#include <iostream.h> #include <iostream.h>
#include <qwidget.h> #include <qwidget.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -54,6 +56,11 @@ KMComposeView::KMComposeView(QWidget *parent, const char *name, QString emailAdd
grid->addMultiCellWidget(editor,3,9,0,1); grid->addMultiCellWidget(editor,3,9,0,1);
grid->setRowStretch(3,100); grid->setRowStretch(3,100);
zone = new KDNDDropZone(editor,DndURL);
connect(zone,SIGNAL(dropAction(KDNDDropZone *)),SLOT(getDNDAttachment()));
urlList = new QStrList;
grid->setColStretch(1,100); grid->setColStretch(1,100);
if(message && action==FORWARD) if(message && action==FORWARD)
@ -79,6 +86,18 @@ KMComposeView::KMComposeView(QWidget *parent, const char *name, QString emailAdd
} }
void KMComposeView::getDNDAttachment()
{
const char *element;
printf("Attachment droped\n");
*urlList = zone->getURLList();
element = urlList->first();
cout << element << "\n";
cout << "Elements in the list: " << urlList->count() << "\n";
while(urlList->next() != 0)
cout << element << "\n";
}
KMComposeView::~KMComposeView() KMComposeView::~KMComposeView()
{} {}
// ****************** Public slots ************* // ****************** Public slots *************
@ -198,54 +217,22 @@ void KMComposeView::attachFile()
void KMComposeView::sendIt() void KMComposeView::sendIt()
{ {
KConfig *config;
QString option; QString option;
// Now, what are we going to do: sendNow() or sendLater()? // Now, what are we going to do: sendNow() or sendLater()?
config = KApplication::getKApplication()->getConfig();
config->setGroup("Settings");
option = config->readEntry("Send Button");
if(!strcmp(option,"now"))
sendNow();
else
toDo();
}
void KMComposeView::sendNow()
{
KMMessage *msg = new KMMessage(); KMMessage *msg = new KMMessage();
msg = currentMessage; msg = currentMessage;
// Now all items in the attachment queue are being displayed. // Now all items in the attachment queue are being displayed.
KMAttachmentItem *itm; /* KMAttachmentItem *itm;
printf("About to display list (sendNow()):\n\n"); printf("About to display list (sendNow()):\n\n");
for ( itm=attachmentList.first(); itm != 0; itm = attachmentList.next()) for ( itm=attachmentList.first(); itm != 0; itm = attachmentList.next())
cout << "FileName: " << itm->fileName << "\tIndex: " << itm->index << "\n"; cout << "FileName: " << itm->fileName << "\tIndex: " << itm->index << "\n";
printf("\nDone displaying list\n"); */
// All attachments in the queue are being attached here. // All attachments in the queue are being attached here.
#if 0
if(indexAttachment !=0)
{int x;
QList<KMAttachmentItem> tempList;
tempList = attachmentList;
tempList.first();
for(x=1; x <= indexAttachment; x++)
{printf("Attaching No.%i\n",x);
Attachment *a = new Attachment();
if(!a->guess(tempList.current()->fileName))
printf("Error\n");
msg->attach(a);
tempList.next();
delete a;
}
printf("Attached files\n");
}
#endif
QString temp=toLEdit->text(); QString temp=toLEdit->text();
if (temp.isEmpty()) { if (temp.isEmpty()) {
KMsgBox::message(0,"Ouch","No recipients defined. aborting ...."); KMsgBox::message(0,"Ouch","No recipients defined. aborting ....");
@ -266,9 +253,14 @@ void KMComposeView::sendNow()
msg->setCc(ccLEdit->text()); msg->setCc(ccLEdit->text());
msg->setSubject(subjLEdit->text()); msg->setSubject(subjLEdit->text());
msg->setBody(temp); msg->setBody(temp);
//msg->sentSMTP(); if(msgSender->send(msg) != TRUE)
{KMsgBox::message(0,"Ouuch!","Error occurred while sending mail!");
delete msg; delete msg;
return;}
delete msg;
((KMComposeWin *)parentWidget())->close(); ((KMComposeWin *)parentWidget())->close();
} }
// ********************* Private slots **************** // ********************* Private slots ****************
@ -492,106 +484,6 @@ void KMComposeView::newComposer()
} }
/*void KMComposeWin::setSettings()
{
setWidget = new QWidget(0,NULL);
setWidget->setMinimumSize(400,320);
setWidget->setMaximumSize(400,320);
setWidget->setCaption("Settings");
QPushButton *ok_bt = new QPushButton("OK",setWidget,NULL);
ok_bt->setGeometry(220,260,70,30);
connect(ok_bt,SIGNAL(clicked()),this,SLOT(applySettings()));
QPushButton *cancel_bt = new QPushButton("Cancel",setWidget,NULL);
cancel_bt->setGeometry(310,260,70,30);
connect(cancel_bt,SIGNAL(clicked()),this,SLOT(cancelSettings()));
QButtonGroup *btGrp = new QButtonGroup(setWidget,NULL);
btGrp->setGeometry(20,20,360,110);
QButtonGroup *btGrpII = new QButtonGroup(setWidget,NULL);
btGrpII->setGeometry(20,140,360,110);
QLabel *sendLabel = new QLabel("Send button in the toolbar is a",btGrp,NULL);
sendLabel->setGeometry(20,10,200,30);
QRadioButton *isNow = new QRadioButton("'send now' Button",btGrp,NULL);
isNow->setGeometry(30,40,150,20);
isLater = new QRadioButton("'send later' Button",btGrp,NULL);
isLater->setGeometry(30,70,150,20);
QLabel *sigLabel = new QLabel("Signature is appended",btGrpII,NULL);
sigLabel->setGeometry(20,10,150,20);
QRadioButton *autoSig = new QRadioButton("'automatically'",btGrpII,NULL);
autoSig->setGeometry(30,40,150,20);
manualSig = new QRadioButton("'manually'",btGrpII,NULL);
manualSig->setGeometry(30,70,150,20);
if(sendButton == false)
isLater->setChecked(true);
else
isNow->setChecked(true);
if(sigStatus == true)
manualSig->setChecked(true);
else
autoSig->setChecked(true);
setWidget->show();
}
void KMComposeWin::applySettings()
{
KConfig *config;
if(isLater->isChecked())
sendButton=false;
else
sendButton=true;
if(manualSig->isChecked())
sigStatus=true;
else
sigStatus=false;
config = KApplication::getKApplication()->getConfig();
config->setGroup("Settings");
if(isLater->isChecked())
{sendButton=false;
config->writeEntry("Send Button","later");
}
else
{sendButton=true;
config->writeEntry("Send Button","now");
}
if(manualSig->isChecked())
config->writeEntry("Signature","manual");
else
config->writeEntry("Signature","auto");
config->sync();
delete setWidget;
}
void KMComposeWin::cancelSettings()
{
delete setWidget;
}
*/
KMComposeWin::KMComposeWin(QWidget *, const char *name, QString emailAddress, KMMessage KMComposeWin::KMComposeWin(QWidget *, const char *name, QString emailAddress, KMMessage
*message, int action) : KTopLevelWidget(name) *message, int action) : KTopLevelWidget(name)
{ {
@ -662,7 +554,7 @@ void KMComposeWin::setupMenuBar()
menuBar = new KMenuBar(this); menuBar = new KMenuBar(this);
QPopupMenu *fmenu = new QPopupMenu(); QPopupMenu *fmenu = new QPopupMenu();
fmenu->insertItem("Send",composeView,SLOT(sendNow()), ALT+Key_X); fmenu->insertItem("Send",composeView,SLOT(sendIt()), ALT+Key_X);
fmenu->insertItem("Send &later",composeView,SLOT(toDo()),ALT+Key_L); fmenu->insertItem("Send &later",composeView,SLOT(toDo()),ALT+Key_L);
fmenu->insertSeparator(); fmenu->insertSeparator();
fmenu->insertItem("Address &Book...",composeView,SLOT(toDo()),ALT+Key_B); fmenu->insertItem("Address &Book...",composeView,SLOT(toDo()),ALT+Key_B);
@ -774,11 +666,14 @@ void KMComposeWin::doNewMailReader()
void KMComposeWin::toggleToolBar() void KMComposeWin::toggleToolBar()
{ {
enableToolBar(KToolBar::Toggle); enableToolBar(KToolBar::Toggle);
printf("before tool : %i\n",toolBarStatus);
if(toolBarStatus==false) if(toolBarStatus==false)
toolBarStatus=true; toolBarStatus=true;
else else
toolBarStatus=false; toolBarStatus=false;
printf("after tool : %i\n",toolBarStatus);
repaint(); repaint();
} }
@ -820,8 +715,6 @@ void KMComposeWin::invokeHelp()
void KMComposeWin::toDo() void KMComposeWin::toDo()
{ {
// KMMainWin::doUnimplemented(); //is private :-(
KMsgBox::message(this,"Ouch", KMsgBox::message(this,"Ouch",
"Not yet implemented!\n" "Not yet implemented!\n"
"We are sorry for the inconvenience :-)",1); "We are sorry for the inconvenience :-)",1);
@ -841,16 +734,17 @@ void KMComposeWin::about()
void KMComposeWin::closeEvent(QCloseEvent *e) void KMComposeWin::closeEvent(QCloseEvent *e)
{ {
KTopLevelWidget::closeEvent(e); KTopLevelWidget::closeEvent(e);
delete this;
KConfig *config = new KConfig(); KConfig *config = new KConfig();
config = KApplication::getKApplication()->getConfig(); config = KApplication::getKApplication()->getConfig();
config->setGroup("Settings"); config->setGroup("Settings");
if(toolBarStatus) printf("Toolbar Status: %i", toolBarStatus);
fflush(stdout);
if(toolBarStatus == true)
config->writeEntry("ShowToolBar","yes"); config->writeEntry("ShowToolBar","yes");
else else
config->writeEntry("ShowToolBar","no"); config->writeEntry("ShowToolBar","no");
config->sync(); config->sync();
delete this;
} }
KMAttachmentItem::KMAttachmentItem(QString _name, int _index) KMAttachmentItem::KMAttachmentItem(QString _name, int _index)

@ -24,6 +24,7 @@
#include <kmsgbox.h> #include <kmsgbox.h>
#include "ktablistbox.h" #include "ktablistbox.h"
#include <qpainter.h> #include <qpainter.h>
#include <drag.h>
#define FORWARD 0 #define FORWARD 0
#define REPLY 1 #define REPLY 1
#define REPLYALL 2 #define REPLYALL 2
@ -46,6 +47,7 @@ public:
KMComposeView(QWidget *parent=0,const char *name=0,QString emailAddress=0, KMMessage *message=0, int action =0); KMComposeView(QWidget *parent=0,const char *name=0,QString emailAddress=0, KMMessage *message=0, int action =0);
~KMComposeView(); ~KMComposeView();
KEdit *editor; KEdit *editor;
KDNDDropZone *zone;
private: private:
QLineEdit *fromLEdit; QLineEdit *fromLEdit;
QLineEdit *toLEdit; QLineEdit *toLEdit;
@ -57,10 +59,10 @@ private:
QString EMailAddress; QString EMailAddress;
QList<KMAttachmentItem> attachmentList; QList<KMAttachmentItem> attachmentList;
int indexAttachment; int indexAttachment;
QStrList *urlList;
public slots: public slots:
void sendIt(); void sendIt();
void sendNow();
void printIt(); void printIt();
void find(); void find();
void attachFile(); void attachFile();
@ -80,6 +82,7 @@ private slots:
void replyAll(); void replyAll();
void detachFile(int,int); void detachFile(int,int);
void insertFile(); void insertFile();
void getDNDAttachment();
protected: protected:
virtual void resizeEvent(QResizeEvent *); virtual void resizeEvent(QResizeEvent *);
QGridLayout* grid; QGridLayout* grid;

@ -114,10 +114,9 @@ void KMReaderView::parseMessage(KMMessage *message)
QString ccStr; QString ccStr;
long length; long length;
int pos=0; int pos=0;
int numParts = message->numBodyParts();
int numParts = message->numBodyParts();
currentMessage = message; // To make sure currentMessage is set. currentMessage = message; // To make sure currentMessage is set.
printf("Debug numBodyparts=%i\n", numParts); printf("Debug numBodyparts=%i\n", numParts);
text = message->body(&length); text = message->body(&length);
@ -151,6 +150,7 @@ void KMReaderView::parseMessage(KMMessage *message)
// Init messageCanvas // Init messageCanvas
messageCanvas->begin(picsDir); messageCanvas->begin(picsDir);
// header // header
messageCanvas->write("<TABLE><TR><TD><IMG SRC=\"" + picsDir +"/kdelogo.xpm\"></TD><TD HSPACE=50><B>"); messageCanvas->write("<TABLE><TR><TD><IMG SRC=\"" + picsDir +"/kdelogo.xpm\"></TD><TD HSPACE=50><B>");
messageCanvas->write(subjStr); messageCanvas->write(subjStr);
@ -167,29 +167,34 @@ void KMReaderView::parseMessage(KMMessage *message)
// ****** 2. Check if message body is html. Search for <html> tag ********// // ****** 2. Check if message body is html. Search for <html> tag ********//
/*
if((text.find(QRegExp("<html>",0,0)) != -1) && (text.find(QRegExp("</html>",0,0)) != -1)) // we found the tags if((text.find(QRegExp("<html>",0,0)) != -1) && (text.find(QRegExp("</html>",0,0)) != -1)) // we found the tags
printf("Found html tags!\n"); printf("Found html tags!\n");
else else
{// First of all convert escape sequences etc to html {// First of all convert escape sequences etc to html*/
text.replace(QRegExp("\n"),"<BR>"); text.replace(QRegExp("\n"),"<BR>");
text.replace(QRegExp("\\x20",FALSE,FALSE),"&nbsp"); // SP text.replace(QRegExp("\\x20",FALSE,FALSE),"&nbsp"); // SP
messageCanvas->write("<HTML><HEAD><TITLE></TITLE></HEAD>"); messageCanvas->write("<HTML><HEAD><TITLE></TITLE></HEAD>");
messageCanvas->write("<BODY BGCOLOR=WHITE>"); messageCanvas->write("<BODY BGCOLOR=WHITE>");
} //}
// Okay! Let's write it to the canvas // Okay! Let's write it to the canvas
messageCanvas->write(text); messageCanvas->write(text);
int x=0; printf("before part\n");
for(x=0;x == noAttach;noAttach++)
{KMMessagePart *part = new KMMessagePart; /* int x=0;
for(x=1;x <= numParts;x++)
{printf("x : %i\n",x);
KMMessagePart *part = new KMMessagePart;
currentMessage->bodyPart(x,part); currentMessage->bodyPart(x,part);
cout << part->typeStr(); cout << part->typeStr();
cout << part->subtypeStr(); cout << part->subtypeStr();
} delete part;
}*/
messageCanvas->write("</BODY></HTML>"); messageCanvas->write("</BODY></HTML>");
messageCanvas->end(); messageCanvas->end();

Loading…
Cancel
Save