/*!
    \fn void QTextTable::resize(int rows, int columns)

    Resizes the table to contain the required number of \a rows and \a columns.

    \sa insertRows() insertColumns() removeRows() removeColumns()
*/
void QTextTable::resize(int rows, int cols)
{
    Q_D(QTextTable);
    if (d->dirty)
        d->update();

    d->pieceTable->beginEditBlock();

    int nRows = this->rows();
    int nCols = this->columns();

    if (rows == nRows && cols == nCols)
	return;

    if (nCols < cols)
        insertColumns(nCols, cols - nCols);
    else if (nCols > cols)
        removeColumns(cols, nCols - cols);

    if (nRows < rows)
        insertRows(nRows, rows-nRows);
    else if (nRows > rows)
        removeRows(rows, nRows-rows);

    d->pieceTable->endEditBlock();
}
      SqlTableModel::SqlTableModel(sql::ResultSet result, Wt::WContainerWidget* parent) : Wt::WStandardItemModel(0, 0, parent) {
        sql::ResultSetMetaData * rsmd = result.getResultSetMetaData();
        int fieldCount = rsmd->getColumnCount();
        insertColumns(0, fieldCount);
        for (int a = 0; a < fieldCount; a++) {
          /*
           * for locale support 
           * if(!setHeaderData(a,Wt::WString::tr(rsmd->getColumnName(a).c_str()))){ 
           */
          if (!setHeaderData(a, rsmd->getColumnName(a))) {
            //        if(!setHeaderData(a,boost::any(rsmd->getColumnName(a)))){
            //        if(!setHeaderData(a,boost::any(string("test")))){
            std::cout << "Failed" << std::endl;
          }
        }

        for (int a = 0; result.next(); a++) {
          if (rowCount() <= a)
            insertRow(rowCount());

          for (int b = 0; b < fieldCount; b++)
            if (!setData(a, b, result.getString(b))) {
              //          if(!setData(a,b,boost::any(result.getString(b)))){
              //          if(!setData(a,b,boost::any(new string("test")))){
              std::cout << "set data Failed" << std::endl;
            }else {
            }
        }

        //      load(result);
      }
