示例#1
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());
}
示例#2
0
/// Remove content metadata for given content node. Caller should no longer
/// use the content node. This function also removes the content node
/// from its parent categories.
bool ContentManager::removeContentNode(ContentNode& info)
{
    // Remove the options.
    ContentOptions::removeOptions(*database_, info.id());

    // Remove from content category table, which also removes
    // from recent document list.
    ContentCategory::removeContentCategory(*database_, info.id());

    // Remove the content itself.
    ContentNode::removeContentNode(*database_, info);
    return true;
}
示例#3
0
bool ContentNode::updateContentNode(QSqlDatabase& database,
                                    const ContentNode & node)
{
    QSqlQuery query(database);
    query.prepare ("update content set "
                   " name = ?, location = ?, title = ?, authors = ?, "
                   " description = ?, last_access = ?, publisher = ?, md5 = ?, "
                   " size = ?, rating = ?, read_time = ?, read_count = ?, "
                   " progress = ?, attributes = ? "
                   " where id = ?");

    query.addBindValue(node.name());
    query.addBindValue(node.location());
    query.addBindValue(node.title());
    query.addBindValue(node.authors());
    query.addBindValue(node.description());
    query.addBindValue(node.last_access());
    query.addBindValue(node.publisher());

    query.addBindValue(node.md5());
    query.addBindValue(node.size());
    query.addBindValue(node.rating());
    query.addBindValue(node.read_time());
    query.addBindValue(node.read_count());

    query.addBindValue(node.progress());
    query.addBindValue(node.attributes());

    query.addBindValue(node.id());

    return query.exec();
}
示例#4
0
/// Remove child content from specified category.
bool ContentManager::removeChildContent(ContentCategory & category,
                                        const ContentNode & node)
{
    return ContentCategory::removeChildContent(*database_,
                                               category,
                                               node.id());
}
示例#5
0
/// Retrieve parent category id list that contains the content.
bool ContentManager::getParentCategories(const ContentNode &node,
                                         cms_ids & categories)
{
    return ContentCategory::getContentParentCategories(*database_,
                                                       node.id(),
                                                       categories);
}
示例#6
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;
}
示例#7
0
bool ContentNode::removeContentNode(QSqlDatabase& database,
                                    ContentNode& node)
{
    QSqlQuery query(database);
    query.prepare( "delete from content where id = ?");
    query.addBindValue(node.id());

    if (query.exec())
    {
        node.clear();
        return true;
    }
    return false;
}
示例#8
0
bool ContentManager::removeChildContent(ContentNode & node)
{
    // Retrieve parent categories from content_category table.
    return ContentCategory::removeChildContent(*database_, node.id());
}
示例#9
0
/// Add child content into specified category.
bool ContentManager::addChildContent(ContentCategory & category,
                                     const ContentNode & node)
{
    // Check it's already in the category or not.
    return ContentCategory::addChildContent(*database_, category, node.id());
}