|
namespace
|
|
{
|
|
class TestModel
|
|
: public Wt::WApplication
|
|
{
|
|
public:
|
|
Wt::WTreeView* treeView;
|
|
Wt::WLineEdit* lineEdit;
|
|
Wt::WStandardItemModel* model;
|
|
TestModel( const Wt::WEnvironment& env )
|
|
: Wt::WApplication( env )
|
|
{
|
|
setCssTheme( "polished" );
|
|
lineEdit = new Wt::WLineEdit( root() );
|
|
lineEdit->keyWentUp().connect( SLOT( this, TestModel::Changed ) );
|
|
lineEdit->changed().connect( SLOT( this, TestModel::Changed ) );
|
|
treeView = new Wt::WTreeView( root() );
|
|
model = new Wt::WStandardItemModel( treeView );
|
|
treeView->setModel( model );
|
|
treeView->resize( 500, 500 );
|
|
auto b = new Wt::WPushButton( "redirect", root() );
|
|
b->clicked().connect( [=]( const Wt::WMouseEvent& e )
|
|
{
|
|
redirect( "https://www.bitfactory.at" );
|
|
quit();
|
|
});
|
|
SetModel( "xxxx" );
|
|
}
|
|
void Changed()
|
|
{
|
|
SetModel( lineEdit->text().toUTF8() );
|
|
}
|
|
void SetModel( const std::string& x )
|
|
{
|
|
model->clear();
|
|
model->insertColumns( 0, 1 );
|
|
model->setHeaderData( 0, Wt::Horizontal, std::string( "string" ) );
|
|
auto item = new Wt::WStandardItem( "root" );
|
|
model->invisibleRootItem()->appendRow( item );
|
|
for( int i = 0; i < 500; ++i )
|
|
item->appendRow( { new Wt::WStandardItem( x ) } );
|
|
}
|
|
};
|
|
}
|
|
CREATE_TEST_SIMPLE( Model )
|