2 #include <Wt/WContainerWidget.h> 3 #include <Wt/WAbstractItemModel.h> 4 #include <Wt/Dbo/Transaction.h> 6 #include <Wtx/Dbo/Session.h> 9 #include "ItemDelegate.h" 11 Wtx::Sys::User::ItemDelegate::ItemDelegate(
const std::string & field,
Wtx::Dbo::Session * s )
17 std::unique_ptr<Wt::WWidget> Wtx::Sys::User::ItemDelegate::update( Wt::WWidget * widget,
const Wt::WModelIndex & index, Wt::WFlags< Wt::ViewItemRenderFlag > flags )
19 auto w = Wt::WItemDelegate::update( widget, index, flags );
21 auto _getValue = [=]()
23 int id = Wt::asNumber( index.model()-> data( index.row(), index.column() ) );
27 Wt::Dbo::Transaction t(*session());
30 session()-> load<Wtx::Sys::User::Item>(id );
32 std::string fieldValue;
34 if( m_field ==
"keyField" )
36 fieldValue = item-> keyField().value();
39 if( m_field ==
"abbreviation" )
41 fieldValue = item-> abbreviation().value();
44 if( fieldValue ==
"" )
45 fieldValue = Wt::WString(
"[sysUser: {1}]").arg( item.id() ).toUTF8();
51 return std::string(
"~ ~ ~");
55 auto text =
dynamic_cast<Wt::WText *
>(w.get());
58 text-> setText( _getValue() );
76 Wt::WItemDelegate * Wtx::Sys::User::ItemDelegate::createAbbreviation(
Wtx::Dbo::Session * s )