예제 #1
0
void CheckIndexingManager::initializeCollectionList(QAbstractItemModel *model, const QModelIndex &parentIndex)
{
    const int rowCount = model->rowCount(parentIndex);
    for (int row = 0; row < rowCount; ++row) {
        const QModelIndex index = model->index(row, 0, parentIndex);
        const Akonadi::Collection collection =
            model->data(
                index, Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();

        if (!collection.isValid() || MailCommon::Util::isVirtualCollection(collection)) {
            continue;
        }
        if (collection.hasAttribute<Akonadi::EntityHiddenAttribute>()) {
            continue;
        }
        if (PimCommon::Util::isImapResource(collection.resource()) && !collection.cachePolicy().localParts().contains(QLatin1String("RFC822"))) {
            continue;
        }
        if (!mCollectionsIndexed.contains(collection.id())) {
            mListCollection.append(collection);
        }
        if (model->rowCount(index) > 0) {
            initializeCollectionList(model, index);
        }
    }
}
void CollectionInternalsPage::load(const Akonadi::Collection & col)
{
  ui.idLabel->setText( QString::number( col.id() ) );
  ui.ridEdit->setText( col.remoteId() );
  ui.rrevEdit->setText( col.remoteRevision() );
  ui.resourceLabel->setText( col.resource() );
  ui.contentTypes->setItems( col.contentMimeTypes() );
  ui.virtCheck->setChecked( col.isVirtual() );
}
예제 #3
0
void CreateCommand::onTargetFetched(KJob *job)
{
  if (job->error()!=0)
  {
    emit error(ki18nc("@info:shell",
                      "Cannot fetch parent collection '%1', %2")
               .subs(mParentCollection)
               .subs(job->errorString()).toString());
    emit finished(RuntimeError);
    return;
  }

  Q_ASSERT(job==mResolveJob);
  Akonadi::Collection parentCollection = mResolveJob->collection();
  Q_ASSERT(parentCollection.isValid());

  // Warning for bug 319513
  if ((mNewCollectionName=="cur") || (mNewCollectionName=="new") || (mNewCollectionName=="tmp"))
  {
    QString parentResource = parentCollection.resource();
    if (parentResource.startsWith(QLatin1String("akonadi_maildir_resource")))
    {
      ErrorReporter::warning(i18n("Creating a maildir folder named '%1' may not work",
                                  mNewCollectionName));
    }
  }

  Akonadi::Collection newCollection;
  newCollection.setParentCollection(parentCollection);
  newCollection.setName(mNewCollectionName);
  newCollection.setContentMimeTypes(parentCollection.contentMimeTypes());
  if (!mDryRun)
  {
    CollectionCreateJob *createJob = new CollectionCreateJob(newCollection);
    connect(createJob, SIGNAL(result(KJob *)), this, SLOT(onCollectionCreated(KJob *)));
  }
예제 #4
0
void CollectionGeneralPage::init(const Akonadi::Collection &collection)
{
    QVBoxLayout *topLayout = new QVBoxLayout(this);

    QHBoxLayout *hbox = new QHBoxLayout();
    topLayout->addItem(hbox);

    QLabel *label = new QLabel(i18nc("@label:textbox Name of the folder.", "&Name:"), this);
    hbox->addWidget(label);

    mNameEdit = new QLineEdit(this);
    mNameEdit->setToolTip(
        i18nc("@info:tooltip", "Set the folder name"));
    mNameEdit->setWhatsThis(
        i18nc("@info:whatsthis",
              "Enter a name here to set the name of this folder."));
    label->setBuddy(mNameEdit);
    hbox->addWidget(mNameEdit);

    // should replies to mails in this folder be kept in this same folder?
    hbox = new QHBoxLayout();
    topLayout->addItem(hbox);

    mBlockAlarmsCheckBox = new QCheckBox(i18nc("@option:check", "Block reminders locally"), this);
    mBlockAlarmsCheckBox->setToolTip(
        i18nc("@info:tooltip", "Ignore reminders from this calendar"));
    mBlockAlarmsCheckBox->setWhatsThis(
        i18nc("@info:whatsthis",
              "Check this box if you do not want to receive reminders from items "
              "associated with this calendar."));
    hbox->addWidget(mBlockAlarmsCheckBox);

    hbox = new QHBoxLayout();
    topLayout->addItem(hbox);
    mIconCheckBox = new QCheckBox(i18nc("@option:check", "&Use custom icon:"), this);
    mIconCheckBox->setToolTip(
        i18nc("@info:tooltip", "Set a custom icon"));
    mIconCheckBox->setWhatsThis(
        i18nc("@info:whatsthis",
              "Check this box if you want to set a custom icon for this folder."));
    mIconButton = new KIconButton(this);
    mIconButton->setIconSize(16);
    hbox->addWidget(mIconCheckBox);
    hbox->addWidget(mIconButton);
    hbox->addStretch();

    if ((collection.parentCollection() != Akonadi::Collection::root()) && PimCommon::Util::isImapResource(collection.resource())) {
        const MailCommon::CollectionAnnotationsAttribute *annotationAttribute =
            collection.attribute<MailCommon::CollectionAnnotationsAttribute>();

        const QMap<QByteArray, QByteArray> annotations =
            (annotationAttribute ?
             annotationAttribute->annotations() :
             QMap<QByteArray, QByteArray>());

        MailCommon::CollectionTypeUtil collectionUtil;
        const MailCommon::CollectionTypeUtil::IncidencesFor incidencesFor =
            collectionUtil.incidencesForFromString(QLatin1String(annotations.value(MailCommon::CollectionTypeUtil::kolabIncidencesFor())));
        hbox = new QHBoxLayout();
        topLayout->addItem(hbox);
        mIncidencesForComboBox = new MailCommon::IncidencesForWidget(this);
        hbox->addWidget(mIncidencesForComboBox);

        mIncidencesForComboBox->setCurrentIndex(incidencesFor);
    }
    topLayout->addStretch(100);   // eat all superfluous space
}