void Utils::ModelListModel::setHeaderDataSubModel(QAbstractItemModel* subModel) { if (!subModel || !m_subModels.contains(subModel)) //except for model == 0, allow only submodels that have been added to this model return; if (m_headerDataSubModel != subModel) { m_headerDataSubModel = subModel; //announce change emit headerDataChanged(Qt::Horizontal, INT_MIN, INT_MAX); //TODO: Is this call valid (with the parameters INT_{MIN,MAX})? emit headerDataChanged(Qt::Vertical, INT_MIN, INT_MAX); } }
void WSortFilterProxyModel::sourceHeaderDataChanged(Orientation orientation, int start, int end) { if (orientation == Vertical) { Item *item = itemFromIndex(WModelIndex()); for (int row = start; row <= end; ++row) { int mappedRow = item->sourceRowMap_[row]; if (mappedRow != -1) headerDataChanged().emit(orientation, mappedRow, mappedRow); } } else headerDataChanged().emit(orientation, start, end); }
void PlaylistTableModel::setCurrentIndex(int pos) { /* Unset previous index */ int tmp = m_currentIndex; m_currentIndex = -1; emit dataChanged(createIndex(tmp, 0), createIndex(tmp, 4)); emit headerDataChanged(Qt::Vertical, tmp, tmp); /* Store the new index */ m_currentIndex = pos; emit dataChanged(createIndex(pos, 0), createIndex(pos, 4)); emit headerDataChanged(Qt::Vertical, pos, pos); }
bool TablaModelR::setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role) { if (role == Qt::EditRole) { if (orientation == Qt::Horizontal) { cabeceraH[section] = value.toString(); emit headerDataChanged(Qt::Horizontal, section, section); }else { cabeceraV[section] = value.toString(); emit headerDataChanged(Qt::Vertical, section, section); } return true; } return false; }
bool StorageVolModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { if ( orientation == Qt::Horizontal ) { if ( role == Qt::EditRole ) { switch (section) { case 0: column0 = value.toString(); break; case 1: column1 = value.toString(); break; case 2: column2 = value.toString(); break; case 3: column3 = value.toString(); break; case 4: column4 = value.toString(); break; default: break; } }; headerDataChanged(Qt::Horizontal, 0, columnCount()-1); }; }
void CheckableHeader::mousePressEvent(QMouseEvent *event) { if (!m_visible) { return; } const QStyle *style = QApplication::style(); QStyleOptionButton option; option.rect.setSize(sizeHint()); option.rect.setWidth(viewport()->width()); QRect rect = style->subElementRect(QStyle::SE_CheckBoxIndicator, &option); QPoint pos = mapFromGlobal(QCursor::pos()); // kDebug() << rect << pos; if (insideCheckBox(rect, pos)) { if (m_state == Qt::Checked) { m_state = Qt::Unchecked; } else { m_state = Qt::Checked; } emit toggled(m_state); headerDataChanged(Qt::Horizontal, 0, 0); } else { QHeaderView::mousePressEvent(event); } }
/*! Removes \a count rows starting at \a row. Since this model does not support hierarchical structures, \a parent must be an invalid model index. Emits the beforeDelete() signal before a row is deleted. When the edit strategy is OnManualSubmit signal emission is delayed until submitAll() is called. Returns true if all rows could be removed; otherwise returns false. Detailed error information can be retrieved using lastError(). \sa removeColumns(), insertRows() */ bool QSqlTableModel::removeRows(int row, int count, const QModelIndex &parent) { Q_D(QSqlTableModel); if (parent.isValid() || row < 0 || count <= 0) return false; int i; switch (d->strategy) { case OnFieldChange: case OnRowChange: for (i = 0; i < count; ++i) { if (row + i == d->insertIndex) d->revertInsertedRow(); else if (!deleteRowFromTable(row + i)) return false; } select(); break; case OnManualSubmit: for (i = 0; i < count; ++i) { int idx = row + i; if (idx >= rowCount()) return false; if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) revertRow(idx); else { d->cache[idx].op = QSqlTableModelPrivate::Delete; emit headerDataChanged(Qt::Vertical, idx, idx); } } break; } return true; }
/*! \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 true if successful; otherwise returns 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, d->primaryValues(row), false); static const QString wh = Sql::where() + Sql::sp(); if (d->filter.startsWith(wh, Qt::CaseInsensitive)) d->filter.remove(0, wh.length()); const QString stmt = selectStatement(); d->sortColumn = table_sort_col; d->filter = table_filter; QSqlQuery q(d->db); q.setForwardOnly(true); if (!q.exec(stmt)) return false; bool exists = q.next(); d->cache[row].refresh(exists, q.record()); emit headerDataChanged(Qt::Vertical, row, row); emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1)); return true; }
void HierarchicalTableModel::setHorizontalHeaderModel(QAbstractItemModel* _model) { m_horizontalHeaderModel = _model; if (sourceModel()->columnCount()) { emit headerDataChanged(Qt::Horizontal, 0, sourceModel()->columnCount() - 1); } }
int QAbstractItemModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break; case 1: headerDataChanged((*reinterpret_cast< Qt::Orientation(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 2: layoutChanged(); break; case 3: layoutAboutToBeChanged(); break; case 4: rowsAboutToBeInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 5: rowsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 6: rowsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 7: rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 8: columnsAboutToBeInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 9: columnsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 10: columnsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 11: columnsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 12: modelAboutToBeReset(); break; case 13: modelReset(); break; case 14: rowsAboutToBeMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break; case 15: rowsMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break; case 16: columnsAboutToBeMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break; case 17: columnsMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break; case 18: { bool _r = submit(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 19: revert(); break; default: ; } _id -= 20; } return _id; }
void TableModel::setHorizontalHeaderItem(int section, TableItem *item) { if ( (section < 0) || ( section >= (int)_imp->horizontalHeaderItems.size() ) ) { return; } TableItem *oldItem = _imp->horizontalHeaderItems.at(section); if (item == oldItem) { return; } if (oldItem) { oldItem->view = 0; } delete oldItem; TableView *view = qobject_cast<TableView*>( QObject::parent() ); if (item) { item->view = view; item->itemFlags = Qt::ItemFlags(int(item->itemFlags) | ItemIsHeaderItem); } _imp->horizontalHeaderItems[section] = item; Q_EMIT headerDataChanged(Qt::Horizontal, section, section); }
void DB2TableModel::fillOffsets() { quint16 offset = 0; for (int i = 0; i < fieldCount; i++) { RecordFld rec; rec.type = (FldType)format[i].toLatin1(); rec.offset = offset; switch(format[i].toLatin1()) { case FLD_INT: rec.title = "integer"; offset += sizeof(int); break; case FLD_KEY: rec.title = "key"; offset += sizeof(int); break; case FLD_FLOAT: rec.title = "float"; offset += sizeof(float); break; case FLD_STRING: rec.title = "string"; offset += sizeof(char*); break; } fieldsOffsets.append(rec); setHeaderData(i, Qt::Horizontal, rec.title, Qt::DisplayRole); } emit headerDataChanged(Qt::Horizontal, 1, fieldsOffsets.size()); }
void DepthModel::setHorizontalHeaderLabels(QStringList list) { if(list.count()!=columnsCount)return; headerLabels=list; fixTitleWidths(); emit headerDataChanged(Qt::Horizontal, 0, columnsCount-1); }
void HierarchicalTableModel::setVerticalHeaderModel(QAbstractItemModel* _model) { m_verticalHeaderModel = _model; if (sourceModel()->rowCount()) { emit headerDataChanged(Qt::Vertical, 0, sourceModel()->rowCount() - 1); } }
bool KWQTableModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role) { if (orientation == Qt::Horizontal) { if (section < 0 || section > 1) return false; if (role == Qt::EditRole) { m_doc->identifier(section).setName(value.toString()); } if (role == Qt::SizeHintRole) { DocumentSettings documentSettings(m_doc->url().url()); documentSettings.setSizeHintColumn(section, qvariant_cast<QSize>(value).width()); documentSettings.save(); } if (role == KWQTableModel::KeyboardLayoutRole) { DocumentSettings documentSettings(m_doc->url().url()); documentSettings.setKeyboardLayoutColumn(section, value.toString()); documentSettings.save(); } emit headerDataChanged(orientation, section, section); return true; } return false; }
void HistoryQueryResultsModel::setTalkableHeader(const QString &talkableHeader) { if (TalkableHeader == talkableHeader) return; TalkableHeader = talkableHeader; emit headerDataChanged(Qt::Horizontal, 0, 0); }
void HistoryQueryResultsModel::setLengthHeader (const QString &lengthHeader) { if (LengthHeader == lengthHeader) return; LengthHeader = lengthHeader; emit headerDataChanged(Qt::Horizontal, 3, 3); }
void DataSetValuesViewTableModel::EmitDataChanged() { QModelIndex start = QAbstractItemModel::createIndex(0,0); int lastRow = rowCount(start); int lastCol = columnCount(start); emit dataChanged(start,QAbstractItemModel::createIndex(lastRow, lastCol)); emit headerDataChanged(Qt::Vertical,0,lastRow); //also update row index/address }
void PacketListModel::resetColumns() { if (cap_file_) { PacketListRecord::resetColumns(&cap_file_->cinfo); } dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); headerDataChanged(Qt::Horizontal, 0, columnCount() - 1); }
void LogWidgetModel::changeMode(bool active) { if (active) { m_mode = qobject_cast<QRadioButton *>(sender())->property("mode").toInt(); requestHistory(b_engine->getFullId(), m_mode); emit headerDataChanged(Qt::Horizontal, 0, 3); reset(); } }
bool RealEstateQueryModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { if (value != headerData(section, orientation, role) && orientation == Qt::Horizontal) { fColumnNames[section] = value; emit headerDataChanged(orientation, section, section); return true; } return false; }
bool IxModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role /* = Qt::EditRole */) { if ((orientation != Qt::Horizontal) || (role != Qt::EditRole)) { return QAbstractItemModel::setHeaderData(section, orientation, value, role); } if ((section < 0) || (section >= m_lstDataMember.count())) { return false; } IxDataMember * pDataMember = m_lstDataMember.at(section); if (! pDataMember) { return false; } m_lstHeaders.insert(pDataMember->getKey(), value.toString()); Q_EMIT headerDataChanged(orientation, section, section); return true; }
void ParamModelBase::AddParameter(const std::string& param, const std::string& value) { std::lock_guard<std::mutex> lock(_mutex); int row = (int)_parameters.size(); QModelIndex row_index = createIndex(row, 0); insertRows(row, 1, QModelIndex()); _parameters[row] = new Param(param, value); emit dataChanged(row_index, row_index); emit headerDataChanged(Qt::Vertical, row, row); }
void DataFrameModel::endChanges(int oldnr, int oldnc) { if (oldnr != -1) { int nr = rowCount(QModelIndex()); int nc = columnCount(QModelIndex()); if (oldnc > nc) endRemoveColumns(); else if (oldnc < nc) endInsertColumns(); // just in case column names/roles changed else headerDataChanged(Qt::Horizontal, 0, nc); if (oldnr > nr) // insert rows endRemoveRows(); else if (oldnr < nr) endInsertRows(); else headerDataChanged(Qt::Vertical, 0, nr); // be lazy and just say everything changed // will not matter unless many rows/cols are in view (rare) dataChanged(index(0, 0), index(nr, nc)); } }
void ribi::QtUblasVectorDoubleModel::SetHeaderData( const std::string& horizontal_header_text, const std::vector<std::string>& vertical_header_text) { if (m_header_horizontal_text != horizontal_header_text) { emit layoutAboutToBeChanged(); assert(this->columnCount() == (this->rowCount() == 0 ? 0 : 1)); m_header_horizontal_text = horizontal_header_text; emit layoutChanged(); emit headerDataChanged(Qt::Horizontal,0,1); } if (m_header_vertical_text != vertical_header_text) { emit layoutAboutToBeChanged(); const int new_size = boost::numeric_cast<int>(vertical_header_text.size()); const int cur_size = this->rowCount(); if (cur_size < new_size) { this->insertRows(cur_size,new_size - cur_size,QModelIndex()); } else if (cur_size > new_size) { this->removeRows(cur_size,cur_size - new_size,QModelIndex()); } //Set the data before emitting signals, as the response to that signal //will be dependent on that data m_header_vertical_text = vertical_header_text; assert(this->rowCount() == boost::numeric_cast<int>(vertical_header_text.size()) && "So emit layoutChange can work on the newest layout"); emit layoutChanged(); emit headerDataChanged(Qt::Vertical,0,new_size); } assert(this->rowCount() == boost::numeric_cast<int>(this->m_data.size())); assert(this->rowCount() == boost::numeric_cast<int>(m_header_vertical_text.size())); assert(this->columnCount() == (this->rowCount() == 0 ? 0 : 1)); }
void RulesModel::setHorizontalHeaderLabels(QStringList list) { if(list.count()!=columnsCount)return; headerLabels=list; stateWidth=qMax(textFontWidth(headerLabels.first()),textFontWidth(julyTr("RULE_STATE_PROCESSING","processing"))); stateWidth=qMax(stateWidth,textFontWidth(julyTr("RULE_STATE_PENDING","pending"))); stateWidth=qMax(stateWidth,textFontWidth(julyTr("RULE_STATE_DONE","done"))); stateWidth=qMax(stateWidth,textFontWidth(julyTr("RULE_STATE_DISABLED","disabled"))); stateWidth+=12; emit headerDataChanged(Qt::Horizontal, 0, columnsCount-1); }
bool TreeModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { if (role != Qt::EditRole || orientation != Qt::Horizontal) return false; bool result = rootItem->setData(section, value); if (result) emit headerDataChanged(orientation, section, section); return result; }
bool UserTreeModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { if (role != Qt::DisplayRole || orientation != Qt::Horizontal) { return false; } rootItem->setData(value.toString()); emit headerDataChanged(orientation, section, section); return true; }
void TradesModel::setHorizontalHeaderLabels(QStringList list) { if(list.count()!=columnsCount)return; textAsk=julyTr("ORDER_TYPE_ASK","ask"); textBid=julyTr("ORDER_TYPE_BID","bid"); dateWidth=qMax(qMax(textFontWidth(QDateTime(QDate(2000,12,30),QTime(23,59,59,999)).toString(baseValues.dateTimeFormat)),textFontWidth(QDateTime(QDate(2000,12,30),QTime(12,59,59,999)).toString(baseValues.dateTimeFormat))),textFontWidth(list.at(0)))+10; typeWidth=qMax(qMax(textFontWidth(textAsk),textFontWidth(textBid)),textFontWidth(list.at(2)))+10; headerLabels=list; emit headerDataChanged(Qt::Horizontal, 0, columnsCount-1); emit layoutChanged(); }
/*! Sets the caption for a horizontal header for the specified \a role to \a value. This is useful if the model is used to display data in a view (e.g., QTableView). Returns true if \a orientation is Qt::Horizontal and the \a section refers to a valid section; otherwise returns false. Note that this function cannot be used to modify values in the database since the model is read-only. \sa data() */ bool QSqlQueryModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { Q_D(QSqlQueryModel); if (orientation != Qt::Horizontal || section < 0 || columnCount() <= section) return false; if (d->headers.size() <= section) d->headers.resize(qMax(section + 1, 16)); d->headers[section][role] = value; emit headerDataChanged(orientation, section, section); return true; }