Example #1
0
bool ContentManager::removeNote(const QString & name)
{
    // Remove from configuration.
    QString path = getSketchDB(name);
    ContentNode info;
    if (getContentNode(info, path, false))
    {
        removeContentNode(info);
    }

    // Remove index.
    if (!NotesManager::removeIndex(*database_, name))
    {
        qDebug() << "Failed to remove index";
        return false;
    }

    // Remove the database too.
    if (!QFile::remove(path))
    {
        qDebug() << "Failed to remove file: " << path;
        return false;
    }

    return true;
}
Example #2
0
bool ContentManager::addNoteIndex(const NoteInfo & note)
{
    QString path = getSketchDB(note.name());

    // Ensure note has been created.
    ContentNode info;
    getContentNode(info, path, true);

    return NotesManager::addIndex(*database_, note);
}
Example #3
0
bool ContentManager::addToRecentDocuments(const QString &doc_path)
{
    ContentNode node;
    getContentNode(node, doc_path);

    if (node.id() == CMS_INVALID_ID)
    {
        return false;
    }

    return addToRecentDocuments(node.id());
}
Example #4
0
bool ContentManager::removeRecentDocument(const QString &doc_path)
{
    ContentNode node;
    getContentNode(node, doc_path);

    if (node.id() == CMS_INVALID_ID)
    {
        return false;
    }

    if (!ContentCategory::removeChildContent(*database_,
                                             node.id()))
    {
        return false;
    }
    return true;
}
Example #5
0
void ContentManager::sortRecentDocuments(cms_ids & documents)
{
    ContentNodePtrs nodes;
    for(cms_ids_iter iter = documents.begin(); iter != documents.end(); ++iter)
    {
        ContentNode *node  = new ContentNode;
        getContentNode(*iter, *node);
        nodes.push_back(node);
    }

    std::sort(nodes.begin(), nodes.end(), LessByAccessTime());

    documents.clear();
    for(ContentNodePtrs::iterator iter = nodes.begin();
        iter != nodes.end();
        ++iter)
    {
        documents.push_back((*iter)->id());
        delete (*iter);
    }
}
Example #6
0
QString ContentManager::latestReading()
{
    QString path;
    cms_ids all;
    if (!getRecentDocuments(all))
    {
        return path;
    }

    if (all.size() <= 0)
    {
        return path;
    }

    ContentNode node;
    if (!getContentNode(all.front(), node))
    {
        return path;
    }

    return node.nativeAbsolutePath();
}