コード例 #1
0
ファイル: manatee.cpp プロジェクト: huangfeidian/challenge1
// Returns true if rect fully overlaps n
bool buildQuery(const Node& n, const Rect rect, const int32_t count, Point* out_points, bool x)
{
  if (n.isLeaf()) {
    return true;
  } else {
    bool leftFullyOverlaps = false, rightFullyOverlaps = false;
    if (x) {
      if (rect.lx < n.split)
        leftFullyOverlaps = buildQuery(*n.left, rect, count, out_points, false);
      if (rect.hx >= n.split)
        rightFullyOverlaps = buildQuery(*n.right, rect, count, out_points, false);
    } else {
      if (rect.ly < n.split)
        leftFullyOverlaps = buildQuery(*n.left, rect, count, out_points, true);
      if (rect.hy >= n.split)
        rightFullyOverlaps = buildQuery(*n.right, rect, count, out_points, true);
    }

    if (leftFullyOverlaps && rightFullyOverlaps) {
      if (n.points.empty()) {
        s_nodes.emplace_back(coverage(n.left->rect, rect), n.left.get());
        s_nodes.emplace_back(coverage(n.right->rect, rect), n.right.get());
        return false;
      }
      return true;
    } else if (leftFullyOverlaps) {
      s_nodes.emplace_back(coverage(n.left->rect, rect), n.left.get());
    } else if (rightFullyOverlaps) {
      s_nodes.emplace_back(coverage(n.right->rect, rect), n.right.get());
    }
    return false;
  }
}
コード例 #2
0
void JsonApiHandlerHttp::processQuery()
{
    buildQuery(jsonParam, [=](json_t *jret)
    {
        sendJson(jret);
    });
}
コード例 #3
0
ファイル: dbenginebase.cpp プロジェクト: tmarques/waheela
QStringList
QueryBuilder::run()
{
    buildQuery();
    //debug() << m_query << endl;
//    return query( m_query );
}
コード例 #4
0
void SqliteTableModel::setTable(const QString& table)
{
    reset();

    m_sTable = table;

    QString sColumnQuery = QString::fromUtf8("SELECT * FROM `%1`;").arg(table);
    if(m_db->getObjectByName(table).gettype() == "table")
    {
        sqlb::Table t = sqlb::Table::parseSQL(m_db->getObjectByName(table).getsql()).first;
        if(t.name() != "") // parsing was OK
        {
            m_headers.push_back(t.rowidColumn());
            m_headers.append(m_db->getTableFields(table));
        }
        else
        {
            m_headers.push_back("rowid");
            m_headers.append(getColumns(sColumnQuery));
        }
    }
    else
    {
        m_headers.push_back("rowid");
        m_headers.append(getColumns(sColumnQuery));
    }

    buildQuery();
}
コード例 #5
0
ファイル: MySQLConnector.cpp プロジェクト: Aredhele/Nemesis
/**
 * \brief return all the table name from the current database
 * \return tables A vector of pointer on tables
 */
std::vector<Table *> MySQLConnector::getTablesName() {

    std::string query = "SELECT TABLE_NAME "
                        "FROM INFORMATION_SCHEMA.TABLES "
                        "WHERE TABLE_SCHEMA = '";

    buildQuery(&query);
    mysql_query(m_ptr_mysql, query.c_str());

    MYSQL_RES *result = NULL;
    MYSQL_ROW row;

    unsigned int fieldNum = 0;

    result = mysql_store_result(m_ptr_mysql);
    fieldNum = mysql_num_fields(result);

    std::vector < Table* > tables;

    while((row = mysql_fetch_row(result))) {
        mysql_fetch_lengths(result);

        for(int i = 0; i < fieldNum; i++) {
            tables.push_back(new Table(row[i]));
        }
    }

    mysql_free_result(result);
    result = NULL;

    return tables;
}
コード例 #6
0
ファイル: MySQLConnector.cpp プロジェクト: Aredhele/Nemesis
/**
 * \brief Set the columns of the table from the database
 * \param table a pointer on the table to fill with columns
 */