PoitemTableModel::PoitemTableModel(QObject * parent, QSqlDatabase db) :
  QSqlRelationalTableModel(parent, db)
{
  setTable("poitem");

  // select statement on which everything else is based
  _selectStatement =
      QString("SELECT pohead_number, "
	     "       item_id, item_number,"
	     "       warehous_id, warehous_code,"
	     "       poitem_unitprice * poitem_qty_ordered AS extprice,"
	     "       prj_number,"
	     "       expcat_code,"
	     "       0 AS itemsrc_minordqty, 0 AS itemsrc_multordqty, "
	     "       1 AS itemsrc_invvendoruomratio,"
	     "       CURRENT_DATE AS earliestdate, "
	     "       poitem.* "
	     "FROM pohead"
	     "     JOIN poitem ON (poitem_pohead_id=pohead_id)"
	     "     LEFT OUTER JOIN itemsite ON (poitem_itemsite_id=itemsite_id)"
	     "     LEFT OUTER JOIN item ON (itemsite_item_id=item_id)"
	     "     LEFT OUTER JOIN whsinfo ON (itemsite_warehous_id=warehous_id)"
	     "     LEFT OUTER JOIN prj ON (poitem_prj_id=prj_id)"
	     "     LEFT OUTER JOIN expcat ON (poitem_expcat_id=expcat_id)"
	     );

  setEditStrategy(QSqlTableModel::OnManualSubmit); // OnRow?
  setSort(POITEM_LINENUMBER_COL, Qt::AscendingOrder);

  // insert only those columns not directly part of the poitem table
  insertColumns(0, 7);

  setHeaderData(POITEM_LINENUMBER_COL,	Qt::Horizontal, tr("#"));
  setHeaderData(ITEM_NUMBER_COL,	Qt::Horizontal, tr("Item"));
  setHeaderData(WAREHOUS_CODE_COL,	Qt::Horizontal, tr("Supplying Site"));
  setHeaderData(POITEM_VEND_ITEM_NUMBER_COL, Qt::Horizontal, tr("Vend Item #"));
  setHeaderData(POITEM_VEND_ITEM_DESCRIP_COL,Qt::Horizontal, tr("Vend Description"));
  setHeaderData(POITEM_VEND_UOM_COL,	Qt::Horizontal, tr("Vend UOM"));
  setHeaderData(POITEM_QTY_ORDERED_COL,	Qt::Horizontal, tr("Qty."));
  setHeaderData(POITEM_UNITPRICE_COL,	Qt::Horizontal, tr("Unit Price"));
  setHeaderData(EXTPRICE_COL,		Qt::Horizontal, tr("Ext. Price"));
  setHeaderData(POITEM_FREIGHT_COL,	Qt::Horizontal, tr("Freight"));
  setHeaderData(POITEM_DUEDATE_COL,	Qt::Horizontal, tr("Due Date"));
  setHeaderData(PRJ_NUMBER_COL,		Qt::Horizontal, tr("Project #"));
  setHeaderData(EXPCAT_CODE_COL,	Qt::Horizontal, tr("Expense Cat."));

  _poheadid	= -1;
  _poitemid	= -1;
  findHeadData();
  _dirty = false;

  select();

  connect(this, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(markDirty(QModelIndex, QModelIndex)));
}
int QAbstractItemModel_insertColumns(lua_State* const state)
{
    auto self = lua::get<QAbstractItemModel*>(state, 1);

    // virtual bool     insertColumns(int column, int count, const QModelIndex & parent = QModelIndex())
    if (lua_gettop(state) == 3) {
        lua::push(state, self->insertColumns(
            lua::get<int>(state, 2),
            lua::get<int>(state, 3)
        ));
    } else {
        lua::push(state, self->insertColumns(
            lua::get<int>(state, 2),
            lua::get<int>(state, 3),
            lua::get<const QModelIndex&>(state, 4)
        ));
    }

    return 1;
}
LogTableModel::LogTableModel (QObject * parent, logs::LogWidget & lw)
	: BaseTableModel(parent, lw.m_config.m_columns_setup, lw.m_config.m_columns_sizes)
	, m_log_widget(lw)
{
	qDebug("%s this=0x%08x", __FUNCTION__, this);

	m_data.init();

	beginInsertColumns(QModelIndex(), 0, columnCount() - 1);
	insertColumns(0, columnCount() - 1);
	endInsertColumns();
}
Exemple #6
0
void TestModel::traverseNode(const QDomNode &node)
{
    QDomElement cells = node.toElement().firstChildElement("cells");
    int rows = cells.attribute("rows").toInt();
    int cols = cells.attribute("cols").toInt();

    insertRows(0, rows);
    insertColumns(0, cols);

    if (rows == 0 || cols == 0) {
        return;
    }

    QDomNode rowNode = cells.firstChild();
    while (!rowNode.isNull()) {
        int row = rowNode.nodeName().remove(0, 3).toInt();

         QDomNode colNode = rowNode.firstChild();
         while (!colNode.isNull()) {
            int col = colNode.nodeName().remove(0, 3).toInt();

            QDomElement colEl = colNode.toElement();
            setColumnType(col, QVariant::nameToType(colEl.attribute("type").toLatin1()));
            setItem(row, col, new QStandardItem(colEl.text()));

            colNode = colNode.nextSibling();
         }

        rowNode = rowNode.nextSibling();
    }

    // Fill empty indexes
    for (int row = 0; row < rowCount(); row++) {

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

            if(!item(row, col)) {
                setItem(row, col, new QStandardItem(QString()));
            }
        }
    }

    QDomElement titles = node.toElement().firstChildElement("titles");
    QDomNode colNode = titles.firstChild();
    while (!colNode.isNull()) {
        int col = colNode.nodeName().remove(0, 3).toInt();
        setHeaderData(col, Qt::Horizontal, colNode.toElement().text());

        colNode = colNode.nextSibling();
    }

}
FilterHorizontalHeaderView::FilterHorizontalHeaderView(SortMultiFilterProxyModel *model, QTableView *parent):
	QHeaderView(Qt::Horizontal,parent)
{
	//setModel(parent->model());
	_model=model;

	setSectionsMovable(parent->horizontalHeader()->sectionsMovable());
	setSectionsClickable(parent->horizontalHeader()->sectionsClickable());

	insertColumns(0,model->columnCount()-1);

	updateWidgetPositions();

	contextMenu.addAction(&saveAct);
	contextMenu.addAction(&clearAct);
	contextMenu.addSeparator();
	connect(&saveAct,&QAction::triggered,this,&FilterHorizontalHeaderView::savePreset);
	connect(&clearAct,&QAction::triggered,this,&FilterHorizontalHeaderView::clearAllFilters);

	connect(parent->horizontalScrollBar(),SIGNAL(valueChanged(int)),
		this,SLOT(updateWidgetPositions()) );
	connect(this,SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
		this,SLOT(setSortIndicator(int,Qt::SortOrder)));
	connect(this,SIGNAL(sectionResized(int,int,int)),
		this,SLOT(updateWidgetPositions()));

	connect(model,&QAbstractItemModel::columnsInserted,
		[=](const QModelIndex&,
		int logicalFirst, int logicalLast) {
		insertColumns(logicalFirst,logicalLast);
	});

	timer.setInterval(300);
	timer.setSingleShot(true);
	connect(&timer,SIGNAL(timeout()),this,SLOT(applyFilters()));

	//TODO: add header data update
	//TODO: add sections removal
}
Exemple #8
0
void MatrixModel::setColumnCount(int cols) {
  if (d_cols == cols)
    return;

  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

  if (cols > d_cols)
    insertColumns(d_cols, cols - d_cols);
  else if (cols < d_cols)
    removeColumns(cols, d_cols - cols);

  QApplication::restoreOverrideCursor();
}
Exemple #9
0
void
TableModel::setColumnCount(int columns)
{
    int cc = (int)_imp->horizontalHeaderItems.size();

    if ( (columns < 0) || (cc == columns) ) {
        return;
    }
    if (cc < columns) {
        insertColumns(std::max(cc, 0), columns - cc);
    } else {
        removeColumns(std::max(columns, 0), cc - columns);
    }
}
void PreviewTable::addColumns(int c)
{
	int max=0, cols = numCols();
	for (int i=0; i<cols; i++){
		if (!col_label[i].contains(QRegExp ("\\D"))){
			int index=col_label[i].toInt();
			if (index>max)
				max=index;
		}
	}
	max++;
	insertColumns(cols, c);
	for (int i=0; i<c; i++){
		comments << QString();
		col_label<< QString::number(max+i);
	}
}
TransactionType::TransactionType(QObject *parent) :
    QStandardItemModel(parent)
{
    insertColumns(0,2);
    insertRows(0,4);

    QHash<int,QString> tmp = typesName();

    setData(index(0,0),tr("-1"));
    setData(index(0,1),tmp.value(-1));
    setData(index(1,0),tr("1"));
    setData(index(1,1),tmp.value(1));
    setData(index(2,0),tr("2"));
    setData(index(2,1),tmp.value(2));
    setData(index(3,0),tr("3"));
    setData(index(3,1),tmp.value(3));

}
Exemple #12
0
void PageItem_Table::initialize(int numRows, int numColumns)
{
	Q_ASSERT(m_Doc);
	Q_ASSERT(numRows > 0);
	Q_ASSERT(numColumns > 0);

	// Internal style is in document-wide style context.
	m_style.setContext(&m_Doc->tableStyles());

	// Reserve space in lists.
	m_cellRows.reserve(numRows);
	m_rowHeights.reserve(numRows);
	m_rowPositions.reserve(numRows);
	m_columnWidths.reserve(numColumns);
	m_columnPositions.reserve(numColumns);

	// Initialize rows of cells.
	QList<TableCell> initialRow;
	initialRow.append(TableCell(0, 0, this));
	m_cellRows.append(initialRow);

	// Initialize row/column geometries.
	m_rowPositions.insert(0, 0.0);
	m_rowHeights.insert(0, 10.0);
	m_columnPositions.insert(0, 0.0);
	m_columnWidths.insert(0, 10.0);

	// Initialize row/column counts.
	m_rows = 1;
	m_columns = 1;

	// Insert any remaining rows and/or columns.
	insertRows(0, numRows - 1);
	insertColumns(0, numColumns - 1);

	// Listen to changes in the document-wide cell/table style contexts.
	m_Doc->tableStyles().connect(this, SLOT(handleStyleChanged()));
	m_Doc->cellStyles().connect(this, SLOT(handleStyleChanged()));

	m_activeCell = cellAt(0, 0);
	m_activeRow = 0;
	m_activeColumn = 0;
}
Exemple #13
0
void MatrixModel::pasteData(double *clipboardBuffer, int topRow, int leftCol,
                            int rows, int cols) {
  int newCols = leftCol + cols;
  if (newCols > d_cols)
    insertColumns(d_cols, newCols - d_cols);

  int newRows = topRow + rows;
  if (newRows > d_rows)
    insertRows(d_rows, newRows - d_rows);

  int cell = 0;
  int bottomRow = newRows - 1;
  int rightCol = newCols - 1;
  for (int i = topRow; i <= bottomRow; i++) {
    int row = i * d_cols + leftCol;
    for (int j = leftCol; j <= rightCol; j++)
      d_data[row++] = clipboardBuffer[cell++];
  }
}
void FilterProxyModel::resizeToCfg (logs::LogConfig const & config)
{
  //@TODO: dedup: logtablemodel, findproxy, filterproxy
	if (config.m_columns_setup.size() > m_column_count)
	{
		int const last = config.m_columns_setup.size() - 1;
		beginInsertColumns(QModelIndex(), m_column_count, last);
		insertColumns(m_column_count, last);
		m_column_count = last + 1;
		endInsertColumns();
	}
  else if (config.m_columns_setup.size() < m_column_count)
	{
		int const last = config.m_columns_setup.size() + 1;
		beginRemoveColumns(QModelIndex(), last, m_column_count);
		removeColumns(last, m_column_count);
		m_column_count = last - 1;
		endInsertColumns();
	}
}
Exemple #15
0
/*!
    \since 4.5
    Appends \a count columns at the right side of the table.

    \sa insertColumns(), insertRows(), resize(), removeRows(), removeColumns(), appendRows()
*/
void QTextTable::appendColumns(int count)
{
    insertColumns(columns(), count);
}
Exemple #16
0
bool WAbstractItemModel::insertColumn(int column, const WModelIndex& parent)
{
  return insertColumns(column, 1, parent);
}
Exemple #17
0
bool FilterTable::insertColumn(int column, const QModelIndex &parent) {
    return insertColumns(column, 1, parent);
}
Exemple #18
0
bool DhQDirModel::DvhinsertColumns(int x1, int x2, const QModelIndex& x3) {
  return insertColumns(x1, x2, x3);
}
Exemple #19
0
bool DhQDirModel::DvhinsertColumns(int x1, int x2) {
  return insertColumns(x1, x2);
}
void RKVarEditDataFrameModel::doInsertColumns (int index, int count) {
	RK_TRACE (EDITOR);

	insertColumns (index, count);
}
Exemple #21
0
void KeyValuesTable::updateThisFromNode(HaveKeyValueData *hv, bool isReadOnly)
{

    if (!isReadOnly)
    {
        if(numCols() == 2)
            insertColumns(2);
        horizontalHeader()->setLabel(2, TR("do"));
    }
    else
    {
        if(numCols() == 3)
            removeColumn(2);
    }

    int index;
    int sup = 0;
    if(hv)
        sup = hv->get_n_keys();
    int rowCount = numRows();
    for (index = rowCount - 1; index > sup; index -= 1)
        removeRow(index);

    if (isReadOnly)
    {
        for (index = 0; index < sup; index += 1)
        {
            TableItem * tiKey = nullptr;
            TableItem * tiValue = nullptr;
            QString s = toUnicode(hv->get_value(index));
            int n = s.count('\n');

            if(index == numRows() || numRows() == 0)
            {
                tiKey = new TableItem(this, Q3TableItem::Never,
                                      toUnicode(hv->get_key(index)));
                tiValue = new TableItem(this, Q3TableItem::Never, s);
                setItem(index, 0, tiKey);
                setItem(index, 1, tiValue);
            }
            else
            {
                tiKey = dynamic_cast<TableItem*>(item(index, 0));
                tiKey->setText(hv->get_key(index));
                tiValue = dynamic_cast<TableItem*>(item(index, 1));
                tiValue->setText(s);
            }
            tiKey->setReplaceable(FALSE);
            tiValue->setReplaceable(FALSE);


            if (n != 0)
            {
                // note : adjustRow(index) does nothing
                setRowHeight(index, rowHeight(index) * (n + 1));
            }
        }
    }
    else
    {
        props.setAutoDelete(TRUE);

        QStringList items;

        for (index = 0; index < sup; index += 1)
        {
            QString k = toUnicode(hv->get_key(index));
            QString v = toUnicode(hv->get_value(index));
            QStringList * psl = props[k];

            setText(index, 0, k);

            if (psl != 0)
                setItem(index, 1, new ComboItem(this, v, *psl, FALSE));

            if ((k.contains(':') == 2) &&
                    ProfiledStereotypes::enumerated(k, items)) {
                psl = new QStringList(items);
                props.insert(k, psl);
                setItem(index, 1, new ComboItem(this, v, *psl, FALSE));
            }
            else
                setItem(index, 1, new MLinesItem(this, v));

            setText(index, 2, QString());
            setRowStretchable(index, TRUE);
        }

        if(index == numRows())
            insertRows(numRows());
        setText(index, 0, QString());
        setItem(index, 1, new MLinesItem(this, QString()));
        setText(index, 2, QString());
        setRowStretchable(index, TRUE);
    }

    horizontalHeader()->setResizeEnabled(TRUE, 0);  //setColumnStretchable (0, TRUE);
    setColumnStretchable(1, TRUE);

    if (! isReadOnly) {
        adjustColumn(2);
        setColumnStretchable(2, FALSE);
    }



}
Exemple #22
0
bool QxtCsvModel::insertColumn(int col, const QModelIndex& parent)
{
    return insertColumns(col, 1, parent);
}
bool DhQAbstractTableModel::DvhinsertColumns(int x1, int x2, const QModelIndex& x3) {
  return insertColumns(x1, x2, x3);
}
bool QTable::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: setNumRows((int)static_QUType_int.get(_o+1)); break;
    case 1: setNumCols((int)static_QUType_int.get(_o+1)); break;
    case 2: setShowGrid((bool)static_QUType_bool.get(_o+1)); break;
    case 3: hideRow((int)static_QUType_int.get(_o+1)); break;
    case 4: hideColumn((int)static_QUType_int.get(_o+1)); break;
    case 5: showRow((int)static_QUType_int.get(_o+1)); break;
    case 6: showColumn((int)static_QUType_int.get(_o+1)); break;
    case 7: static_QUType_bool.set(_o,isRowHidden((int)static_QUType_int.get(_o+1))); break;
    case 8: static_QUType_bool.set(_o,isColumnHidden((int)static_QUType_int.get(_o+1))); break;
    case 9: setColumnWidth((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 10: setRowHeight((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 11: adjustColumn((int)static_QUType_int.get(_o+1)); break;
    case 12: adjustRow((int)static_QUType_int.get(_o+1)); break;
    case 13: setColumnStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 14: setRowStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 15: static_QUType_bool.set(_o,isColumnStretchable((int)static_QUType_int.get(_o+1))); break;
    case 16: static_QUType_bool.set(_o,isRowStretchable((int)static_QUType_int.get(_o+1))); break;
    case 17: setSorting((bool)static_QUType_bool.get(_o+1)); break;
    case 18: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 19: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 20: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 21: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 22: swapCells((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break;
    case 23: setLeftMargin((int)static_QUType_int.get(_o+1)); break;
    case 24: setTopMargin((int)static_QUType_int.get(_o+1)); break;
    case 25: setCurrentCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 26: clearSelection(); break;
    case 27: clearSelection((bool)static_QUType_bool.get(_o+1)); break;
    case 28: setColumnMovingEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 29: setRowMovingEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 30: setReadOnly((bool)static_QUType_bool.get(_o+1)); break;
    case 31: setRowReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 32: setColumnReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 33: setDragEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 34: static_QUType_bool.set(_o,dragEnabled()); break;
    case 35: insertRows((int)static_QUType_int.get(_o+1)); break;
    case 36: insertRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 37: insertColumns((int)static_QUType_int.get(_o+1)); break;
    case 38: insertColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 39: removeRow((int)static_QUType_int.get(_o+1)); break;
    case 40: removeRows((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break;
    case 41: removeColumn((int)static_QUType_int.get(_o+1)); break;
    case 42: removeColumns((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break;
    case 43: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 44: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 45: setRowLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break;
    case 46: setColumnLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break;
    case 47: columnWidthChanged((int)static_QUType_int.get(_o+1)); break;
    case 48: rowHeightChanged((int)static_QUType_int.get(_o+1)); break;
    case 49: columnIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break;
    case 50: rowIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break;
    case 51: columnClicked((int)static_QUType_int.get(_o+1)); break;
    case 52: doAutoScroll(); break;
    case 53: doValueChanged(); break;
    case 54: updateGeometriesSlot(); break;
    default:
	return QScrollView::qt_invoke( _id, _o );
    }
    return TRUE;
}
        ProfileTableModel(){
          insertColumns(0, 3);
          setHeaderData(0, std::string("Id"));
          setHeaderData(1, std::string("Name"));

        }
bool DhQAbstractTableModel::DvhinsertColumns(int x1, int x2) {
  return insertColumns(x1, x2);
}