Can use the parameter list in the query window now.
Still requires extensive testing for all possible types.
This commit is contained in:
parent
aefc9eb7ba
commit
3af26d915e
14 changed files with 461 additions and 242 deletions
|
|
@ -33,3 +33,67 @@ QWidget *ParamTypeDelegate::createEditor(QWidget *parent,
|
|||
|
||||
return w;
|
||||
}
|
||||
|
||||
void ParamTypeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
// if (index.data().canConvert<StarRating>()) {
|
||||
// StarRating starRating = qvariant_cast<StarRating>(index.data());
|
||||
// StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
|
||||
// starEditor->setStarRating(starRating);
|
||||
// } else {
|
||||
// QStyledItemDelegate::setEditorData(editor, index);
|
||||
// }
|
||||
if (index.column() == 1) {
|
||||
QComboBox *cmbbx = dynamic_cast<QComboBox*>(editor);
|
||||
if (cmbbx) {
|
||||
auto data = index.data();
|
||||
if (data.canConvert<QString>()) {
|
||||
QModelIndexList indexes = m_typeSelectionModel->match(
|
||||
m_typeSelectionModel->index(0, 1), Qt::DisplayRole, data, 1, Qt::MatchFlags( Qt::MatchExactly ));
|
||||
if (!indexes.empty()) {
|
||||
cmbbx->setCurrentIndex(indexes.at(0).row());
|
||||
}
|
||||
else {
|
||||
cmbbx->setCurrentIndex(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
QStyledItemDelegate::setEditorData(editor, index);
|
||||
}
|
||||
}
|
||||
|
||||
void ParamTypeDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
// if (index.data().canConvert<StarRating>()) {
|
||||
// StarEditor *starEditor = qobject_cast<StarEditor *>(editor);
|
||||
// model->setData(index, QVariant::fromValue(starEditor->starRating()));
|
||||
// } else {
|
||||
// QStyledItemDelegate::setModelData(editor, model, index);
|
||||
// }
|
||||
if (index.column() == 1) {
|
||||
QComboBox *cmbbx = dynamic_cast<QComboBox*>(editor);
|
||||
if (cmbbx) {
|
||||
auto data = index.data();
|
||||
if (data.canConvert<QString>()) {
|
||||
QVariant d = m_typeSelectionModel->data(
|
||||
m_typeSelectionModel->index(cmbbx->currentIndex(), 0));
|
||||
model->setData(index, d);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QStyledItemDelegate::setModelData(editor, model, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// triggered by editing finished from editor
|
||||
void ParamTypeDelegate::commitAndCloseEditor()
|
||||
{
|
||||
// StarEditor *editor = qobject_cast<StarEditor *>(sender());
|
||||
// emit commitData(editor);
|
||||
// emit closeEditor(editor);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue