Exemple #1
0
//! Updates the entire row
void PointTableWidget::updateTable(int row) {
        //Select the row representing the point
        if (settings.autoSelectRow && row != -1) {
            setCurrentCell(row, 1);
        }

        //Remove any unneeded rows
        while (points.size() < rowCount())
            removeRow(rowCount() - 1);

        for (int a = 0; a < points.size(); a++) {
            //Create and change rows as nessecary
            if (a >= rowCount())
                createNewRow(a);
            else
                changeRow(a);
        }
}
void ContactTable::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::RightButton)
    {
        QTableWidgetItem *item = itemAt(event->x(), event->y());

        if (item != NULL)
        {
            currentRow = row(item);
            setCurrentCell(currentRow, 0);
            contextMenu->exec(QCursor::pos());
        }

        event->accept();
    }
    else
        QTableWidget::mousePressEvent(event);
}
Exemple #3
0
void QCustomTableWidget::removeCharacter(int index)
{
    if (index != -1)
    {
        removeRow(logicalRow(index));
        // updating the CharacterList
        if (pCharacters)
        {
            emit modificationDone(new CharacterModification(pCharacters, new Character((*pCharacters)[index]), index, false));
            pCharacters->remove(index);
        }
        if (index == rowCount())
        {
            index--;
        }
        setCurrentCell(index, 0, QItemSelectionModel::Select | QItemSelectionModel::Rows);
    }
}
void ViewTable::returnToId( bool focus )
{
    int row = this->getRowById( LastId );
    if( row < 0 )
    {
        returnToCell( focus );
        return;
    }

    setCurrentCell( row, LastColumn );
    setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );

    QTableWidgetItem *item = this->item( row, LastColumn );
    if( item )
            scrollToItem( item, QAbstractItemView::PositionAtCenter );

    if( focus )
        setFocus();
}
void ViewTable::selectRow(int row, bool em)
{
	if( row < 0 || row >= rowCount() )
		return;

	setCurrentCell(row, 0);
	//selectRow();

	clearSelection();
	setRangeSelected( QTableWidgetSelectionRange( row, 0, row, columnCount()-1 ), true );

	setRowTextBold( row );
	if( lastRow != row )
		setRowTextBold( lastRow, false );
	lastRow = row;
	
	if( em )
		emit rowSelected( row );
}
Exemple #6
0
void TableWidget::populateTable(const openstudio::WorkspaceObject& obj)
{
  clear();
  setCurrentCell(0,0);
  setRowCount(1);

  openstudio::IddObject iddObj = obj.iddObject();
  for(unsigned i=0; i<obj.numFields(); ++i){
    bool defaultText = false;
    OptionalString val = obj.getString(i);
    if(!val){
      defaultText = true;
      val = obj.getString(i, true);
      // if still no value it is just blank
      if (!val){
        val = "";
      }
    }
    // setItem causes QTableWIdget to take ownership of newItem
    QTableWidgetItem * newItem = new QTableWidgetItem((*val).c_str());
    if(defaultText){
      newItem->setTextColor(Qt::gray);
    }
    setItem(rowCount()-1, 1, newItem);

    openstudio::OptionalIddField iddField = iddObj.getField(i);
    if(!iddField){
      // log error
    }
    else{
      *val = iddField->name();
    }
    // setItem causes QTableWIdget to take ownership of newItem
    newItem = new QTableWidgetItem((*val).c_str());
    setItem(rowCount()-1, 0, newItem);

    setRowCount(rowCount() + 1);
  }

  resizeColumnsToContents();
  resizeRowsToContents();
}
Exemple #7
0
void Spreadsheet::findPrevious(const QString &str, Qt::CaseSensitivity cs)
{
    int row = currentRow();
    int col = currentColumn() - 1;

    while(row >= 0){
        while(col > 0){
            if(text(row, col).contains(str, cs)){
                clearSelection();
                setCurrentCell(row, col);
                activateWindow();
                return;
            }
            col--;
        }
        col = ColumnCount - 1;
        row--;
    }
    QApplication::beep();
}
void cCustomTitleModelTable::PrepareTable(cModelList *Table) {
    if (InModifTable) return;
    InModifTable=true;
    CustomTitleModelTableLockPaint.lock();
    this->setUpdatesEnabled(false);
    ModelTable=Table;
    int CurIndex=0;
    int NbrItem =ModelTable->List.count();
    int NbrCol  =this->viewport()->width()/ModelTable->ThumbnailSize.width();   if (NbrCol==0) NbrCol=1;
    int NbrRow  =NbrItem/NbrCol;
    if (NbrRow*NbrCol<NbrItem) NbrRow++;
    setColumnCount(NbrCol);
    setRowCount(NbrRow);
    setCurrentCell(CurIndex/NbrCol,CurIndex-(CurIndex/NbrCol)*NbrCol);
    for (int i=0;i<columnCount();i++)  setColumnWidth(i,ModelTable->ThumbnailSize.width()+20);
    for (int i=0;i<rowCount();i++)     setRowHeight(i,ModelTable->ThumbnailSize.height()+20);
    this->setUpdatesEnabled(true);
    InModifTable=false;
    CustomTitleModelTableLockPaint.unlock();
}
void Spreadsheet::findNext(const QString &str, Qt::CaseSensitivity cs)
{
    int row = currentRow();
    int column = currentColumn() + 1;

    while (row < RowCount) {
        while (column < ColumnCount) {
            if (text(row, column).contains(str, cs)) {
                clearSelection();
                setCurrentCell(row, column);
                activateWindow();
                return;
            }
            ++column;
        }
        column = 0;
        ++row;
    }
    QApplication::beep();
}
Exemple #10
0
void Spreadsheet::setNextCell(){
    int currentCol = winRecord->getColumnNum();
    int currentRow = winRecord->getRecordNum()-1;

    if(currentCol < range->columnCount()-1) {
        if (!ui->btnPrevCell->isEnabled()){
            ui->btnPrevCell->setEnabled(true);
        }
        if (!ui->btnNext->isEnabled()){
            ui->btnNextCell->setEnabled(false);
        }
        setCurrentCell(currentRow, currentCol+1);
    } else {
        if(!ui->btnPrev->isEnabled()){
            ui->btnPrev->setEnabled(true);
        }
        if(currentRow < range->rowCount()-2){
            setNextRecord();
        }
    }
}
Exemple #11
0
MVListBase::MVListBase(MGLDevCtx& dc,const MVRect& bounds,
    const MVPoint& cellSize,MVScrollBar *vScroll,MVScrollBar *hScroll,
    uint flags)
    : MVView(dc,bounds), flags(flags), cellSize(cellSize)
