int KColorCells::sizeHintForColumn( int /*column*/ ) const { return width() / columnCount() ; }
void DGameTree::ResizeAllCols() { for (int i = 0; i < columnCount(); i++) resizeColumnToContents(i); }
void EntryAttachmentsModel::attachmentChange(const QString& key) { int row = m_entryAttachments->keys().indexOf(key); Q_EMIT dataChanged(index(row, 0), index(row, columnCount()-1)); }
void ListModel::Update (int pos) { emit dataChanged (index (pos, 0), index (pos, columnCount () - 1)); }
Message ChatLineModel::takeMessageAt(int i) { Message msg = _messageList[i].message(); _messageList.removeAt(i); return msg; } void ChatLineModel::styleChanged() { foreach(ChatLineModelItem item, _messageList) { item.invalidateWrapList(); } emit dataChanged(index(0, 0), index(rowCount()-1, columnCount()-1)); } QDataStream &operator<<(QDataStream &out, const ChatLineModel::WrapList wplist) { out << wplist.count(); ChatLineModel::WrapList::const_iterator it = wplist.begin(); while (it != wplist.end()) { out << (*it).start << (*it).width << (*it).trailing; ++it; } return out; }
QVariant QgsNodeEditorModel::data( const QModelIndex& index, int role ) const { if ( !index.isValid() || ( role != Qt::DisplayRole && role != Qt::EditRole && role != MinRadiusRole && role != Qt::FontRole ) ) return QVariant(); if ( index.row() >= mSelectedFeature->vertexMap().count() ) return QVariant(); if ( index.column() >= columnCount() ) return QVariant(); //get QgsVertexEntry for row const QgsVertexEntry* vertex = mSelectedFeature->vertexMap().at( index.row() ); if ( !vertex ) { return QVariant(); } if ( role == Qt::FontRole ) { double r = 0; double minRadius = 0; if ( calcR( index.row(), r, minRadius ) ) { QFont curvePointFont = mWidgetFont; curvePointFont.setItalic( true ); return curvePointFont; } else { return QVariant(); } } if ( role == MinRadiusRole ) { if ( index.column() == mRCol ) { double r = 0; double minRadius = 0; if ( calcR( index.row(), r, minRadius ) ) { return minRadius; } } return QVariant(); } if ( index.column() == 0 ) return vertex->point().x(); else if ( index.column() == 1 ) return vertex->point().y(); else if ( index.column() == mZCol ) return vertex->point().z(); else if ( index.column() == mMCol ) return vertex->point().m(); else if ( index.column() == mRCol ) { double r = 0; double minRadius = 0; if ( calcR( index.row(), r, minRadius ) ) { return r; } return QVariant(); } else { return QVariant(); } }
void TorrentContentModel::selectNone() { for (int i = 0; i < m_rootItem->childCount(); ++i) m_rootItem->child(i)->setPriority(prio::IGNORED); emit dataChanged(index(0, 0), index(rowCount(), columnCount())); }
QVariant SimpleTreeItem::data(int column, int role) const { if(column >= columnCount() || role != Qt::DisplayRole) return QVariant(); else return _itemData[column]; }
Iax2AnalysisTreeWidgetItem(QTreeWidget *tree, tap_iax2_stat_t *statinfo, packet_info *pinfo) : QTreeWidgetItem(tree, iax2_analysis_type_) { frame_num_ = pinfo->fd->num; pkt_len_ = pinfo->fd->pkt_len; flags_ = statinfo->flags; if (flags_ & STAT_FLAG_FIRST) { delta_ = 0.0; jitter_ = 0.0; } else { delta_ = statinfo->delta; jitter_ = statinfo->jitter; } bandwidth_ = statinfo->bandwidth; ok_ = false; QColor bg_color = QColor(); QString status; if (statinfo->flags & STAT_FLAG_WRONG_SEQ) { status = QObject::tr("Wrong sequence number"); bg_color = ColorUtils::expert_color_error; } else if (statinfo->flags & STAT_FLAG_REG_PT_CHANGE) { status = QObject::tr("Payload changed to PT=%1").arg(statinfo->pt); bg_color = color_rtp_warn_; } else if (statinfo->flags & STAT_FLAG_WRONG_TIMESTAMP) { status = QObject::tr("Incorrect timestamp"); /* color = COLOR_WARNING; */ bg_color = color_rtp_warn_; } else if ((statinfo->flags & STAT_FLAG_PT_CHANGE) && !(statinfo->flags & STAT_FLAG_FIRST) && !(statinfo->flags & STAT_FLAG_PT_CN) && (statinfo->flags & STAT_FLAG_FOLLOW_PT_CN) && !(statinfo->flags & STAT_FLAG_MARKER)) { status = QObject::tr("Marker missing?"); bg_color = color_rtp_warn_; } else { if (statinfo->flags & STAT_FLAG_MARKER) { bg_color = color_rtp_warn_; } } if (status.isEmpty()) { ok_ = true; status = UTF8_CHECK_MARK; } setText(packet_col_, QString::number(frame_num_)); setText(delta_col_, QString::number(delta_, 'f', 2)); setText(jitter_col_, QString::number(jitter_, 'f', 2)); setText(bandwidth_col_, QString::number(bandwidth_, 'f', 2)); setText(status_col_, status); setText(length_col_, QString::number(pkt_len_)); setTextAlignment(packet_col_, Qt::AlignRight); setTextAlignment(delta_col_, Qt::AlignRight); setTextAlignment(jitter_col_, Qt::AlignRight); setTextAlignment(bandwidth_col_, Qt::AlignRight); setTextAlignment(length_col_, Qt::AlignRight); if (bg_color.isValid()) { for (int col = 0; col < columnCount(); col++) { setBackground(col, bg_color); setForeground(col, ColorUtils::expert_color_foreground); } } }
void cCustomShotTable::SetCurrentCell(int Index) { if ((Index<0)||(Index>=columnCount())) return; setCurrentCell(0,Index,QItemSelectionModel::Select|QItemSelectionModel::Current); }
void cCustomShotTable::RepaintCell(int Index) { if ((Index<0)||(Index>=columnCount())) return; update(model()->index(0,Index)); }
int cCustomShotTable::NbrItem() { return columnCount(); }
void RenderMultiColumnSet::collectLayerFragments(LayerFragments& fragments, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) { // Let's start by introducing the different coordinate systems involved here. They are different // in how they deal with writing modes and columns. RenderLayer rectangles tend to be more // physical than the rectangles used in RenderObject & co. // // The two rectangles passed to this method are physical, except that we pretend that there's // only one long column (that's the flow thread). They are relative to the top left corner of // the flow thread. All rectangles being compared to the dirty rect also need to be in this // coordinate system. // // Then there's the output from this method - the stuff we put into the list of fragments. The // translationOffset point is the actual physical translation required to get from a location in // the flow thread to a location in some column. The paginationClip rectangle is in the same // coordinate system as the two rectangles passed to this method (i.e. physical, in flow thread // coordinates, pretending that there's only one long column). // // All other rectangles in this method are slightly less physical, when it comes to how they are // used with different writing modes, but they aren't really logical either. They are just like // RenderBox::frameRect(). More precisely, the sizes are physical, and the inline direction // coordinate is too, but the block direction coordinate is always "logical top". These // rectangles also pretend that there's only one long column, i.e. they are for the flow thread. // // To sum up: input and output from this method are "physical" RenderLayer-style rectangles and // points, while inside this method we mostly use the RenderObject-style rectangles (with the // block direction coordinate always being logical top). // Put the layer bounds into flow thread-local coordinates by flipping it first. Since we're in // a renderer, most rectangles are represented this way. LayoutRect layerBoundsInFlowThread(layerBoundingBox); flowThread()->flipForWritingMode(layerBoundsInFlowThread); // Now we can compare with the flow thread portions owned by each column. First let's // see if the rect intersects our flow thread portion at all. LayoutRect clippedRect(layerBoundsInFlowThread); clippedRect.intersect(RenderRegion::flowThreadPortionOverflowRect()); if (clippedRect.isEmpty()) return; // Now we know we intersect at least one column. Let's figure out the logical top and logical // bottom of the area we're checking. LayoutUnit layerLogicalTop = isHorizontalWritingMode() ? layerBoundsInFlowThread.y() : layerBoundsInFlowThread.x(); LayoutUnit layerLogicalBottom = (isHorizontalWritingMode() ? layerBoundsInFlowThread.maxY() : layerBoundsInFlowThread.maxX()) - 1; // Figure out the start and end columns and only check within that range so that we don't walk the // entire column set. unsigned startColumn = columnIndexAtOffset(layerLogicalTop); unsigned endColumn = columnIndexAtOffset(layerLogicalBottom); LayoutUnit colLogicalWidth = computedColumnWidth(); LayoutUnit colGap = columnGap(); unsigned colCount = columnCount(); RenderBlockFlow* parentFlow = toRenderBlockFlow(parent()); bool progressionReversed = parentFlow->multiColumnFlowThread()->progressionIsReversed(); bool progressionIsInline = parentFlow->multiColumnFlowThread()->progressionIsInline(); LayoutUnit initialBlockOffset = initialBlockOffsetForPainting(); for (unsigned i = startColumn; i <= endColumn; i++) { // Get the portion of the flow thread that corresponds to this column. LayoutRect flowThreadPortion = flowThreadPortionRectAt(i); // Now get the overflow rect that corresponds to the column. LayoutRect flowThreadOverflowPortion = flowThreadPortionOverflowRect(flowThreadPortion, i, colCount, colGap); // In order to create a fragment we must intersect the portion painted by this column. LayoutRect clippedRect(layerBoundsInFlowThread); clippedRect.intersect(flowThreadOverflowPortion); if (clippedRect.isEmpty()) continue; // We also need to intersect the dirty rect. We have to apply a translation and shift based off // our column index. LayoutPoint translationOffset; LayoutUnit inlineOffset = progressionIsInline ? i * (colLogicalWidth + colGap) : LayoutUnit(); bool leftToRight = style().isLeftToRightDirection() ^ progressionReversed; if (!leftToRight) { inlineOffset = -inlineOffset; if (progressionReversed) inlineOffset += contentLogicalWidth() - colLogicalWidth; } translationOffset.setX(inlineOffset); LayoutUnit blockOffset = initialBlockOffset + (isHorizontalWritingMode() ? -flowThreadPortion.y() : -flowThreadPortion.x()); if (!progressionIsInline) { if (!progressionReversed) blockOffset = i * colGap; else blockOffset -= i * (computedColumnHeight() + colGap); } if (isFlippedBlocksWritingMode(style().writingMode())) blockOffset = -blockOffset; translationOffset.setY(blockOffset); if (!isHorizontalWritingMode()) translationOffset = translationOffset.transposedPoint(); // FIXME: The translation needs to include the multicolumn set's content offset within the // multicolumn block as well. This won't be an issue until we start creating multiple multicolumn sets. // Shift the dirty rect to be in flow thread coordinates with this translation applied. LayoutRect translatedDirtyRect(dirtyRect); translatedDirtyRect.moveBy(-translationOffset); // See if we intersect the dirty rect. clippedRect = layerBoundingBox; clippedRect.intersect(translatedDirtyRect); if (clippedRect.isEmpty()) continue; // Something does need to paint in this column. Make a fragment now and supply the physical translation // offset and the clip rect for the column with that offset applied. LayerFragment fragment; fragment.paginationOffset = translationOffset; LayoutRect flippedFlowThreadOverflowPortion(flowThreadOverflowPortion); // Flip it into more a physical (RenderLayer-style) rectangle. flowThread()->flipForWritingMode(flippedFlowThreadOverflowPortion); fragment.paginationClip = flippedFlowThreadOverflowPortion; fragments.append(fragment); } }
void RenderMultiColumnSet::paintColumnRules(PaintInfo& paintInfo, const LayoutPoint& paintOffset) { if (paintInfo.context->paintingDisabled()) return; RenderMultiColumnFlowThread* flowThread = toRenderBlockFlow(parent())->multiColumnFlowThread(); const RenderStyle& blockStyle = parent()->style(); const Color& ruleColor = blockStyle.visitedDependentColor(CSSPropertyWebkitColumnRuleColor); bool ruleTransparent = blockStyle.columnRuleIsTransparent(); EBorderStyle ruleStyle = blockStyle.columnRuleStyle(); LayoutUnit ruleThickness = blockStyle.columnRuleWidth(); LayoutUnit colGap = columnGap(); bool renderRule = ruleStyle > BHIDDEN && !ruleTransparent; if (!renderRule) return; unsigned colCount = columnCount(); if (colCount <= 1) return; bool antialias = shouldAntialiasLines(paintInfo.context); if (flowThread->progressionIsInline()) { bool leftToRight = style().isLeftToRightDirection() ^ flowThread->progressionIsReversed(); LayoutUnit currLogicalLeftOffset = leftToRight ? LayoutUnit() : contentLogicalWidth(); LayoutUnit ruleAdd = logicalLeftOffsetForContent(); LayoutUnit ruleLogicalLeft = leftToRight ? LayoutUnit() : contentLogicalWidth(); LayoutUnit inlineDirectionSize = computedColumnWidth(); BoxSide boxSide = isHorizontalWritingMode() ? leftToRight ? BSLeft : BSRight : leftToRight ? BSTop : BSBottom; for (unsigned i = 0; i < colCount; i++) { // Move to the next position. if (leftToRight) { ruleLogicalLeft += inlineDirectionSize + colGap / 2; currLogicalLeftOffset += inlineDirectionSize + colGap; } else { ruleLogicalLeft -= (inlineDirectionSize + colGap / 2); currLogicalLeftOffset -= (inlineDirectionSize + colGap); } // Now paint the column rule. if (i < colCount - 1) { LayoutUnit ruleLeft = isHorizontalWritingMode() ? paintOffset.x() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd : paintOffset.x() + borderLeft() + paddingLeft(); LayoutUnit ruleRight = isHorizontalWritingMode() ? ruleLeft + ruleThickness : ruleLeft + contentWidth(); LayoutUnit ruleTop = isHorizontalWritingMode() ? paintOffset.y() + borderTop() + paddingTop() : paintOffset.y() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd; LayoutUnit ruleBottom = isHorizontalWritingMode() ? ruleTop + contentHeight() : ruleTop + ruleThickness; IntRect pixelSnappedRuleRect = pixelSnappedIntRectFromEdges(ruleLeft, ruleTop, ruleRight, ruleBottom); drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); } ruleLogicalLeft = currLogicalLeftOffset; } } else { bool topToBottom = !style().isFlippedBlocksWritingMode() ^ flowThread->progressionIsReversed(); LayoutUnit ruleLeft = isHorizontalWritingMode() ? LayoutUnit() : colGap / 2 - colGap - ruleThickness / 2; LayoutUnit ruleWidth = isHorizontalWritingMode() ? contentWidth() : ruleThickness; LayoutUnit ruleTop = isHorizontalWritingMode() ? colGap / 2 - colGap - ruleThickness / 2 : LayoutUnit(); LayoutUnit ruleHeight = isHorizontalWritingMode() ? ruleThickness : contentHeight(); LayoutRect ruleRect(ruleLeft, ruleTop, ruleWidth, ruleHeight); if (!topToBottom) { if (isHorizontalWritingMode()) ruleRect.setY(height() - ruleRect.maxY()); else ruleRect.setX(width() - ruleRect.maxX()); } ruleRect.moveBy(paintOffset); BoxSide boxSide = isHorizontalWritingMode() ? topToBottom ? BSTop : BSBottom : topToBottom ? BSLeft : BSRight; LayoutSize step(0, topToBottom ? computedColumnHeight() + colGap : -(computedColumnHeight() + colGap)); if (!isHorizontalWritingMode()) step = step.transposedSize(); for (unsigned i = 1; i < colCount; i++) { ruleRect.move(step); IntRect pixelSnappedRuleRect = pixelSnappedIntRect(ruleRect); drawLineForBoxSide(paintInfo.context, pixelSnappedRuleRect.x(), pixelSnappedRuleRect.y(), pixelSnappedRuleRect.maxX(), pixelSnappedRuleRect.maxY(), boxSide, ruleColor, ruleStyle, 0, 0, antialias); } } }
void ConnectionModel::updateAll() { emit dataChanged(index(0, 0), index(rowCount(), columnCount())); }
void SeView::dropEvent(QDropEvent * e) { QString str, tmp; bool lastPage = false; if (e->mimeData()->hasFormat("page/magic")) { e->setDropAction(Qt::MoveAction); e->accept(); // HACK to prevent strange Qt4 cursor behaviour after dropping. It's examined by Trolltech now - PV. // It's the one and only reason why to include QApplication here. // But sadly this destroys our normal Cursors // Fixed at least in Qt-4.4.2 // QApplication::restoreOverrideCursor(); str = e->mimeData()->text(); ClearPix(); if (str.startsWith("1")) { int a = rowAt(e->pos().y()); int b = columnAt(e->pos().x()); int p; tmp = str.remove(0,1); if ((a == -1) || (b == -1)) return; if (a == rowCount()-1) { emit NewPage(MaxC+1, tmp); return; } p = GetPage(a, b, &lastPage); if (columnCount() == 1) { if ((a % 2) == 0) emit NewPage(p, tmp); else { emit UseTemp(tmp, p); QTableWidgetItem* ite = item(a, b); if (ite == 0) return; if (ite->type() == 1002) { SeItem* it = (SeItem*)ite; it->pageName = tmp; } } return; } else { if ((b % 2) == 0) { if (lastPage) emit NewPage(p+1, tmp); else emit NewPage(p, tmp); } else { emit UseTemp(tmp, p); QTableWidgetItem* ite = item(a, b); if (ite == 0) return; if (ite->type() == 1002) { SeItem* it = (SeItem*)ite; it->pageName = tmp; } } return; } } if (str.startsWith("2")) { int st = str.indexOf(" "); int en = str.indexOf(" ", st+1); tmp = str.mid(en+1); int dr = str.mid(st, en-st).toInt(); int a = rowAt(e->pos().y()); int b = columnAt(e->pos().x()); int p; if ((a == -1) || (b == -1)) return; QTableWidgetItem* ite = item(a, b); p = GetPage(a, b, &lastPage); if (a == rowCount()-1) { emit movePage(dr, p+1); return; } if (columnCount() == 1) { if ((a % 2) == 0) emit movePage(dr, p); else { emit UseTemp(tmp, p); if (ite == 0) return; SeItem* it = (SeItem*)ite; it->pageName = tmp; } return; } else { if ((b % 2) == 0) emit movePage(dr, lastPage ? p+1 : p); else { emit UseTemp(tmp, p); if (ite == 0) return; if (ite->type() == 1002) { SeItem* it = (SeItem*)ite; it->pageName = tmp; } } return; } } } }
void MemoryViewWidget::Update() { clearSelection(); setColumnCount(3 + GetColumnCount(m_type)); if (rowCount() == 0) setRowCount(1); setRowHeight(0, 24); // Calculate (roughly) how many rows will fit in our table int rows = std::round((height() / static_cast<float>(rowHeight(0))) - 0.25); setRowCount(rows); for (int i = 0; i < rows; i++) { setRowHeight(i, 24); u32 addr = m_address - ((rowCount() / 2) * 16) + i * 16; auto* bp_item = new QTableWidgetItem; bp_item->setFlags(Qt::ItemIsEnabled); bp_item->setData(Qt::UserRole, addr); setItem(i, 0, bp_item); auto* addr_item = new QTableWidgetItem(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0'))); addr_item->setData(Qt::UserRole, addr); addr_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); setItem(i, 1, addr_item); if (addr == m_address) addr_item->setSelected(true); if (Core::GetState() != Core::State::Paused || !PowerPC::HostIsRAMAddress(addr)) { for (int c = 2; c < columnCount(); c++) { auto* item = new QTableWidgetItem(QStringLiteral("-")); item->setFlags(Qt::ItemIsEnabled); item->setData(Qt::UserRole, addr); setItem(i, c, item); } continue; } auto* description_item = new QTableWidgetItem(QString::fromStdString(PowerPC::debug_interface.GetDescription(addr))); description_item->setForeground(Qt::blue); description_item->setFlags(Qt::ItemIsEnabled); setItem(i, columnCount() - 1, description_item); bool row_breakpoint = true; auto update_values = [&](auto value_to_string) { for (int c = 0; c < GetColumnCount(m_type); c++) { auto* hex_item = new QTableWidgetItem; hex_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); const u32 address = addr + c * (16 / GetColumnCount(m_type)); if (PowerPC::memchecks.OverlapsMemcheck(address, 16 / GetColumnCount(m_type))) hex_item->setBackground(Qt::red); else row_breakpoint = false; setItem(i, 2 + c, hex_item); if (PowerPC::HostIsRAMAddress(address)) { hex_item->setText(value_to_string(address)); hex_item->setData(Qt::UserRole, address); } else { hex_item->setFlags(0); hex_item->setText(QStringLiteral("-")); } } }; switch (m_type) { case Type::U8: update_values([](u32 address) { const u8 value = PowerPC::HostRead_U8(address); return QStringLiteral("%1").arg(value, 2, 16, QLatin1Char('0')); }); break; case Type::ASCII: update_values([](u32 address) { const char value = PowerPC::HostRead_U8(address); return std::isprint(value) ? QString{QChar::fromLatin1(value)} : QStringLiteral("."); }); break; case Type::U16: update_values([](u32 address) { const u16 value = PowerPC::HostRead_U16(address); return QStringLiteral("%1").arg(value, 4, 16, QLatin1Char('0')); }); break; case Type::U32: update_values([](u32 address) { const u32 value = PowerPC::HostRead_U32(address); return QStringLiteral("%1").arg(value, 8, 16, QLatin1Char('0')); }); break; case Type::Float32: update_values([](u32 address) { return QString::number(PowerPC::HostRead_F32(address)); }); break; } if (row_breakpoint) { bp_item->setData(Qt::DecorationRole, Resources::GetScaledThemeIcon("debugger_breakpoint").pixmap(QSize(24, 24))); } } setColumnWidth(0, 24 + 5); for (int i = 1; i < columnCount(); i++) { resizeColumnToContents(i); // Add some extra spacing because the default width is too small in most cases setColumnWidth(i, columnWidth(i) * 1.1); } viewport()->update(); update(); }
bool JSON_Model::setData(QModelIndex const& index, QVariant const& value, int role) { if (!index.isValid()) { return false; } auto* ti = (Tree_Item*)index.internalPointer(); if (!ti || !ti->m_json) { return false; } bool modified = false; auto* json = ti->m_json; if (role == Qt::DisplayRole || role == Qt::EditRole) { if (index.column() == 1) { if (json->IsBool()) { json->SetBool(value.toBool()); modified = true; } else if (json->IsInt()) { json->SetInt(value.toInt()); modified = true; } else if (json->IsUint()) { json->SetUint(value.toUInt()); modified = true; } else if (json->IsInt64()) { json->SetInt64(value.toLongLong()); modified = true; } else if (json->IsUint64()) { json->SetUint64(value.toULongLong()); modified = true; } else if (json->IsDouble() || json->IsNumber()) { json->SetDouble(value.toDouble()); modified = true; } else if (json->IsString()) { json->SetString(value.toString().toLatin1().data(), m_document->GetAllocator()); modified = true; } } } if (modified) { emit dataChanged(createIndex(index.row(), 0, index.internalPointer()), createIndex(index.row(), columnCount(), index.internalPointer())); } return modified; }
void RenderMultiColumnSet::collectLayerFragments(LayerFragments& fragments, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect) { // The two rectangles passed to this method are physical, except that we pretend that there's // only one long column (that's how a flow thread works). // // Then there's the output from this method - the stuff we put into the list of fragments. The // fragment.paginationOffset point is the actual physical translation required to get from a // location in the flow thread to a location in a given column. The fragment.paginationClip // rectangle, on the other hand, is in the same coordinate system as the two rectangles passed // to this method (flow thread coordinates). // // All other rectangles in this method are sized physically, and the inline direction coordinate // is physical too, but the block direction coordinate is "logical top". This is the same as // e.g. RenderBox::frameRect(). These rectangles also pretend that there's only one long column, // i.e. they are for the flow thread. // Put the layer bounds into flow thread-local coordinates by flipping it first. Since we're in // a renderer, most rectangles are represented this way. LayoutRect layerBoundsInFlowThread(layerBoundingBox); flowThread()->flipForWritingMode(layerBoundsInFlowThread); // Now we can compare with the flow thread portions owned by each column. First let's // see if the rect intersects our flow thread portion at all. LayoutRect clippedRect(layerBoundsInFlowThread); clippedRect.intersect(RenderRegion::flowThreadPortionOverflowRect()); if (clippedRect.isEmpty()) return; // Now we know we intersect at least one column. Let's figure out the logical top and logical // bottom of the area we're checking. LayoutUnit layerLogicalTop = isHorizontalWritingMode() ? layerBoundsInFlowThread.y() : layerBoundsInFlowThread.x(); LayoutUnit layerLogicalBottom = (isHorizontalWritingMode() ? layerBoundsInFlowThread.maxY() : layerBoundsInFlowThread.maxX()) - 1; // Figure out the start and end columns and only check within that range so that we don't walk the // entire column set. unsigned startColumn = columnIndexAtOffset(layerLogicalTop); unsigned endColumn = columnIndexAtOffset(layerLogicalBottom); LayoutUnit colLogicalWidth = computedColumnWidth(); LayoutUnit colGap = columnGap(); unsigned colCount = columnCount(); for (unsigned i = startColumn; i <= endColumn; i++) { // Get the portion of the flow thread that corresponds to this column. LayoutRect flowThreadPortion = flowThreadPortionRectAt(i); // Now get the overflow rect that corresponds to the column. LayoutRect flowThreadOverflowPortion = flowThreadPortionOverflowRect(flowThreadPortion, i, colCount, colGap); // In order to create a fragment we must intersect the portion painted by this column. LayoutRect clippedRect(layerBoundsInFlowThread); clippedRect.intersect(flowThreadOverflowPortion); if (clippedRect.isEmpty()) continue; // We also need to intersect the dirty rect. We have to apply a translation and shift based off // our column index. LayoutPoint translationOffset; LayoutUnit inlineOffset = i * (colLogicalWidth + colGap); if (!style()->isLeftToRightDirection()) inlineOffset = -inlineOffset; translationOffset.setX(inlineOffset); LayoutUnit blockOffset = isHorizontalWritingMode() ? -flowThreadPortion.y() : -flowThreadPortion.x(); if (isFlippedBlocksWritingMode(style()->writingMode())) blockOffset = -blockOffset; translationOffset.setY(blockOffset); if (!isHorizontalWritingMode()) translationOffset = translationOffset.transposedPoint(); // FIXME: The translation needs to include the multicolumn set's content offset within the // multicolumn block as well. This won't be an issue until we start creating multiple multicolumn sets. // Shift the dirty rect to be in flow thread coordinates with this translation applied. LayoutRect translatedDirtyRect(dirtyRect); translatedDirtyRect.moveBy(-translationOffset); // See if we intersect the dirty rect. clippedRect = layerBoundingBox; clippedRect.intersect(translatedDirtyRect); if (clippedRect.isEmpty()) continue; // Something does need to paint in this column. Make a fragment now and supply the physical translation // offset and the clip rect for the column with that offset applied. LayerFragment fragment; fragment.paginationOffset = translationOffset; LayoutRect flippedFlowThreadOverflowPortion(flowThreadOverflowPortion); // Flip it into more a physical (RenderLayer-style) rectangle. flowThread()->flipForWritingMode(flippedFlowThreadOverflowPortion); fragment.paginationClip = flippedFlowThreadOverflowPortion; fragments.append(fragment); } }
QModelIndex GlodonTableModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 || column < 0 || row >= rowCount(parent) || column >= columnCount(parent)) return QModelIndex(); return createIndex(row, column); }
/** * @brief This returns the type of data shown in the specified column * @param column must be valid * @return The type, or ML_END in case of error */ ml_select_e MLModel::columnType( int logicalindex ) const { if( logicalindex < 0 || logicalindex >= columnCount() ) return ML_END; return meta_to_mlmeta( columnToMeta( logicalindex ) ); }
void ResultList::saveToFile(QXmlStreamWriter* stream) { int num_rows = rowCount(); int num_columns = columnCount(); stream->writeStartElement("ResultList"); stream->writeAttribute("title", title); stream->writeAttribute("decimal_places", QString::number(decimal_places)); stream->writeAttribute("decimal_factor", QString::number(decimal_factor)); stream->writeAttribute("column_category", QString::number(column_category)); stream->writeAttribute("column_rank", QString::number(column_rank)); stream->writeAttribute("column_first_runner", QString::number(column_first_runner)); stream->writeAttribute("column_last_runner", QString::number(column_last_runner)); stream->writeAttribute("column_club", QString::number(column_club)); stream->writeAttribute("column_status", QString::number(column_status)); stream->writeAttribute("column_time", QString::number(column_time)); stream->writeAttribute("column_points", QString::number(column_points)); stream->writeAttribute("column_additional_start", QString::number(column_additional_start)); stream->writeAttribute("column_additional_end", QString::number(column_additional_end)); stream->writeAttribute("num_rows", QString::number(num_rows)); stream->writeAttribute("num_cols", QString::number(num_columns)); for (int i = 0; i < num_columns; ++i) { stream->writeEmptyElement("Column"); stream->writeAttribute("type", QString::number(static_cast<int>(columnTypes[i]))); stream->writeAttribute("label", columnLabel[i]); } for (int i = 0; i < num_rows; ++i) { stream->writeStartElement("Row"); for (int k = 0; k < num_columns; ++k) { stream->writeEmptyElement("Value"); ColumnType type = columnTypes[k]; switch (type) { case ColumnRank: case ColumnTime: case ColumnResult: stream->writeAttribute("v", QString::number(columns[k][i].toInt())); break; case ColumnCategory: stream->writeAttribute("v", reinterpret_cast<AbstractCategory*>(columns[k][i].value<void*>())->name); break; case ColumnRunner: { Runner* runner = reinterpret_cast<Runner*>(columns[k][i].value<void*>()); stream->writeAttribute("i", QString::number(runner->getID())); stream->writeAttribute("f", runner->getFirstName()); stream->writeAttribute("l", runner->getLastName()); stream->writeAttribute("m", runner->isMale() ? "yes" : "no"); stream->writeAttribute("y", QString::number(runner->getYear())); break; } case ColumnClub: { Club* club = reinterpret_cast<Club*>(columns[k][i].value<void*>()); stream->writeAttribute("v", club ? club->getName() : ""); stream->writeAttribute("i", club ? QString::number(club->getID()) : "-1"); break; } case ColumnPoints: case ColumnPointInfo: stream->writeAttribute("v", columns[k][i].isValid() ? QString::number(columns[k][i].toInt()) : "-"); break; } } stream->writeEndElement(); } stream->writeEndElement(); }
/*! \since 5.0 Refreshes \a row in the model with values from the database table row matching on primary key values. Without a primary key, all column values must match. If no matching row is found, the model will show an empty row. Returns \c true if successful; otherwise returns \c false. \sa select() */ bool QSqlTableModel::selectRow(int row) { Q_D(QSqlTableModel); if (row < 0 || row >= rowCount()) return false; const int table_sort_col = d->sortColumn; d->sortColumn = -1; const QString table_filter = d->filter; d->filter = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement, d->tableName, primaryValues(row), false); static const QString wh = Sql::where() + Sql::sp(); if (d->filter.startsWith(wh, Qt::CaseInsensitive)) d->filter.remove(0, wh.length()); QString stmt; if (!d->filter.isEmpty()) stmt = selectStatement(); d->sortColumn = table_sort_col; d->filter = table_filter; if (stmt.isEmpty()) return false; bool exists; QSqlRecord newValues; { QSqlQuery q(d->db); q.setForwardOnly(true); if (!q.exec(stmt)) return false; exists = q.next(); newValues = q.record(); } bool needsAddingToCache = !exists || d->cache.contains(row); if (!needsAddingToCache) { const QSqlRecord curValues = record(row); needsAddingToCache = curValues.count() != newValues.count(); if (!needsAddingToCache) { // Look for changed values. Primary key fields are customarily first // and probably change less often than other fields, so start at the end. for (int f = curValues.count() - 1; f >= 0; --f) { if (curValues.value(f) != newValues.value(f)) { needsAddingToCache = true; break; } } } } if (needsAddingToCache) { d->cache[row].refresh(exists, newValues); emit headerDataChanged(Qt::Vertical, row, row); emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1)); } return true; }
bool ChartTableModel::loadOdf( const KoXmlElement &tableElement, KoShapeLoadingContext &context ) { Q_UNUSED( context ); setRowCount( 0 ); setColumnCount( 0 ); ///const QDomNode &node = tableElement.asQDomNode( QDomDocument() ); //QTextStream stream(stdout); //stream << node; // FIXME: Rewrite this without the for loop. I think there can // only be one table-rows and one table-header-rows element // in each table. int row = 0; KoXmlElement n; int found = false; forEachElement ( n, tableElement ) { if ( n.namespaceURI() != KoXmlNS::table ) continue; if ( n.localName() == "table-rows" || n.localName() == "table-header-rows" ) { found = true; KoXmlElement _n; forEachElement ( _n, n ) { // Must be a table:table-row, else go to next element. if ( _n.namespaceURI() != KoXmlNS::table || _n.localName() != "table-row" ) continue; // Add a row to the internal representation. setRowCount( rowCount() + 1 ); // Loop through all cells in a table row. int column = 0; KoXmlElement __n; forEachElement ( __n, _n ) { // Must be a table:table-cell, otherwise go to // next element. if ( __n.namespaceURI() == KoXmlNS::table && __n.localName() == "table-cell" ) { // continue; // If this row is wider than any previous one, // then add another column. // Is this efficient enough? if ( column >= columnCount() ) setColumnCount( columnCount() + 1 ); const QString valueType = __n.attributeNS( KoXmlNS::office, "value-type" ); QString valueString = __n.attributeNS( KoXmlNS::office, "value" ); const KoXmlElement valueElement = __n.namedItemNS( KoXmlNS::text, "p" ).toElement(); if ( ( valueElement.isNull() || !valueElement.isElement() ) && valueString.isEmpty() ) { qWarning() << "ChartTableModel::loadOdf(): Cell contains no valid <text:p> element, cannnot load cell data."; // Even if it doesn't contain any value, it's still a cell. column++; continue; } // Read the actual value in the cell. QVariant value; if ( valueString.isEmpty() ) valueString = valueElement.text(); if ( valueType == "float" ) value = valueString.toDouble(); else if ( valueType == "boolean" ) value = (bool)valueString.toInt(); else // if ( valueType == "string" ) value = valueString; setData( index( row, column ), value ); ++column; } } // foreach table:table-cell ++row; } // foreach table:table-row } }
QVariant FeedbackModel::headerData( int section, Qt::Orientation orientation, int role ) const { if ( orientation == Qt::Horizontal && role == Qt::DisplayRole && section >= 0 && section < columnCount() ) { switch ( section ) { case 0: return tr( "Date time" ); case 1: return tr( "Message" ); } } return QAbstractTableModel::headerData( section, orientation, role ); }
QVariant ScanFoldersModel::headerData(int section, Qt::Orientation orientation, int role) const { if ((orientation != Qt::Horizontal) || (role != Qt::DisplayRole) || (section < 0) || (section >= columnCount())) return {}; QVariant title; switch (section) { case WATCH: title = tr("Monitored Folder"); break; case DOWNLOAD: title = tr("Override Save Location"); break; } return title; }
QMap<int, QString> EditableResultsetTableModel::generateDml(const QString &schema, const QString &table, const QString &dblink) const { QMap<int, QString> result; QString dml; QString fullTableName = schema.isEmpty() ? QString("\"%1\"").arg(table) : QString("\"%1\".\"%2\"").arg(schema, table); if(!dblink.isEmpty()){ fullTableName.append("@").append(dblink); } QString fieldValue; QString colNames = joinEnclosed(columnMetadata->columnTitles, ", ", "\"", columnMetadata->columnTitles.size()-1); for(int i=0; i<insertedRows.size(); ++i){ dml = QString("INSERT INTO %1 (%2) VALUES (").arg(fullTableName, colNames); for(int k=0; k<columnMetadata->columnTitles.size()-1; ++k){ fieldValue = index(i, k).data().toString(); escapeFieldValue(fieldValue, columnMetadata.data(), k+1, true); //colIx is 1 based if(k>0){ dml.append(", "); } dml.append(fieldValue); } dml.append(")"); result[i] = dml; } QMapIterator< int, QMap<int, QString> > i(changedData); while (i.hasNext()) { i.next(); dml.clear(); if(deletedRows.contains(i.key())){ continue; } QMapIterator< int, QString > i2(i.value()); while (i2.hasNext()) { i2.next(); if(!dml.isEmpty()){ dml.append(", "); } QString columnName = columnMetadata->columnTitles.at(i2.key()); fieldValue = i2.value(); escapeFieldValue(fieldValue, columnMetadata.data(), i2.key()+1, true); //colIx is 1 based dml.append(QString("\"%1\" = %2").arg(columnName, fieldValue)); } Q_ASSERT(!dml.isEmpty()); dml.prepend(QString("UPDATE %1 SET ").arg(fullTableName)); int modelRow = i.key() + insertedRows.size(); dml.append(QString(" WHERE ROWID = '%1'").arg(index(modelRow, columnCount()-1).data().toString())); result[modelRow] = dml; } for(int i=0; i<deletedRows.size(); ++i){ int modelRow = deletedRows.at(i) + insertedRows.size(); dml = QString("DELETE FROM %1 WHERE ROWID = '%2'").arg(fullTableName, index(modelRow, columnCount()-1).data().toString()); result[modelRow] = dml; } return result; }
QVariant PasswordFileModel::data(const QModelIndex &index, int role) const { // We validate arguments. if (!index.isValid() || (index.column() >= columnCount()) || (index.row() >= rowCount())) return QVariant(); switch (role) { case Qt::DisplayRole: return m_data.at(index.column()).at(index.row()); break; case Qt::CheckStateRole: if ((index.column() == 0) && (index.row() < m_checkedRows.count())) { return m_checkedRows[index.row()]; } else { return QVariant(); } break; case Qt::FontRole: if ((index.column() == 0) && (!m_data.at(PASSWORD_COL).at(index.row()).isEmpty())) { QFont font; font.setBold(true); return font; } else if ((index.column() == PASSWORD_COL) && (m_rowsWithEmptyPasswords.contains(index.row()))) { //Special case empty password ("") QFont font; font.setItalic(true); return font; } else { return QVariant(); } break; case Qt::BackgroundRole: // Show differently cracked passwords if ((index.row() < m_checkedRows.count()) && (m_checkedRows.at(index.row()) == Qt::Unchecked)) { return QVariant(QColor("#EEEEEE")); // a kind of light-gray } else { return QVariant(); } break; case Qt::ForegroundRole: // Special case empty password ("") if ((index.column() == PASSWORD_COL) && (m_rowsWithEmptyPasswords.contains(index.row()))) { return QVariant(QBrush(Qt::darkGray)); } else { return QVariant(); } break; case Qt::TextAlignmentRole: // Special case empty password ("") if ((index.column() == PASSWORD_COL) && (m_rowsWithEmptyPasswords.contains(index.row()))) { return Qt::AlignCenter; } else { return QVariant(); } default: return QVariant(); } }
void TorrentModel::handleTorrentStatusUpdated(BitTorrent::TorrentHandle *const torrent) { const int row = m_torrents.indexOf(torrent); if (row >= 0) emit dataChanged(index(row, 0), index(row, columnCount() - 1)); }
int KColorCells::count() const { return rowCount() * columnCount(); }