Classified ads
|
Model-class for performing text-based searches on objects in db This datamodel part is dual-use ; it inherits listmodel so that it may be used as underlaying data-container for list views. It may also be used as engine of network searches that happen invisibly to user e.g. those queries do not modify the content shown to UI via QAbstractListModel. More...
#include <searchmodel.h>
Classes | |
struct | SearchResultItemStruct |
Public Types | |
typedef struct SearchModel::SearchResultItemStruct | SearchResultItem |
Signals | |
void | error (MController::CAErrorSituation aError, const QString &aExplanation) |
Public Member Functions | |
SearchModel (MModelProtocolInterface &aModel, MController &aController) | |
~SearchModel () | |
void | setSearchString (const QString &aSearch, bool aSearchAds, bool aSearchProfiles, bool aSearchComments, bool aNetworkSeacrh=false) |
virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const |
virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
QList < SearchModel::SearchResultItem > | performSearch (const QString &aForString, bool aSearchAds, bool aSearchProfiles, bool aSearchComments) |
void | appendNetworkSearchResults (const QList< SearchModel::SearchResultItem > &aResults, quint32 aSearchId, const Hash &aFromPeer) |
bool | isFTSSupported () const |
void | indexClassifiedAd (const CA &aCa) |
void | indexProfileComment (const ProfileComment &aProfileComment) |
void | indexProfile (const Profile &aProfile, bool aWasUpdate=false) |
void | getSearchCriteria (QString *aSearchStrPtr, bool *aSearchAdsPtr, bool *aSearchProfilesPtr, bool *aSearchCommentsPtr, Hash *aSearchIdPtr) const |
Static Public Member Functions | |
static QVariant | serializeSearchResults (const QList< SearchModel::SearchResultItem > &aResults, quint32 aSearchId) |
static bool | deSerializeSearchResults (const QVariantMap &aResultJson, QList< SearchModel::SearchResultItem > *aResults, quint32 *aSearchId) |
static bool | queryIfFTSSupported () |
static void | createFTSTables () |
Private Attributes | |
MModelProtocolInterface & | iModel |
QString | iSearchString |
const bool | iIsFTSSupported |
QTextDocument * | iHtmlParser |
QList< SearchResultItem > | iDisplayedResults |
MController & | iController |
Hash | iSearchId |
bool | iSearchAds |
bool | iSearchProfiles |
bool | iSearchComments |
Model-class for performing text-based searches on objects in db This datamodel part is dual-use ; it inherits listmodel so that it may be used as underlaying data-container for list views. It may also be used as engine of network searches that happen invisibly to user e.g. those queries do not modify the content shown to UI via QAbstractListModel.
typedef struct SearchModel::SearchResultItemStruct SearchModel::SearchResultItem |
Data structure for search results.
SearchModel::SearchModel | ( | MModelProtocolInterface & | aModel, |
MController & | aController | ||
) |
SearchModel::~SearchModel | ( | ) |
void SearchModel::appendNetworkSearchResults | ( | const QList< SearchModel::SearchResultItem > & | aResults, |
quint32 | aSearchId, | ||
const Hash & | aFromPeer | ||
) |
Method called from protocol parser in purpose of appending search results from remote node into datamodel. Model is locked during this call
|
static |
method for creating db tables related to FTS
|
virtual |
re-implemented from QAbstractListModel
|
static |
opposite to serializeSearchResults
aResultJson | json object containing search results. |
aResults | array where contents of aResultJson will be appended |
aSearchId | pointer to unsigned that will contain search identifier from aResultJson |
|
signal |
void SearchModel::getSearchCriteria | ( | QString * | aSearchStrPtr, |
bool * | aSearchAdsPtr, | ||
bool * | aSearchProfilesPtr, | ||
bool * | aSearchCommentsPtr, | ||
Hash * | aSearchIdPtr | ||
) | const |
method for obtaining the search criteria inside
void SearchModel::indexClassifiedAd | ( | const CA & | aCa | ) |
method for adding a classified ad into index
aCa | is the classified ad to add to index |
void SearchModel::indexProfile | ( | const Profile & | aProfile, |
bool | aWasUpdate = false |
||
) |
method for adding a profile into index
aProfile | is the profile to add to index |
aWasUpdate | if the profile was updated instead of inserted |
void SearchModel::indexProfileComment | ( | const ProfileComment & | aProfileComment | ) |
method for adding a profile-comment into index
aProfileComment | is the comment to add to index |
|
inline |
method for querying if search is supported at all
QList<SearchModel::SearchResultItem> SearchModel::performSearch | ( | const QString & | aForString, |
bool | aSearchAds, | ||
bool | aSearchProfiles, | ||
bool | aSearchComments | ||
) |
method for actually searching the index. datamodel must be locked when this is called
|
static |
method for checking if database has support for full text search
|
virtual |
re-implemented from QAbstractListModel
|
static |
Method for serializing search results to be sent to peering node. Usually items sent over to peering nodes like profiles or comments are classes and they will (de)serialize themselves. Search resultset is list of structures so lets have just serialization methods here in model, these are called from protocol formatter/parser.
aResults | actual results of search |
aSearchId | id from peering node |
void SearchModel::setSearchString | ( | const QString & | aSearch, |
bool | aSearchAds, | ||
bool | aSearchProfiles, | ||
bool | aSearchComments, | ||
bool | aNetworkSeacrh = false |
||
) |
Method that performs search from local UI. This will change model contens as is shown via QAbstractListModel inheritance
aSearch is the string to offer to FTS implementation aSearchAds if true, classified ads are to be searched aSearchProfiles if true, profiles are to be searched aSearchComments if true, profile comments are to be searched. aNetworkSeacrh if true no local search is performed, and datamodel is emptied with idea that search results from remote nodes will populate the model
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
searches may be lengthty: this connects results
|
private |
|
private |