GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
DelegateBalance.cpp
Go to the documentation of this file.
1#line 2 "src/Gui/AccountRegister/DelegateBalance.cpp"
2
3#include "Editor.h"
4#include "DelegateBalance.h"
5
6/* * * * * * * * * * * * * * * * * * * * * * * * * * */
7
10{
11// std::cout << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << "(): " << std::endl;
12}
13
16{
17// std::cout << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << "(): " << std::endl;
18}
19
20auto
22createEditor( const Wt::WModelIndex & _index, Wt::WFlags< Wt::ViewItemRenderFlag > _flags ) const-> std::unique_ptr< Wt::WWidget >
23{
24#ifdef NEVER
25 std::cout << __FILE__ << ":" << __LINE__
26 << "(): " << _index.row() << "," << _index.column()
27 << " BalanceDelegate::" << __FUNCTION__
28 << " '" << Wt::asString( _index.data( Wt::ItemDataRole::Edit ) ) << "'"
29 << std::endl;
30#endif
31
32#ifdef NEVER
33 auto retVal = std::make_unique< Wt::WContainerWidget >();
34 retVal-> setSelectable( false );
35
36 /*
37 ** Get the data from the string value
38 **
39 */
40 auto balance = Wt::asString( _index.data( Wt::ItemDataRole::Edit ) );
41
42 /*
43 ** Build an editor
44 **
45 ** This is actually only a WText object, since it's not really an editor,
46 ** it is a widget that responds to clicks. It's not a push-button (doesn't
47 ** need to be) it's just text, and upon clicking on the widget it will respond
48 ** and change values accordingly.
49 **
50 */
51 auto balanceEdit = std::make_unique< Wt::WText >();
52 balanceEdit-> setText( balance );
53
54 /*!
55 ** \todo applying styles here; this needs to be moved to the .css files
56 */
57 balanceEdit-> setAttributeValue( "style", "background-color:yellow;border-radius:4px;border:1px solid rgb(204,204,204)" );
58
59 /*
60 ** Stuff it in to the layout
61 **
62 */
63 retVal-> setLayout( std::make_unique< Wt::WHBoxLayout >() );
64 retVal-> layout()-> setContentsMargins( 0,0,0,0 );
65 retVal-> layout()-> addWidget( std::move( balanceEdit ) );
66#endif
67
68#ifndef NEVER
69 auto retVal = DelegateBase::createEditor( _index, _flags );
70 auto cw = dynamic_cast< Wt::WContainerWidget* >( retVal.get() );
71 auto lineEdit = dynamic_cast< Wt::WLineEdit* >( cw-> widget(0) );
72 lineEdit-> setReadOnly( true );
73 lineEdit-> setAttributeValue( "style", "text-align:right;" );
74#endif
75
76 return retVal;
77
78} // endcreateEditor( ... ) const-> std::unique_ptr< Wt::WWidget >
79
80
81
auto createEditor(const Wt::WModelIndex &_index, Wt::WFlags< Wt::ViewItemRenderFlag > _flags) const -> std::unique_ptr< Wt::WWidget >
virtual auto createEditor(const Wt::WModelIndex &index, Wt::WFlags< Wt::ViewItemRenderFlag > flags) const -> std::unique_ptr< Wt::WWidget >
static constexpr const int Edit
WString asString(const cpp17::any &v, const WString &formatString=WString())