-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 29 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.h | 5 |
3 files changed, 25 insertions, 18 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index 1c80adb..1246037 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp @@ -3,38 +3,38 @@ #include "defines.h" #include "editaccounts.h" AccountListItem::AccountListItem( QListView *parent, Account *a) : QListViewItem( parent ) { account = a; setText( 0, account->getAccountName() ); setText( 1, account->getType() ); } EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : EditAccountsUI( parent, name, modal, flags ) { qDebug( "New Account Configuration Widget" ); settings = s; - + mailList->addColumn( tr( "Account" ) ); mailList->addColumn( tr( "Type" ) ); newsList->addColumn( tr( "Account" ) ); - + connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); slotFillLists(); } void EditAccounts::slotFillLists() { mailList->clear(); newsList->clear(); QList<Account> accounts = settings->getAccounts(); @@ -57,56 +57,57 @@ void EditAccounts::slotNewMail() if ( QDialog::Accepted == selType.exec() ) { slotNewAccount( *selection ); } } void EditAccounts::slotNewAccount( const QString &type ) { if ( type.compare( "IMAP" ) == 0 ) { qDebug( "-> config IMAP" ); IMAPaccount *account = new IMAPaccount(); IMAPconfig imap( account, this, 0, true ); imap.showMaximized(); if ( QDialog::Accepted == imap.exec() ) { settings->addAccount( account ); account->save(); slotFillLists(); - } else { + } else { account->remove(); } } else if ( type.compare( "POP3" ) == 0 ) { qDebug( "-> config POP3" ); POP3account *account = new POP3account(); POP3config pop3( account, this, 0, true ); pop3.showMaximized(); if ( QDialog::Accepted == pop3.exec() ) { settings->addAccount( account ); account->save(); slotFillLists(); } else { account->remove(); } } else if ( type.compare( "SMTP" ) == 0 ) { qDebug( "-> config SMTP" ); SMTPaccount *account = new SMTPaccount(); SMTPconfig smtp( account, this, 0, true ); smtp.showMaximized(); if ( QDialog::Accepted == smtp.exec() ) { settings->addAccount( account ); account->save(); slotFillLists(); + } else { account->remove(); } } else if ( type.compare( "NNTP" ) == 0 ) { qDebug( "-> config NNTP" ); NNTPaccount *account = new NNTPaccount(); NNTPconfig nntp( account, this, 0, true ); nntp.showMaximized(); if ( QDialog::Accepted == nntp.exec() ) { settings->addAccount( account ); account->save(); slotFillLists(); } else { account->remove(); } } @@ -134,148 +135,148 @@ void EditAccounts::slotEditAccount( Account *account ) smtp.showMaximized(); if ( QDialog::Accepted == smtp.exec() ) { slotFillLists(); } } else if ( account->getType().compare( "NNTP" ) == 0 ) { NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); NNTPconfig nntp( nntpAcc, this, 0, true ); nntp.showMaximized(); if ( QDialog::Accepted == nntp.exec() ) { slotFillLists(); } } } void EditAccounts::slotDeleteAccount( Account *account ) { - if ( QMessageBox::information( this, tr( "Question" ), + if ( QMessageBox::information( this, tr( "Question" ), tr( "<p>Do you really want to delete the selected Account?</p>" ), tr( "Yes" ), tr( "No" ) ) == 0 ) { settings->delAccount( account ); slotFillLists(); } } void EditAccounts::slotEditMail() { qDebug( "Edit Mail Account" ); if ( !mailList->currentItem() ) { - QMessageBox::information( this, tr( "Error" ), + QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select an account.</p>" ), tr( "Ok" ) ); return; } Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); slotEditAccount( a ); } void EditAccounts::slotDeleteMail() { if ( !mailList->currentItem() ) { - QMessageBox::information( this, tr( "Error" ), + QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select an account.</p>" ), tr( "Ok" ) ); return; } - + Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); slotDeleteAccount( a ); } void EditAccounts::slotNewNews() { qDebug( "New News Account" ); slotNewAccount( "NNTP" ); } void EditAccounts::slotEditNews() { qDebug( "Edit News Account" ); if ( !newsList->currentItem() ) { - QMessageBox::information( this, tr( "Error" ), + QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select an account.</p>" ), tr( "Ok" ) ); return; } Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); slotEditAccount( a ); } void EditAccounts::slotDeleteNews() { qDebug( "Delete News Account" ); if ( !newsList->currentItem() ) { - QMessageBox::information( this, tr( "Error" ), + QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select an account.</p>" ), tr( "Ok" ) ); return; } - + Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); slotDeleteAccount( a ); } void EditAccounts::slotAdjustColumns() { int currPage = configTab->currentPageIndex(); - + configTab->showPage( mailTab ); mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); mailList->setColumnWidth( 1, 50 ); configTab->showPage( newsTab ); newsList->setColumnWidth( 0, newsList->visibleWidth() ); configTab->setCurrentPage( currPage ); } void EditAccounts::accept() { settings->saveAccounts(); - + QDialog::accept(); } /** * SelectMailType */ SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) : SelectMailTypeUI( parent, name, modal, flags ) { selected = selection; selected->replace( 0, selected->length(), typeBox->currentText() ); connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) ); } void SelectMailType::slotSelection( const QString &sel ) { selected->replace( 0, selected->length(), sel ); } /** * IMAPconfig */ IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : IMAPconfigUI( parent, name, modal, flags ) { data = account; - + fillValues(); connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); } void IMAPconfig::slotSSL( bool enabled ) { if ( enabled ) { portLine->setText( IMAP_SSL_PORT ); } else { portLine->setText( IMAP_PORT ); } } void IMAPconfig::fillValues() { @@ -416,33 +417,33 @@ void SMTPconfig::accept() data->setSignature( sigMultiLine->text() ); QDialog::accept(); } /** * NNTPconfig */ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : NNTPconfigUI( parent, name, modal, flags ) { data = account; connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); - + fillValues(); connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); } void NNTPconfig::slotSSL( bool enabled ) { if ( enabled ) { portLine->setText( NNTP_SSL_PORT ); } else { portLine->setText( NNTP_PORT ); } } void NNTPconfig::fillValues() { diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 93f3bb7..740e4cf 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -1,27 +1,27 @@ #include "opiemail.h" #include "editaccounts.h" #include "composemail.h" OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) : MainWindow( parent, name, flags ) { settings = new Settings(); - + folderView->populate( settings->getAccounts() ); - + connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) ); connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); } void OpieMail::slotComposeMail() { qDebug( "Compose Mail" ); ComposeMail compose( settings, this, 0 , true ); compose.showMaximized(); compose.slotAdjustColumns(); compose.exec(); } @@ -34,17 +34,22 @@ void OpieMail::slotSearchMails() { qDebug( "Search Mails" ); } void OpieMail::slotEditSettings() { qDebug( "Edit Settings" ); } void OpieMail::slotEditAccounts() { qDebug( "Edit Accounts" ); EditAccounts eaDialog( settings, this, 0, true ); eaDialog.showMaximized(); eaDialog.slotAdjustColumns(); eaDialog.exec(); + if ( settings ) delete settings; + settings = new Settings(); + + folderView->populate( settings->getAccounts() ); } + diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h index 7bcd818..ba60297 100644 --- a/noncore/net/mail/opiemail.h +++ b/noncore/net/mail/opiemail.h @@ -1,26 +1,27 @@ #ifndef OPIEMAIL_H #define OPIEMAIL_H #include "mainwindow.h" #include "settings.h" class OpieMail : public MainWindow { Q_OBJECT public: OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); static QString appName() { return QString::fromLatin1("opiemail"); } -protected slots: + +public slots: void slotComposeMail(); +protected slots: void slotSendQueued(); void slotSearchMails(); void slotEditSettings(); void slotEditAccounts(); - private: Settings *settings; }; #endif |