void MySQLConnector::getColumnsFromTable(Table *table) {

    std::string query = "SELECT COLUMN_NAME "
                        "FROM INFORMATION_SCHEMA.COLUMNS "
                        "WHERE TABLE_SCHEMA = '";

    buildQuery(&query, table->getTableName());
    mysql_query(m_ptr_mysql, query.c_str());

    MYSQL_RES *result = NULL;
    MYSQL_ROW row;

    unsigned int fieldNum = 0;

    result = mysql_store_result(m_ptr_mysql);
    fieldNum = mysql_num_fields(result);

    while((row = mysql_fetch_row(result))) {
        mysql_fetch_lengths(result);

        for(int i = 0; i < fieldNum; i++) {
            table->addColumns(row[i]);
        }
    }

    mysql_free_result(result);
    result = NULL;
}
コード例 #7
0
ファイル: test_json_query.c プロジェクト: CloCkWeRX/Evergreen
static int test_json_query( const char* json_query ) {

	jsonObject* hash = jsonParse( json_query );
	if( !hash ) {
		fprintf( stderr, "Invalid JSON\n" );
		return -1;
	}

	int flags = 0;

	if ( obj_is_true( jsonObjectGetKeyConst( hash, "distinct" )))
		flags |= SELECT_DISTINCT;

	if ( obj_is_true( jsonObjectGetKeyConst( hash, "no_i18n" )))
		flags |= DISABLE_I18N;

	char* sql_query = buildQuery( NULL, hash, flags );

	if ( !sql_query ) {
		fprintf( stderr, "Invalid query\n" );
		return -1;
	}
	else
		printf( "%s\n", sql_query );

	free( sql_query );
	jsonObjectFree( hash );
	return 0;
}
コード例 #8
0
void JsonApiHandlerWS::processQuery(const Params &jsonReq, const string &client_id)
{
    buildQuery(jsonReq, [=](json_t *jret)
    {
        sendJson("query", jret, client_id);
    });
}
コード例 #9
0
ファイル: updates.cpp プロジェクト: leewood/kadu
Updates::Updates(QObject *parent) :
		QObject(parent), UpdateChecked{false}
{
	kdebugf();
	buildQuery();
	triggerAllAccountsRegistered();
}
コード例 #10
0
checkpivotmodel::checkpivotmodel(  QObject * parent )
    : QSqlQueryModel(parent)
{
    primarykey=0;
    infocolumns.clear();
    detectorcolumns.clear();
    addFilter="";
    buildQuery();
}
コード例 #11
0
ファイル: dbenginebase.cpp プロジェクト: tmarques/waheela
// get the builded SQL-Query (used in smartplaylisteditor soon)
QString
QueryBuilder::getQuery()
{
    if ( m_query.isEmpty())
    {
        buildQuery();
    }
    return m_query;
}
コード例 #12
0
QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QgisApp * app, Qt::WFlags fl ):
    QDialog( app, fl ), qgisApp( app )
{
  setupUi( this );
  setWindowTitle( tr( "Add SpatiaLite Table(s)" ) );
  connectionsGroupBox->setTitle( tr( "Databases" ) );
  btnEdit->hide();  // hide the edit button
  btnSave->hide();
  btnLoad->hide();

  mAddButton = new QPushButton( tr( "&Add" ) );
  buttonBox->addButton( mAddButton, QDialogButtonBox::ActionRole );
  connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addClicked() ) );
  mAddButton->setEnabled( false );

  mBuildQueryButton = new QPushButton( tr( "&Build Query" ) );
  buttonBox->addButton( mBuildQueryButton, QDialogButtonBox::ActionRole );
  connect( mBuildQueryButton, SIGNAL( clicked() ), this, SLOT( buildQuery() ) );
  mBuildQueryButton->setEnabled( false );

  populateConnectionList();

  mSearchModeComboBox->addItem( tr( "Wildcard" ) );
  mSearchModeComboBox->addItem( tr( "RegExp" ) );

  mSearchColumnComboBox->addItem( tr( "All" ) );
  mSearchColumnComboBox->addItem( tr( "Table" ) );
  mSearchColumnComboBox->addItem( tr( "Type" ) );
  mSearchColumnComboBox->addItem( tr( "Geometry column" ) );
  mSearchColumnComboBox->addItem( tr( "Sql" ) );

  mProxyModel.setParent( this );
  mProxyModel.setFilterKeyColumn( -1 );
  mProxyModel.setFilterCaseSensitivity( Qt::CaseInsensitive );
  mProxyModel.setDynamicSortFilter( true );
  mProxyModel.setSourceModel( &mTableModel );
  mTablesTreeView->setModel( &mProxyModel );
  mTablesTreeView->setSortingEnabled( true );

  //for Qt < 4.3.2, passing -1 to include all model columns
  //in search does not seem to work
  mSearchColumnComboBox->setCurrentIndex( 1 );

  //hide the search options by default
  //they will be shown when the user ticks
  //the search options group box
  mSearchLabel->setVisible( false );
  mSearchColumnComboBox->setVisible( false );
  mSearchColumnsLabel->setVisible( false );
  mSearchModeComboBox->setVisible( false );
  mSearchModeLabel->setVisible( false );
  mSearchTableEdit->setVisible( false );
  cbxAllowGeometrylessTables->setVisible( false );
}
コード例 #13
0
void SqliteTableModel::sort(int column, Qt::SortOrder order)
{
    // Don't do anything when the sort order hasn't changed
    if(m_iSortColumn == column && m_sSortOrder == (order == Qt::AscendingOrder ? "ASC" : "DESC"))
        return;

    // Save sort order
    m_iSortColumn = column;
    m_sSortOrder = (order == Qt::AscendingOrder ? "ASC" : "DESC");

    // Set the new query (but only if a table has already been set
    if(m_sTable != "")
        buildQuery();
}
コード例 #14
0
    void SuggestionQueryEngine::submitQuery(const QStringList &queryKeywords) {
        QUrl url = buildQuery(queryKeywords);
        QNetworkRequest request(url);

        QString decodedClientId = Encryption::decodeText(m_ClientId, "MasterPassword");
        QString decodedClientSecret = Encryption::decodeText(m_ClientSecret, "MasterPassword");

        QString authStr = QString("%1:%2").arg(decodedClientId).arg(decodedClientSecret);
        QString headerData = "Basic " + authStr.toLocal8Bit().toBase64();
        request.setRawHeader("Authorization", headerData.toLocal8Bit());

        QNetworkReply *reply = m_NetworkManager.get(request);
        QObject::connect(this, SIGNAL(cancelAllQueries()),
                         reply, SLOT(abort()));
    }
