00001 /* 00002 * This file is part of Soprano Project. 00003 * 00004 * Copyright (C) 2008 Sebastian Trueg <trueg@kde.org> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef _SOPRANO_ASYNC_MODEL_H_ 00023 #define _SOPRANO_ASYNC_MODEL_H_ 00024 00025 #include "filtermodel.h" 00026 #include "soprano_export.h" 00027 00028 00029 namespace Soprano { 00030 00031 class Statement; 00032 class StatementIterator; 00033 class Node; 00034 class NodeIterator; 00035 class QueryResultIterator; 00036 00037 namespace Util { 00038 00039 class AsyncModel; 00040 00050 class SOPRANO_EXPORT AsyncResult : public QObject, public Error::ErrorCache 00051 { 00052 Q_OBJECT 00053 00054 Q_SIGNALS: 00061 void resultReady( Soprano::Util::AsyncResult* ); 00062 00063 public: 00077 QVariant value() const { return m_result; } 00078 00083 void setResult( const QVariant& result, const Error::Error& error ) { 00084 m_result = result; 00085 setError( error ); 00086 emit resultReady( this ); 00087 deleteLater(); 00088 } 00091 private: 00092 AsyncResult() 00093 : QObject( 0 ) {} 00094 00095 QVariant m_result; 00096 00097 friend class AsyncModel; 00098 }; 00099 00100 class AsyncModelPrivate; 00101 00122 class SOPRANO_EXPORT AsyncModel : public FilterModel 00123 { 00124 Q_OBJECT 00125 00126 public: 00132 AsyncModel( Model* parent = 0 ); 00133 00137 ~AsyncModel(); 00138 00149 AsyncResult* addStatementAsync( const Statement& statement ); 00150 00163 AsyncResult* removeStatementAsync( const Statement& statement ); 00164 00177 AsyncResult* removeAllStatementsAsync( const Statement& statement ); 00178 00187 AsyncResult* isEmptyAsync() const; 00188 00197 AsyncResult* statementCountAsync() const; 00198 00210 AsyncResult* listStatementsAsync( const Statement& statement ) const; 00211 00220 AsyncResult* listContextsAsync() const; 00221 00240 AsyncResult* executeQueryAsync( const QString& query, 00241 Query::QueryLanguage language, 00242 const QString& userQueryLanguage = QString() ) const; 00243 00256 AsyncResult* containsStatementAsync( const Statement& statement ) const; 00257 00269 AsyncResult* containsAnyStatementAsync( const Statement& statement ) const; 00270 00279 AsyncResult* createBlankNodeAsync(); 00280 00281 private: 00282 AsyncModelPrivate* const d; 00283 00284 Q_PRIVATE_SLOT( d, void _s_executeNextCommand() ) 00285 }; 00286 } 00287 } 00288 00289 #endif