forked from jtdx-project/jtdx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ForeignKeyDelegate.cpp
41 lines (35 loc) · 1.67 KB
/
ForeignKeyDelegate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "ForeignKeyDelegate.hpp"
#include <QComboBox>
#include "CandidateKeyFilter.hpp"
ForeignKeyDelegate::ForeignKeyDelegate (QAbstractItemModel * referenced_model
, int referenced_key_column
, QObject * parent
, int referenced_key_role)
: QStyledItemDelegate {parent}
, candidate_key_filter_ {new CandidateKeyFilter {referenced_model, referenced_key_column, nullptr, referenced_key_role}}
{
}
ForeignKeyDelegate::ForeignKeyDelegate (QAbstractItemModel * referenced_model
, QAbstractItemModel const * referencing_model
, int referenced_key_column
, int referencing_key_column
, QObject * parent
, int referenced_key_role
, int referencing_key_role)
: QStyledItemDelegate {parent}
, candidate_key_filter_ {new CandidateKeyFilter {referenced_model, referencing_model, referenced_key_column, referencing_key_column, nullptr, referenced_key_role, referencing_key_role}}
{
}
ForeignKeyDelegate::~ForeignKeyDelegate ()
{
}
QWidget * ForeignKeyDelegate::createEditor (QWidget * parent
, QStyleOptionViewItem const& /* option */
, QModelIndex const& index) const
{
auto editor = new QComboBox {parent};
editor->setFrame (false);
candidate_key_filter_->set_active_key (index);
editor->setModel (candidate_key_filter_.data ());
return editor;
}