コード例 #1
0
ファイル: addresseditwidget.cpp プロジェクト: lenggi/kcalcore
void AddressEditWidget::editAddress()
{
  AutoQPointer<AddressEditDialog> dialog = new AddressEditDialog( this );
  dialog->setAddress( mAddressSelectionWidget->currentAddress() );
  if ( dialog->exec() ) {
    const KABC::Address address = dialog->address();
    fixPreferredAddress( address );
    mAddressList[ mAddressSelectionWidget->currentIndex() ] = address;
    mAddressSelectionWidget->setAddresses( mAddressList );
    mAddressSelectionWidget->setCurrentAddress( address );

    updateAddressView();
  }
}
コード例 #2
0
ファイル: addresseditwidget.cpp プロジェクト: lenggi/kcalcore
void AddressEditWidget::createAddress()
{
  AutoQPointer<AddressEditDialog> dialog = new AddressEditDialog( this );
  if ( dialog->exec() ) {
    const KABC::Address address = dialog->address();
    fixPreferredAddress( address );
    mAddressList.append( address );
    mAddressSelectionWidget->setAddresses( mAddressList );
    mAddressSelectionWidget->setCurrentAddress( address );

    updateAddressView();
    updateButtons();
  }
}
コード例 #3
0
ファイル: addresseditwidget.cpp プロジェクト: lenggi/kcalcore
void AddressTypeCombo::otherSelected()
{
  AutoQPointer<AddressTypeDialog> dlg = new AddressTypeDialog( mType, this );
  if ( dlg->exec() ) {
    mType = dlg->type();
    if ( !mTypeList.contains( mType ) ) {
      mTypeList.insert( mTypeList.at( mTypeList.count() - 1 ), mType );
    }
  } else {
    setType( KABC::Address::Type( mTypeList.at( mLastSelected ) ) );
  }

  update();
}
コード例 #4
0
ファイル: emaileditwidget.cpp プロジェクト: lenggi/kcalcore
void EmailEditWidget::edit()
{
  AutoQPointer<EmailEditDialog> dlg = new EmailEditDialog( mEmailList, this );

  if ( dlg->exec() ) {
    if ( dlg->changed() ) {
      mEmailList = dlg->emails();
      if ( !mEmailList.isEmpty() ) {
        mEmailEdit->setText( mEmailList.first() );
      } else {
        mEmailEdit->setText( QString() );
      }
    }
  }
}
コード例 #5
0
QString FileDialog::getSaveFileName(const KUrl& dir, const QString& filter, QWidget* parent, const QString& caption, bool* append)
{
    bool defaultDir = dir.isEmpty();
    bool specialDir = !defaultDir && dir.protocol() == "kfiledialog";
    // Use AutoQPointer to guard against crash on application exit while
    // the dialogue is still open. It prevents double deletion (both on
    // deletion of parent, and on return from this function).
    AutoQPointer<FileDialog> dlg = new FileDialog(specialDir ? dir : KUrl(), filter, parent);
    if (!specialDir && !defaultDir)
    {
        if (!dir.isLocalFile())
            kWarning() << "FileDialog::getSaveFileName called with non-local start dir " << dir;
        dlg->setSelection(dir.isLocalFile() ? dir.toLocalFile() : dir.path());  // may also be a filename
    }
    dlg->setOperationMode(Saving);
    dlg->setMode(KFile::File | KFile::LocalOnly);
    dlg->setConfirmOverwrite(true);
    if (!caption.isEmpty())
        dlg->setCaption(caption);
    mAppendCheck = 0;
    if (append)
    {
        // Show an 'append' option in the dialogue.
        // Note that the dialogue will take ownership of the QCheckBox.
        mAppendCheck = new QCheckBox(i18nc("@option:check", "Append to existing file"), 0);
        connect(mAppendCheck, SIGNAL(toggled(bool)), dlg, SLOT(appendToggled(bool)));
        dlg->fileWidget()->setCustomWidget(mAppendCheck);
        *append = false;
    }
    dlg->setWindowModality(Qt::WindowModal);
    dlg->exec();
    if (!dlg)
        return QString();   // dialogue was deleted

    QString filename = dlg->selectedFile();
    if (!filename.isEmpty())
    {
        if (append)
            *append = mAppendCheck->isChecked();
        KRecentDocument::add(filename);
    }
    return filename;
}
コード例 #6
0
/******************************************************************************
* Called when the file picker button is clicked.
*/
void SoundPicker::slotPickFile()
{
    KUrl oldfile = mFile;
    // Use AutoQPointer to guard against crash on application exit while
    // the dialogue is still open. It prevents double deletion (both on
    // deletion of EditAlarmDlg, and on return from this function).
    AutoQPointer<SoundDlg> dlg = new SoundDlg(mFile.prettyUrl(), mVolume, mFadeVolume, mFadeSeconds, mRepeatPause, i18nc("@title:window", "Sound File"), this);
    dlg->setReadOnly(mReadOnly);
    bool accepted = (dlg->exec() == QDialog::Accepted);
    if (mReadOnly)
        return;
    if (accepted)
    {
        float volume, fadeVolume;
        int   fadeTime;
        dlg->getVolume(volume, fadeVolume, fadeTime);
        KUrl file    = dlg->getFile();
        if (!file.isEmpty())
            mFile    = file;
        mRepeatPause = dlg->repeatPause();
        mVolume      = volume;
        mFadeVolume  = fadeVolume;
        mFadeSeconds = fadeTime;
    }
    if (mFile.isEmpty())
    {
        // No audio file is selected, so revert to previously selected option
#if 0
// Remove mRevertType, setLastType(), #include QTimer
        // But wait a moment until setting the radio button, or it won't work.
        mRevertType = true;   // prevent sound dialog popping up twice
        QTimer::singleShot(0, this, SLOT(setLastType()));
#else
        mTypeCombo->setCurrentIndex(indexes[mLastType]);
#endif
        mTypeCombo->setToolTip(QString());
    }
    else
        mTypeCombo->setToolTip(mFile.prettyUrl());
    if (accepted  ||  mFile != oldfile)
        emit changed();
}