コード例 #15
0
void SqliteTableModel::setTable(const QString& table)
{
    m_sTable = table;

    m_headers.clear();
    QString rowid = "rowid";
    if(m_db->getObjectByName(table).gettype() == "table")
        rowid = sqlb::Table::parseSQL(m_db->getObjectByName(table).getsql()).rowidColumn();
    m_headers.push_back(rowid);
    m_headers.append(m_db->getTableFields(table));

    m_mWhere.clear();

    buildQuery();
}
コード例 #16
0
void SqliteTableModel::updateFilter(int column, const QString& value)
{
    // Check for any special comparison operators at the beginning of the value string. If there are none default to LIKE.
    QString op = "LIKE";
    QString val;
    bool numeric = false;
    if(value.left(2) == ">=" || value.left(2) == "<=" || value.left(2) == "<>")
    {
        bool ok;
        value.mid(2).toFloat(&ok);
        if(ok)
        {
            op = value.left(2);
            val = value.mid(2);
            numeric = true;
        }
    } else if(value.left(1) == ">" || value.left(1) == "<") {
        bool ok;
        value.mid(1).toFloat(&ok);
        if(ok)
        {
            op = value.left(1);
            val = value.mid(1);
            numeric = true;
        }
    } else {
        if(value.left(1) == "=")
        {
            op = "=";
            val = value.mid(1);
        }
    }
    if(val.isEmpty())
        val = value;
    if(!numeric)
        val = QString("'%1'").arg(val.replace("'", "''"));

    // If the value was set to an empty string remove any filter for this column. Otherwise insert a new filter rule or replace the old one if there is already one
    if(val == "''")
        m_mWhere.remove(column);
    else
        m_mWhere.insert(column, QString("%1 %2").arg(op).arg(val));

    // Build the new query
    buildQuery();
}
コード例 #17
0
ファイル: MysqlCSP.cpp プロジェクト: AwesomeDoesIt/crisp-nlg
bool MysqlCSP::is_unique() {
	stringstream ss;
	
	ss << "SELECT COUNT(*)";
	buildQuery(ss);
	
	mysqlpp::Query query = conn->query();
	query << ss.str();
	mysqlpp::Result res = query.store();

	if (res) {
		int count = res.at(0).at(0);
		return (count == 1);
	} else {
		return false;
	}
	
}
コード例 #18
0
ファイル: manatee.cpp プロジェクト: huangfeidian/challenge1
EXPORT int32_t __stdcall search(SearchContext* sc, const Rect rect, const int32_t count, Point* out_points)
{
  if (count == 0)
    return 0;

  s_nodes.clear();
  s_rank_threshold = std::numeric_limits<int32_t>::max();
  out_points[count-1].rank = s_rank_threshold;

  buildQuery(*sc->root, rect, count, out_points, true);

  std::sort(s_nodes.begin(), s_nodes.end());
  int pio = 0;
  for (auto p: s_nodes)
    searchNode(*p.second, rect, count, out_points, pio);

  return pio;
}
コード例 #19
0
void SqliteTableModel::setPseudoPk(const QString& pseudoPk)
{
    // Do nothing if the value didn't change
    if(m_pseudoPk == pseudoPk)
        return;

    if(pseudoPk.isEmpty())
    {
        m_pseudoPk.clear();
        if(m_headers.size())
            m_headers[0] = m_sRowidColumn;
    } else {
        m_pseudoPk = pseudoPk;
        if(m_headers.size())
            m_headers[0] = pseudoPk;
    }

    buildQuery();
}
コード例 #20
0
ファイル: MysqlCSP.cpp プロジェクト: AwesomeDoesIt/crisp-nlg
// TODO - there is a memory leak here - whose job is it to clean up
// the memory for the duplicated strings?
void MysqlCSP::distractors(const char* arg, vector<const char*>& dlist) {
	stringstream ss;
	
	ss << "SELECT DISTINCT " << arg << ".it1";
	buildQuery(ss);
	
	// cerr << "Query: " << ss.str() << endl;
	
	dlist.clear();
	
	mysqlpp::Query query = conn->query();
	query << ss.str();
	mysqlpp::Result res = query.store();

	if (res) {
		mysqlpp::Row row;
		mysqlpp::Row::size_type i;
		for (i = 0; row = res.at(i); ++i) {
			dlist.push_back(strdup(row.at(0))); // MEMORY LEAK HERE
		}
	}
}
コード例 #21
0
ファイル: telemetryworker.cpp プロジェクト: Ribtoks/xpiks
    void TelemetryWorker::processOneItem(const std::shared_ptr<AnalyticsUserEvent> &item) {
        LOG_INFO << "Reporting action:" << item->getActionString();

        QUrlQuery query;
        buildQuery(item, m_UserAgentId, query);

        QString customVarsStr = QString::fromLatin1("{\"1\":[\"OS_type\",\"%1\"],\"2\":[\"OS_version\",\"%2\"],\"3\":[\"Xpiks_version\",\"%3\"],\"4\":[\"UI_language\",\"%4\"]}");

#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
        query.addQueryItem(QLatin1String("_cvar"),
                           customVarsStr
                           .arg(QSysInfo::productType())
                           .arg(QSysInfo::productVersion())
                           .arg(XPIKS_VERSION_STRING)
                           .arg(m_InterfaceLanguage));
#else
        query.addQueryItem(QLatin1String("_cvar"),
                           customVarsStr
#  ifdef Q_OS_WIN
                           .arg(QString("windows"))
#  elsif Q_OS_DARWIN
                           .arg(QString("osx"))
#  else
                           .arg(QString("Linux QT<5.4"))
#  endif
                           .arg(QString("-"))
                           .arg(XPIKS_VERSION_STRING)
                           .arg(m_InterfaceLanguage));
#endif

#ifdef QT_DEBUG
        LOG_DEBUG << "Telemetry request:" << m_ReportingEndpoint << query.toString();
#endif

#if defined(TELEMETRY_ENABLED) && !defined(INTEGRATION_TESTS) && !defined(UI_TESTS)
        sendOneReport(m_ReportingEndpoint, query.toString());
#endif
    }
コード例 #22
0
void QgsWFSSourceSelect::buildQueryButtonClicked()
{
  QgsDebugMsg( "mBuildQueryButton click called" );
  buildQuery( treeView->selectionModel()->currentIndex() );
}
コード例 #23
0
void QgsWFSSourceSelect::treeWidgetItemDoubleClicked( const QModelIndex& index )
{
  QgsDebugMsg( "double click called" );
  buildQuery( index );
}
コード例 #24
0
void QgsArcGisServiceSourceSelect::buildQueryButtonClicked()
{
  QgsDebugMsg( QStringLiteral( "mBuildQueryButton click called" ) );
  QgsOwsConnection connection( mServiceName, cmbConnections->currentText() );
  buildQuery( connection, treeView->selectionModel()->currentIndex() );
}
コード例 #25
0
QDomElement SmartPlaylistEditor::result() {
    QDomDocument doc;
    QDomNode node = doc.namedItem( "smartplaylists" );
    QDomElement nodeE;
    nodeE = node.toElement();

    QDomElement smartplaylist = doc.createElement( "smartplaylist" );

    smartplaylist.setAttribute( "name", name() );

    // Limit
    if ( m_limitCheck->isChecked() )
        smartplaylist.setAttribute( "maxresults", m_limitSpin->value() );

    nodeE.appendChild( smartplaylist );
    // Matches
    if( m_matchAnyCheck->isChecked() ) {
        QDomElement matches = doc.createElement("matches");
        smartplaylist.appendChild( matches );
        // Iterate through all criteria list
        CriteriaEditor *criteriaeditor = m_criteriaEditorAnyList.first();
        for( int i=0; criteriaeditor; criteriaeditor = m_criteriaEditorAnyList.next(), ++i ) {
            matches.appendChild( doc.importNode( criteriaeditor->getDomSearchCriteria( doc ), true ) );
        }
        matches.setAttribute( "glue",  "OR" );
        smartplaylist.appendChild( matches );
    }

    if( m_matchAllCheck->isChecked() ) {
        QDomElement matches = doc.createElement("matches");
        smartplaylist.appendChild( matches );
        // Iterate through all criteria list
        CriteriaEditor *criteriaeditor = m_criteriaEditorAllList.first();
        for( int i=0; criteriaeditor; criteriaeditor = m_criteriaEditorAllList.next(), ++i ) {
            matches.appendChild( doc.importNode( criteriaeditor->getDomSearchCriteria( doc ), true ) );
        }
        matches.setAttribute( "glue",  "AND" );
        smartplaylist.appendChild( matches );
    }

    // Order By
    if( m_orderCheck->isChecked() ) {
        QDomElement orderby = doc.createElement("orderby");
        if (m_orderCombo->currentItem() != m_orderCombo->count()-1) {
            orderby.setAttribute( "field", m_dbFields[ m_orderCombo->currentItem() ] );
            orderby.setAttribute( "order", m_orderTypeCombo->currentItem() == 1 ? "DESC" : "ASC" );
        } else {
            orderby.setAttribute( "field", "random" );
            orderby.setAttribute( "order", m_orderTypeCombo->currentItem() == 1 ? "weighted" : "random" );
        }

        smartplaylist.appendChild( orderby );
    }
    QDomElement Sql = doc.createElement("sqlquery");
    buildQuery();
    Sql.appendChild( doc.createTextNode( m_query ) );
    smartplaylist.appendChild( Sql );

    if( m_expandCheck->isChecked() ) {
        QDomElement expandBy = doc.createElement("expandby");
        expandBy.setAttribute( "field", m_expandableFields[ m_expandCombo->currentItem() ] );
        QDomText t = doc.createTextNode( m_expandQuery );
        expandBy.appendChild( t );
        smartplaylist.appendChild( expandBy );
    }
    return (smartplaylist);
}
コード例 #26
0
void KinectSensorCollection::setStatusChangeCb(KEventHandler<KinectStatus> cb)
{
    if (!_statusChangedCb)
        processQuery(buildQuery("StatusChanged"));
    _statusChangedCb = cb;
}
コード例 #27
0
void SqliteTableModel::updateFilter(int column, const QString& value, bool applyQuery)
{
    // Check for any special comparison operators at the beginning of the value string. If there are none default to LIKE.
    QString op = "LIKE";
    QString val, val2;
    QString escape;
    bool numeric = false, ok = false;

    // range/BETWEEN operator
    if (value.contains("~")) {
        int sepIdx = value.indexOf('~');
        val  = value.mid(0, sepIdx);
        val2 = value.mid(sepIdx+1);
        val.toFloat(&ok);
        if (ok) {
            val2.toFloat(&ok);
            ok = ok && (val.toFloat() < val2.toFloat());
        }
    }
    if (ok) {
        op = "BETWEEN";
        numeric = true;
    } else {
        val.clear();
        val2.clear();
        if(value.left(2) == ">=" || value.left(2) == "<=" || value.left(2) == "<>")
        {
            // Check if we're filtering for '<> NULL'. In this case we need a special comparison operator.
            if(value.left(2) == "<>" && value.mid(2) == "NULL")
            {
                // We are filtering for '<>NULL'. Override the comparison operator to search for NULL values in this column. Also treat search value (NULL) as number,
                // in order to avoid putting quotes around it.
                op = "IS NOT";
                numeric = true;
                val = "NULL";
            } else if(value.left(2) == "<>" && value.mid(2) == "''") {
                // We are filtering for "<>''", i.e. for everything which is not an empty string
                op = "<>";
                numeric = true;
                val = "''";
            } else {
                value.mid(2).toFloat(&numeric);
                op = value.left(2);
                val = value.mid(2);
            }
        } else if(value.left(1) == ">" || value.left(1) == "<") {
            value.mid(1).toFloat(&numeric);
            op = value.left(1);
            val = value.mid(1);
        } else if(value.left(1) == "=") {
            val = value.mid(1);

            // Check if value to compare with is 'NULL'
            if(val != "NULL")
            {
                // It's not, so just compare normally to the value, whatever it is.
                op = "=";
            } else {
                // It is NULL. Override the comparison operator to search for NULL values in this column. Also treat search value (NULL) as number,
                // in order to avoid putting quotes around it.
                op = "IS";
                numeric = true;
            }
        } else {
            // Keep the default LIKE operator

            // Set the escape character if one has been specified in the settings dialog
            QString escape_character = Settings::getValue("databrowser", "filter_escape").toString();
            if(escape_character == "'") escape_character = "''";
            if(escape_character.length())
                escape = QString("ESCAPE '%1'").arg(escape_character);

            // Add % wildcards at the start and at the beginning of the filter query, but only if there weren't set any
            // wildcards manually. The idea is to assume that a user who's just typing characters expects the wildcards to
            // be added but a user who adds them herself knows what she's doing and doesn't want us to mess up her query.
            if(!value.contains("%"))
            {
                val = value;
                val.prepend('%');
                val.append('%');
            }
        }
    }
    if(val.isEmpty())
        val = value;

    // If the value was set to an empty string remove any filter for this column. Otherwise insert a new filter rule or replace the old one if there is already one
    if(val == "" || val == "%" || val == "%%")
        m_mWhere.remove(column);
    else {
        // Quote and escape value, but only if it's not numeric and not the empty string sequence
        if(!numeric && val != "''")
            val = QString("'%1'").arg(val.replace("'", "''"));

        QString whereClause(op + " " + QString(encode(val.toUtf8())));
        if (!val2.isEmpty())
            whereClause += " AND " + QString(encode(val2.toUtf8()));
        whereClause += " " + escape;
        m_mWhere.insert(column, whereClause);
    }

    // Build the new query
    if (applyQuery)
        buildQuery();
}
コード例 #28
0
void QgsArcGisServiceSourceSelect::treeWidgetItemDoubleClicked( const QModelIndex &index )
{
  QgsDebugMsg( QStringLiteral( "double-click called" ) );
  QgsOwsConnection connection( mServiceName, cmbConnections->currentText() );
  buildQuery( connection, index );
}
コード例 #29
0
QgsSpatiaLiteSourceSelect::QgsSpatiaLiteSourceSelect( QWidget * parent, Qt::WindowFlags fl, bool embedded ):
    QDialog( parent, fl )
{
  setupUi( this );

  QSettings settings;
  restoreGeometry( settings.value( "/Windows/SpatiaLiteSourceSelect/geometry" ).toByteArray() );
  mHoldDialogOpen->setChecked( settings.value( "/Windows/SpatiaLiteSourceSelect/HoldDialogOpen", false ).toBool() );

  setWindowTitle( tr( "Add SpatiaLite Table(s)" ) );
  connectionsGroupBox->setTitle( tr( "Databases" ) );
  btnEdit->hide();  // hide the edit button
  btnSave->hide();
  btnLoad->hide();

  mStatsButton = new QPushButton( tr( "&Update Statistics" ) );
  connect( mStatsButton, SIGNAL( clicked() ), this, SLOT( updateStatistics() ) );
  mStatsButton->setEnabled( false );

  mAddButton = new QPushButton( tr( "&Add" ) );
  connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addClicked() ) );
  mAddButton->setEnabled( false );

  mBuildQueryButton = new QPushButton( tr( "&Set Filter" ) );
  connect( mBuildQueryButton, SIGNAL( clicked() ), this, SLOT( buildQuery() ) );
  mBuildQueryButton->setEnabled( false );

  if ( embedded )
  {
    buttonBox->button( QDialogButtonBox::Close )->hide();
  }
  else
  {
    buttonBox->addButton( mAddButton, QDialogButtonBox::ActionRole );
    buttonBox->addButton( mBuildQueryButton, QDialogButtonBox::ActionRole );
    buttonBox->addButton( mStatsButton, QDialogButtonBox::ActionRole );
  }

  populateConnectionList();

  mSearchModeComboBox->addItem( tr( "Wildcard" ) );
  mSearchModeComboBox->addItem( tr( "RegExp" ) );

  mSearchColumnComboBox->addItem( tr( "All" ) );
  mSearchColumnComboBox->addItem( tr( "Table" ) );
  mSearchColumnComboBox->addItem( tr( "Type" ) );
  mSearchColumnComboBox->addItem( tr( "Geometry column" ) );
  mSearchColumnComboBox->addItem( tr( "Sql" ) );

  mProxyModel.setParent( this );
  mProxyModel.setFilterKeyColumn( -1 );
  mProxyModel.setFilterCaseSensitivity( Qt::CaseInsensitive );
  mProxyModel.setDynamicSortFilter( true );
  mProxyModel.setSourceModel( &mTableModel );
  mTablesTreeView->setModel( &mProxyModel );
  mTablesTreeView->setSortingEnabled( true );

  connect( mTablesTreeView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( treeWidgetSelectionChanged( const QItemSelection&, const QItemSelection& ) ) );

  //for Qt < 4.3.2, passing -1 to include all model columns
  //in search does not seem to work
  mSearchColumnComboBox->setCurrentIndex( 1 );

  //hide the search options by default
  //they will be shown when the user ticks
  //the search options group box
  mSearchLabel->setVisible( false );
  mSearchColumnComboBox->setVisible( false );
  mSearchColumnsLabel->setVisible( false );
  mSearchModeComboBox->setVisible( false );
  mSearchModeLabel->setVisible( false );
  mSearchTableEdit->setVisible( false );

  cbxAllowGeometrylessTables->setDisabled( true );
}
コード例 #30
0
ファイル: sasourceselect.cpp プロジェクト: aaronr/Quantum-GIS
SaSourceSelect::SaSourceSelect( QWidget *parent, Qt::WFlags fl )
    : QDialog( parent, fl ), mColumnTypeThread( NULL )
{
  setupUi( this );

  mAddButton = new QPushButton( tr( "&Add" ) );
  buttonBox->addButton( mAddButton, QDialogButtonBox::ActionRole );
  connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addTables() ) );
  mAddButton->setEnabled( false );

  mBuildQueryButton = new QPushButton( tr( "&Build Query" ) );
  buttonBox->addButton( mBuildQueryButton, QDialogButtonBox::ActionRole );
  connect( mBuildQueryButton, SIGNAL( clicked() ), this, SLOT( buildQuery() ) );
  mBuildQueryButton->setEnabled( false );

  populateConnectionList();

  mSearchModeComboBox->addItem( tr( "Wildcard" ) );
  mSearchModeComboBox->addItem( tr( "RegExp" ) );

  mSearchColumnComboBox->addItem( tr( "All" ) );
  mSearchColumnComboBox->addItem( tr( "Schema" ) );
  mSearchColumnComboBox->addItem( tr( "Table" ) );
  mSearchColumnComboBox->addItem( tr( "Type" ) );
  mSearchColumnComboBox->addItem( tr( "SRID" ) );
  mSearchColumnComboBox->addItem( tr( "Line Interpretation" ) );
  mSearchColumnComboBox->addItem( tr( "Geometry column" ) );
  mSearchColumnComboBox->addItem( tr( "Sql" ) );

  mProxyModel.setParent( this );
  mProxyModel.setFilterKeyColumn( -1 );
  mProxyModel.setFilterCaseSensitivity( Qt::CaseInsensitive );
  mProxyModel.setDynamicSortFilter( true );
  mProxyModel.setSourceModel( &mTableModel );

  mTablesTreeView->setModel( &mProxyModel );
  mTablesTreeView->setSortingEnabled( true );
  mTablesTreeView->setEditTriggers( QAbstractItemView::CurrentChanged );
  mTablesTreeView->setItemDelegate( new SaSourceSelectDelegate( this ) );


  //for Qt < 4.3.2, passing -1 to include all model columns
  //in search does not seem to work
  mSearchColumnComboBox->setCurrentIndex( 2 );

  QSettings settings;
  restoreGeometry( settings.value( "/Windows/SaSourceSelect/geometry" ).toByteArray() );

  for ( int i = 0; i < mTableModel.columnCount(); i++ )
  {
    mTablesTreeView->setColumnWidth( i, settings.value( QString( "/Windows/SaSourceSelect/columnWidths/%1" ).arg( i ), mTablesTreeView->columnWidth( i ) ).toInt() );
  }

  //hide the search options by default
  //they will be shown when the user ticks
  //the search options group box
  mSearchLabel->setVisible( false );
  mSearchColumnComboBox->setVisible( false );
  mSearchColumnsLabel->setVisible( false );
  mSearchModeComboBox->setVisible( false );
  mSearchModeLabel->setVisible( false );
  mSearchTableEdit->setVisible( false );
}