void SearchQueryPerformer::AskForSearchQuery(const std::string& query, bool selectFirstResult, const std::string& interiorId) { Eegeo::Space::LatLongAltitude location = Eegeo::Space::LatLongAltitude::FromECEF(m_cameraController.GetCameraState().InterestPointEcef()); const float radius = GetSearchRadius(m_cameraController); SearchQuery searchQuery(query, false, true, selectFirstResult, location, radius, interiorId); m_messageBus.Publish(SearchQueryRequestMessage(searchQuery)); }
void SearchQueryPerformer::PerformSearchQuery(const std::string& query, bool isCategory, Eegeo::Space::LatLongAltitude& location, float radius) { m_hasQuery = true; SearchQuery searchQuery(query, isCategory, location, radius); m_previousQuery = searchQuery; m_searchService.PerformLocationQuerySearch(searchQuery); }
int main(int, char *[]) { QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("MyDatabase.sqlite"); if (db.open()) { // Try to locate the contacts database. // If it is not available create it. if (db.tables().indexOf("people") == -1) { QSqlQuery query(db); bool success = query.exec("create table people " "(id integer primary key, " "name TEXT, " "age integer)"); if (!success) { qCritical() << query.lastError(); } else { std::cout << "Created table" << std::endl; } } else { std::cout << "Table already exists" << std::endl; // NULL = is the keyword for the autoincrement to generate next value QSqlQuery insertQuery; bool success = insertQuery.exec(QString("insert into person values(NULL,'%1','%2')") .arg("David").arg(25)); std::cout << "Successfull insertion? " << success << std::endl; QSqlQuery searchQuery(QString("select * from person where id = %1").arg(1)); if (searchQuery.next()) { std::cout << "id: " << searchQuery.value(0).toInt() << std::endl; std::cout << "Name: " << searchQuery.value(1).toString().toStdString() << std::endl; std::cout << "age: " << searchQuery.value(2).toInt() << std::endl; } } } else { std::cout << "Could not open database" << std::endl; qCritical() << db.lastError(); } return 0; }
void SearchQueryPerformer::AskForSearchQuery(const std::string& query, bool isTag, bool tryInteriorSearch, bool selectFirstResult, const Eegeo::Space::LatLongAltitude& location, bool startAtGPSLocation, const std::string& interiorId) { const float radius = GetSearchRadius(m_cameraController); Eegeo::Space::LatLongAltitude searchLocation = location; if (startAtGPSLocation) { searchLocation = Eegeo::Space::LatLongAltitude::FromECEF(m_cameraController.GetRenderCamera().GetEcefLocation()); } SearchQuery searchQuery(query, isTag, tryInteriorSearch, selectFirstResult, searchLocation, radius, interiorId); m_messageBus.Publish(SearchQueryRequestMessage(searchQuery)); }
void SearchQueryPerformer::PerformSearchQuery(const std::string& query, bool isTag, bool tryInteriorSearch, const Eegeo::Space::LatLongAltitude& location, float radius, bool startAtGPSLocation, const std::string& interiorId) { m_hasQuery = true; Eegeo::Space::LatLongAltitude searchLocation = location; if (startAtGPSLocation) { searchLocation = Eegeo::Space::LatLongAltitude::FromECEF(m_cameraController.GetRenderCamera().GetEcefLocation()); } bool searchFirstResult = false; SearchQuery searchQuery(query, isTag, tryInteriorSearch, searchFirstResult, searchLocation, radius, interiorId); m_previousQuery = searchQuery; m_searchService.PerformLocationQuerySearch(searchQuery); }
QList<int> Database::advanceSearch(const QString &keyword, const QDate &startDate, const QDate &endDate, const QTime &startTime, const QTime &endTime, int group, int domain, const QRectF & geo, const QString & weather ) { BEGIN_FNC_DEBUG QString query_str = "SELECT id,ctime,cdate FROM Papers WHERE "; QHash<QString,QVariant> boundValues; bool has_previous = false; if( !keyword.isEmpty() ) { query_str += "(title LIKE :fkwrd OR text LIKE :skwrd)"; has_previous = true; } if( !startDate.isNull() ) { if( has_previous ) query_str += " AND "; query_str += "cdate>=:csdate"; boundValues.insert(":csdate",QDate(1,1,1).daysTo(startDate)); has_previous = true; } if( !endDate.isNull() ) { if( has_previous ) query_str += " AND "; query_str += "cdate<=:cedate"; boundValues.insert(":cedate",QDate(1,1,1).daysTo(endDate)); has_previous = true; } if( !startTime.isNull() ) { if( has_previous ) query_str += " AND "; query_str += "ctime>=:cstime"; boundValues.insert(":cstime",QTime(0,0,0).secsTo(startTime)); has_previous = true; } if( !endTime.isNull() ) { if( has_previous ) query_str += " AND "; query_str += "ctime<=:cetime"; boundValues.insert(":cetime",QTime(0,0,0).secsTo(endTime)); has_previous = true; } if( group != -1 ) { if( has_previous ) query_str += " AND "; query_str += "grp=:grp"; boundValues.insert(":grp",group); has_previous = true; } if( !weather.isEmpty() ) { if( has_previous ) query_str += " AND "; query_str += "weather=:wthr"; boundValues.insert(":wthr",weather); has_previous = true; } if( geo.isValid() ) { if( has_previous ) query_str += " AND "; query_str += ":llttd<latitude AND latitude<:blttd"; boundValues.insert(":llttd",geo.y()); boundValues.insert(":blttd",geo.y()+geo.height()); query_str += " AND "; query_str += ":llntd<longitude AND longitude<:blntd"; boundValues.insert(":llntd",geo.x()); boundValues.insert(":blntd",geo.x()+geo.width()); has_previous = true; } if( domain != Enums::AllPapers ) { if( has_previous ) query_str += " AND "; query_str += "type=:type"; switch( domain ) { case Enums::NormalPapers: boundValues.insert(":type",static_cast<int>(Enums::Normal)); break; case Enums::ToDoPapers: boundValues.insert(":type",static_cast<int>(Enums::ToDo)); break; case Enums::UncompletedTasks: query_str += " AND text LIKE :kwd"; boundValues.insert(":kwd","%- %"); boundValues.insert(":type",static_cast<int>(Enums::ToDo)); break; case Enums::CompletedTasks: query_str += " AND text LIKE :kwd"; boundValues.insert(":kwd","%* %"); boundValues.insert(":type",static_cast<int>(Enums::ToDo)); break; } has_previous = true; } END_FNC_DEBUG if( !has_previous ) return QList<int>(); return searchQuery(query_str,keyword,boundValues); }
QList<int> Database::search(const QString &keyword) { QString query_str = "SELECT id,ctime,cdate FROM Papers WHERE title LIKE :fkwrd OR text LIKE :skwrd"; return searchQuery(query_str,keyword); }
helpDialog::helpDialog(QWidget *parent, QString page, struct CONFIG *config) : QDialog(parent) { setupUi(this); setWindowFlags(Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); cfg = config; lng = QFile::exists(QString("%1/hlp/obpm_%2.qhc").arg(QApplication::applicationDirPath()).arg(QLocale::system().name().mid(0, 2))) ? QLocale::system().name().mid(0, 2) : "en"; helpEngine = new QHelpEngine(QString("%1/hlp/obpm_%2.qhc").arg(QApplication::applicationDirPath()).arg(lng)); helpEngine->setupData(); searchEngine = helpEngine->searchEngine(); searchEngine->reindexDocumentation(); contentWidget = helpEngine->contentWidget(); indexWidget = helpEngine->indexWidget(); queryWidget = searchEngine->queryWidget(); resultWidget = searchEngine->resultWidget(); verticalLayout_content->addWidget(contentWidget); verticalLayout_index->addWidget(indexWidget); verticalLayout_search->addWidget(queryWidget); verticalLayout_search->addWidget(resultWidget); helpBrowser = new HelpBrowser(helpEngine); helpBrowser->setContextMenuPolicy(Qt::NoContextMenu); splitter->addWidget(helpBrowser); splitter->setStretchFactor(0, 0); splitter->setStretchFactor(1, 1); splitter->widget(0)->setMinimumWidth(260); connect(contentWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(setSourceFromContent(QModelIndex))); connect(contentWidget, SIGNAL(activated(QModelIndex)), this, SLOT(setSourceFromContent(QModelIndex))); connect(indexWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(setSourceFromIndex(QModelIndex))); connect(indexWidget, SIGNAL(activated(QModelIndex)), this, SLOT(setSourceFromIndex(QModelIndex))); connect(resultWidget, SIGNAL(requestShowLink(const QUrl&)), this, SLOT(setSource(const QUrl&))); connect(queryWidget, SIGNAL(search()),this, SLOT(searchQuery())); connect(helpBrowser, SIGNAL(anchorClicked(const QUrl&)),this, SLOT(anchorClicked(const QUrl&))); show(); activateWindow(); if(cfg->shelp.width() == -1 || cfg->shelp.height() == -1) { move(parent->mapToGlobal(parent->rect().center()) - rect().center()); } else { move(cfg->phelp); resize(cfg->shelp); } QApplication::processEvents(); setSourceFromPage(page); contentWidget->expandAll(); }