summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-03 13:04:52 (UTC)
committer alwin <alwin>2004-01-03 13:04:52 (UTC)
commit22564b62e15c1ea3feada5b2f9b6ec4d98b40c6b (patch) (side-by-side diff)
tree85847776be6743270b18f5e1df9fa6451288f7a6
parent452aac36b77ed1f7e6db3a7952028bf6027e54b6 (diff)
downloadopie-22564b62e15c1ea3feada5b2f9b6ec4d98b40c6b.zip
opie-22564b62e15c1ea3feada5b2f9b6ec4d98b40c6b.tar.gz
opie-22564b62e15c1ea3feada5b2f9b6ec4d98b40c6b.tar.bz2
some more display beauty
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/viewmail.cpp14
-rw-r--r--noncore/net/mail/viewmail.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index d4c5150..ed77eb5 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -41,48 +41,60 @@ AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QStrin
}
bool AttachItem::isParentof(const QValueList<int>&path)
{
/* if not set, then no parent */
if (path.count()==0||_path.count()==0) return false;
/* the parent must have one digit less then a child */
if (path.count()!=_path.count()+1) return false;
for (unsigned int i=0; i < _path.count();++i) {
if (_path[i]!=path[i]) return false;
}
return true;
}
AttachItem* ViewMail::searchParent(const QValueList<int>&path)
{
QListViewItemIterator it( attachments );
for ( ; it.current(); ++it ) {
AttachItem*ati = (AttachItem*)it.current();
if (ati->isParentof(path)) return ati;
}
return 0;
}
+AttachItem* ViewMail::lastChild(AttachItem*parent)
+{
+ if (!parent) return 0;
+ AttachItem* item = (AttachItem*)parent->firstChild();
+ if (!item) return item;
+ AttachItem*temp=0;
+ while( (temp=(AttachItem*)item->nextSibling())) {
+ item = temp;
+ }
+ return item;
+}
+
void ViewMail::setBody( RecBody body ) {
m_body = body;
m_mail[2] = body.Bodytext();
attachbutton->setEnabled(body.Parts().count()>0);
attachments->setEnabled(body.Parts().count()>0);
if (body.Parts().count()==0) {
return;
}
AttachItem * curItem=0;
AttachItem * parentItem = 0;
QString type=body.Description().Type()+"/"+body.Description().Subtype();
QString desc,fsize;
double s = body.Description().Size();
int w;
w=0;
while (s>1024) {
s/=1024;
++w;
if (w>=2) break;
}
QString q="";
@@ -125,48 +137,50 @@ for (unsigned int i = 0; i < body.Parts().count();++i) {
w = 0;
while (s>1024) {
s/=1024;
++w;
if (w>=2) break;
}
switch(w) {
case 1:
q="k";
break;
case 2:
q="M";
break;
default:
q="";
break;
}
QTextOStream o(&fsize);
if (w>0) o.precision(2); else o.precision(0);
o.setf(QTextStream::fixed);
o << s << " " << q << "Byte";
desc = body.Parts()[i].Description();
parentItem = searchParent(body.Parts()[i].Positionlist());
if (parentItem) {
+ AttachItem*temp = lastChild(parentItem);
+ if (temp) curItem = temp;
curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
attachments->setRootIsDecorated(true);
curItem = parentItem;
} else {
curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
}
}
}
void ViewMail::slotShowHtml( bool state ) {
m_showHtml = state;
setText();
}
void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) {
if (!item )
return;
if ( ( ( AttachItem* )item )->Partnumber() == -1 ) {
setText();
return;
}
QPopupMenu *menu = new QPopupMenu();
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index b3d3b4e..29681cc 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -21,48 +21,49 @@ public:
private:
int _partNum;
/* needed for a better display of attachments */
QValueList<int> _path;
};
class ViewMail : public ViewMailBase
{
Q_OBJECT
public:
ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal);
~ViewMail();
void hide();
void exec();
void setMail( RecMail mail );
void setBody( RecBody body );
bool deleted;
protected:
QString deHtml(const QString &string);
AttachItem* searchParent(const QValueList<int>&path);
+ AttachItem* lastChild(AttachItem*parent);
protected slots:
void slotReply();
void slotForward();
void setText();
void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
void slotDeleteMail( );
void slotShowHtml( bool );
private:
void readConfig();
bool _inLoop;
QString m_mailHtml;
bool m_gotBody;
RecBody m_body;
RecMail m_recMail;
bool m_showHtml;
// 0 from 1 subject 2 bodytext 3 date
QMap <int,QString> m_mail;
// 0 to 1 cc 2 bcc
QMap <int,QStringList> m_mail2;