The previous patch affected the copyright somehow so i am sending a new one.
- Smit Shah (My real name)
diff --git a/querymodel.cpp b/querymodel.cpp
index d78a865..5679e56 100644
--- a/querymodel.cpp
+++ b/querymodel.cpp
@@ -37,13 +37,13 @@
namespace {
-void splitUri( const QUrl& uri, QUrl& ns, QString& name )
-{
- const QString uriStr = uri.toString();
- const int i = uriStr.lastIndexOf( QRegExp(QLatin1String("[/#]")) ) + 1;
- ns = uriStr.left( i );
- name = uriStr.mid( i );
-}
+ void splitUri( const QUrl& uri, QUrl& ns, QString& name )
+ {
+ const QString uriStr = uri.toString();
+ const int i = uriStr.lastIndexOf( QRegExp(QLatin1String("[/#]")) ) + 1;
+ ns = uriStr.left( i );
+ name = uriStr.mid( i );
+ }
}
class Nepomuk::QueryModel::Private
@@ -108,13 +108,13 @@ QString Nepomuk::QueryModel::Private::resourceToString(const QUrl &uri) const
Nepomuk::QueryModel::QueryModel( QObject* parent )
: QAbstractTableModel( parent ),
- d(new Private( this ))
+ d(new Private( this ))
{
Soprano::NRLModel nrlModel( ResourceManager::instance()->mainModel() );
nrlModel.setEnableQueryPrefixExpansion( true );
QHash<QString, QUrl> queryPrefixes = nrlModel.queryPrefixes();
for( QHash<QString, QUrl>::const_iterator it = queryPrefixes.constBegin();
- it != queryPrefixes.constEnd(); ++it ) {
+ it != queryPrefixes.constEnd(); ++it ) {
d->m_bnames.insert( it.value(), it.key() );
}
}
@@ -150,18 +150,18 @@ QVariant Nepomuk::QueryModel::data( const QModelIndex& index, int role ) const
if( index.isValid() &&
index.row() < d->m_bindings.count() ) {
const Soprano::Node node = d->m_bindings[index.row()][index.column()];
- switch( role ) {
- case Qt::DisplayRole:
- if( node.isResource() ) {
- return d->resourceToString(node.uri());
- }
- else {
- return node.toString();
- }
-
- case Qt::ToolTipRole:
+ switch( role ) {
+ case Qt::DisplayRole:
+ if( node.isResource() ) {
+ return d->resourceToString(node.uri());
+ }
+ else {
return node.toString();
}
+
+ case Qt::ToolTipRole:
+ return node.toString();
+ }
}
return QVariant();
@@ -213,13 +213,8 @@ Soprano::Node Nepomuk::QueryModel::nodeForIndex( const QModelIndex& index ) cons
void Nepomuk::QueryModel::slotNextResultReady(Soprano::Util::AsyncQuery* query)
{
- if( query != d->m_currentQuery ) {
- query->close();
- return;
- }
-
beginInsertRows( QModelIndex(), d->m_bindings.size(), d->m_bindings.size() );
-
+
if( query->isBool() ) {
Soprano::BindingSet set;
set.insert( QLatin1String( "result" ), Soprano::LiteralValue( query->boolValue() ) );
@@ -227,7 +222,7 @@ void Nepomuk::QueryModel::slotNextResultReady(Soprano::Util::AsyncQuery* query)
}
else if ( query->isGraph() ) {
query->next();
-
+
const Soprano::Statement s = query->currentStatement();
Soprano::BindingSet set;
set.insert( QLatin1String( "subject" ), s.subject() );
@@ -240,9 +235,9 @@ void Nepomuk::QueryModel::slotNextResultReady(Soprano::Util::AsyncQuery* query)
query->next();
d->m_bindings << query->currentBindings();
}
-
+
endInsertRows();
-
+
// This is called because columnCount would return 0 initially
if( d->m_bindings.size() == 1 ) {
emit layoutAboutToBeChanged();
@@ -258,7 +253,7 @@ void Nepomuk::QueryModel::slotQueryFinished(Soprano::Util::AsyncQuery* query)
kDebug() << query->lastError().message();
if( query->lastError() != Soprano::Error::ErrorNone )
emit queryError( query->lastError() );
-
+
d->m_queryTime = d->m_queryTimer.elapsed();
emit queryFinished();
}
@@ -270,9 +265,17 @@ int Nepomuk::QueryModel::queryTime() const
void Nepomuk::QueryModel::stopQuery()
{
- d->m_currentQuery = 0;
+ if(d->m_currentQuery)
+ {
+ d->m_currentQuery->close();
+ d->m_currentQuery->disconnect(this);
+ d->m_queryTime = d->m_queryTimer.elapsed();
+ emit queryFinished();
+ }
}
#include "querymodel.moc"
+
+
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk