bool XComboBox::isValid() const { if ((allowNull()) && (id() == -1)) return FALSE; else return TRUE; }
void XComboBox::sHandleNewIndex(int pIndex) { if (DEBUG) qDebug("%s::sHandleNewIndex(%d)",objectName().toAscii().data(), pIndex); if ((pIndex >= 0) && (pIndex < _ids.count()) && (_ids.at(pIndex) != _lastId)) { _lastId = _ids.at(pIndex); emit newID(_lastId); if (DEBUG) qDebug("%s::sHandleNewIndex() emitted %d", objectName().toAscii().data(), _lastId); if (allowNull()) { emit valid((pIndex != 0)); emit notNull((pIndex != 0)); } } if (DEBUG) qDebug("%s::sHandleNewIndex() returning", objectName().toAscii().data()); }
void XComboBox::populate(XSqlQuery &pQuery, int pSelected) { int selected = 0; int counter = 0; // Clear any old data clear(); if (allowNull()) counter++; // Load the combobox with the contents of the passed query, if any if (pQuery.first()) { do { append(pQuery.value(0).toInt(), pQuery.value(1).toString(), pQuery.value(2).toString()); if (pQuery.value(0).toInt() == pSelected) selected = counter; counter++; } while(pQuery.next()); } setCurrentIndex(selected); if (_ids.count()) { _lastId = _ids.at(selected); if (allowNull()) emit notNull(TRUE); } else { _lastId = -1; if (allowNull()) emit notNull(FALSE); } emit newID(_lastId); emit valid((_lastId != -1)); }
TupleSchema* TupleSchema::createKeySchema(const std::vector<ValueType>& columnTypes, const std::vector<int32_t>& columnSizes, const std::vector<bool>& columnInBytes) { std::vector<bool> allowNull(columnTypes.size(), true); TupleSchema* schema = createTupleSchema(columnTypes, columnSizes, allowNull, columnInBytes); schema->m_isHeaderless = true; return schema; }
void XComboBox::setCode(QString pString) { if (DEBUG) qDebug("%s::setCode(%d %d %s) with _codes.count %d and _ids.count %d", objectName().toAscii().data(), pString.isNull(), pString.isEmpty(), pString.toAscii().data(), _codes.count(), _ids.count()); if (pString.isEmpty()) { setId(-1); setCurrentText(pString); } else if (count() == _codes.count()) { for (int counter = ((allowNull()) ? 1 : 0); counter < count(); counter++) { if (_codes.at(counter) == pString) { if (DEBUG) qDebug("%s::setCode(%s) found at %d with _ids.count %d & _lastId %d", objectName().toAscii().data(), pString.toAscii().data(), counter, _ids.count(), _lastId); setCurrentIndex(counter); if (_ids.count() && _lastId!=_ids.at(counter)) setId(_ids.at(counter)); return; } else if (DEBUG) qDebug("%s::setCode(%s) not found (%s)", qPrintable(objectName()), qPrintable(pString), qPrintable(_codes.at(counter))); } } else // this is an ad-hoc combobox without a query behind it? { setCurrentItem(findText(pString)); if (DEBUG) qDebug("%s::setCode(%s) set current item to %d using findData()", objectName().toAscii().data(), pString.toAscii().data(), currentItem()); if (_ids.count() > currentItem()) setId(_ids.at(currentItem())); if (DEBUG) qDebug("%s::setCode(%s) current item is %d after setId", objectName().toAscii().data(), pString.toAscii().data(), currentItem()); } if (editable()) { setId(-1); setCurrentText(pString); } }
int QgsFeatureListComboBox::nullIndex() const { int index = -1; if ( allowNull() ) { index = findText( tr( "NULL" ) ); } return index; }
void XComboBox::setNullStr(const QString& pNullStr) { if (DEBUG) qDebug("%s::setNullStr(%s)", qPrintable(objectName()), qPrintable(pNullStr)); _nullStr = pNullStr; if (allowNull()) { append(-1, _nullStr); setItemText(0, pNullStr); } }
void XComboBox::setNull() { if (allowNull()) { _lastId = -1; setCurrentIndex(0); emit newID(-1); emit valid(FALSE); emit notNull(FALSE); } }
int XComboBox::id(int pIndex) const { if ((pIndex >= 0) && (pIndex < count())) { if ( (allowNull()) && (currentItem() <= 0) ) return -1; else return _ids.at(pIndex); } else return -1; }
int XComboBox::id() const { if (_ids.count()) { if ( (allowNull()) && (currentItem() <= 0) ) return -1; else return _ids.at(currentItem()); } else return -1; }
void XComboBox::clear() { QComboBox::clear(); if (_ids.count()) _ids.clear(); if (_codes.count()) _codes.clear(); if (allowNull()) append(-1, _nullStr); }
QString XComboBox::code() const { if (DEBUG) qDebug("%s::code() with currentItem %d, allowNull %d, and _codes.count %d", objectName().toAscii().data(), currentItem(), allowNull(), _codes.count()); QString returnValue; if ( allowNull() && (currentItem() <= 0) ) returnValue = QString::Null(); else if (currentItem() >= 0 && _codes.count() > currentItem()) returnValue = _codes.at(currentItem()); else if (currentItem() >= 0) returnValue = currentText(); else returnValue = QString::Null(); if (DEBUG) qDebug("%s::code() returning %s", objectName().toAscii().data(), returnValue.toAscii().data()); return returnValue; }
TupleSchema* TupleSchema::createTrackerTupleSchema() { std::vector<ValueType> columnTypes(2); std::vector<int32_t> columnSizes(2); std::vector<bool> allowNull(2); // COLUMN 0: TABLE_NAME columnTypes[0] = VALUE_TYPE_VARCHAR; columnSizes[0] = static_cast<int32_t>(32); allowNull[0] = false; // COLUMN 1: TUPLE_ID columnTypes[1] = VALUE_TYPE_INTEGER; columnSizes[1] = static_cast<int32_t>(NValue::getTupleStorageSize(VALUE_TYPE_INTEGER)); allowNull[1] = false; TupleSchema *schema = TupleSchema::createTupleSchema(columnTypes, columnSizes, allowNull, false); return (schema); }
void XComboBox::setText(const QString &pString) { if (count()) { for (int counter = ((allowNull()) ? 1 : 0); counter < count(); counter++) { if (text(counter) == pString) { setCurrentItem(counter); return; } } } if (editable()) { setId(-1); setCurrentText(pString); } }
TupleSchema* TupleSchema::createEvictedTupleSchema() { std::vector<ValueType> columnTypes(2); std::vector<int32_t> columnSizes(2); std::vector<bool> allowNull(2); // create a schema containing a single column for the block_id columnTypes[0] = VALUE_TYPE_SMALLINT; columnSizes[0] = static_cast<int32_t>(NValue::getTupleStorageSize(VALUE_TYPE_SMALLINT)); allowNull[0] = false; columnTypes[1] = VALUE_TYPE_INTEGER; columnSizes[1] = static_cast<int32_t>(NValue::getTupleStorageSize(VALUE_TYPE_INTEGER)); allowNull[1] = false; TupleSchema *blockids_schema = TupleSchema::createTupleSchema(columnTypes, columnSizes, allowNull, false); //TupleSchema *evicted_schema = TupleSchema::createTupleSchema(pkey_schema, blockids_schema); // Always make sure that we return memory! //TupleSchema::freeTupleSchema(blockids_schema); return (blockids_schema); }
void XComboBox::setId(int pTarget) { // reports are a special case: they should really be stored by name, not id if (_type == Reports) { XSqlQuery query; query.prepare("SELECT report_id " "FROM report " "WHERE (report_name IN (SELECT report_name " " FROM report " " WHERE (report_id=:report_id)));"); query.bindValue(":report_id", pTarget); query.exec(); while (query.next()) { int id = query.value("report_id").toInt(); for (int counter = 0; counter < count(); counter++) { if (_ids.at(counter) == id) { setCurrentIndex(counter); if(_lastId!=id) { _lastId = id; emit newID(pTarget); emit valid(TRUE); if (allowNull()) emit notNull(TRUE); } return; } } } } else { for (int counter = 0; counter < count(); counter++) { if (_ids.at(counter) == pTarget) { setCurrentIndex(counter); if(_lastId!=pTarget) { _lastId = pTarget; emit newID(pTarget); emit valid(TRUE); if (allowNull()) emit notNull(TRUE); } return; } } } setNull(); }
void QgsScaleComboBox::setNull() { if ( allowNull() ) setScale( std::numeric_limits< double >::quiet_NaN() ); }
void XComboBox::setNullStr(const QString& pNullStr) { _nullStr = pNullStr; if (allowNull()) setItemText(0, pNullStr); }