示例#1
0
void FolderArchiveManager::slotCollectionRemoved(const Akonadi::Collection &collection)
{
    KConfig config(FolderArchive::FolderArchiveUtil::configFileName());
    mFolderArchiveCache->clearCacheWithContainsCollection(collection.id());
    Q_FOREACH (FolderArchiveAccountInfo *info, mListAccountInfo) {
        if (info->archiveTopLevel() == collection.id()) {
            info->setArchiveTopLevel(-1);
            KConfigGroup group = config.group(FolderArchive::FolderArchiveUtil::groupConfigPattern() + info->instanceName());
            info->writeConfig(group);
        }
    }
    load();
}
示例#2
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() );
}
示例#4
0
static Akonadi::Collection detatchCollection(const Akonadi::Collection &collection)
{
    //HACK: Attributes are accessed via a const function, and the implicitly shared private pointer thus doesn't detach.
    //We force a detach to avoid surprises. (RetrieveItemsTask used to write back the collection changes, even though the task was canceled)
    //Once this is fixed this function can go away.
    Akonadi::Collection col = collection;
    col.setId(col.id());
    return col;
}
Akonadi::Item::Id KMail::Util::putRepliesInSameFolder( const Akonadi::Item& item )
{
  Akonadi::Collection parentCollection = item.parentCollection();
  if ( parentCollection.isValid() ) {
    const QSharedPointer<FolderCollection> fd = FolderCollection::forCollection( parentCollection, false );
    if( fd->putRepliesInSameFolder() ) {
      return parentCollection.id();
    }
  }
  return -1;
}
示例#6
0
void EmptyTrashCommand::execute()
{
    if (!mFolder.isValid() && !mModel) {
        emitResult(Failed);
        return;
    }

    if (!mFolder.isValid()) {   //expunge all
        const QString title = i18n("Empty Trash");
        const QString text = i18n("Are you sure you want to empty the trash folders of all accounts?");
        if (KMessageBox::warningContinueCancel(nullptr, text, title,
                                               KStandardGuiItem::cont(), KStandardGuiItem::cancel(),
                                               QStringLiteral("confirm_empty_trash"))
            != KMessageBox::Continue) {
            emitResult(OK);
            return;
        }
        Akonadi::Collection trash = trashCollectionFolder();
        QVector<Akonadi::Collection> trashFolder;
        trashFolder << trash;

        const Akonadi::AgentInstance::List lst = agentInstances();
        for (const Akonadi::AgentInstance &type : lst) {
            if (type.identifier().contains(IMAP_RESOURCE_IDENTIFIER)) {
                if (type.status() == Akonadi::AgentInstance::Broken) {
                    continue;
                }
                OrgKdeAkonadiImapSettingsInterface *iface = Util::createImapSettingsInterface(type.identifier());
                if (iface->isValid()) {
                    const int trashImap = iface->trashCollection();
                    if (trashImap != trash.id()) {
                        trashFolder << Akonadi::Collection(trashImap);
                    }
                }
                delete iface;
            }
        }
        mNumberOfTrashToEmpty = trashFolder.count();
        for (int i = 0; i < mNumberOfTrashToEmpty; ++i) {
            expunge(trashFolder.at(i));
        }
    } else {
        if (folderIsTrash(mFolder)) {
            mNumberOfTrashToEmpty++;
            expunge(mFolder);
        } else {
            emitResult(OK);
        }
    }
}
QString KJotsLinkDialog::linkUrl() const
{
    if (hrefComboRadioButton->isChecked()){
        const QModelIndex index = hrefCombo->view()->currentIndex();
        const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
        if (collection.isValid()) {
          return "kjots://org.kjots.book/" + QString::number(collection.id());
        }
        const Akonadi::Item item = index.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
        Q_ASSERT(item.isValid());
        return "kjots://org.kjots.page/" + QString::number(item.id());
    } else {
        return linkUrlLineEdit->text();
    }
}
void TomboyNotesResource::retrieveItems(const Akonadi::Collection &collection)
{
    if (configurationNotValid()) {
        cancelTask(i18n("Resource configuration is not valid"));
        return;
    }

    // create the job
    auto job = new TomboyItemsDownloadJob(collection.id(), mManager, this);
    job->setAuthentication(Settings::requestToken(), Settings::requestTokenSecret());
    job->setServerURL(Settings::serverURL(), Settings::contentURL());
    // connect to its result() signal
    connect(job, &KJob::result, this, &TomboyNotesResource::onItemsRetrieved);
    job->start();
    qCDebug(log_tomboynotesresource) << "Retriving items job started";
}
示例#9
0
文件: eventid.cpp 项目: KDE/kdepim
/** Set by event ID and optional resource ID, in the format "[rid:]eid". */
EventId::EventId(const QString& resourceEventId)
{
    bool resourceOk = false;
    QRegExp rx(QStringLiteral("^\\w+:"));
    if (rx.indexIn(resourceEventId) == 0)
    {
        // A resource ID has been supplied, so use it
        int n = rx.matchedLength();
        Akonadi::Collection c = CollectionControlModel::collectionForResource(resourceEventId.left(n - 1));
        {
            first  = c.id();
            second = resourceEventId.mid(n);
            resourceOk = true;
        }
    }
    if (!resourceOk)
    {
        // Only an event ID has been supplied (or the syntax was invalid)
        first  = -1;
        second = resourceEventId;
    }
}
示例#10
0
bool EmptyTrashCommand::folderIsTrash(const Akonadi::Collection &col)
{
    if (col == Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::Trash)) {
        return true;
    }
    const Akonadi::AgentInstance::List lst = agentInstances();
    for (const Akonadi::AgentInstance &type : lst) {
        if (type.status() == Akonadi::AgentInstance::Broken) {
            continue;
        }
        if (type.identifier().contains(IMAP_RESOURCE_IDENTIFIER)) {
            OrgKdeAkonadiImapSettingsInterface *iface = Util::createImapSettingsInterface(type.identifier());
            if (iface->isValid()) {
                if (iface->trashCollection() == col.id()) {
                    delete iface;
                    return true;
                }
            }
            delete iface;
        }
    }
    return false;
}
void AggregationComboBox::readStorageModelConfig(const Akonadi::Collection &col, bool &isPrivateSetting)
{
    if (col.isValid()) {
        readStorageModelConfig(QString::number(col.id()), isPrivateSetting);
    }
}
示例#12
0
uint Akonadi::qHash(const Akonadi::Collection &collection)
{
    return ::qHash(collection.id());
}
示例#13
0
 bool isFavoriteCollection( const Akonadi::Collection &collection )
 {
   return mFavoriteCollectionMap.contains( collection.id() );
 }