Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/EditTableDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ void EditTableDialog::populateFields()
index = typeBox->count() - 1;
}
typeBox->setCurrentIndex(index);
typeBox->installEventFilter(this);
connect(typeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTypes()));
ui->treeWidget->setItemWidget(tbitem, kType, typeBox);

Expand Down Expand Up @@ -227,13 +228,13 @@ void EditTableDialog::checkInput()
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
}

void EditTableDialog::updateTypes()
void EditTableDialog::updateTypes(QObject *object)
{
QComboBox* typeBox = qobject_cast<QComboBox*>(sender());
QComboBox* typeBox = qobject_cast<QComboBox*>(object);
if(typeBox)
{
QString type = typeBox->currentText();
QString column = sender()->property("column").toString();
QString column = typeBox->property("column").toString();

int index;
for(index=0; index < m_table.fields().size(); ++index)
Expand All @@ -249,6 +250,20 @@ void EditTableDialog::updateTypes()
}
}

void EditTableDialog::updateTypes()
{
updateTypes(sender());
}

bool EditTableDialog::eventFilter(QObject *object, QEvent *event)
{
if(event->type() == QEvent::FocusOut)
{
updateTypes(object);
}
return false;
}

void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
{
int index = ui->treeWidget->indexOfTopLevelItem(item);
Expand Down Expand Up @@ -533,6 +548,7 @@ void EditTableDialog::addField()
}

ui->treeWidget->setItemWidget(tbitem, kType, typeBox);
typeBox->installEventFilter(this);
connect(typeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTypes()));

tbitem->setCheckState(kNotNull, Qt::Unchecked);
Expand Down Expand Up @@ -636,7 +652,8 @@ void EditTableDialog::moveCurrentField(bool down)
QComboBox* oldCombo = qobject_cast<QComboBox*>(ui->treeWidget->itemWidget(ui->treeWidget->topLevelItem(currentRow), kType));
QComboBox* newCombo = new QComboBox(ui->treeWidget);
newCombo->setProperty("column", oldCombo->property("column"));
connect(newCombo, SIGNAL(activated(int)), this, SLOT(updateTypes()));
newCombo->installEventFilter(this);
connect(newCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTypes()));
newCombo->setEditable(true);
for(int i=0; i < oldCombo->count(); ++i)
newCombo->addItem(oldCombo->itemText(i));
Expand Down
2 changes: 2 additions & 0 deletions src/EditTableDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ private slots:
virtual void reject();
void checkInput();
void itemChanged(QTreeWidgetItem* item, int column);
void updateTypes(QObject *object);
bool eventFilter(QObject *object, QEvent *event);
void updateTypes();
void moveUp();
void moveDown();
Expand Down