Source Code (Use browser search to find items of interest.)

Class Index

kmail'KMAccountSettings (./kdenetwork/kmail/kmsettings.h:113)

class KMAccountSettings : public QDialog
{
  Q_OBJECT

public:
  KMAccountSettings(QWidget *parent=0,const char *name=0,KMAccount *a=NULL);

protected slots:
 void accept();

private slots:
  void chooseLocation();
  void slotIntervalChange();

private:
  QLineEdit *mEdtName, *mEdtLocation, *mEdtLogin, *mEdtPasswd, *mEdtHost;
  QLineEdit *mEdtPort, *mChkInt;
  QComboBox *mFolders;
  KMAccount *mAcct;
  QCheckBox *mStorePasswd, *mChkDelete, *mChkInterval, *mChkExclude;
  QCheckBox *mChkRetrieveAll;
};

kmail'KMAccountSettings::KMAccountSettings() (./kdenetwork/kmail/kmsettings.cpp:1431)

KMAccountSettings::KMAccountSettings(QWidget *parent, const char *name,
				     KMAccount *aAcct):
  QDialog(parent,name,TRUE)
{
  QGridLayout *grid;
  QPushButton *btnDetail, *ok, *cancel;
  QString acctType;
  QWidget *btnBox;
  QLabel *lbl;
  KMFolder *folder, *acctFolder;
  KMFolderDir* fdir = (KMFolderDir*)&kernel->folderMgr()->dir();
  int i;

  initMetaObject();

  assert(aAcct != NULL);

  mAcct=aAcct;
  setCaption(name);

  acctType = mAcct->type();

  setCaption("Configure Account");
  grid = new QGridLayout(this, 19, 3, 8, 4);
  grid->setColStretch(1, 5);

  lbl = new QLabel(i18n("Type:"), this);
  lbl->adjustSize();
  lbl->setMinimumSize(lbl->sizeHint());
  grid->addWidget(lbl, 0, 0);

  lbl = new QLabel(this);
  grid->addWidget(lbl, 0, 1);

  mEdtName = createLabeledEntry(this, grid, i18n("Name:"),
				mAcct->name(), 1, 0);

  if (acctType == "local")
  {
    QString tmpStr;
    lbl->setText(i18n("Local Account"));

    mEdtLocation = createLabeledEntry(this, grid, i18n("Location:"),
				      ((KMAcctLocal*)mAcct)->location(),
				      2, 0, &btnDetail);
    tmpStr.sprintf("%u", ((KMAccount*)mAcct)->checkInterval());
    mChkInt = createLabeledEntry(this, grid, i18n("Check interval(minutes):"),
				 tmpStr, 6, 0);
    if (((KMAccount*)mAcct)->checkInterval() < 1) {
      mChkInt->setEnabled(false);
    }

    connect(btnDetail,SIGNAL(clicked()), SLOT(chooseLocation()));
  }
  else if ((acctType == "pop") || (acctType == "experimental pop"))
  {
    lbl->setText(i18n("Pop Account"));
    if (acctType == "experimental pop")
      lbl->setText(i18n("Experimental Pop Account"));

    mEdtLogin = createLabeledEntry(this, grid, i18n("Login:"),
				   ((KMAcctPop*)mAcct)->login(), 2, 0);

    mEdtPasswd = createLabeledEntry(this, grid, i18n("Password:"),
				    ((KMAcctPop*)mAcct)->passwd(), 3, 0);
    mEdtPasswd->setEchoMode(QLineEdit::Password);

    mEdtHost = createLabeledEntry(this, grid, i18n("Host:"),
				  ((KMAcctPop*)mAcct)->host(), 4, 0);

    QString tmpStr;
    tmpStr.sprintf("%u",((KMAcctPop*)mAcct)->port());
    mEdtPort = createLabeledEntry(this, grid, i18n("Port:"),
				  tmpStr, 5, 0);
    tmpStr.sprintf("%u", ((KMAccount*)mAcct)->checkInterval());
    mChkInt = createLabeledEntry(this, grid, i18n("Check interval(minutes):"),
                                  tmpStr, 6, 0);
    if (((KMAccount*)mAcct)->checkInterval() < 1) {
       mChkInt->setEnabled(false);
    }
    // The range on this validator is 1..0xFFFF which should be fine for
    // both fields.
    mEdtPort->setValidator(&intValidator);
    mChkInt->setValidator(&intValidator);

    mStorePasswd = new QCheckBox(i18n("Store POP password in config file"), this);
    mStorePasswd->setMinimumSize(mStorePasswd->sizeHint());
    mStorePasswd->setChecked(((KMAcctPop*)mAcct)->storePasswd());
    grid->addMultiCellWidget(mStorePasswd, 7, 7, 1, 2);

    mChkDelete = new QCheckBox(i18n("Delete mail from server"), this);
    mChkDelete->setMinimumSize(mChkDelete->sizeHint());
    mChkDelete->setChecked(!((KMAcctPop*)mAcct)->leaveOnServer());
    grid->addMultiCellWidget(mChkDelete, 8, 8, 1, 2);

    mChkRetrieveAll=new QCheckBox(i18n("Retrieve all mail from server"), this);
    mChkRetrieveAll->setMinimumSize(mChkRetrieveAll->sizeHint());
    mChkRetrieveAll->setChecked(((KMAcctPop*)mAcct)->retrieveAll());
    grid->addMultiCellWidget(mChkRetrieveAll, 9, 9, 1, 2);

  }
  else 
  {
    KMessageBox::information(0,i18n("KMAccountSettings: "
				    "unsupported account type"));
    return;
  }

  mChkInterval = new QCheckBox(i18n("Enable interval Mail checking"), this);
  mChkInterval->setMinimumSize(mChkInterval->sizeHint());
  mChkInterval->setChecked(mAcct->checkInterval() > 0);
  connect(mChkInterval,SIGNAL(clicked()),SLOT(slotIntervalChange()));
  grid->addMultiCellWidget(mChkInterval, 10, 10, 1, 2);

  mChkExclude = new QCheckBox(i18n("Exclude from \"Check Mail\""), this);
  mChkExclude->setMinimumSize(mChkExclude->sizeHint());
  mChkExclude->setChecked(mAcct->checkExclude());
  grid->addMultiCellWidget(mChkExclude, 11, 11, 1, 2);

  // label with "Local Account" or "Pop Account" created previously
  lbl->adjustSize();
  lbl->setMinimumSize(lbl->sizeHint());


  lbl = new QLabel(i18n("Store new mail in account:"), this);
  lbl->adjustSize();
  lbl->setMinimumSize(lbl->sizeHint());
  grid->addMultiCellWidget(lbl, 12, 12, 0, 2);

  // combobox of all folders with current account folder selected
  acctFolder = mAcct->folder();
  if (acctFolder == 0)
  {
    acctFolder = (KMFolder*)fdir->first();
  }  
  mFolders = new QComboBox(this);
  if (acctFolder == 0)
  {
    mFolders->insertItem(i18n("<none>"));
  }
  else for (i=0, folder=(KMFolder*)fdir->first(); 
  	    folder; 
            folder=(KMFolder*)fdir->next())
  {
    if (folder->isDir() || folder->isSystemFolder()) continue;
    mFolders->insertItem(folder->name());
    if (folder == acctFolder) mFolders->setCurrentItem(i);
    i++;
  }
  mFolders->adjustSize();
  mFolders->setMinimumSize(100, mEdtName->minimumSize().height());
  mFolders->setMaximumSize(500, mEdtName->minimumSize().height());
  grid->addWidget(mFolders, 13, 1);


  // buttons at bottom
  btnBox = new QWidget(this);
  ok = new QPushButton(i18n("OK"), btnBox);
  ok->adjustSize();
  ok->setMinimumSize(ok->sizeHint());
  ok->resize(100, ok->size().height());
  ok->move(10, 5);
  connect(ok, SIGNAL(clicked()), SLOT(accept()));

  cancel = new QPushButton(i18n("Cancel"), btnBox);
  cancel->adjustSize();
  cancel->setMinimumSize(cancel->sizeHint());
  cancel->resize(100, cancel->size().height());
  cancel->move(120, 5);
  connect(cancel, SIGNAL(clicked()), SLOT(reject()));

  btnBox->setMinimumSize(230, ok->size().height()+10);
  btnBox->setMaximumSize(2048, ok->size().height()+10);
  grid->addMultiCellWidget(btnBox, 16, 16, 0, 2);

  resize(350,350);
  grid->activate();
  adjustSize();
  setMinimumSize(size());
}


