author | alwin <alwin> | 2003-12-17 00:30:31 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-17 00:30:31 (UTC) |
commit | a928f1fc8469124e10a7042846d258401e41f7d6 (patch) (side-by-side diff) | |
tree | 225db6d7356d3ff3a0a3f3768c2fc0fa10360edc /noncore/net | |
parent | 27151bb106e2cbd7f649dae228189ebcaccd7aac (diff) | |
download | opie-a928f1fc8469124e10a7042846d258401e41f7d6.zip opie-a928f1fc8469124e10a7042846d258401e41f7d6.tar.gz opie-a928f1fc8469124e10a7042846d258401e41f7d6.tar.bz2 |
imap folder will be displayed more structured
-rw-r--r-- | noncore/net/mail/accountview.cpp | 65 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/mailwrapper.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 2 |
10 files changed, 98 insertions, 23 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 8e21d39..b6bf298 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -108,2 +108,3 @@ void IMAPviewItem::refresh(QList<RecMail>&) { + if (childCount()>0) return; QList<Folder> *folders = wrapper->listFolders(); @@ -119,8 +120,44 @@ void IMAPviewItem::refresh(QList<RecMail>&) QListViewItem*item = 0; + QListViewItem*titem = 0; + QListViewItem*inboxitem = 0; + QString fname,del,search; + int pos; + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + folders->setAutoDelete(false); + + for ( it = folders->first(); it; it = folders->next() ) { + if (it->getDisplayName().lower()=="inbox") { + inboxitem = new IMAPfolderItem( it, this , item ); + folders->remove(it); + qDebug("inbox found"); + break; + } + } + for ( it = folders->first(); it; it = folders->next() ) { - item = new IMAPfolderItem( it, this , item ); + fname = it->getDisplayName(); + pos = fname.findRev(it->Separator()); + if (pos != -1) { + fname = fname.left(pos); + qDebug(fname); + } + IMAPfolderItem*pitem = (IMAPfolderItem*)firstChild(); + while (pitem) { + if (pitem->matchName(fname)) { + break; + } + pitem=(IMAPfolderItem*)pitem->nextSibling(); + } + if (pitem) { + titem = item; + item = new IMAPfolderItem(it,pitem,item,this); + item->setSelectable(it->may_select()); + /* setup the short name */ + item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); + item = titem; + } else { + item = new IMAPfolderItem( it, this , (inboxitem?inboxitem:item) ); item->setSelectable(it->may_select()); } - // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - folders->setAutoDelete(false); + } delete folders; @@ -139,3 +176,3 @@ IMAPfolderItem::~IMAPfolderItem() IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) - : AccountViewItem( parent,after ) + : AccountViewItem( parent ) { @@ -151,2 +188,20 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QList +IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) + : AccountViewItem( parent,after ) +{ + folder = folderInit; + imap = master; + if (folder->getDisplayName().lower()!="inbox") { + setPixmap( 0, PIXMAP_IMAPFOLDER ); + } else { + setPixmap( 0, PIXMAP_INBOXFOLDER); + } + setText( 0, folder->getDisplayName() ); +} + +bool IMAPfolderItem::matchName(const QString&name)const +{ + return folder->getDisplayName()==name; +} + void IMAPfolderItem::refresh(QList<RecMail>&target) @@ -171,3 +226,3 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) SLOT( refresh( QListViewItem * ) ) ); - setSorting(-1); + setSorting(0); } diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index d035af4..a57935f 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h @@ -72,2 +72,3 @@ public: IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); + IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); ~IMAPfolderItem(); @@ -75,2 +76,3 @@ public: virtual RecBody fetchBody(const RecMail&); + bool matchName(const QString&name)const; private: diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index d56d7f9..8a86c95 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp @@ -167,2 +167,3 @@ QList<Folder>* IMAPwrapper::listFolders() err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); + QString del; if ( err == MAILIMAP_NO_ERROR ) { @@ -174,3 +175,4 @@ QList<Folder>* IMAPwrapper::listFolders() temp = list->mb_name; - folders->append( new IMAPFolder(temp)); + del = list->mb_delimiter; + folders->append( new IMAPFolder(temp,del,true,account->getPrefix())); current = current->next; @@ -208,3 +210,4 @@ QList<Folder>* IMAPwrapper::listFolders() } - folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); + del = list->mb_delimiter; + folders->append(new IMAPFolder(temp,del,selectable,account->getPrefix())); } diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index d56d7f9..8a86c95 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -167,2 +167,3 @@ QList<Folder>* IMAPwrapper::listFolders() err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); + QString del; if ( err == MAILIMAP_NO_ERROR ) { @@ -174,3 +175,4 @@ QList<Folder>* IMAPwrapper::listFolders() temp = list->mb_name; - folders->append( new IMAPFolder(temp)); + del = list->mb_delimiter; + folders->append( new IMAPFolder(temp,del,true,account->getPrefix())); current = current->next; @@ -208,3 +210,4 @@ QList<Folder>* IMAPwrapper::listFolders() } - folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); + del = list->mb_delimiter; + folders->append(new IMAPFolder(temp,del,selectable,account->getPrefix())); } diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index 96602c2..858283f 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp @@ -19,3 +19,3 @@ Attachment::Attachment( DocLnk lnk ) -Folder::Folder(const QString&tmp_name ) +Folder::Folder(const QString&tmp_name, const QString&sep ) { @@ -37,7 +37,12 @@ Folder::Folder(const QString&tmp_name ) qDebug( "folder " + name + " - displayed as " + nameDisplay ); + separator = sep; } +const QString& Folder::Separator()const +{ + return separator; +} -IMAPFolder::IMAPFolder(const QString&name,bool select,const QString&prefix ) - : Folder( name ),m_MaySelect(select) +IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,const QString&prefix ) + : Folder( name,sep ),m_MaySelect(select) { diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 6994dd8..d78f8e9 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h @@ -73,3 +73,3 @@ class Folder : public QObject public: - Folder( const QString&init_name ); + Folder( const QString&init_name,const QString&sep ); const QString&getDisplayName()const { return nameDisplay; } @@ -77,5 +77,6 @@ public: virtual bool may_select()const{return true;}; + const QString&Separator()const; protected: - QString nameDisplay, name; + QString nameDisplay, name, separator; @@ -86,3 +87,3 @@ class IMAPFolder : public Folder public: - IMAPFolder(const QString&name,bool select=true,const QString&prefix="" ); + IMAPFolder(const QString&name, const QString&sep, bool select=true,const QString&prefix="" ); virtual bool may_select()const{return m_MaySelect;} diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 075d8c7..4508a95 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp @@ -325,3 +325,3 @@ QList<Folder>* POP3wrapper::listFolders() folders->setAutoDelete( false ); - Folder*inb=new Folder("INBOX"); + Folder*inb=new Folder("INBOX","/"); folders->append(inb); diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp index 96602c2..858283f 100644 --- a/noncore/net/mail/mailwrapper.cpp +++ b/noncore/net/mail/mailwrapper.cpp @@ -19,3 +19,3 @@ Attachment::Attachment( DocLnk lnk ) -Folder::Folder(const QString&tmp_name ) +Folder::Folder(const QString&tmp_name, const QString&sep ) { @@ -37,7 +37,12 @@ Folder::Folder(const QString&tmp_name ) qDebug( "folder " + name + " - displayed as " + nameDisplay ); + separator = sep; } +const QString& Folder::Separator()const +{ + return separator; +} -IMAPFolder::IMAPFolder(const QString&name,bool select,const QString&prefix ) - : Folder( name ),m_MaySelect(select) +IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,const QString&prefix ) + : Folder( name,sep ),m_MaySelect(select) { diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h index 6994dd8..d78f8e9 100644 --- a/noncore/net/mail/mailwrapper.h +++ b/noncore/net/mail/mailwrapper.h @@ -73,3 +73,3 @@ class Folder : public QObject public: - Folder( const QString&init_name ); + Folder( const QString&init_name,const QString&sep ); const QString&getDisplayName()const { return nameDisplay; } @@ -77,5 +77,6 @@ public: virtual bool may_select()const{return true;}; + const QString&Separator()const; protected: - QString nameDisplay, name; + QString nameDisplay, name, separator; @@ -86,3 +87,3 @@ class IMAPFolder : public Folder public: - IMAPFolder(const QString&name,bool select=true,const QString&prefix="" ); + IMAPFolder(const QString&name, const QString&sep, bool select=true,const QString&prefix="" ); virtual bool may_select()const{return m_MaySelect;} diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index 075d8c7..4508a95 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp @@ -325,3 +325,3 @@ QList<Folder>* POP3wrapper::listFolders() folders->setAutoDelete( false ); - Folder*inb=new Folder("INBOX"); + Folder*inb=new Folder("INBOX","/"); folders->append(inb); |