editaccount.cpp
来自「Qtopia下的邮件处理程序」· C++ 代码 · 共 681 行 · 第 1/2 页
CPP
681 行
smtpPortInput->setEnabled( true ); smtpServerInput->setEnabled( true ); deleteCheckBox->setEnabled( true ); defaultMailCheckBox->setEnabled( true ); thresholdCheckBox->setEnabled( true ); } if (accountType->currentText() == "POP") { mailPortInput->setText("110"); imapSettings->hide(); syncCheckBox->show(); } else if (accountType->currentText() == "IMAP") { syncCheckBox->hide(); imapSettings->show(); mailboxButton->setEnabled( account->mailboxes.count() > 0 ); mailPortInput->setText("143"); }}void EditAccount::deleteAccount(){ qWarning("delete"); done(2);}void EditAccount::accept(){ QString name = accountNameInput->text(); if ( name.trimmed().isEmpty() ) { name = mailServerInput->text(); if ( name.trimmed().isEmpty() ) name = smtpServerInput->text(); } if (name.trimmed().isEmpty()) { int ret = QMessageBox::warning(this, tr("Empty account name"), tr("<qt>Do you want to continue and discard any changes?</qt>"), QMessageBox::Yes, QMessageBox::No|QMessageBox::Default|QMessageBox::Escape); if (ret == QMessageBox::Yes) reject(); return; } account->setAccountName( accountNameInput->text() ); account->setUserName( nameInput->text() ); account->setEmailAddress( emailInput->text() ); account->setMailUserName( mailUserInput->text() ); account->setMailPassword( mailPasswInput->text() ); account->setMailServer( mailServerInput->text() ); account->setSmtpServer( smtpServerInput->text() ); account->setSynchronize( syncCheckBox->isChecked() ); account->setDeleteMail( deleteCheckBox->isChecked() ); if ( accountType->currentText() == "POP" ) { account->setAccountType( MailAccount::POP ); } else if ( accountType->currentText() == "IMAP") { account->setAccountType( MailAccount::IMAP ); } else { account->setAccountType( MailAccount::Synchronized ); } account->setUseSig( sigCheckBox->isChecked() ); account->setSig( sig ); account->setDefaultMailServer( defaultMailCheckBox->isChecked() ); if ( thresholdCheckBox->isChecked() ) { account->setMaxMailSize( maxSize->value() ); } else { account->setMaxMailSize( -1 ); } account->setCheckInterval( -1 ); if ( account->accountType() == MailAccount::IMAP ) account->setBaseFolder( imapBaseDir->text() ); QString temp; bool result; temp = mailPortInput->text(); account->setMailPort( temp.toInt(&result) ); if ( (!result) ) { // should only happen when the string is empty, since we use a validator. if (accountType->currentText() == "POP") account->setMailPort( 110 ); else account->setMailPort( 143 ); } temp = smtpPortInput->text(); account->setSmtpPort( temp.toInt(&result) ); // should only happen when the string is empty, since we use a validator. if ( !result ) account->setSmtpPort( 25 ); //try to guess email address if ( (!emailTyped) && (account->emailAddress().isEmpty()) ) { QString address = account->smtpServer(); if ( address.count('.')) { account->setEmailAddress( account->mailUserName() + "@" + address.mid( address.indexOf('.') + 1, address.length() ) ); } else if (address.count('.') == 1) { account->setEmailAddress( account->mailUserName() + "@" + address ); } } //set an accountname if ( account->accountName().isEmpty() ) { int pos = name.indexOf('.'); if ( pos != -1) { name = name.mid( pos + 1, name.length() ); pos = name.indexOf('.', pos); if (pos != -1) name = name.mid(0, pos); } account->setAccountName( name ); } #ifdef SMTPAUTH account->setSmtpUsername(smtpUsernameInput->text()); account->setSmtpPassword(smtpPasswordInput->text()); account->setSmtpAuthentication(static_cast<MailAccount::AuthType>(authentication->currentIndex())); account->setSmtpEncryption(static_cast<MailAccount::EncryptType>(encryption->currentIndex())); if(encryptionCheckBox->isChecked()) account->setMailEncryption(MailAccount::Encrypt_SSL); else account->setMailEncryption(MailAccount::Encrypt_NONE);#endif QDialog::accept();}SigEntry::SigEntry(QWidget *parent, const char *name, Qt::WFlags fl ) : QDialog(parent,fl){ setObjectName(name); setWindowTitle( tr("Signature") ); QGridLayout *grid = new QGridLayout(this); input = new QTextEdit(this); grid->addWidget(input, 0, 0); resize(180, 100);}// /* class MailboxView */// MailboxView::MailboxView(QWidget *parent, const char* name)// : QListWidget(parent)// {// setObjectName(name);// pop = new QMenu(this);// connect(pop, SIGNAL( triggered(QAction*) ), this,// SLOT( changeMessageSettings(QAction*) ) );// // pop->addAction( tr("All"));// pop->addAction( tr("Only recent"));// pop->addAction( tr("None (only headers)"));// // connect( &menuTimer, SIGNAL( timeout() ), SLOT( showMessageOptions() ) );// connect( this, SIGNAL( itemChanged() ), SLOT( cancelMenuTimer() ) );// }// // void MailboxView::changeMessageSettings(QAction* id)// {// QListWidgetItem *item = currentItem();// if ( !item )// return;// // item->setText(id->text());// }// // void MailboxView::showMessageOptions()// {// pop->popup( QCursor::pos() );// }// // void MailboxView::mousePressEvent( QMouseEvent * e )// {// QListView::mousePressEvent( e );// menuTimer.start( 500);// menuTimer.setSingleShot(true);// }// // void MailboxView::mouseReleaseEvent( QMouseEvent * e )// {// QListView::mouseReleaseEvent( e );// menuTimer.stop();// }// // void MailboxView::cancelMenuTimer()// {// if( menuTimer.isActive() )// menuTimer.stop();// }// // /* Class MailboxSelector */// MailboxSelector::MailboxSelector(QWidget *parent, const char *name, MailAccount *account)// : QDialog(parent)// { // setObjectName(name);// _account = account;// // setWindowTitle( tr("Configure IMAP folders") );// // QGridLayout *grid = new QGridLayout(this);// // grid->setSpacing(4);// // grid->setMargin(4);// // view = new MailboxView(this, "mview");// QAction* what = QWhatsThis::createAction(view);// what->setText(tr("Lists your IMAP mailboxes. Tick the mailboxes which you want to access on your device."));// // // what = QWhatsThis::createAction(view->header());// // what->setText(tr("For selected mailboxes, you can choose which type of messages to download."));// // view->addColumn(tr("Keep local copy"), 120);// view->addColumn(tr("Complete messages"), 115);// view->setAllColumnsShowFocus( true );// grid->addMultiCellWidget(view, 0, 0, 0, 3);// // QPushButton *button = new QPushButton( tr("Select all"), this);// // what = QWhatsThis::createAction(button);// what->setText(tr("Select all mailboxes in your account."));// connect(button, SIGNAL( clicked() ), this, SLOT( selectAll() ) );// grid->addWidget(button, 1, 0);// // button = new QPushButton( tr("Deselect all"), this);// // what = QWhatsThis::createAction(button);// what->setText(tr("Deselect all mailboxes in your account."));// connect(button, SIGNAL( clicked() ), this, SLOT( clearAll() ) );// grid->addWidget(button, 1, 1);// // QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );// // grid->addItem(spacer, 1, 2);// // button = new QPushButton( tr("Change message type"), this );// what = QWhatsThis::createAction(button);// what->setText(tr("Choose the message types you want to download for the selected mailbox."));// connect(button, SIGNAL(clicked() ), this, SLOT( itemSelected() ) );// grid->addWidget(button, 1, 3);// // Mailbox *box;// QCheckListItem *item;// uint row = 0;// for (box = _account->mailboxes.first(); box != NULL;// box = _account->mailboxes.next() ) {// // item = new QCheckListItem(view, box->pathName(), QCheckListItem::CheckBox);// item->setOn( box->localCopy() );// // QString sync = tr("All");// FolderSyncSetting fs = box->folderSync();// if ( fs == Sync_OnlyNew)// sync = tr("Only recent");// if ( fs == Sync_OnlyHeaders)// sync = tr("None (only headers)");// // item->setText(1, sync );// // row++;// }// // }// // void MailboxSelector::accept()// {// QCheckListItem *item;// QListViewItemIterator it(view);// uint row = 0, localCopy = 0;// // for ( ; it.current(); ++it ) {// item = (QCheckListItem *) it.current();// if ( item->isOn() )// localCopy++;// }// // if ( localCopy == 0 && view->childCount() > 0 ) {// QString message = tr("<qt>No local copies? You must select the mailboxes you want to access mail from</qt>");// // switch( QMessageBox::warning( this, tr("Email"), message,// tr("I know"), tr("Whoops"), 0, 0, 1 ) ) {// // case 0: break;// case 1: return;// }// // }// // localCopy = 0;// it = view->firstChild();// for ( ; it.current(); ++it) {// item = (QCheckListItem *) it.current();// Mailbox *box = _account->getMailboxRef( item->text(0) );// if ( box ) {// box->setLocalCopy( item->isOn() );// if ( item->isOn() )// localCopy++;// // FolderSyncSetting fs = Sync_AllMessages;// QString sync = item->text(1);// if ( sync == tr("Only recent") ) {// fs = Sync_OnlyNew;// } else if ( sync == tr("None (only headers)") ) {// fs = Sync_OnlyHeaders;// }// box->setFolderSync( fs );// }// // row++;// }// // QDialog::accept();// }// // void MailboxSelector::selectAll()// {// QListViewItemIterator it(view);// for ( ; it.current(); ++it) {// ( (QCheckListItem *) it.current())->setOn(true);// }// }// // void MailboxSelector::clearAll()// {// QListViewItemIterator it(view);// for ( ; it.current(); ++it) {// ( (QCheckListItem *) it.current())->setOn(false);// }// }// // void MailboxSelector::itemSelected()// {// QListViewItem *item = view->selectedItem();// if ( item )// view->showMessageOptions();// }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?