本文整理汇总了C++中ContentNode::location方法的典型用法代码示例。如果您正苦于以下问题:C++ ContentNode::location方法的具体用法?C++ ContentNode::location怎么用?C++ ContentNode::location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentNode
的用法示例。
在下文中一共展示了ContentNode::location方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateContentNode
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();
}
示例2: createContentNode
bool ContentNode::createContentNode(QSqlDatabase& database,
ContentNode & node)
{
QSqlQuery query(database);
query.prepare ("insert into content "
"(name, location, title, authors, description, "
"last_access, publisher, md5, "
"size, rating, read_time, read_count, progress, attributes ) "
" values "
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
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());
if (query.exec())
{
node.id_ = query.lastInsertId().toInt();
return true;
}
return false;
}
示例3: getContentNode
/// TODO, need a better way to identify the file.
/// Lookup the file name.
/// Check the location.
/// File content hash. (Which part to hash and length).
bool ContentNode::getContentNode(QSqlDatabase & database,
ContentNode &node)
{
QSqlQuery query(database);
query.prepare( "select id, title, authors, description, "
"last_access, publisher, md5, "
"rating, read_time, read_count, progress, attributes "
"from content where name = :name and location = :location "
"and size = :size" );
query.bindValue(":name", node.name());
query.bindValue(":location", node.location());
query.bindValue(":size", node.size());
if (query.exec() && query.next())
{
int index = 0;
node.id_ = query.value(index++).toInt();
node.title_ = query.value(index++).toString();
node.mutable_authors() = query.value(index++).toString();
node.mutable_description() = query.value(index++).toString();
node.mutable_last_access() = query.value(index++).toString();
node.mutable_publisher() = query.value(index++).toString();
node.mutable_md5() = query.value(index++).toString();
node.mutable_rating() = query.value(index++).toInt();
node.mutable_read_time() = query.value(index++).toInt();
node.mutable_read_count() = query.value(index++).toInt();
node.mutable_progress() = query.value(index++).toString();
node.mutable_attributes() = query.value(index++).toByteArray();
return true;
}
return false;
}
示例4: updateContentNodeByUrl
/// Update content by url.
bool ContentNode::updateContentNodeByUrl(QSqlDatabase& database,
const ContentNode & node,
const QString & url)
{
// Check at first.
ContentNode tmp;
bool found = getContentNodeByUrl(database, url, tmp);
if (!found)
{
QSqlQuery query(database);
query.prepare ("INSERT into content "
" (name, location, title, authors, "
" description, last_access, publisher, md5, "
" size, rating, read_time, read_count, "
" progress, attributes) values "
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");
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(url);
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());
if (!query.exec())
{
qDebug() << query.lastError();
return false;
}
}
else
{
QSqlQuery query(database);
query.prepare ("update content set "
" name = ?, location = ?, title = ?, authors = ?, "
" description = ?, last_access = ?, publisher = ?, "
" size = ?, rating = ?, read_time = ?, read_count = ?, "
" progress = ?, attributes = ? "
" where md5 = ?");
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.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(url);
if (!query.exec())
{
qDebug() << query.lastError();
return false;
}
}
return true;
}
示例5: info
// Need to define the search policy.
// - Match the name, location and size.
// - Otherwise, we just ignore the request.
// - We can also use the hash code to match the file.
/// Query the content node in the specified database.
/// \param database The sqlitepp wrapper of database.
/// \param info The content node information returned by this function.
/// \param absolute_path The absolute path of the node.
/// \param create Create the content node automatically if not found.
/// \return This function returns true if the content node is already in
/// the database, otherwise it returns false.
bool
ContentNode::getContentNode(QSqlDatabase &database,
ContentNode & node,
const QString & absolute_path,
bool create)
{
// Initialize query parameters and initialize all stuff
// that does not rely on the database.
QFileInfo info(absolute_path);
node.mutable_size() = info.size();
node.mutable_location() = info.path();
node.mutable_name() = info.fileName();
// Query by name, location and size.
QSqlQuery query(database);
query.prepare( "select id, title, authors, description, "
"last_access, publisher, md5, "
"rating, read_time, read_count, progress, attributes "
"from content where name = :name and location = :location "
"and size = :size" );
query.bindValue(":name", node.name());
query.bindValue(":location", node.location());
query.bindValue(":size", node.size());
if (query.exec() && query.next())
{
int index = 0;
node.id_ = query.value(index++).toInt();
node.title_ = query.value(index++).toString();
node.mutable_authors() = query.value(index++).toString();
node.mutable_description() = query.value(index++).toString();
node.mutable_last_access() = query.value(index++).toString();
node.mutable_publisher() = query.value(index++).toString();
node.mutable_md5() = query.value(index++).toString();
node.mutable_rating() = query.value(index++).toInt();
node.mutable_read_time() = query.value(index++).toInt();
node.mutable_read_count() = query.value(index++).toInt();
node.mutable_progress() = query.value(index++).toString();
node.mutable_attributes() = query.value(index++).toByteArray();
return true;
}
// File has been moved, check the name and size.
/*
{
statement st(database);
st << "select id, title, authors, description, "
<< "last_access, publisher, md5, "
<< "rating, read_time, read_count "
<< "from content where name = :name and size = :size",
node.id_),
into(info.mutable_title()),
into(info.mutable_authors()),
into(info.mutable_description()),
into(info.mutable_last_access()),
into(info.mutable_publisher()),
into(info.mutable_md5()),
into(info.mutable_rating()),
into(info.mutable_read_time()),
into(info.mutable_read_count()),
use(info.name()),
use(info.size());
if (st.exec())
{
return true;
}
}
// File name has been changed, check the md5 only.
// Check if the md5 is ready or not. Make sure md5
// is calculated only once.
// TODO, maybe just ignore the node as it's not important.
if (info.md5().empty() &&
FileMd5Sum(absolute_path, info.mutable_md5()))
{
statement st(database);
st << "select id, title, authors, description, "
<< "last_access, publisher, "
<< "rating, read_time, read_count "
<< "from content where md5 = :md5",
into(info.id_),
into(info.mutable_title()),
into(info.mutable_authors()),
into(info.mutable_description()),
into(info.mutable_last_access()),
into(info.mutable_publisher()),
into(info.mutable_rating()),
into(info.mutable_read_time()),
//.........这里部分代码省略.........