EditIndexDialog::EditIndexDialog(DBBrowserDB& db, const QString& indexName, bool createIndex, QWidget* parent)
    : QDialog(parent),
      pdb(db),
      curIndex(indexName),
      index(indexName),
      newIndex(createIndex),
      ui(new Ui::EditIndexDialog),
      m_sRestorePointName(pdb.generateSavepointName("editindex"))
{
    // Create UI
    ui->setupUi(this);

    // Get list of tables, sort it alphabetically and fill the combobox
    objectMap dbobjs;
    QList<sqlb::ObjectPtr> tables = pdb.objMap.values("table");
    for(auto it=tables.constBegin();it!=tables.constEnd();++it)
        dbobjs.insert((*it)->name(), (*it));
    ui->comboTableName->blockSignals(true);
    for(auto it=dbobjs.constBegin();it!=dbobjs.constEnd();++it)
        ui->comboTableName->addItem(QIcon(QString(":icons/table")), (*it)->name());
    ui->comboTableName->blockSignals(false);

    QHeaderView *tableHeaderView = ui->tableIndexColumns->horizontalHeader();
    tableHeaderView->setSectionResizeMode(0, QHeaderView::Stretch);

    // Editing an existing index?
    if(!newIndex)
    {
        // Load the current layout and fill in the dialog fields
        index = *(pdb.getObjectByName(curIndex).dynamicCast<sqlb::Index>());

        ui->editIndexName->blockSignals(true);
        ui->editIndexName->setText(index.name());
        ui->editIndexName->blockSignals(false);
        ui->checkIndexUnique->blockSignals(true);
        ui->checkIndexUnique->setChecked(index.unique());
        ui->checkIndexUnique->blockSignals(false);
        ui->comboTableName->blockSignals(true);
        ui->comboTableName->setCurrentText(index.table());
        ui->comboTableName->blockSignals(false);
        ui->editPartialClause->blockSignals(true);
        ui->editPartialClause->setText(index.whereExpr());
        ui->editPartialClause->blockSignals(false);

        tableChanged(index.table(), true);
    } else {
        tableChanged(ui->comboTableName->currentText(), false);
    }

    // Add event handler for index column name changes. These are only allowed for expression columns, though.
    connect(ui->tableIndexColumns, static_cast<void(QTableWidget::*)(QTableWidgetItem*)>(&QTableWidget::itemChanged),
            [=](QTableWidgetItem* item)
    {
        index.columns().at(item->row())->setName(item->text());
        updateSqlText();
    });

    // Create a savepoint to revert back to
    pdb.setSavepoint(m_sRestorePointName);
}
Exemple #2
0
void VectorSpace::OnMouseDblClick(int x, int y, IMouseMod* pMouseMod) {
    VectorPoint imHere = getPoint(x, y);
    //the uid = 0 means no point
    if (imHere.uid == 0) {
        // No point exist, add a new one
        VectorPoint newPoint;
        newPoint.x = convertToPercentX(x);
        newPoint.y = convertToPercentY(y);
        points.push_back(newPoint);
        // And we sort it!
        std::sort(points.begin(), points.end());
        SetDirty();
        if (sendSignals) {
            tableChanged(index);
        }
    } else {
        // A point exists, we delete it
        if (imHere.uid > 1) {
            points.erase(std::remove(points.begin(), points.end(), imHere), points.end());
            SetDirty();
            if (sendSignals) {
                tableChanged(index);
            }
        }
    }
};
Exemple #3
0
void VectorSpace::OnMouseUp(int x, int y, IMouseMod* pMouseMod) {
    isDragging = false;
    if (pMouseMod->C) {
        // if the control key is held, clear the vecrtor space
        clear();
        return;
    }
    
    std::sort(points.begin(), points.end());
    VectorPoint imHere = getPoint(x, y);
    
    if ((currentTool == kToolPencil && imHere.uid == 0 && !pMouseMod->R) || ((currentTool == kToolDelete && pMouseMod->R) && imHere.uid == 0)) {
        // If we are using the pencil tool and left clicking add a new point
        VectorPoint newPoint;
        newPoint.x = convertToPercentX(x);
        newPoint.y = convertToPercentY(y);
        points.push_back(newPoint);
        // make sure that the list is still in order
        std::sort(points.begin(), points.end());
        SetDirty();
        if (sendSignals) {
            tableChanged(index);
        }
    } else if ((currentTool == kToolDelete && !pMouseMod->R) || (currentTool == kToolPencil && pMouseMod->R)) {
        // We delete the point if the tool is delete and it is a left click, or if it is the pencil tool and a right click
        if (imHere.uid > 1) {
            for (int i = 0; i < selected.size(); i++) {
                points.erase(std::remove(points.begin(), points.end(), selected[i]), points.end());
            }
            for (std::vector<VectorPoint>::iterator i = selected.begin(); i != selected.end();) {
                i = selected.erase(i);
            }
            SetDirty();
            if (sendSignals) {
                tableChanged(index);
            }
        }
    } else {
        SetDirty();
        if (sendSignals) {
            tableChanged(index);
        }
    }
};
void TextDelimiterSourceNode::updateTable()
{
	m_dtxt->Update();
	m_table = m_dtxt->GetOutput();

	VTKTableParameter * outParameter = dynamic_cast<VTKTableParameter*>(getParameter(m_outputVTKTableName));
	outParameter->setVTKTable(m_table);
	outParameter->propagateDirty(0);
//	setValue(m_outputVTKTableName, QVariant::fromValue<vtkTable *>(m_table), true);

	emit tableChanged(m_table);
}
void QgsSubstitutionListWidget::mButtonImport_clicked()
{
  QString fileName = QFileDialog::getOpenFileName( this, tr( "Load substitutions" ), QDir::homePath(),
                     tr( "XML files (*.xml *.XML)" ) );
  if ( fileName.isEmpty() )
  {
    return;
  }

  QFile file( fileName );
  if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
  {
    QMessageBox::warning( nullptr, tr( "Import substitutions" ),
                          tr( "Cannot read file %1:\n%2." ).arg( fileName, file.errorString() ),
                          QMessageBox::Ok,
                          QMessageBox::Ok );
    return;
  }

  QDomDocument doc;
  QString errorStr;
  int errorLine;
  int errorColumn;

  if ( !doc.setContent( &file, true, &errorStr, &errorLine, &errorColumn ) )
  {
    QMessageBox::warning( nullptr, tr( "Import substitutions" ),
                          tr( "Parse error at line %1, column %2:\n%3" )
                          .arg( errorLine )
                          .arg( errorColumn )
                          .arg( errorStr ),
                          QMessageBox::Ok,
                          QMessageBox::Ok );
    return;
  }

  QDomElement root = doc.documentElement();
  if ( root.tagName() != QLatin1String( "substitutions" ) )
  {
    QMessageBox::warning( nullptr, tr( "Import substitutions" ),
                          tr( "The selected file is not a substitution list." ),
                          QMessageBox::Ok,
                          QMessageBox::Ok );
    return;
  }

  QgsStringReplacementCollection collection;
  collection.readXml( root );
  setSubstitutions( collection );
  tableChanged();
}
Exemple #6
0
void VectorSpace::setValues(std::tr1::array<double, 2048> table, int precision) {
    clear();
    double increment = 2048.0 / precision;
    for (double i = 0; i < 2048; i += increment) {
        VectorPoint point;
        point.x = i / 2048.0;
        point.y = (table[i] + 1) / 2;
        points.push_back(point);
    }
    std::sort(points.begin(), points.end());
    SetDirty();
    if (sendSignals) {
        tableChanged(index);
    }
}
Exemple #7
0
void IndexDialog::init_combobox()
{
    cbTable = new QComboBox;
    QSqlDatabase db = QSqlDatabase::database(conname);
    cbTable->addItems(db.tables());
    connect(cbTable,SIGNAL(currentIndexChanged(QString)),
            this,SLOT(tableChanged(QString)));

    int count = cbTable->count();
    for(int index=0;index<count;index++){
        if(cbTable->itemText(index)==tbname){
            cbTable->setCurrentIndex(index);
            return;
        }
    }
    cbTable->setCurrentIndex(0);
}
Exemple #8
0
void VectorSpace::clear() {
    //remove all elements
    for (std::vector<VectorPoint>::iterator i = points.begin(); i != points.end();) {
         i = points.erase(i);
    }
    //Points at the very ends of the space need to be recreated as they must always be there
    VectorPoint start;
    start.x = 0;
    start.y = .5;
    start.uid = 1;
    VectorPoint end;
    end.x = 1;
    end.y = .5;
    end.uid = 1;
    points.push_back(start);
    points.push_back(end);
    SetDirty();
    if (sendSignals) {
        tableChanged(index);
    }
}
void QgsSubstitutionListWidget::mButtonRemove_clicked()
{
  int currentRow = mTableSubstitutions->currentRow();
  mTableSubstitutions->removeRow( currentRow );
  tableChanged();
}
TEST_F(GameLogicTests, ShouldFinishByDraw)
{
    Array defaultArray = createArray10x10({{o,WQ, o, o, o, o, o, o, o, o}
                                          ,{o, o, o, o, o, o, o, o, o, o}
                                          ,{o, o, o, o, o, o, o, o, o, o}
                                          ,{o, o, o, o, o, o, o, o, o, o}
                                          ,{o, o, o, o, o, o, o, o, o, o}
                                          ,{o, o, o, o, o, o, o, o, o, o}
                                          ,{o, o, o, o, o, o, o, o, o, o}
                                          ,{o, o, o, o, o, o, o, o, o, o}
                                          ,{o, o, o, o, o, o, o, o, o, o}
                                          ,{o, o, o, o, o,BQ, o, o, o, o}});

    auto game = createAndStartGame(defaultArray, Table::TableVersion::Version_100, PieceColor::White);

    Array array2 = createArray10x10({{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o,WQ, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o,BQ, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(0,1), {Position(1,2)}, array2, PieceColor::White, PieceColor::Black));

    Array array3 = createArray10x10({{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, WQ, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, BQ, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(9,5), {Position(8,4)}, array3, PieceColor::Black, PieceColor::White));

    Array array4 = createArray10x10({{o, WQ, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o,BQ, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(1,2), {Position(0,1)}, array4, PieceColor::White, PieceColor::Black));

    Array array5 = createArray10x10({{o, WQ, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o,BQ, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(8,4), {Position(9,5)}, array5, PieceColor::Black, PieceColor::White));

    Array array6 = createArray10x10({{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, WQ, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o,BQ, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(0,1), {Position(1,2)}, array6, PieceColor::White, PieceColor::Black));

    Array array7 = createArray10x10({{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, WQ, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, BQ, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(9,5), {Position(8,4)}, array7, PieceColor::Black, PieceColor::White));

    Array array8 = createArray10x10({{o, WQ, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o,BQ, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(1,2), {Position(0,1)}, array8, PieceColor::White, PieceColor::Black));

    Array array9 = createArray10x10({{o, WQ, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o,BQ, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(8,4), {Position(9,5)}, array9, PieceColor::Black, PieceColor::White));

    Array array10 = createArray10x10({{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, WQ, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o,BQ, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(0,1), {Position(1,2)}, array10, PieceColor::White, PieceColor::Black));

    Array array11 = createArray10x10({{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, WQ, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, BQ, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(9,5), {Position(8,4)}, array11, PieceColor::Black, PieceColor::White));

    Array array12 = createArray10x10({{o, WQ, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o,BQ, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(1,2), {Position(0,1)}, array12, PieceColor::White, PieceColor::Black));

    Array array13 = createArray10x10({{o, WQ, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o,BQ, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(8,4), {Position(9,5)}, array13, PieceColor::Black, PieceColor::White));

    Array array14 = createArray10x10({{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, WQ, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o, o, o, o, o, o}
                                    ,{o, o, o, o, o,BQ, o, o, o, o}});

    EXPECT_NO_FATAL_FAILURE(movePiece(game, Position(0,1), {Position(1,2)}, array14, PieceColor::White, PieceColor::Black));

    Array array15 = createArray10x10({{o, o, o, o, o, o, o, o, o, o}
                                     ,{o, o,WQ, o, o, o, o, o, o, o}
                                     ,{o, o, o, o, o, o, o, o, o, o}
                                     ,{o, o, o, o, o, o, o, o, o, o}
                                     ,{o, o, o, o, o, o, o, o, o, o}
                                     ,{o, o, o, o, o, o, o, o, o, o}
                                     ,{o, o, o, o, o, o, o, o, o, o}
                                     ,{o, o, o, o, o, o, o, o, o, o}
                                     ,{o, o, o, o,BQ, o, o, o, o, o}
                                     ,{o, o, o, o, o, o, o, o, o, o}});


    EXPECT_CALL(*uiMock, onDraw());
    EXPECT_CALL(*uiMock, tableChanged(MatchArray(array15)));

    EXPECT_CALL(*uiMock, movePerformed(Position(9,5), std::vector<Position>{Position(8,4)}));
    game->movePiece(Position(9,5), {Position(8,4)}, PieceColor::Black);
}
Exemple #11
0
//----------------------------------------------------
// edits the color table with the given stroke line
//----------------------------------------------------
//
void QFunctionEditor::
DoLine(
  int &start_x,
  int &start_y,
  int &end_x,
  int &end_y)
{
  bool bChanged = false;
  ClipLine(end_x, end_y, start_x, start_y);
  int x1 = start_x;
  int x2 = end_x;
  Q_ASSERT((x1 >= 0) && (x1 < 256));
  Q_ASSERT((x2 >= 0) && (x2 < 256));
  float y1 = (float) start_y;
  float y2 = (float) end_y;
  int xstep = 1;
  int value;
  if(x1 > x2)
  {
    xstep = -1;
  }
  int i;
  float ystep = (y2-y1) / (float) (xstep * (x2-x1));
  for(int x = x1; x != x2+xstep; x+= xstep)
  {

    value = 255 - (int) (y1+0.5);
    if(value > 255)
    {
      value = 255;
    }
    else if(value < 0)
    {
      value = 0;
    }

    i = 4*x;
    if(m_nInternalMode == INTERNAL_MODE_COLOR_TABLE)
    {
      if(m_nMode & 1)
      {
	m_pColorTableBuffer[i  ] = (unsigned char)value;
      }
      if(m_nMode & 2)
      {
	m_pColorTableBuffer[i+1] = (unsigned char)value;
      }
      if(m_nMode & 4)
      {
	m_pColorTableBuffer[i+2] = (unsigned char)value;
      }
      if(m_nMode & 8)
      {
	m_pColorTableBuffer[i+3] = (unsigned char)value;
      }
    }
    else
    {
      if(m_nMode & 1)
      {
	m_pColorMapBuffer->set1Value(x*4, (float)value / 255.0F);
      }
      if(m_nMode & 2)
      {
	m_pColorMapBuffer->set1Value(x*4+1, (float)value / 255.0F);
      }
      if(m_nMode & 4)
      {
	m_pColorMapBuffer->set1Value(x*4+2, (float)value / 255.0F);
      }
      if(m_nMode & 8)
      {
	m_pColorMapBuffer->set1Value(x*4+3, (float)value / 255.0F);
      }
    }
    y1 += ystep;
    bChanged = true;
  }

  if(bChanged)
  {
    emit(tableChanged());
  }
}