void KMail::ManageSieveScriptsDialog::slotRefresh()
{
    killAllJobs();
    mUrls.clear();
    mListView->clear();

    KMail::AccountManager *am = kmkernel->acctMgr();
    assert(am);
    QCheckListItem *last = 0;
    for(KMAccount *a = am->first() ; a ; a = am->next())
    {
        last = new QCheckListItem(mListView, last, a->name(), QCheckListItem::Controller);
        last->setPixmap(0, SmallIcon("server"));
        if(ImapAccountBase *iab = dynamic_cast<ImapAccountBase *>(a))
        {
            const KURL u = ::findUrlForAccount(iab);
            if(u.isEmpty())
                continue;
            SieveJob *job = SieveJob::list(u);
            connect(job, SIGNAL(item(KMail::SieveJob *, const QString &, bool)),
                    this, SLOT(slotItem(KMail::SieveJob *, const QString &, bool)));
            connect(job, SIGNAL(result(KMail::SieveJob *, bool, const QString &, bool)),
                    this, SLOT(slotResult(KMail::SieveJob *, bool, const QString &, bool)));
            mJobs.insert(job, last);
            mUrls.insert(last, u);
        }
        else
        {
            QListViewItem *item = new QListViewItem(last, i18n("No Sieve URL configured"));
            item->setEnabled(false);
            last->setOpen(true);
        }
    }
示例#2
0
void K3bVideoDVDRippingDialog::populateTitleView( const QValueList<int>& titles )
{
  m_w->m_titleView->clear();
  m_titleRipInfos.clear();

  QCheckListItem* titleItem = 0;
  for( QValueList<int>::const_iterator it = titles.begin(); it != titles.end(); ++it ) {
    titleItem = new QCheckListItem( m_w->m_titleView,
				    titleItem,
				    i18n("Title %1 (%2)")
				    .arg(*it)
				    .arg(m_dvd[*it-1].playbackTime().toString()),
				    QCheckListItem::RadioButtonController );
    titleItem->setText( 1, QString("%1x%2")
		       .arg(m_dvd[*it-1].videoStream().realPictureWidth())
		       .arg(m_dvd[*it-1].videoStream().realPictureHeight()) );
    titleItem->setText( 3, QString("%1 Title %2.avi").arg(m_dvd.volumeIdentifier()).arg(*it) );

    // now for the rip info
    K3bVideoDVDRippingJob::TitleRipInfo ri( *it );

    //
    // Determine default language selection:
    // first try the configured locale, if that fails, fall back to the first audio stream
    //
    ri.audioStream = 0;
    for( unsigned int i = 0; i < m_dvd[*it-1].numAudioStreams(); ++i ) {
      if( m_dvd[*it-1].audioStream(i).langCode() == KGlobal::locale()->language() &&
	  m_dvd[*it-1].audioStream(i).format() != K3bVideoDVD::AUDIO_FORMAT_DTS ) {
	ri.audioStream = i;
	break;
      }
    }

    QListViewItem* asI = 0;
    for( unsigned int i = 0; i < m_dvd[*it-1].numAudioStreams(); ++i ) {
      QString text = i18n("%1 %2Ch (%3%4)")
	.arg( K3bVideoDVD::audioFormatString( m_dvd[*it-1].audioStream(i).format() ) )
	.arg( m_dvd[*it-1].audioStream(i).channels() )
	.arg( m_dvd[*it-1].audioStream(i).langCode().isEmpty()
	      ? i18n("unknown language")
	      : KGlobal::locale()->twoAlphaToLanguageName( m_dvd[*it-1].audioStream(i).langCode() ) )
	.arg( m_dvd[*it-1].audioStream(i).codeExtension() != K3bVideoDVD::AUDIO_CODE_EXT_UNSPECIFIED
	      ? QString(" ") + K3bVideoDVD::audioCodeExtensionString( m_dvd[*it-1].audioStream(i).codeExtension() )
	      : QString::null );

      if( m_dvd[*it-1].audioStream(i).format() == K3bVideoDVD::AUDIO_FORMAT_DTS ) {
	// width of the radio button from QCheckListItem::paintCell
	int buttonSize = style().pixelMetric( QStyle::PM_CheckListButtonSize, m_w->m_titleView ) + 4;
	int spaceWidth = fontMetrics().width( ' ' );
	int numSpaces = buttonSize/spaceWidth;
	asI = new QListViewItem( titleItem, asI, QString().fill( ' ', numSpaces ) + text + " (" + i18n("not supported") + ")" );
      }
      else {
	asI = new AudioStreamViewItem( this, titleItem, asI, text, i );

	if( ri.audioStream == (int)i )
	  ((AudioStreamViewItem*)asI)->setState( QCheckListItem::On );
      }
    }

    titleItem->setOpen( true );

    m_titleRipInfos[titleItem] = ri;
  }
}