-rw-r--r-- | noncore/unsupported/mail2/addresspicker.cpp | 10 | ||||
-rw-r--r-- | noncore/unsupported/mail2/attachdiag.cpp | 10 | ||||
-rw-r--r-- | noncore/unsupported/mail2/configdiag.cpp | 21 | ||||
-rw-r--r-- | noncore/unsupported/mail2/rename.cpp | 28 |
4 files changed, 35 insertions, 34 deletions
diff --git a/noncore/unsupported/mail2/addresspicker.cpp b/noncore/unsupported/mail2/addresspicker.cpp index 178fe27..7f32725 100644 --- a/noncore/unsupported/mail2/addresspicker.cpp +++ b/noncore/unsupported/mail2/addresspicker.cpp @@ -11,107 +11,107 @@ #include "addresspicker.h" AddressPicker::AddressPicker(QWidget *parent, const char *name, bool modal, WFlags fl) : AddressPickerBase(parent, name, modal, fl) { okButton->setIconSet(Resource::loadPixmap("enter")); cancelButton->setIconSet(Resource::loadPixmap("editdelete")); connect(okButton, SIGNAL(clicked()), SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), SLOT(close())); QFile f((QString) getenv("HOME") + "/Applications/" + "addressbook/addressbook.xml"); if (f.open(IO_ReadOnly)) { QTextStream stream(&f); QString content; while (!f.atEnd()) content += stream.readLine() + "\n"; QStringList lines = QStringList::split(QRegExp("\\n"), content); QStringList::Iterator it; for (it = lines.begin(); it != lines.end(); it++) { if ((*it).find(QRegExp("^<Contact.*")) != -1) { int pos = (*it).find("FirstName=\""); QString fname; if (pos != -1) { int i = 1; QChar c; while (c != '"') { c = (*it)[pos + 10 + i]; if (c != '"') fname += c; i++; } } pos = (*it).find("LastName=\""); QString lname; if (pos != -1) { int i = 1; QChar c; while (c != '"') { c = (*it)[pos + 9 + i]; if (c != '"') lname += c; i++; } } pos = (*it).find("DefaultEmail=\""); QString email; if (pos != -1) { int i = 1; QChar c; while (c != '"') { c = (*it)[pos + 13 + i]; if (c != '"') email += c; i++; } } QString tname, temail; if (!fname.isEmpty()) tname += fname; if (!lname.isEmpty()) tname += fname.isEmpty() ? lname : (" " + lname); if (!email.isEmpty()) temail += tname.isEmpty() ? email : (" <" + email + ">"); if (!email.isEmpty()) addressList->insertItem(tname + temail); } } } if (addressList->count() <= 0) { addressList->insertItem(tr("There are no entries in the addressbook.")); addressList->setEnabled(false); okButton->setEnabled(false); } } void AddressPicker::accept() { QListBoxItem *item = addressList->firstItem(); QString names; while (item) { if (item->selected()) names += item->text() + ", "; item = item->next(); } names.replace(names.length() - 2, 2, ""); if (names.isEmpty()) { QMessageBox::information(this, tr("Error"), tr("<p>You have to select" " at least one address entry.</p>"), tr("Ok")); return; } selectedNames = names; QDialog::accept(); } QString AddressPicker::getNames() { QString names = 0; - AddressPicker *picker = new AddressPicker(0, 0, true); - picker->showMaximized(); - picker->show(); + AddressPicker picker(0, 0, true); + picker.showMaximized(); + picker.show(); - int ret = picker->exec(); + int ret = picker.exec(); if (QDialog::Accepted == ret) { - return picker->selectedNames; + return picker.selectedNames; } return 0; } diff --git a/noncore/unsupported/mail2/attachdiag.cpp b/noncore/unsupported/mail2/attachdiag.cpp index bedf3c4..36e1948 100644 --- a/noncore/unsupported/mail2/attachdiag.cpp +++ b/noncore/unsupported/mail2/attachdiag.cpp @@ -1,71 +1,71 @@ #include <qmessagebox.h> #include <qpushbutton.h> #include <qlistbox.h> #include <qlayout.h> #include <qpe/fileselector.h> #include <qpe/resource.h> #include <stdlib.h> #include "attachdiag.h" AttachDiag::AttachDiag(QWidget* parent = 0, const char* name = 0, bool modal, WFlags fl = 0) : QDialog(parent, name, modal, fl) { setCaption(tr("Attach File")); QGridLayout *layout = new QGridLayout(this); layout->setSpacing(3); layout->setMargin(4); FileSelector *fileSelector = new FileSelector("*", this, "FileSelector"); fileSelector->setCloseVisible(false); fileSelector->setNewVisible(false); layout->addMultiCellWidget(fileSelector, 0, 0, 0, 1); QPushButton *attachButton = new QPushButton(this); attachButton->setText(tr("Ok")); attachButton->setIconSet(Resource::loadPixmap("enter")); layout->addWidget(attachButton, 1, 0); QPushButton *cancelButton = new QPushButton(this); cancelButton->setText(tr("Cancel")); cancelButton->setIconSet(Resource::loadPixmap("editdelete")); layout->addWidget(cancelButton, 1, 1); connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), SLOT(fileSelected(const DocLnk &))); connect(attachButton, SIGNAL(clicked()), SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), SLOT(close())); if (fileSelector->selected() != NULL) currentFile = *fileSelector->selected(); if (fileSelector->fileCount() == 0) { attachButton->setEnabled(false); fileSelector->setEnabled(false); } } void AttachDiag::fileSelected(const DocLnk &file) { currentFile = file; } DocLnk AttachDiag::getFile(QWidget *parent) { - AttachDiag *attach = new AttachDiag(parent, 0, true); - attach->showMaximized(); - attach->show(); + AttachDiag attach(parent, 0, true); + attach.showMaximized(); + attach.show(); - if (QDialog::Accepted == attach->exec()) { - return attach->currentFile; + if (QDialog::Accepted == attach.exec()) { + return attach.currentFile; } return DocLnk(); } diff --git a/noncore/unsupported/mail2/configdiag.cpp b/noncore/unsupported/mail2/configdiag.cpp index be1f1f4..b89b937 100644 --- a/noncore/unsupported/mail2/configdiag.cpp +++ b/noncore/unsupported/mail2/configdiag.cpp @@ -1,144 +1,145 @@ #include <qmessagebox.h> #include <qpushbutton.h> #include <qtoolbutton.h> #include <qgroupbox.h> #include <qcheckbox.h> #include <qspinbox.h> #include <qheader.h> #include <qtimer.h> #include <qlabel.h> #include <qpe/resource.h> #include <qpe/config.h> #include "accounteditor.h" #include "zaurusstuff.h" #include "configdiag.h" #include "defines.h" AccountListItem::AccountListItem(QListView *parent, Account &account) : QListViewItem(parent), _account(account) { QString displayText; if (!_account.realName().isEmpty() && !_account.email().isEmpty()) setText(0, _account.realName() + " <" + _account.email() + ">"); else if (_account.realName().isEmpty() && !_account.email().isEmpty()) setText(0, _account.email()); else if (!_account.realName().isEmpty() && _account.email().isEmpty()) setText(0, _account.realName()); else setText(0, QObject::tr("(no name)")); setPixmap(0, Resource::loadPixmap("mail/inbox")); } ConfigDiag::ConfigDiag(QWidget *parent, const char *name, bool modal, WFlags fl) : ConfigDiagBase(parent, name, modal, fl) { _configBenD = new Config("mail"); _configBenD->setGroup("Settings"); disabled->setChecked(_configBenD->readBoolEntry("Disabled", false)); playSound->setChecked(_configBenD->readBoolEntry("PlaySound", false)); blinkLed->setChecked(_configBenD->readBoolEntry("BlinkLed", true)); checkDelay->setValue(_configBenD->readNumEntry("CheckDelay", 5)); accountList->header()->hide(); disclaimer->setText(disclaimer->text().arg(VERSION)); connect(accountNew, SIGNAL(clicked()), SLOT(slotNewAccount())); connect(accountEdit, SIGNAL(clicked()), SLOT(slotEditAccount())); connect(accountDelete, SIGNAL(clicked()), SLOT(slotDelAccount())); connect(testbutton, SIGNAL(clicked()), SLOT(slotTestSettings())); slotFillLists(); } void ConfigDiag::accept() { _configBenD->setGroup("Settings"); _configBenD->writeEntry("Disabled", disabled->isChecked()); _configBenD->writeEntry("PlaySound", playSound->isChecked()); _configBenD->writeEntry("BlinkLed", blinkLed->isChecked()); _configBenD->writeEntry("CheckDelay", checkDelay->value()); _configBenD->write(); QDialog::accept(); } void ConfigDiag::slotFillLists() { accountList->clear(); QValueList<Account> accounts = ConfigFile::getAccounts(); QValueList<Account>::Iterator it; for (it = accounts.begin(); it != accounts.end(); it++) (void) new AccountListItem(accountList, *it); } void ConfigDiag::slotNewAccount() { - AccountEditor *editor = new AccountEditor(Account(), 0, 0, true); - editor->showMaximized(); - editor->show(); + Account account; + AccountEditor editor(account, 0, 0, true); + editor.showMaximized(); + editor.show(); - if (QDialog::Accepted == editor->exec()) { - ConfigFile::updateAccount(editor->_account); + if (QDialog::Accepted == editor.exec()) { + ConfigFile::updateAccount(editor._account); slotFillLists(); emit changed(); } } void ConfigDiag::slotEditAccount() { if (!accountList->currentItem()) { QMessageBox::information(this, tr("Error"), tr("<p>You have to select an account first.</p>"), tr("Ok")); return; } Account account = ((AccountListItem *)accountList->currentItem())->account(); - AccountEditor *editor = new AccountEditor(account, 0, 0, true); - editor->showMaximized(); - editor->show(); + AccountEditor editor(account, 0, 0, true); + editor.showMaximized(); + editor.show(); - if (QDialog::Accepted == editor->exec()) { - ConfigFile::updateAccount(editor->_account); + if (QDialog::Accepted == editor.exec()) { + ConfigFile::updateAccount(editor._account); slotFillLists(); emit changed(); } } void ConfigDiag::slotDelAccount() { if (!accountList->currentItem()) { QMessageBox::information(this, tr("Error"), tr("<p>You have to select an account first.</p>"), tr("Ok")); return; } Account account = ((AccountListItem *)accountList->currentItem())->account(); int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you relly want to delete the selected account?</p>"), tr("Yes"), tr("No")); if (1 == ret) return; ConfigFile::deleteAccount(account); slotFillLists(); emit changed(); } void ConfigDiag::slotTestSettings() { testbutton->setEnabled(false); if (blinkLed->isChecked()) ZaurusStuff::blinkLedOn(); if (playSound->isChecked()) ZaurusStuff::buzzerOn(); QTimer::singleShot(3000, this, SLOT(slotEndTest())); } void ConfigDiag::slotEndTest() { if (playSound->isChecked()) ZaurusStuff::buzzerOff(); if (blinkLed->isChecked()) ZaurusStuff::blinkLedOff(); testbutton->setEnabled(true); } diff --git a/noncore/unsupported/mail2/rename.cpp b/noncore/unsupported/mail2/rename.cpp index 8c2fde1..627db0b 100644 --- a/noncore/unsupported/mail2/rename.cpp +++ b/noncore/unsupported/mail2/rename.cpp @@ -1,39 +1,39 @@ #include <qlineedit.h> #include <qlabel.h> #include "rename.h" Rename::Rename(QWidget *parent, const char *name, bool modal, WFlags fl) : RenameBase(parent, name, modal, fl) { } QString Rename::rename(const QString &on, QWidget *parent) { - Rename *rename = new Rename(parent, 0, true); - rename->oldName->setText(on); - rename->newName->setText(on); - rename->newName->setFocus(); + Rename rename(parent, 0, true); + rename.oldName->setText(on); + rename.newName->setText(on); + rename.newName->setFocus(); - if (rename->exec() == QDialog::Accepted) { - return rename->newName->text(); + if (rename.exec() == QDialog::Accepted) { + return rename.newName->text(); } return QString(0); } QString Rename::getText(const QString &caption, const QString &secondLabel, QWidget *parent) { - Rename *rename = new Rename(parent, 0, true); - rename->firstLabel->hide(); - rename->oldName->hide(); - rename->setCaption(caption); - rename->secondLabel->setText(secondLabel); - - if (rename->exec() == QDialog::Accepted) { - return rename->newName->text(); + Rename rename(parent, 0, true); + rename.firstLabel->hide(); + rename.oldName->hide(); + rename.setCaption(caption); + rename.secondLabel->setText(secondLabel); + + if (rename.exec() == QDialog::Accepted) { + return rename.newName->text(); } return QString(0); } |