Пример #1
0
Poco::Dynamic::Var RecordSet::value(const std::string& name, std::size_t row, bool useFilter) const
{
	if (useFilter && isFiltered() && !isAllowed(row))
		throw InvalidAccessException("Row not allowed");

	if (isNull(metaColumn(name).position(), row)) return Poco::Dynamic::Var();

	switch (columnType(name))
	{
	case MetaColumn::FDT_BOOL:      return value<bool>(name, row, useFilter);
	case MetaColumn::FDT_INT8:      return value<Int8>(name, row, useFilter);
	case MetaColumn::FDT_UINT8:     return value<UInt8>(name, row, useFilter);
	case MetaColumn::FDT_INT16:     return value<Int16>(name, row, useFilter);
	case MetaColumn::FDT_UINT16:    return value<UInt16>(name, row, useFilter);
	case MetaColumn::FDT_INT32:	    return value<Int32>(name, row, useFilter);
	case MetaColumn::FDT_UINT32:    return value<UInt32>(name, row, useFilter);
	case MetaColumn::FDT_INT64:     return value<Int64>(name, row, useFilter);
	case MetaColumn::FDT_UINT64:    return value<UInt64>(name, row, useFilter);
	case MetaColumn::FDT_FLOAT:     return value<float>(name, row, useFilter);
	case MetaColumn::FDT_DOUBLE:    return value<double>(name, row, useFilter);
	case MetaColumn::FDT_STRING:    return value<std::string>(name, row, useFilter);
	case MetaColumn::FDT_WSTRING:   return value<UTF16String>(name, row, useFilter);
	case MetaColumn::FDT_BLOB:      return value<BLOB>(name, row, useFilter);
	case MetaColumn::FDT_DATE:      return value<Date>(name, row, useFilter);
	case MetaColumn::FDT_TIME:      return value<Time>(name, row, useFilter);
	case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(name, row, useFilter);
	default:
		throw UnknownTypeException("Data type not supported.");
	}
}
Пример #2
0
QVariant MLModel::data( const QModelIndex &index, const int role ) const
{
    if( index.isValid() )
    {
        if( role == Qt::DisplayRole || role == Qt::EditRole )
        {
            MLItem *it = static_cast<MLItem*>( index.internalPointer() );
            if( !it ) return QVariant();
            QVariant tmp = it->data( columnType( index.column() ) );
            return tmp;
        }
        else if( role == Qt::DecorationRole && index.column() == 0  )
        {
            /*
                FIXME: (see ml_type_e)
                media->type uses flags for media type information
            */
            return QVariant( icons[ getInputItem(index)->i_type ] );
        }
        else if( role == IsLeafNodeRole )
            return isLeaf( index );
        else if( role == IsCurrentsParentNodeRole )
            return isParent( index, currentIndex() );
        else if( role == IsCurrentRole )
        {
            return QVariant( isCurrent( index ) );
        }
    }
    return QVariant();
}
Пример #3
0
CardView::CardView(Table table, QSqlRelationalTableModel &model, int row)
	:ui(new Ui::CardView),
	mTable(table),
	mModel(model),
	mRow(row),
	isInsert(row == -1)
{
	ui->setupUi(this);



	for (int i=0; i < mTable.colums().size(); ++i)
	{
		auto column = mTable.colums()[i];

		QWidget* widget = column.isForeingKey()
						? createForeingLinkItem(column, mModel.data(mModel.index(row, i)))
						: createSimpleItem(column.columnType(), mModel.data(mModel.index(row, i)));

		if(!isInsert && column.isPrimaryKey())
			widget->setEnabled(false);

		if(column.isAutoInc())
			widget->setEnabled(false);

		ui->formLayout->addRow(column.caption(), widget);
	}
}
Пример #4
0
QVariant
CQJsonModel::
headerData(int section, Qt::Orientation orientation, int role) const
{
  if (orientation != Qt::Horizontal)
    return CQBaseModel::headerData(section, orientation, role);

  if (role == Qt::DisplayRole) {
    QString str;

    if (headerString(section, str))
      return QVariant(str);
  }
  else if (role == Qt::ToolTipRole) {
    QString str;

    if (headerString(section, str)) {
      CQBaseModelType type = columnType(section);

      str += ":" + typeName(type);

      return QVariant(str);
    }
  }
  else if (role == Qt::EditRole) {
    return QVariant();
  }
  else {
    return CQBaseModel::headerData(section, orientation, role);
  }

  return QVariant();
}
Пример #5
0
bool MLModel::setData( const QModelIndex &idx, const QVariant &value,
                             int role )
{
    if( role != Qt::EditRole || !idx.isValid() ) return false;
    MLItem *media = static_cast<MLItem*>( idx.internalPointer() );
    media->setData( columnType( idx.column() ), value );
    emit dataChanged( idx, idx );
    return true;
}
QList<int> LinearChart::barStyleColumns() const {
    QList<int> bars;
    for ( int c = 0;  c < this->model()->columnCount(); ++c ) {
      if ( columnType( c ) == Marb::Bar ) {
        bars.append( c );
      }
    }
    return bars;
}
QVariant
RideFileTableModel::data(const QModelIndex & index, int role) const
{
    if (role == Qt::ToolTipRole) return toolTip(index.row(), columnType(index.column()));

    if (index.row() >= ride->dataPoints().count() || index.column() >= headings_.count())
        return QVariant();
    else
        return ride->getPointValue(index.row(), headingsType[index.column()]);
}
Пример #8
0
QByteArray TestModel::save()
{
    QDomDocument doc;
    QDomProcessingInstruction pi = doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf8\"");
    doc.appendChild(pi);

    QDomElement modelEl = doc.createElement("model");
    doc.appendChild(modelEl);

    QDomElement  cellsEl = doc.createElement("cells");
    cellsEl.setAttribute("rows", rowCount());
    cellsEl.setAttribute("cols", columnCount());
    modelEl.appendChild(cellsEl);

    QDomElement titlesEl = doc.createElement("titles");
    for (int i = 0; i < columnCount(); i++) {
        QDomElement col = doc.createElement(QString("col%1").arg(i));
        QDomText text = doc.createTextNode(headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
        col.appendChild(text);
        titlesEl.appendChild(col);
    }
    modelEl.appendChild(titlesEl);

    for (int row = 0; row < rowCount(); row++) {
        QDomElement itemRow = doc.createElement(QString("row%1").arg(row));

        for (int col = 0; col < columnCount(); col++ ) {

            //TODO save images
            if (index(row, col).data().toString().simplified().isEmpty()) {
                continue;
            }

            QDomElement itemCol = doc.createElement(QString("col%1").arg(col));
            itemCol.setAttribute("type", QVariant::typeToName(columnType(col)));

            QDomText text = doc.createTextNode(index(row, col).data().toByteArray());
            itemCol.appendChild(text);
            itemRow.appendChild(itemCol);
        }

        if (itemRow.childNodes().count() > 0)
            cellsEl.appendChild(itemRow);
    }

//    QFile file("c:/test.xml");
//    if(file.open(QIODevice::WriteOnly)) {
//        QTextStream(&file) << doc.toString();
//        file.close();
//    }

    return doc.toByteArray().toBase64();
}
Пример #9
0
// Recursively figure out how many locations are used up by an input or output type.
// Return the size of type, as measured by "locations".
int TIntermediate::computeTypeLocationSize(const TType& type) const
{
    // "If the declared input is an array of size n and each element takes m locations, it will be assigned m * n 
    // consecutive locations..."
    if (type.isArray()) {
        // TODO: perf: this can be flattened by using getCumulativeArraySize(), and a deref that discards all arrayness
        TType elementType(type, 0);
        if (type.isImplicitlySizedArray()) {
            // TODO: are there valid cases of having an implicitly-sized array with a location?  If so, running this code too early.
            return computeTypeLocationSize(elementType);
        } else
            return type.getOuterArraySize() * computeTypeLocationSize(elementType);
    }

    // "The locations consumed by block and structure members are determined by applying the rules above 
    // recursively..."    
    if (type.isStruct()) {
        int size = 0;
        for (int member = 0; member < (int)type.getStruct()->size(); ++member) {
            TType memberType(type, member);
            size += computeTypeLocationSize(memberType);
        }
        return size;
    }

    // ES: "If a shader input is any scalar or vector type, it will consume a single location."

    // Desktop: "If a vertex shader input is any scalar or vector type, it will consume a single location. If a non-vertex 
    // shader input is a scalar or vector type other than dvec3 or dvec4, it will consume a single location, while 
    // types dvec3 or dvec4 will consume two consecutive locations. Inputs of type double and dvec2 will 
    // consume only a single location, in all stages."
    if (type.isScalar())
        return 1;
    if (type.isVector()) {
        if (language == EShLangVertex && type.getQualifier().isPipeInput())
            return 1;
        if (type.getBasicType() == EbtDouble && type.getVectorSize() > 2)
            return 2;
        else
            return 1;
    }

    // "If the declared input is an n x m single- or double-precision matrix, ...
    // The number of locations assigned for each matrix will be the same as 
    // for an n-element array of m-component vectors..."
    if (type.isMatrix()) {
        TType columnType(type, 0);
        return type.getMatrixCols() * computeTypeLocationSize(columnType);
    }

    assert(0);
    return 1;
}
Пример #10
0
// ----------------------------------------------------------------------------
// ArchiveEntryList::getItemText
//
// Called when the widget requests the text for [item] at [column]
// ----------------------------------------------------------------------------
string ArchiveEntryList::getItemText(long item, long column, long index) const
{
	// Get entry
	ArchiveEntry* entry = getEntry(index, false);

	// Check entry
	if (!entry)
		return "INVALID INDEX";

	// Determine what column we want
	int col = columnType(column);

	if (col == 0)
		return entry->getName();	// Name column
	else if (col == 1)
	{
		// Size column
		if (entry->getType() == EntryType::folderType())
		{
			// Entry is a folder, return the number of entries+subdirectories in it
			ArchiveTreeNode* dir = nullptr;

			// Get selected directory
			if (entry == entry_dir_back)
				dir = (ArchiveTreeNode*)current_dir->getParent();	// If it's the 'back directory', get the current dir's parent
			else
				dir = archive->getDir(entry->getName(), current_dir);

			// If it's null, return error
			if (!dir)
				return "INVALID DIRECTORY";

			// Return the number of items in the directory
			return S_FMT("%d entries", dir->numEntries() + dir->nChildren());
		}
		else
			return entry->getSizeString();	// Not a folder, just return the normal size string
	}
	else if (col == 2)
		return entry->getTypeString();	// Type column
	else if (col == 3)
	{
		// Index column
		if (entry->getType() == EntryType::folderType())
			return "";
		else
			return S_FMT("%d", entry->getParentDir()->entryIndex(entry));
	}
	else
		return "INVALID COLUMN";		// Invalid column
}
Пример #11
0
std::string TupleSchema::debug() const {
    std::ostringstream buffer;

    buffer << "Schema has " << columnCount() << " columns, allowInlinedObjects = " << allowInlinedObjects()
           << ", length = " << tupleLength() <<  ", uninlinedObjectColumns "  << m_uninlinedObjectColumnCount
           << std::endl;

    for (uint16_t i = 0; i < columnCount(); i++) {
        buffer << " column " << i << ": type = " << getTypeName(columnType(i));
        buffer << ", length = " << columnLength(i) << ", nullable = ";
        buffer << (columnAllowNull(i) ? "true" : "false") << ", isInlined = " << columnIsInlined(i) <<  std::endl;
    }

    std::string ret(buffer.str());
    return ret;
}
Пример #12
0
QList<int> LinearChart::calculateColumnsOrder() {

  QList<int> bars;
  QList<int> lines;
  QList<int> points;
  for ( int i = 0; i < this->model()->columnCount(); ++i ) {
    Marb::Types t = columnType( i );
    if ( t.testFlag( Marb::Bar ) ) {
      bars << i;
    } else if ( t.testFlag( Marb::Point ) ) {
      points << i;
    } else  {
      lines << i;
    }
  }
  bars << lines << points;
  return bars;
}
Пример #13
0
QString
WSearchListItem::text(int c) const
{
	QString tmp = WUniListItem::text(c);
	switch (columnType(c))
	{
	case String_NoCase:
	case String_NoCase_Stripped:
	case String_Cased:
	case String_Cased_Stripped:
		tmp.replace(QRegExp("\r\n"), " ");
		tmp.replace(QRegExp("\r"), " ");
		tmp.replace(QRegExp("\n"), " ");
	default:
		break; // empty
	};
	return tmp;
}
Пример #14
0
DynamicAny RecordSet::value(const std::string& name, std::size_t row) const
{
	switch (columnType(name))
	{
		case MetaColumn::FDT_BOOL:
		case MetaColumn::FDT_INT8:   return value<Int8>(name, row);        
		case MetaColumn::FDT_UINT8:  return value<UInt8>(name, row);       
		case MetaColumn::FDT_INT16:  return value<Int16>(name, row);       
		case MetaColumn::FDT_UINT16: return value<UInt16>(name, row);      
		case MetaColumn::FDT_INT32:  return value<Int32>(name, row);       
		case MetaColumn::FDT_UINT32: return value<UInt32>(name, row);      
		case MetaColumn::FDT_INT64:  return value<Int64>(name, row);       
		case MetaColumn::FDT_UINT64: return value<UInt64>(name, row);      
		case MetaColumn::FDT_FLOAT:  return value<float>(name, row);       
		case MetaColumn::FDT_DOUBLE: return value<double>(name, row);      
		case MetaColumn::FDT_STRING: return value<std::string>(name, row); 
		case MetaColumn::FDT_BLOB:   return value<BLOB>(name, row);        
		default:
			throw Poco::InvalidArgumentException("Data type not supported.");
	}
}
Пример #15
0
bool MLModel::isEditable( const QModelIndex &index ) const
{
    if( !index.isValid() )
        return false;

    ml_select_e type = columnType( index.column() );
    switch( type )
    {
    // Read-only members: not editable
    case ML_ALBUM_ID:
    case ML_ARTIST_ID:
    case ML_DURATION:
    case ML_ID:
    case ML_LAST_PLAYED:
    case ML_PLAYED_COUNT:
    case ML_TYPE:
        return false;
    // Read-write members: editable
    case ML_ALBUM:
    case ML_ARTIST:
    case ML_COVER:
    case ML_EXTRA:
    case ML_GENRE:
    case ML_ORIGINAL_TITLE:
    // case ML_ROLE:
    case ML_SCORE:
    case ML_TITLE:
    case ML_TRACK_NUMBER:
    case ML_URI:
    case ML_VOTE:
    case ML_YEAR:
        return true;
    default:
        return false;
    }
}