COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-ui-core-ntree.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for the ui NTree class"
9 
10 #include <QModelIndex>
11 #include <QSignalSpy>
12 
13 #include "rapidxml/rapidxml.hpp"
14 
15 #include "common/Group.hpp"
16 #include "common/Link.hpp"
17 #include "common/OptionT.hpp"
18 
20 #include "common/XML/Protocol.hpp"
22 
24 
25 #include "ui/core/NGeneric.hpp"
26 #include "ui/core/NLog.hpp"
27 #include "ui/core/NRoot.hpp"
28 #include "ui/core/NTree.hpp"
30 #include "ui/core/TreeNode.hpp"
31 #include "ui/core/TreeThread.hpp"
32 
34 #include "test/ui/MyNode.hpp"
35 
36 using namespace cf3;
37 using namespace cf3::common;
38 using namespace cf3::common::XML;
39 using namespace cf3::ui::core;
40 using namespace cf3::ui::CoreTest;
41 
42 Q_DECLARE_METATYPE(QModelIndex)
43 
45 {
46  static boost::shared_ptr< XmlDoc > doc = XML::parse_file(URI("./tree.xml"));
47 
48  static boost::shared_ptr< NRoot > root = boost::dynamic_pointer_cast<NRoot>(CNode::create_from_xml(doc->content->first_node("node")));
49  return root->handle<NRoot>();
50 }
51 
54 
55 BOOST_AUTO_TEST_SUITE( uiCoreNBrowserSuite )
56 
57 
60 {
61  application();
62 
63  ThreadManager::instance().tree();
64 
69 }
70 
72 
73 BOOST_AUTO_TEST_CASE( constructor )
74 {
75  NTree t(ThreadManager::instance().tree().root());
76  NTree t2(makeTreeFromFile());
77 
78  // the root must be the same as the client root
79  //BOOST_CHECK_EQUAL(t.tree_root().get(), ThreadManager::instance().tree().root().get());
80  BOOST_CHECK_EQUAL(makeTreeFromFile().get(), t2.tree_root().get());
81 
82  // the root must be different from nullptr
83  BOOST_CHECK(t2.tree_root().get() != nullptr);
84 }
85 
87 
89 {
90  NTree t(ThreadManager::instance().tree().root());
91  boost::shared_ptr< NRoot > newRoot(new NRoot("Root"));
92  QSignalSpy spy(&t, SIGNAL(layoutChanged()));
93 
94  newRoot->create_component<Link>("link");
95  newRoot->create_component<Group>("Group1");
96  newRoot->create_component<Group>("Group2");
97  newRoot->create_component<Group>("Group3");
98  newRoot->create_component<Group>("Group4");
99 
100  t.set_tree_root(newRoot->handle<NRoot>());
101 
102  // the tree must have emitted a layoutChanged signal exactly once
103  BOOST_CHECK_EQUAL(spy.count(), 1);
104 
105  // newRoot must be the tree root now
106  BOOST_CHECK_EQUAL(t.tree_root(), newRoot->handle<NRoot>());
107 
108  // the tree root should have 5 children now
109  BOOST_CHECK_EQUAL( t.tree_root()->count_children(), std::size_t(5));
110 }
111 
113 
114 BOOST_AUTO_TEST_CASE( set_current_index )
115 {
116  // QModelIndex needs to be registered. See QSignalSpy class doc.
117  qRegisterMetaType<QModelIndex>("QModelIndex");
118  QList<QVariant> arguments;
119  NTree t(ThreadManager::instance().tree().root());
120  QModelIndex index = t.current_index();
121  QSignalSpy spy(&t, SIGNAL(current_index_changed(QModelIndex,QModelIndex)));
122 
123  //
124  // 1. setting a correct index
125  //
126  t.set_current_index(t.index(0, 0));
127 
128  BOOST_CHECK(index != t.current_index());
129 
130  // the tree must have emitted a current_index_changed signal exactly once
131  BOOST_CHECK_EQUAL(spy.count(), 1);
132 
133  // check signal parameters
134  arguments = spy.takeFirst();
135  BOOST_CHECK_EQUAL(qvariant_cast<QModelIndex>(arguments.at(0)).internalPointer(), t.current_index().internalPointer());
136  BOOST_CHECK_EQUAL(qvariant_cast<QModelIndex>(arguments.at(1)).internalPointer(), index.internalPointer());
137 
138  //
139  // 2. setting the same index as the current one (no signal should be emitted)
140  //
141  index = t.current_index();
142  spy.clear();
143  t.set_current_index( t.index(0,0) );
144 
145  BOOST_CHECK_EQUAL(spy.count(), 0);
146 
147  //
148  // 3. setting an invalid index (should work as well)
149  //
150  index = t.current_index();
151  spy.clear();
152  t.set_current_index(QModelIndex());
153 
154  BOOST_CHECK_EQUAL(spy.count(), 1);
155 
156  // check signal parameters
157  arguments = spy.takeFirst();
158  BOOST_CHECK_EQUAL(qvariant_cast<QModelIndex>(arguments.at(0)).internalPointer(), QModelIndex().internalPointer());
159  BOOST_CHECK_EQUAL(qvariant_cast<QModelIndex>(arguments.at(1)).internalPointer(), index.internalPointer());
160 }
161 
163 
164 BOOST_AUTO_TEST_CASE( current_path )
165 {
166  NTree t(ThreadManager::instance().tree().root());
167  QModelIndex rootIndex = t.index(0, 0);
168 
169  // 1. when the current index is not valid
170  BOOST_CHECK_EQUAL( t.current_path().string(), std::string() );
171 
172  // 2. when the current index is the root
173  t.set_current_index( rootIndex );
174  BOOST_CHECK_EQUAL( t.current_path().string(), std::string("cpath:/") );
175 
176  // 3. when the current index is not the root (i.e the ui group)
177  t.set_current_index( t.index(0, 0, rootIndex) );
178  BOOST_CHECK_EQUAL( t.current_path().string(), std::string("cpath:/UI") );
179 }
180 
182 
184 {
185  NTree t(ThreadManager::instance().tree().root());
186  QModelIndex rootIndex = t.index(0, 0);
187 
188  // 1. when the index is not valid
189  BOOST_CHECK_EQUAL( t.node_path( QModelIndex() ).toStdString(), std::string() );
190 
191  // 2. when the index is the root
192  BOOST_CHECK_EQUAL( t.node_path( rootIndex ).toStdString(), std::string("Root/") );
193 
194  // 3. when the index is not the root (i.e the ui group)
195  BOOST_CHECK_EQUAL( t.node_path( t.index(0, 0, rootIndex) ).toStdString(), std::string("Root/UI/") );
196 }
197 
199 
200 BOOST_AUTO_TEST_CASE( path_from_index )
201 {
202  NTree t(ThreadManager::instance().tree().root());
203  QModelIndex rootIndex = t.index(0, 0);
204 
205  // 1. when the current index is not valid
206  BOOST_CHECK_EQUAL( t.pathFromIndex( QModelIndex() ).string(), std::string() );
207 
208  // 2. when the current index is the root
209  BOOST_CHECK_EQUAL( t.pathFromIndex( rootIndex ).string(), std::string("cpath:/") );
210 
211  // 3. when the current index is not the root (i.e the ui group)
212  BOOST_CHECK_EQUAL( t.pathFromIndex( t.index(0, 0, rootIndex) ).string(), std::string("cpath:/UI") );
213 
214 }
215 
217 
218 BOOST_AUTO_TEST_CASE( list_node_options )
219 {
220  NTree t(ThreadManager::instance().tree().root());
221  boost::shared_ptr< MyNode > node(new MyNode("UselessNode"));
222  QModelIndex index;
224  bool ok = false;
225 
226  //
227  // 1. index is not valid
228  //
229  t.list_node_options(QModelIndex(), options, &ok);
230  BOOST_CHECK(!ok);
231  BOOST_CHECK_EQUAL(options.count(), 0);
232 
233  //
234  // 2. the list is not empty
235  //
236  options.append( boost::shared_ptr<Option>(new OptionT<bool>("opt1", true)) );
237  options.append( boost::shared_ptr<Option>(new OptionT<int>("opt2", 42)) );
238  options.append( boost::shared_ptr<Option>(new OptionT<std::string>("opt3", std::string())) );
239  t.list_node_options(QModelIndex(), options, &ok);
240  BOOST_CHECK(!ok);
241  BOOST_CHECK_EQUAL(options.count(), 0);
242 
243  //
244  // 3. everything is OK
245  //
246  t.tree_root()->add_node(node);
247 
248  index = t.index_from_path( node->uri() );
249 
250  BOOST_CHECK(index.isValid());
251 
252  t.list_node_options(index, options, &ok);
253 
254  BOOST_CHECK(ok);
255  BOOST_CHECK_EQUAL(options.count(), 3);
256 
257  t.tree_root()->remove_component(node->name());
258 }
259 
261 
262 BOOST_AUTO_TEST_CASE( set_advanced_mode )
263 {
264  NTree t(ThreadManager::instance().tree().root());
265  QSignalSpy spy(&t, SIGNAL(advanced_mode_changed(bool)));
266  QList<QVariant> arguments;
267 
268  //
269  // 1. default value
270  //
271 
272  // by default, advanced is disabled
273  BOOST_CHECK(!t.is_advanced_mode());
274 
275  //
276  // 2. enable advanced mode
277  //
278  t.set_advanced_mode(true);
279 
280  // the tree must have emitted a advanced_mode_changed signal exactly once
281  BOOST_CHECK_EQUAL(spy.count(), 1);
282 
283  // check signal parameter
284  arguments = spy.takeFirst();
285  BOOST_CHECK_EQUAL(arguments.at(0).toBool(), true);
286 
287  //
288  // 3. disable advanced mode
289  //
290  spy.clear();
291  t.set_advanced_mode(false);
292 
293  // the tree must have emitted a advanced_mode_changed signal exactly once
294  BOOST_CHECK_EQUAL(spy.count(), 1);
295 
296  // check signal parameter
297  arguments = spy.takeFirst();
298  BOOST_CHECK_EQUAL(arguments.at(0).toBool(), false);
299 }
300 
302 
303 BOOST_AUTO_TEST_CASE( are_from_same_node )
304 {
305  NTree t(ThreadManager::instance().tree().root());
306  QModelIndex index = t.index(0, 0);
307  QModelIndex anotherIndex = t.index(0, 0, index);
308 
309  t.set_current_index(index);
310 
311  BOOST_CHECK( t.are_from_same_node(t.current_index(), index) );
312  BOOST_CHECK( !t.are_from_same_node(t.current_index(), anotherIndex) );
313 }
314 
316 
317 BOOST_AUTO_TEST_CASE( node_by_path )
318 {
319  NTree t(ThreadManager::instance().tree().root());
320  Handle< CNode > log_node = t.node_by_path("cpath:/Path/That/Does/Not/Exist") ;
321  Handle<CNode> root = t.node_by_path("cpath:/");
322 
323  BOOST_CHECK(log_node.get() == nullptr);
324 
325  log_node = t.node_by_path(CLIENT_LOG_PATH);
326 
327  BOOST_REQUIRE_EQUAL(log_node.get(), NLog::global().get());
328 
329  // note: we can freely use logNode here, even if the previous BOOST_REQUIRE_EQUAL() failed,
330  // since a failing BOOST_REQUIRE_EQUAL() interrupts the test case execution
331  BOOST_CHECK_EQUAL(log_node->uri().path(), std::string(CLIENT_LOG_PATH));
332 
333  // check the root
334  BOOST_REQUIRE_EQUAL(root.get(), ThreadManager::instance().tree().root().get());
335  BOOST_CHECK_EQUAL(root->uri().path(), std::string(CLIENT_ROOT_PATH));
336 
337 }
338 
340 
341 BOOST_AUTO_TEST_CASE( index_from_path )
342 {
343  NTree t(ThreadManager::instance().tree().root());
344  QModelIndex rootIndex = t.index(0, 0);
345  QModelIndex index = t.index(0, 0, rootIndex);
346 
347  Handle< CNode > node = static_cast<TreeNode*>(index.internalPointer())->node();
348 
349 
350  // 1. get the root
351  QModelIndex foundRootIndex = t.index_from_path("cpath:/");
352  BOOST_CHECK( foundRootIndex.isValid() );
353  BOOST_CHECK_EQUAL( foundRootIndex.internalPointer(), rootIndex.internalPointer() );
354 
355  // 2. get another node
356  QModelIndex foundIndex = t.index_from_path(node->uri());
357  BOOST_CHECK( foundIndex.isValid() );
358  BOOST_CHECK_EQUAL( foundIndex.internalPointer(), index.internalPointer() );
359 
360  // 3. unexisting path
361  QModelIndex badIndex = t.index_from_path("cpath:/Unexisting/Path");
362  BOOST_CHECK( !badIndex.isValid() );
363 
364  // 4. unexisting path (bis, no path but just a name)
365  QModelIndex badIndexBis = t.index_from_path("cpath:UnexistingPath");
366  BOOST_CHECK( !badIndexBis.isValid() );
367 
368  // 5. path is not a CPATH
369  BOOST_CHECK_THROW( t.index_from_path("http://www.google.com"), FailedAssertion);
370 }
371 
373 
375 {
376  NTree t(ThreadManager::instance().tree().root());
377  QModelIndex logIndex = t.index_from_path(CLIENT_LOG_PATH);
378  QModelIndex logScndCol = t.index(logIndex.row(), 1, logIndex.parent());
379 
380  //
381  // 1. index is not valid
382  //
383  BOOST_CHECK( !t.data(QModelIndex(), Qt::DisplayRole).isValid() );
384 
385  //
386  // 2. try to get the log (local component) while in non-debug mode
387  // (should return invalid data)
388  //
389  BOOST_CHECK( !t.data(logIndex, Qt::DisplayRole).isValid() );
390  BOOST_CHECK( !t.data(logIndex, Qt::ToolTip).isValid() );
391  BOOST_CHECK( !t.data(logScndCol, Qt::DisplayRole).isValid() );
392  BOOST_CHECK( !t.data(logScndCol, Qt::ToolTip).isValid() );
393 
394  t.set_debug_mode_enabled(true);
395 
396  //
397  // 3. try to get the log (local component) while in debug mode
398  // (should return correct data)
399  //
400  QVariant logName = t.data(logIndex, Qt::DisplayRole);
401  QVariant logToolTip = t.data(logIndex, Qt::ToolTipRole);
402  QVariant logToolTipScndCol = t.data(logScndCol, Qt::ToolTipRole);
403 
404  // verify data
405  BOOST_CHECK_EQUAL( logName.toString().toStdString(), std::string(CLIENT_LOG) );
406  BOOST_CHECK_EQUAL( logToolTip.toString().toStdString(), NLog().tool_tip().toStdString() );
407  BOOST_CHECK_EQUAL( logToolTipScndCol.toString().toStdString(), NLog().tool_tip().toStdString() );
408 }
409 
411 
413 {
414  NTree t(ThreadManager::instance().tree().root());
415  QModelIndex index = t.index(0, 0);
416 
417  // 1. get the first item (the root), 1st column. Should be valid.
418  BOOST_CHECK( index.isValid() );
419 
420  // 2. get the first item (the root), 2nd column. Should be valid.
421  BOOST_CHECK( t.index(0, 1).isValid() );
422 
423  // 3. get the 1st child under the root. *Should* be valid.
424  BOOST_CHECK( t.index(0, 0, index).isValid() );
425 
426  // 4. get the 12th child under the root. Should *not* be valid.
427  BOOST_CHECK( !t.index(12, 0, index).isValid() );
428 }
429 
431 
433 {
434  NTree t(ThreadManager::instance().tree().root());
435  QModelIndex rootIndex = t.index(0, 0);
436  QModelIndex childIndex = t.index(0, 0, rootIndex);
437 
438  BOOST_CHECK( !t.parent(rootIndex).isValid() );
439  BOOST_CHECK_EQUAL( t.parent(childIndex).internalPointer(), rootIndex.internalPointer() );
440 }
441 
443 
445 {
446  NTree t(ThreadManager::instance().tree().root());
447  TreeThread & tree = ThreadManager::instance().tree();
448 
449  BOOST_CHECK_EQUAL(t.rowCount(), 1);
450  BOOST_CHECK_EQUAL(t.rowCount(t.index(0, 0)), (int) tree.root()->count_children());
451  BOOST_CHECK_EQUAL(t.rowCount(t.index(0, 1)), 0);
452 }
453 
455 
456 BOOST_AUTO_TEST_CASE( header_data )
457 {
458  NTree t(ThreadManager::instance().tree().root());
459 
460  BOOST_CHECK_EQUAL(t.headerData(0, Qt::Horizontal).toString().toStdString(), std::string("Name"));
461  BOOST_CHECK_EQUAL(t.headerData(1, Qt::Horizontal).toString().toStdString(), std::string("Type"));
462 
463  BOOST_CHECK(!t.headerData(0, Qt::Vertical).isValid());
464  BOOST_CHECK(!t.headerData(0, Qt::Horizontal, Qt::DecorationRole).isValid());
465 }
466 
468 
469 BOOST_AUTO_TEST_CASE( set_debug_mode_enabled )
470 {
471  NTree t(ThreadManager::instance().tree().root());
472  QSignalSpy spy(&t, SIGNAL(layoutChanged()));
473 
474  // by default, debug mode is disabled
475  BOOST_CHECK(!t.is_debug_mode_enabled());
476 
477  t.set_debug_mode_enabled(true);
478 
479  // the tree must have emitted a layout changed signal exactly once
480  BOOST_CHECK_EQUAL(spy.count(), 1);
481 }
482 
484 
485 BOOST_AUTO_TEST_CASE( options_changed )
486 {
487  Handle< NTree > t = NTree::global();
488  boost::shared_ptr< NGeneric > node(new NGeneric("ThisNodeShouldDisappear", "MyType"));
489  Handle< XmlDoc > doc;
490  SignalFrame frame;
492  boost::shared_ptr<Component> newRoot = allocate_component<Group>("Root");
493 
494  newRoot->create_component<Link>("Environment");
495  newRoot->create_component<Group>("Tools");
496 
497  newRoot->signal_list_tree( frame );
498 
499  SignalFrame replyFrame = frame.get_reply();
500 
501  // add a node
502  root->add_node(node);
503 
504  // set the new tree
505  BOOST_CHECK_NO_THROW ( t->list_tree_reply( replyFrame ) );
506 
507  // check that the previously added node has been removed
508  BOOST_CHECK_THROW( root->get_child_checked("ThisNodeShouldDisappear"), ValueNotFound);
509 
510  // check that new nodes have been added
511  BOOST_CHECK_NO_THROW( root->get_child("Environment") );
512  BOOST_CHECK_NO_THROW( root->get_child("Tools") );
513 
514  // check that the local components are still there
515  Handle< Component > uidir;
516 
517  BOOST_CHECK_NO_THROW( uidir = root->get_child("UI") );
518  BOOST_CHECK_NO_THROW( uidir->get_child("Browsers") );
519  BOOST_CHECK_NO_THROW( uidir->get_child("Log") );
520  BOOST_CHECK_NO_THROW( uidir->get_child("Plugins") );
521  BOOST_CHECK_NO_THROW( uidir->get_child("Tree") );
522 }
523 
525 
526 BOOST_AUTO_TEST_CASE( node_matches )
527 {
528  NTree t(ThreadManager::instance().tree().root());
529  QSignalSpy spy(&t, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
530  QModelIndex index = t.index_from_path( CLIENT_LOG_PATH );
531  QList<QVariant> args;
532 
533  t.options_changed("//A/Path/That/Does/Not/Exist");
534 
535  BOOST_CHECK_EQUAL( spy.count(), 0 );
536 
538 
539  BOOST_CHECK_EQUAL( spy.count(), 1 );
540  args = spy.takeFirst();
541  BOOST_CHECK_EQUAL( qvariant_cast<QModelIndex>(args.at(0)).internalPointer(), index.internalPointer() );
542  BOOST_CHECK_EQUAL( qvariant_cast<QModelIndex>(args.at(1)).internalPointer(), index.internalPointer() );
543 }
544 
546 
547 BOOST_AUTO_TEST_CASE( signal_list_tree )
548 {
549  NTree t(ThreadManager::instance().tree().root());
550  boost::shared_ptr< NGeneric > node(new NGeneric("MyNode", "MyType"));
551  QModelIndex rootIndex = t.index_from_path( CLIENT_ROOT_PATH );
552  QModelIndex treeIndex = t.index_from_path( CLIENT_TREE_PATH );
553  QModelIndex logIndex = t.index_from_path( CLIENT_LOG_PATH );
554 
555  t.tree_root()->get_child("UI")->get_child("Log")->handle<NLog>()->add_node( node );
556 
557  QModelIndex nodeIndex = t.index_from_path( CLIENT_TREE_PATH "/MyNode" );
558 
559  //
560  // 1. check with an invalid index
561  //
562  BOOST_CHECK( !t.node_matches(QModelIndex(), QRegExp("(nothing)")));
563 
564  //
565  // 2. check with a direct local component child while not in debug mode
566  //
567  BOOST_CHECK( !t.node_matches(rootIndex, QRegExp("Tree", Qt::CaseSensitive)) );
568 
569  t.set_debug_mode_enabled(true);
570 
571  //
572  // 3. check with a direct child
573  //
574  // 3a. lower case and case sensitive (should return false)
575  BOOST_CHECK( !t.node_matches(rootIndex, QRegExp("tree", Qt::CaseSensitive)) );
576  // 3b. lower case and case insensitive (should return true)
577  BOOST_CHECK( t.node_matches(rootIndex, QRegExp("tree", Qt::CaseInsensitive)) );
578  // 3c. correct case and case sensitive (should return true)
579  BOOST_CHECK( t.node_matches(rootIndex, QRegExp("Tree", Qt::CaseSensitive)) );
580 
581  //
582  // 4. check with a non-direct child
583  //
584  // 4a. lower case and case sensitive (should return false)
585  BOOST_CHECK( !t.node_matches(rootIndex, QRegExp("mynode", Qt::CaseSensitive)) );
586  // 4b. lower case and case insensitive (should return true)
587  BOOST_CHECK( t.node_matches(rootIndex, QRegExp("mynode", Qt::CaseInsensitive)) );
588  // 4c. correct case and case sensitive (should return true)
589  BOOST_CHECK( t.node_matches(rootIndex, QRegExp("MyNode", Qt::CaseSensitive)) );
590 }
591 
593 
594 BOOST_AUTO_TEST_CASE( index_is_visible )
595 {
596  NTree t(ThreadManager::instance().tree().root());
597  boost::shared_ptr< NGeneric > node(new NGeneric("Node", "MyType"));
598  boost::shared_ptr< MyNode > myNode(new MyNode("AnotherNode"));
599 
600  t.tree_root()->add_node(node);
601  t.tree_root()->add_node(myNode);
602 
603  QModelIndex nodeIndex = t.index_from_path( node->uri() );
604  QModelIndex myNodeIndex = t.index_from_path( myNode->uri() );
605 
606  // 1. invalid index
607  BOOST_CHECK( !t.check_index_visible( QModelIndex() ) );
608 
609  // 2. check with the root (should always be visible)
610  BOOST_CHECK( t.check_index_visible( t.index(0,0) ) );
611 
612  //
613  // 3. checks with a non-local but advanced component
614  //
615  // 3a. in basic mode (components are advanced by default)
616  BOOST_CHECK( !t.check_index_visible( nodeIndex ) );
617  // 3b. in advanced mode
618  t.set_advanced_mode(true);
619  BOOST_CHECK( t.check_index_visible( nodeIndex ) );
620  // 3c. in advanced mode with the component marked as basic
621  node->mark_basic();
622  BOOST_CHECK( t.check_index_visible( nodeIndex ) );
623 
624  t.set_advanced_mode(true);
625 
626  //
627  // 4. checks with a non-local but advanced component
628  //
629  // 4a. in basic mode (components are advanced by default)
630  BOOST_CHECK( !t.check_index_visible( myNodeIndex ) );
631  // 4b. in advanced mode
632  t.set_advanced_mode(true);
633  BOOST_CHECK( !t.check_index_visible( myNodeIndex ) );
634  // 4c. in advanced mode with the component marked as basic
635  myNode->mark_basic();
636  BOOST_CHECK( !t.check_index_visible( myNodeIndex ) );
637  // 4d. in debug mode
638  t.set_debug_mode_enabled(true);
639  BOOST_CHECK( t.check_index_visible( myNodeIndex ) );
640 }
641 
644 
645 BOOST_AUTO_TEST_SUITE_END()
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Implementation of QAbstractItemModel::rowCount().
Definition: NTree.cpp:545
virtual QVariant data(const QModelIndex &index, int role) const
Implementation of QAbstractItemModel::data().
Definition: NTree.cpp:468
Log component.
Definition: NLog.hpp:34
QApplication * application()
Definition: Application.hpp:11
Safe pointer to an object. This is the supported method for referring to components.
Definition: Handle.hpp:39
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Implementation of QAbstractItemModel::index().
Definition: NTree.cpp:500
bool AssertionThrows
assertions throw exceptions
Definition: Assertions.hpp:67
bool ExceptionOutputs
if exception contructor should output
Definition: Exception.hpp:32
static AssertionManager & instance()
Gets the instance of the manager.
Definition: Assertions.cpp:33
void add_node(boost::shared_ptr< CNode > node)
Adds a sub-node.
Definition: CNode.cpp:452
void signal_list_tree(SignalArgs &args) const
lists the sub components and puts them on the xml_tree
Definition: Component.cpp:765
Classes that implement the XML protocol for use in COOLFluiD.
Definition: Component.hpp:43
Basic Classes for client-core library used by coolfluid-client application.
Definition: CNode.cpp:57
bool AssertionDumps
assertions dump backtraces
Definition: Assertions.hpp:65
std::string path() const
Definition: URI.cpp:253
bool is_debug_mode_enabled() const
Indicates whether the debug mode is activated or not.
Definition: NTree.cpp:370
URI uri() const
Construct the full path.
Definition: Component.cpp:248
bool ExceptionDumps
if exception contructor should dump backtrace
Definition: Exception.hpp:34
Handle< CNode > node_by_path(const cf3::common::URI &path) const
Retrieves a node from its path.
Definition: NTree.cpp:228
virtual QModelIndex parent(const QModelIndex &child) const
Implementation of QAbstractItemModel::parent()->
Definition: NTree.cpp:524
void set_advanced_mode(bool advanceMode)
Set advanced mode.
Definition: NTree.cpp:192
Handles a CNode component in the tree.
Definition: TreeNode.hpp:30
tuple root
Definition: coolfluid.py:24
bool node_matches(const QModelIndex &index, const QRegExp &regex) const
Checks whether a node name or one of its children matches a provided regular expression.
Definition: NTree.cpp:404
#define CLIENT_TREE_PATH
Handle< Component > get_child_checked(const std::string &name)
Definition: Component.cpp:458
Handle< NRoot > tree_root() const
Gives the current root.
Definition: NTree.cpp:75
bool is_advanced_mode() const
Indicates whether advanced mode is activated or not.
Definition: NTree.cpp:210
Manages a set of maps.
Definition: SignalFrame.hpp:31
QString node_path(const QModelIndex &index) const
Retrieves a node path.
Definition: NTree.cpp:177
void set_current_index(const QModelIndex &newIndex)
Sets the current index.
Definition: NTree.cpp:82
void set_tree_root(Handle< NRoot > node)
Replaces the current component tree.
Definition: NTree.cpp:57
bool are_from_same_node(const QModelIndex &left, const QModelIndex &right) const
Checks whether two indexes point to the same node.
Definition: NTree.cpp:219
void list_tree_reply(cf3::common::SignalArgs &node)
Signal called when the tree needs to be updated.
Definition: NTree.cpp:591
Manages the client root node.
Definition: TreeThread.hpp:37
Component for grouping other components.
Definition: Group.hpp:25
virtual QString tool_tip() const
Gives the text to put on a tool tip.
Definition: NLog.cpp:127
Handle< Component > get_child(const std::string &name)
Definition: Component.cpp:441
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Handle< NRoot > makeTreeFromFile()
std::string tree(bool basic_mode=false, Uint depth=0, Uint recursion_level=0) const
Definition: Component.cpp:785
static ExceptionManager & instance()
Gets the instance of the manager.
Definition: Exception.cpp:34
QModelIndex current_index() const
Gives the current index.
Definition: NTree.cpp:98
#define CLIENT_LOG_PATH
SignalFrame get_reply() const
Handle< NRoot > root() const
Definition: TreeThread.hpp:59
void options_changed(const cf3::common::URI &path)
Definition: NTree.cpp:392
cf3::common::URI pathFromIndex(const QModelIndex &index) const
Gives the path of the provided index.
Definition: NTree.cpp:337
BOOST_AUTO_TEST_CASE(init)
Tree model.
Definition: NTree.hpp:39
Client root. This class is wrapper for cf3::common::Root class on the client side. A NRoot object may never have any child. Add them to the internal Root componenent instead. It can be obtained by calling root() method.
Definition: NRoot.hpp:34
bool check_index_visible(const QModelIndex &index) const
Checks whether a nodeis visible or not.
Definition: NTree.cpp:424
Client generic component.
Definition: NGeneric.hpp:29
Definition: CNode.hpp:22
void set_debug_mode_enabled(bool debugMode)
Set the debug mode.
Definition: NTree.cpp:354
#define CLIENT_LOG
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Gives header titles.
Definition: NTree.cpp:577
void list_node_options(const QModelIndex &index, QList< boost::shared_ptr< cf3::common::Option > > &options, bool *ok=nullptr) const
Gets node options.
Definition: NTree.cpp:116
Handle< Component > create_component(const std::string &name, const std::string &builder)
Build a (sub)component of this component using the extended type_name of the component.
Definition: Component.cpp:568
cf3::common::URI current_path() const
Gives the path of the current index.
Definition: NTree.cpp:107
Most basic kernel library.
Definition: Action.cpp:19
std::string string() const
Definition: URI.cpp:258
T * get() const
Raw pointer to the stored value, or null if there is none.
Definition: Handle.hpp:65
QModelIndex index_from_path(const cf3::common::URI &path) const
Retrieves a node index from its path.
Definition: NTree.cpp:302
boost::shared_ptr< XmlDoc > parse_file(const URI &file)
#define CLIENT_ROOT_PATH
Send comments to:
COOLFluiD Web Admin