author | groucho <groucho> | 2003-04-20 07:59:48 (UTC) |
---|---|---|
committer | groucho <groucho> | 2003-04-20 07:59:48 (UTC) |
commit | 8b85cba50912127ff6a2d048021baf68306481c6 (patch) (side-by-side diff) | |
tree | bfd1b377911d05db8e1c816f72fe070d5a5b2ff3 /noncore/net/mailit/emailclient.cpp | |
parent | 6b381e438fdeb1757b3278c683349dee9c4ab230 (diff) | |
download | opie-8b85cba50912127ff6a2d048021baf68306481c6.zip opie-8b85cba50912127ff6a2d048021baf68306481c6.tar.gz opie-8b85cba50912127ff6a2d048021baf68306481c6.tar.bz2 |
- Added CC: support
- Added mail forwarding
- Added icon for selective mail download
- Removing mails from mail list via icon
- Temporarily disabled mail header download queue
Diffstat (limited to 'noncore/net/mailit/emailclient.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 154 |
1 files changed, 143 insertions, 11 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 0d82a9a..ad1e0b4 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp @@ -56,14 +56,18 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) connect(emailHandler, SIGNAL(smtpError(int)), this, SLOT(smtpError(int)) ); connect(emailHandler, SIGNAL(popError(int)), this, SLOT(popError(int)) ); - connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); - connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); + connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); + connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); + + connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); + connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); + connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, SLOT(mailArrived(const Email &, bool)) ); connect(emailHandler, SIGNAL(mailTransfered(int)), this, SLOT(allMailArrived(int)) ); @@ -140,16 +144,32 @@ void EmailClient::init() mail->insertItem(tr("Get Mail in"), selectAccountMenu); configure->insertItem(tr("Edit account"), editAccountMenu); configure->insertItem(tr("Delete account"), deleteAccountMenu); bar = new QToolBar(this); - getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); + getMailButton = new QToolButton(Resource::loadPixmap("mailit/getmail"),tr("getMail"),tr("select account"), this,SLOT(getAllNewMail()),bar); + //connect(setAccountlButton, SIGNAL(activated()), this, SLOT(setCurrentAccount()) ); + // setAccountButton->addTo(bar); + //setAccountButton->addTo(mail); + + /*idCount = 0; + + for (MailAccount* accountPtr = accountList.first(); accountPtr != 0; + accountPtr = accountList.next()) { + + selectAccountMenu->insertItem(accountPtr->accountName,this, SLOT(selectAccount(int)), 0, idCount); + idCount++; + }*/ + getMailButton->setPopup(selectAccountMenu); + + + /*getMailButton = new QAction(tr("Get all mail"), Resource::loadPixmap("mailit/getmail"), QString::null, 0, this, 0); connect(getMailButton, SIGNAL(activated()), this, SLOT(getAllNewMail()) ); - getMailButton->addTo(bar); - getMailButton->addTo(mail); + getMailButton->addTo(bar);*/ + //getMailButton->addTo(mail); sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); sendMailButton->addTo(bar); sendMailButton->addTo(mail); @@ -161,12 +181,16 @@ void EmailClient::init() cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); cancelButton->addTo(mail); cancelButton->addTo(bar); cancelButton->setEnabled(FALSE); + deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); + connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); + deleteButton->addTo(bar); + mailboxView = new OTabWidget( this, "mailboxView" ); QWidget* widget = new QWidget( mailboxView, "widget" ); grid_2 = new QGridLayout( widget ); // grid_2->setSpacing(6); // grid_2->setMargin( 11 ); @@ -192,12 +216,14 @@ void EmailClient::init() outboxView->setAllColumnsShowFocus(TRUE); grid_3->addWidget( outboxView, 0, 0 ); mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); setCentralWidget(mailboxView); + + mailboxView->setCurrentTab(0); } void EmailClient::compose() { emit composeRequested(); } @@ -229,12 +255,14 @@ void EmailClient::enqueMail(const Email &mail) Email addMail = mail; addMail.from = currentAccount->name; addMail.fromMail = currentAccount->emailAddress; addMail.rawMail.prepend("From: " + addMail.from + "<" + addMail.fromMail + ">\n"); item = new EmailListItem(outboxView, addMail, false); + mailboxView->setCurrentTab(1); + } void EmailClient::sendQuedMail() { int count = 0; @@ -293,22 +321,22 @@ void EmailClient::getNewMail() { selectAccountMenu->setEnabled(FALSE); status1Label->setText(currentAccount->accountName + " headers"); progressBar->reset(); //get any previous mails not downloaded and add to queue - mailDownloadList.clear(); +/* mailDownloadList.clear(); Email *mailPtr; item = (EmailListItem *) inboxView->firstChild(); while (item != NULL) { mailPtr = item->getMail(); if ( (!mailPtr->downloaded) && (mailPtr->fromAccountId == currentAccount->id) ) { mailDownloadList.sizeInsert(mailPtr->serverId, mailPtr->size); } item = (EmailListItem *) item->nextSibling(); - } + }*/ emailHandler->getMailHeaders(); } void EmailClient::getAllNewMail() { @@ -412,12 +440,14 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) } else { item = new EmailListItem(inboxView, newMail, TRUE); if (!newMail.downloaded) mailDownloadList.sizeInsert(newMail.serverId, newMail.size); } + mailboxView->setCurrentTab(0); + } void EmailClient::allMailArrived(int count) { // not previewing means all mailtransfer has been done if (!previewingMail) { @@ -441,12 +471,14 @@ void EmailClient::allMailArrived(int count) // all headers downloaded from server, start downloading remaining mails previewingMail = FALSE; status1Label->setText(currentAccount->accountName); progressBar->reset(); emailHandler->getMailByList(&mailDownloadList); + + mailboxView->setCurrentTab(0); } void EmailClient::moveMailFront(Email *mailPtr) { if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) { mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size); @@ -506,20 +538,24 @@ void EmailClient::popError(int code) cancelButton->setEnabled(FALSE); selectAccountMenu->setEnabled(TRUE); } void EmailClient::inboxItemSelected() { + killTimer(timerID); + item = (EmailListItem*) inboxView->selectedItem(); if (item != NULL) { emit viewEmail(inboxView, item->getMail()); } } void EmailClient::outboxItemSelected() { + killTimer(timerID); + item = (EmailListItem*) outboxView->selectedItem(); if (item != NULL) { emit viewEmail(outboxView, item->getMail()); } } @@ -689,22 +725,23 @@ void EmailClient::readSettings() accountIdCount = y; } } void EmailClient::saveSettings() { + QString temp; QFile f( getPath(FALSE) + "settings.txt"); MailAccount *accountPtr; if (! f.open(IO_WriteOnly) ) { qWarning("could not save settings file"); return; } QTextStream t(&f); - t << "#Settings for QPE Mailit program\n"; + t << "#Settings for OPIE Mailit program\n"; for (accountPtr = accountList.first(); accountPtr != 0; accountPtr = accountList.next()) { t << "accountStart;\n"; t << "AccountName: " + accountPtr->accountName + "\n"; @@ -808,26 +845,27 @@ void EmailClient::updateAccounts() idCount = 0; for (accountPtr = accountList.first(); accountPtr != 0; accountPtr = accountList.next()) { editAccountMenu->insertItem(accountPtr->accountName, this, SLOT(editAccount(int)), 0, idCount); - selectAccountMenu->insertItem(accountPtr->accountName, + selectAccountMenu->insertItem(accountPtr->accountName, this, SLOT(selectAccount(int)), 0, idCount); deleteAccountMenu->insertItem(accountPtr->accountName, this, SLOT(deleteAccount(int)), 0, idCount); idCount++; } } void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) { Email *mPtr; Enclosure *ePtr; - if (inbox) { + if (inbox) + { mPtr = mailItem->getMail(); //if mail is in queue for download, remove it from //queue if possible if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { if ( !mPtr->downloaded ) @@ -841,13 +879,15 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { if (ePtr->saved) { QFile::remove( (ePtr->path + ePtr->name) ); } } inboxView->takeItem(mailItem); - } else { + } + else + { outboxView->takeItem(mailItem); } } void EmailClient::setMailSize(int size) { @@ -867,6 +907,98 @@ void EmailClient::setDownloadedSize(int size) if (size < total) { progressBar->setProgress(size); } else { progressBar->setProgress(total); } } + +void EmailClient::deleteItem() +{ + bool inbox=mailboxView->currentTab()==0; + + EmailListItem* eli; + + inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem(); + + if (eli) + deleteMail(eli,(bool&)inbox); +} + +void EmailClient::inboxItemPressed() +{ +// timerID=startTimer(500); +} + +void EmailClient::inboxItemReleased() +{ + // killTimer(timerID); +} + +void EmailClient::timerEvent(QTimerEvent *e) +{ + /*killTimer(timerID); + + + QPopupMenu *action = new QPopupMenu(this); + + int reply=0; + + action->insertItem(tr( "Reply To" ),this,SLOT(reply())); + action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); + action->insertItem( tr( "Forward" ), this,SLOT(forward())); + action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); + + action->exec(QCursor::pos()); + + if (action) delete action; + */ +} + +Email* EmailClient::getCurrentMail() +{ + EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem()); + if (eli!=NULL) + return eli->getMail(); + else + return NULL; +} + +/* +void EmailClient::reply() +{ + Email* mail=getCurrentMail(); + + if (mail!=NULL) + { + emit reply(*mail); + } +} + +void EmailClient::replyAll() +{ + Email* mail=getCurrentMail(); + + if (mail!=NULL) + { + emit replyAll(*mail); + } +} + +void EmailClient::forward() +{ + Email* mail=getCurrentMail(); + + if (mail!=NULL) + { + emit reply(*mail); + } +} + +void EmailClient::remove() +{ + Email* mail=getCurrentMail(); + + if (mail!=NULL) + { + emit remove(*mail); + } +}*/
\ No newline at end of file |