/****************************************************************************
*
* Function:     MVListBase::MVListBase
* Parameters:   bounds      - Bounding box for the list
*               cellSize    - Dimensions in pixels for each list cell
*               vScroll     - Pointer to horizontal scroll bar (NULL if none)
*               hScroll     - Pointer to vertical scroll bar (NULL if none)
*               flags       - Creation flags
*
* Description:  Constructor for the MVListBase class. Works out the number
*               of visible rows and columns in the list.
*
****************************************************************************/
{
    options |= ofSelectable | ofFirstClick;

    // Set the default indents for no visible scroll bars.
    leftIndent = 2;
    topIndent = 2;
    rightIndent = 2;
    botIndent = 2;

    // Find the visible set of cells
    visible.left() = visible.top() = 0;
    visible.bottom() = (bounds.bottom() - bounds.top() - (leftIndent + rightIndent))
                                / cellSize.y;
    visible.right() = (bounds.right() - bounds.left() - (topIndent + botIndent))
                                / cellSize.x;
    if (visible.bottom() == 0)
        visible.bottom() = 1;
    if (visible.right() == 0)
        visible.right() = 1;
    setHScroll(hScroll);
    setVScroll(vScroll);
    setCurrentCell(0,0);
}
static void _update_table_row( QTableWidgetItem * item,bool setSelected )
{
	if( item ){

		auto table = item->tableWidget() ;

		count_t row = item->row() ;
		count_t col = table->columnCount() ;

		for( count_t i = 0 ; i < col ; i++ ){

			table->item( row,i )->setSelected( setSelected ) ;
		}

		if( setSelected ){

			table->setCurrentCell( row,col - 1 ) ;
		}

		table->setFocus() ;
	}
}
Exemple #13
0
void KVocTrainTable::contentsMousePressEvent(QMouseEvent * e)
{
  delayTimer->stop();
  int cc = columnAt(e->x());
  int cr = rowAt(e->y());
  int co = currentColumn();

  QTable::contentsMousePressEvent(e);

  if(cc >= KV_EXTRA_COLS) {
    // update color of original when column changes and more than 1 translation
    bool update_org = false;
    if (cc != co && numCols() > 2)
      update_org = true;

    int topCell = rowAt(0);
    int lastRowVisible = QMIN(numRows(), rowAt(contentsHeight()));
    if (update_org)
      for (int i = topCell; i <= lastRowVisible; i++)
        updateCell(i, KV_COL_ORG);
  }
  if(e->button() == LeftButton)
    setCurrentCell(cr, cc);
}
void QQuestionsTableWidget::addQuestionRow()
{
    bool restore_sort = false;
    if (isSortingEnabled())
    {
        setSortingEnabled(false);
        restore_sort = true;
    }
    insertRow(rowCount());
    for (unsigned int i = 0; i < 1 + CHOICE_COUNT; i++)
        setItem(rowCount() - 1,i,new QTableWidgetItem());
    QComboBox * combobox = new QComboBox();
    for (unsigned int i = 1; i <= CHOICE_COUNT; i++)
        combobox -> addItem(QString::number(i));
    setCellWidget(rowCount() - 1, 1 + CHOICE_COUNT,combobox);
    setItem(rowCount() - 1, 1 + CHOICE_COUNT,new QComboBoxTableItem());
    if (RATING)
    {

        connect(combobox,SIGNAL(currentIndexChanged(int)),this,SIGNAL(signalNeedSave()));
        combobox = new QComboBox();
        for (unsigned int i = 1; i <= RATING; i++)
            combobox -> addItem(QString::number(i));
        setCellWidget(rowCount() - 1,1 + CHOICE_COUNT + 1,combobox);
        setItem(rowCount() - 1, 1 + CHOICE_COUNT + 1,new QComboBoxTableItem());
    }
    connect(combobox,SIGNAL(currentIndexChanged(int)),this,SIGNAL(signalNeedSave()));

    if (restore_sort)
    {
        setSelectionMode(QAbstractItemView::SingleSelection);
        setCurrentCell(rowCount()-1,0);
        setSelectionMode(QAbstractItemView::ExtendedSelection);
        setSortingEnabled(true);
    }
}
Exemple #15
0
void pTableWidget::setCurrentRow(int row)
{
    setCurrentCell(row, 0);
}
Exemple #16
0
void QCustomTableWidget::updateDisplay(int row, int column)
{
    // storing the scroll state
    QScrollBar *hbar = horizontalScrollBar();
    QScrollBar *vbar = verticalScrollBar();
    int x = hbar->value();
    int y = vbar->value();
    // iterating over characters and properties to populate the table
    bUpdate = true;
    clear();
    setColumnCount(0);
    setRowCount(0);
    int i=0;
    for (PropertyList::iterator it = pProperties->begin(); it != pProperties->end(); it++)
    {
        insertColumn(i);
        setHorizontalHeaderItem(i,new QTableWidgetItem((*it).c_str()));
        i++;
    }
    int j=0,k;
    for (CharacterList::iterator it = pCharacters->begin(); it != pCharacters->end(); it++)
    {
        insertRow(j);
        setVerticalHeaderItem(j, new QTableWidgetItem(headerText((*it).name().c_str(), (*it).shortDescription().c_str())));
        // creating items
        for (k=0;k<i;k++)
        {
        }
        // setting values
        k = 0;
        for (Character::PropertyIterator itProperty = (*it).begin(); itProperty != (*it).end() && k<i; itProperty++)
        {
            setItem(j,k,new QTableWidgetItem((*itProperty).c_str()));
            k++;
        } 
        for (;k<i;k++)
        {
            setItem(j,k,new QTableWidgetItem("0"));
        }
        j++;
    }
    bUpdate = false;
    if (row > -1 || column > -1)
    {
        // restoring the scroll state
        hbar->setValue(x);
        vbar->setValue(y);
        scrollTo(row, column);
        // setting the current cell, row or column
        QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::Select;
        if (row == -1)
        {
            flags |= QItemSelectionModel::Columns;
            row = 0;
        }
        if (column == -1)
        {
            flags |= QItemSelectionModel::Rows;
            column = 0;
        }
        setCurrentCell(row, column, flags);
    }
}
void KWidgetListbox::setSelected(int index)
{
  setCurrentCell(index, 0);
}
Exemple #18
0
void TableView::clearSelection()
{
  setCurrentCell(-1, 0);
  selectedRows_.clear();
}
void cCustomTitleModelTable::SetCurrentModel(QString ModelName) {
    if (!ModelTable) return;
    CurrentSel=ModelTable->SearchModel(ModelName);
    setCurrentCell(CurrentSel/columnCount(),CurrentSel-(CurrentSel/columnCount())*columnCount());
}
Exemple #20
0
int QtTableSelectionManager::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:
            currentChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< int(*)>(_a[4])));
            break;
        case 1:
            anchorChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< int(*)>(_a[4])));
            break;
        case 2:
            selectionsChanged((*reinterpret_cast< const QList<QtTableSelectionRange>(*)>(_a[1])));
            break;
        case 3:
            setCurrentCell((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
            break;
        case 4:
            setAnchorCell((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
            break;
        case 5:
            setSelected((*reinterpret_cast< const QtTableSelectionRange(*)>(_a[1])),(*reinterpret_cast< SelectionMode(*)>(_a[2])));
            break;
        case 6:
            setSelected((*reinterpret_cast< const QtTableSelectionRange(*)>(_a[1])));
            break;
        case 7:
            clearSelections();
            break;
        case 8:
            d_func()->_q_modelDestroyed();
            break;
        case 9:
            d_func()->_q_rowsInserted((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
            break;
        case 10:
            d_func()->_q_rowsRemoved((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
            break;
        case 11:
            d_func()->_q_columnsInserted((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
            break;
        case 12:
            d_func()->_q_columnsRemoved((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
            break;
        default:
            ;
        }
        _id -= 13;
    }
#ifndef QT_NO_PROPERTIES
    else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            *reinterpret_cast< QtCell*>(_v) = currentCell();
            break;
        case 1:
            *reinterpret_cast< QtCell*>(_v) = anchorCell();
            break;
        case 2:
            *reinterpret_cast< bool*>(_v) = isAnchorSelectionActive();
            break;
        case 3:
            *reinterpret_cast< SelectionMode*>(_v) = selectionMode();
            break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            setCurrentCell(*reinterpret_cast< QtCell*>(_v));
            break;
        case 1:
            setAnchorCell(*reinterpret_cast< QtCell*>(_v));
            break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 4;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemple #21
0
/// 这个需要定时刷新的,使用model是否会好点
void QJDHistoryBrowser::setLogFile()
{
    /// 最好界面上哪里转一圈....
    /// Refreashing History Log
    hashFilePath.clear();  //刷新清除

    /// -------------------------head--------------------///
    QTableWidgetItem *headItem1=new QTableWidgetItem;
    QTableWidgetItem *headItem2=new QTableWidgetItem;
    QTableWidgetItem *headItem3=new QTableWidgetItem;
    QTableWidgetItem *headItem4=new QTableWidgetItem;
    headItem1->setText("Name");
    headItem2->setText("Stat");
    headItem3->setText("Progress");
    headItem4->setText("Last Modify");    // 为什么没有显示
    setHorizontalHeaderItem(0,headItem1);
    setHorizontalHeaderItem(1,headItem2);
    setHorizontalHeaderItem(2,headItem3);
    setHorizontalHeaderItem(3,headItem4);

    /// -----------------------内容------------------------///
    logDir.setPath("log");  //就是本地目录
    logDir.setFilter(QDir::Files | QDir::NoSymLinks);  //是文件,不需要链接
    fileInfoList=logDir.entryInfoList();
    QStringList fileNameList;
    QStringList filePathList;
    QStringList fileTimeList;

    for(int i=0;i<fileInfoList.size();i++)
    {
        if(fileInfoList.at(i).baseName().contains("job"))
        {
            // qDebug()<<"~~~~~~~~"<<fileInfoList.at(i).baseName();
            fileNameList.append(fileInfoList.at(i).baseName());
            filePathList.append(fileInfoList.at(i).filePath());
            fileTimeList.append(fileInfoList.at(i).lastModified().toString("yyyy-MM-dd,hh:mm:ss"));
        }
    }

    if(fileNameList.size()>0)
    {
        _hasLog=true;
    }
    else
    {
        _hasLog=false;
    }

    /// 还需要添加“进度”
    for(int i=0;i<fileNameList.size();i++)
    {
        hashFilePath.insert(i,filePathList.at(i));  // 保存文件路径
        QTableWidgetItem *nameItem=new QTableWidgetItem;
        QTableWidgetItem *statItem=new QTableWidgetItem;
        QTableWidgetItem *timeItem=new QTableWidgetItem;
        QProgressBar *progressBar=new QProgressBar;
        progressBar->setAlignment(Qt::AlignCenter);

        nameItem->setText(fileNameList.at(i));
        if(getLogStat(filePathList.at(i))=="Success")
        {
            statItem->setTextColor(QColor(0, 0, 255, 255));
            statItem->setIcon(QIcon(":/images/success.png"));
        }
        if(getLogStat(filePathList.at(i))=="Error")
        {
            statItem->setTextColor(QColor(255, 0, 0, 255));
            statItem->setIcon(QIcon(":/images/error.png"));
        }
        if(getLogStat(filePathList.at(i))=="Failed")
        {
            statItem->setTextColor(QColor(139,129,76 ,255));
            statItem->setIcon(QIcon(":/images/retina-failed.png"));
        }
        statItem->setText(getLogStat(filePathList.at(i)));

        timeItem->setText(fileTimeList.at(i));
        progressBar->setValue(getLogProgress(filePathList.at(i)));
        // getLogProgress
        this->setItem(i,0,nameItem);  // 名字
        this->setItem(i,1,statItem);  // 状态
        this->setCellWidget(i,2,progressBar);
        this->setItem(i,3,timeItem);  // 时间
        /// 还需要显示状态,但是需要读取文件
    }

    if(fileNameList.size()>=saveSelect)
    {
        setCurrentCell(saveSelect,0);
    }

    /// 需要显示的信息
    // job名称,状态,最后修改时间----双击显示日志
}
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;
}
Exemple #23
0
//     My own version of the table's actions
//    In principle it does the same as QTable, but
//       deletes selected cells
//      closes application on ESCAPE
bool MTable::eventFilter( QObject *o, QEvent *e )
{
    if ( !o || !e )
	return QScrollView::eventFilter( o, e );

    //QWidget *editorWidget = cellWidget( currentRow(), currentColumn() );

    switch ( e->type() ) {
    case QEvent::KeyPress:
	if ( !isEditing() ) {
                  QKeyEvent *ke = (QKeyEvent*)e;
	    if ( ke->key() == Key_Escape ) {
                           QApplication::sendEvent( parentWidget ( FALSE ) , e );
		return TRUE;
	    }

	    if ( ke->key() == Key_Return || ke->key() == Key_Enter ) {
		if ( currentRow() >= numRows() - 1 ){
		    setUpdatesEnabled( false );
		    setNumRows( numRows() + 10 );
		    setUpdatesEnabled( true );
		}
	        activateNextCell();
                ensureCellVisible ( currentRow(), currentColumn() );
		return TRUE;
	    }

	    if ( ke->key() == Key_Delete ) {
	            if (numSelections() > 0) {
		    QTableSelection ts = selection( currentSelection() );
		    for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){
			for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
                                         clearCell( irow, icol );
		      }
		    }
		    setCurrentCell ( ts.anchorRow(), ts.anchorCol() );
		    clearSelection ( TRUE );
		}
	              else {
                                 clearCell( currentRow(), currentColumn() );
	              }
		return TRUE;
	    }
	    if ( ke->key() == Key_C && ( ke->state() & ControlButton ) == ControlButton ) {
	              QString cellText;
		 itemCopy.clear();
		if (numSelections() > 0) {
	                  QTableSelection ts;
		    ts = selection( currentSelection() );
		    for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
		      for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){
		             cellText = text( irow, icol );
                                         if ( !cellText.isEmpty() )
                                              itemCopy.push_back( cellText.latin1() );
		             else
                                              itemCopy.push_back( "" );
		      }
		    }
		}
		else {
	                   cellText = text( currentRow(), currentColumn() );
                                 if ( !cellText.isEmpty() )
                                              itemCopy.push_back( cellText.latin1() );
                                 else      itemCopy.push_back( "" );
		}
		return TRUE;
	    }
	    if ( ke->key() == Key_V && ( ke->state() & ControlButton ) == ControlButton ) {
		if ( numSelections() > 0 && itemCopy.size() > 0 ) {
		    QTableSelection ts = selection( currentSelection() );
		    uint icount;
		    for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
		       for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){
		             //icount = (icol - ts.leftCol())*(ts.bottomRow() - ts.topRow()+1) + irow-ts.topRow();
		             icount = (irow - ts.topRow())*(ts.rightCol() - ts.leftCol()+1) + icol-ts.leftCol();
                                         if ( icount < itemCopy.size() )
                                            setText( irow, icol, (itemCopy[icount]).c_str() );
		      }
		    }
		}
		else {
		    if ( itemCopy.size() > 0 ) // there was not selection, copy first item only
		         setText( currentRow(), currentColumn(), (itemCopy[0]).c_str() );
		}
		return TRUE;
	    }
	    if ( ke->key() == Key_X && ( ke->state() & ControlButton ) == ControlButton ) {
		QString cellText;
		if (numSelections() > 0) {
		    itemCopy.clear();
		   QTableSelection ts;
		    ts = selection( currentSelection() );
		    for ( int irow = ts.topRow(); irow <= ts.bottomRow(); irow++){
		      for ( int icol = ts.leftCol(); icol <= ts.rightCol(); icol++){
		             cellText = text( irow, icol );
                                         if ( !cellText.isEmpty() )
                                              itemCopy.push_back( cellText.latin1() );
		             else
                                              itemCopy.push_back( "" );
                                         clearCell( irow, icol );
		      }
		    }
		    setCurrentCell ( ts.anchorRow(), ts.anchorCol() );
		    clearSelection ( TRUE );
		}
		else {
	                   cellText = text( currentRow(), currentColumn() );
                                 if ( !cellText.isEmpty() )
                                              itemCopy.push_back( cellText.latin1() );
                                 else      itemCopy.push_back( "" );
                                clearCell( currentRow(), currentColumn() );
		}
		return TRUE;
	    }

	    if ( currentColumn() == 0 &&
	         ctype == ComboBox   &&
                       ke->key() != Key_Left  && ke->key() != Key_Right &&
                       ke->key() != Key_Up  && ke->key() != Key_Down &&
                       ke->key() != Key_Control && ke->key() != Key_Alt &&
                       ke->key() != Key_Shift ) {
		//QApplication::beep ();
		keyPressEvent( (QKeyEvent*)e );
		return true;
	    }
	}
        else{
            QKeyEvent *ke = (QKeyEvent*)e;
	    if ( ke->key() == Key_Return || ke->key() == Key_Enter ) {
                stopEditing();
		if ( currentRow() >= numRows() - 1 ){
		    setUpdatesEnabled( false );
		    setNumRows( numRows() + 10 );
		    setUpdatesEnabled( true );
		}
                //else {stopEditing();}
                activateNextCell();
		return true;
	    }
        }
        break;
    default:
	break;
    }

    return QTable::eventFilter( o, e ) ;
}
Exemple #24
0
void ColMsgTable::change_ranks(int row, int col) {
  ColMsg * msg = flat_msg_list[row];
  HierarchicalRankValidator validator(view, msg->hierarchical_rank);
  BooL ok;
  QString new_hr = MyInputDialog::getText(TR("Enter new hierarchical rank"), TR("Hierarchical rank : "),
					  msg->hierarchical_rank, ok,
					  &validator);
  
  if (ok && (new_hr != msg->hierarchical_rank)) {
    QString old_hr = msg->hierarchical_rank;
    
#ifndef NEW_METHOD
    // it may be (?, not reproduced) not possible to reintroduce the message
    // at its original rank when the new rank is wrong => stop to follow this
    // way and save the original def before trying to use the new rank ;-(
    //
    // Fixed by doing a ColDiagramView::update_msgs() after load ?
    
    for (;;) {
      msg->in->remove_it(msg);
      msg->extract_it(view->get_msgs());
      ColMsg::update_ranks(view->get_msgs());
      
      msg->hierarchical_rank = new_hr;
      msg->place_in_internal(view->get_msgs());
      msg->place_in_its_support();
      ColMsg::update_ranks(view->get_msgs());
      
      if (new_hr.find('.') != -1) {
	// upper level msg dest must be msg start
	ColMsg * upper =
	  ColMsg::find_rec(new_hr.left(new_hr.findRev('.')), view->get_msgs());
	
	if (upper == 0)
	  // error
	  new_hr = QString::null;
	else {
	  CodObjCanvas * from;
	  CodObjCanvas * from_bis;
	  CodObjCanvas * to;
	  
	  msg->in->get_from_to(from, to, msg->is_forward);
 	  upper->in->get_from_to(from_bis, to, upper->is_forward);
 
	  if (to != from)
	    // error
	    new_hr = QString::null;
	}
      }
      if (msg->hierarchical_rank != new_hr) {
	msg_warning(TR("Warning"), TR("Invalid hierarchical rank"));
	new_hr = old_hr;
      }
      else
	break;
    }
    view->update_msgs();
    
    if (new_hr != old_hr) {
      refresh();
      setCurrentCell(flat_msg_list.findIndex(msg), col);
    }
#else
    // save all the messages
    Q3PtrDict<ColMsgList> saved;
    
    saved.setAutoDelete(TRUE);
    save_list(view->get_msgs(), saved);
    
    // remove the message
    msg->in->remove_it(msg);
    msg->extract_it(view->get_msgs());
    ColMsg::update_ranks(view->get_msgs());
    
    // try to insert the msg with the asked rank
    msg->hierarchical_rank = new_hr;
    msg->place_in_internal(view->get_msgs());
    msg->place_in_its_support();
    ColMsg::update_ranks(view->get_msgs());
    
    if (new_hr.find('.') != -1) {
      // upper level msg dest must be msg start
      ColMsg * upper =
	ColMsg::find_rec(new_hr.left(new_hr.findRev('.')), view->get_msgs());
      
      if (upper == 0)
	// error
	new_hr = QString::null;
      else {
	CodObjCanvas * from;
	CodObjCanvas * from_bis;
	CodObjCanvas * to;
	
	msg->in->get_from_to(from, to, msg->is_forward);
	upper->in->get_from_to(from_bis, to, upper->is_forward);
	
	if (to != from)
	  // error
	  new_hr = QString::null;
      }
    }
    
    if (msg->hierarchical_rank != new_hr) {
      msg_warning(TR("Warning"), TR("Invalid hierarchical rank"));
      
      msg->hierarchical_rank = old_hr;
      
      // restore saved lists
      
       Q3PtrDictIterator<ColMsgList> it(saved);
       
       while (it.current()) {
	 *((ColMsgList *) it.currentKey()) = *(it.current());
	 ++it;
       }
    }
      
    view->update_msgs();
    refresh();
    setCurrentCell(flat_msg_list.findIndex(msg), col);
#endif
  }
}
void cCustomShotTable::SetCurrentCell(int Index) {
    if ((Index<0)||(Index>=columnCount())) return;
    setCurrentCell(0,Index,QItemSelectionModel::Select|QItemSelectionModel::Current);
}