//-----------------------------------------------------------------------------

kmail'KMAccountSettings::chooseLocation() (./kdenetwork/kmail/kmsettings.cpp:1614)

void KMAccountSettings::chooseLocation()
{
  static QString sSelLocation( "/" );
  
  KFileDialog fdlg( sSelLocation, "*", this, NULL, TRUE );
  fdlg.setCaption(i18n("Choose Location"));

  bool result = fdlg.exec();

  KURL url = fdlg.selectedURL();
  
  if( url.isEmpty() )
    return;
  
  if( !url.isLocalFile() )
  {
    KMessageBox::sorry( 0L, i18n( "Only local files supported yet." ) );
    return;
  }
  
  if( result )
    mEdtLocation->setText( url.path() );
  
  sSelLocation = url.directory();
}

//-----------------------------------------------------------------------------

kmail'KMAccountSettings::accept() (./kdenetwork/kmail/kmsettings.cpp:1641)

void KMAccountSettings::accept()
{
  QString acctType = mAcct->type();
  KMFolder* fld;
  int id;

  if (mEdtName->text() != mAcct->name())
  {
    mAcct->setName(mEdtName->text());
  }

  id = mFolders->currentItem();
  fld = kernel->folderMgr()->find(mFolders->currentText());
  mAcct->setFolder((KMFolder*)fld);

  int _ChkInt = atoi(mChkInt->text());
  if (_ChkInt < 1)
     _ChkInt = ((KMAccount*)mAcct)->defaultCheckInterval();
  mAcct->setCheckInterval(mChkInterval->isChecked() ? _ChkInt : 0);
  mAcct->setCheckExclude(mChkExclude->isChecked());

  if (acctType == "local")
  {
    ((KMAcctLocal*)mAcct)->setLocation(mEdtLocation->text());
  }

  else if (acctType == "pop")
  {
    ((KMAcctPop*)mAcct)->setHost(mEdtHost->text());
    ((KMAcctPop*)mAcct)->setPort(atoi(mEdtPort->text()));
    ((KMAcctPop*)mAcct)->setLogin(mEdtLogin->text());
    ((KMAcctPop*)mAcct)->setPasswd(mEdtPasswd->text(), true);
    ((KMAcctPop*)mAcct)->setStorePasswd(mStorePasswd->isChecked());
    ((KMAcctPop*)mAcct)->setPasswd(mEdtPasswd->text(),
                 ((KMAcctPop*)mAcct)->storePasswd());
    ((KMAcctPop*)mAcct)->setLeaveOnServer(!mChkDelete->isChecked());
    ((KMAcctPop*)mAcct)->setRetrieveAll(mChkRetrieveAll->isChecked());
  }

  else if (acctType == "experimental pop")
  {
    ((KMAcctExpPop*)mAcct)->setHost(mEdtHost->text());
    ((KMAcctExpPop*)mAcct)->setPort(atoi(mEdtPort->text()));
    ((KMAcctExpPop*)mAcct)->setLogin(mEdtLogin->text());
    ((KMAcctExpPop*)mAcct)->setPasswd(mEdtPasswd->text(), true);
    ((KMAcctExpPop*)mAcct)->setStorePasswd(mStorePasswd->isChecked());
    ((KMAcctExpPop*)mAcct)->setPasswd(mEdtPasswd->text(),
                 ((KMAcctExpPop*)mAcct)->storePasswd());
    ((KMAcctExpPop*)mAcct)->setLeaveOnServer(!mChkDelete->isChecked());
    ((KMAcctExpPop*)mAcct)->setRetrieveAll(mChkRetrieveAll->isChecked());
  }

  kernel->acctMgr()->writeConfig(TRUE);

  QDialog::accept();
}



//-----------------------------------------------------------------------------

kmail'KMAccountSettings::slotIntervalChange() (./kdenetwork/kmail/kmsettings.cpp:1701)

void KMAccountSettings::slotIntervalChange()
{
  if (mChkInterval->isChecked()) {
      int _ChkInt = atoi(mChkInt->text());
      if (_ChkInt < 1)
         mChkInt->setText(QString("5"));      
      mChkInt->setEnabled(true);
  } else mChkInt->setEnabled(false);
}