DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::MainWindow Class Reference

#include <MainWindow.hpp>

Inheritance diagram for dbe::MainWindow:
[legend]
Collaboration diagram for dbe::MainWindow:
[legend]

Public Slots

void slot_batch_change_start ()
void slot_batch_change_stop (const QList< QPair< QString, QString > > &)
void slot_information_message (QString const, QString const)
void slot_warning_message (QString const, QString const)
void slot_error_message (QString const, QString const)

Signals

void signal_batch_change_stopped (const QList< QPair< QString, QString > > &)
void signal_db_loaded ()
void signal_externalchanges_processed ()
void signal_new_file_model ()

Public Member Functions

 MainWindow (QMap< QString, QString > const &CommandLine, QWidget *parent=nullptr)
bool check_ready () const
cptr< dbe::CustomTreeViewget_view () const
QString find_db_repository_dir ()
void build_file_model ()

Static Public Member Functions

static MainWindowfindthis ()

Private Slots

void slot_create_newdb ()
void slot_open_database_from_file ()
void slot_load_db_from_create_widget (const QString &)
bool slot_commit_database (bool Exit=false)
void slot_abort_changes ()
void slot_abort_external_changes ()
void slot_launch_object_editor (tref)
void slot_edit_object_from_class_view (QModelIndex const &)
void slot_fetch_data (treenode const *)
void slot_launch_batchchange ()
void slot_launch_batchchange_on_table ()
void reload_default_settings ()
void slot_filter_query ()
void slot_filter_textchange (const QString &)
void slot_filter_table_textchange (const QString &)
void slot_tree_reset ()
void slot_model_rebuild ()
void slot_whatisthis ()
void slot_show_information_about_dbe ()
void slot_show_userguide ()
void slot_show_userchanges ()
void slot_process_externalchanges ()
void slot_undo_allchanges ()
void slot_toggle_casesensitive_for_treeview (bool)
void slot_add_tab ()
void slot_remove_tab (int i)
void slot_toggle_commit_button ()
void slot_update_committed_files (const std::list< std::string > &, const std::string &)
void slot_loaded_db_file (QString)
void slot_launch_preferences ()

Private Member Functions

std::vector< dbe::trefProcessQuery (QString const &)
void closeEvent (QCloseEvent *event)
bool eventFilter (QObject *Target, QEvent *Event)
bool check_close ()
void init ()
void attach ()
bool dbopen (QString const &, dbinfo const &)
bool dbload ()
bool dbreload ()
void setinternals ()
void build_class_tree_model ()
void build_table_model ()
void apply_settings (QSettings &setting)
void WriteSettings ()
void argsparse (QMap< QString, QString > const &)
void init_tabs ()
void edit_object_at (const QModelIndex &Index)
void update_total_objects ()
void display_message_box (const QString &title, const QString &msg, const QMessageBox::Icon &icon)
void load_default_settings ()

Private Attributes

QSet< QString > allFiles
bool m_batch_change_in_progress
FileModelthis_files
QSortFilterProxyModel this_filesort
dbe::models::treethis_classes
models::treeselectionthis_treefilter
std::atomic< bool > isArchivedConf

Detailed Description

Definition at line 48 of file MainWindow.hpp.

Constructor & Destructor Documentation

◆ MainWindow()

dbe::MainWindow::MainWindow ( QMap< QString, QString > const & CommandLine,
QWidget * parent = nullptr )
explicit

Setting up ui

Initial Settings

Setting up application controller

Reading Applications Settings/CommandLine

Definition at line 55 of file MainWindow.cpp.

56 : QMainWindow ( parent ),
58 this_files ( nullptr ),
59 this_filesort ( new QSortFilterProxyModel ( this ) ),
60 this_classes ( nullptr ),
61 this_treefilter ( nullptr ),
62 isArchivedConf ( false )
63{
64 //qRegisterMetaType<RDBMap>("RDBMap");
65
67 setupUi ( this );
68
70 init();
71 init_tabs();
72 //init_rdb_menu();
73
75 attach();
76
78 QCoreApplication::setOrganizationName("dunedaq");
79 QCoreApplication::setApplicationName("dbe_main");
80 load_default_settings(); // Start with defaults in case no user setting saved
81 QSettings settings; // Then try user settings
82 apply_settings(settings);
83 argsparse ( cmdargs );
84
85 if (isArchivedConf == true) {
86 OpenDB->setEnabled(false);
87 //OpenOracleDB->setEnabled(false);
88 //ConnectToRdb->setEnabled(false);
89 CreateDatabase->setEnabled(false);
90 Commit->setEnabled(false);
91
92 QMessageBox::information(this,
93 "DBE",
94 QString("The configuration is opened in archival/detached mode.")
95 .append("\nYou can browse or modify objects, but changes cannot be saved or commited."));
96 }
97
98 UndoView->show();
99
100}
std::atomic< bool > isArchivedConf
dbe::models::tree * this_classes
void load_default_settings()
void argsparse(QMap< QString, QString > const &)
void apply_settings(QSettings &setting)
models::treeselection * this_treefilter
FileModel * this_files
bool m_batch_change_in_progress
QSortFilterProxyModel this_filesort

Member Function Documentation

◆ apply_settings()

void dbe::MainWindow::apply_settings ( QSettings & setting)
private

Definition at line 836 of file MainWindow.cpp.

837{
838 settings.beginGroup ( "MainWindow-layout" );
839 if (settings.contains("size")) {
840 resize ( settings.value ( "size" ).toSize() );
841 }
842 if (settings.contains("pos")) {
843 move ( settings.value ( "pos" ).toPoint() );
844 }
845 if (settings.contains("TableView")) {
846 DisplayTableView->setChecked ( settings.value ( "TableView" ).toBool() );
847 }
848 if (settings.contains("ClassView")) {
849 DisplayClassView->setChecked ( settings.value ( "ClassView" ).toBool() );
850 }
851 if (settings.contains("Messages")) {
852 DisplayMessages->setChecked ( settings.value ( "Messages" ).toBool() );
853 }
854 if (settings.contains("geometry")) {
855 restoreGeometry ( settings.value ( "geometry" ).toByteArray() );
856 }
857 if (settings.contains("state")) {
858 restoreState ( settings.value ( "state" ).toByteArray() );
859 }
860 settings.endGroup();
861
862 settings.beginGroup ( "MainWindow-checkboxes" );
863 if (settings.contains("tree-case-sensitive")) {
864 CaseSensitiveCheckBoxTree->setChecked (
865 settings.value ( "tree-case-sensitive" ).toBool() );
866 }
867 if (settings.contains("table-case-sensitive")) {
868 CaseSensitiveCheckBoxTable->setChecked (
869 settings.value ( "table-case-sensitive" ).toBool() );
870 }
871 settings.endGroup();
872
874}
static void InitColorManagement()

◆ argsparse()

void dbe::MainWindow::argsparse ( QMap< QString, QString > const & opts)
private

Definition at line 896 of file MainWindow.cpp.

897{
898 if ( !opts.isEmpty() )
899 {
900 dbinfo LoadConfig;
901 QString FileToLoad;
902
903 QString FileName = opts.value ( "f" );
904 QString RdbFileName = opts.value ( "r" );
905 QString RoksFileName = opts.value ( "o" );
906 QString HashVersion = opts.value ( "v" );
907
908 if ( !FileName.isEmpty() )
909 {
910 FileToLoad = FileName;
911 LoadConfig = dbinfo::oks;
912
913 if ( !HashVersion.isEmpty() )
914 {
915 ::setenv("TDAQ_DB_VERSION", QString("hash:").append(HashVersion).toStdString().c_str(), 1);
916 ::setenv("OKS_GIT_PROTOCOL", "http", 1);
917 isArchivedConf = true;
918 }
919 }
920 else if ( !RdbFileName.isEmpty() )
921 {
922 FileToLoad = RdbFileName;
923 LoadConfig = dbinfo::rdb;
924 }
925 else if ( !RoksFileName.isEmpty() )
926 {
927 FileToLoad = RoksFileName;
928 LoadConfig = dbinfo::roks;
929 }
930
931 if ( not FileToLoad.isEmpty() )
932 {
933 dbopen ( FileToLoad, LoadConfig );
934 }
935 }
936}
bool dbopen(QString const &, dbinfo const &)
dbinfo
Definition dbinfo.hpp:20

◆ attach()

void dbe::MainWindow::attach ( )
private

Definition at line 180 of file MainWindow.cpp.

181{
182 connect ( OpenDB, SIGNAL ( triggered() ), this, SLOT ( slot_open_database_from_file() ) );
183 connect ( Commit, SIGNAL ( triggered() ), this, SLOT ( slot_commit_database() ) );
184 connect ( Exit, SIGNAL ( triggered() ), this, SLOT ( close() ) );
185 connect ( actionPreferences, SIGNAL ( triggered() ), this, SLOT ( slot_launch_preferences() ) );
186 connect ( UndoAction, SIGNAL ( triggered() ), UndoView->stack(), SLOT ( undo() ) );
187 connect ( RedoAction, SIGNAL ( triggered() ), UndoView->stack(), SLOT ( redo() ) );
188 connect ( UndoAll, SIGNAL ( triggered() ), this, SLOT ( slot_undo_allchanges() ) );
189 connect ( BatchChange, SIGNAL ( triggered() ), this, SLOT ( slot_launch_batchchange() ) );
190 connect ( BatchChangeTable, SIGNAL ( triggered() ), this,
192
193 connect ( DisplayClassView, SIGNAL ( triggered ( bool ) ), TreeDockWidget,
194 SLOT ( setVisible ( bool ) ) );
195 connect ( DisplayTableView, SIGNAL ( triggered ( bool ) ), TableGroupBox,
196 SLOT ( setVisible ( bool ) ) );
197 connect ( DisplayMessages, SIGNAL ( triggered ( bool ) ), InfoDockWidget,
198 SLOT ( setVisible ( bool ) ) );
199 connect ( DisplayToolbar, SIGNAL ( triggered ( bool ) ), MainToolBar,
200 SLOT ( setVisible ( bool ) ) );
201
202 connect ( TreeDockWidget, SIGNAL ( visibilityChanged ( bool ) ), DisplayTableView,
203 SLOT ( setChecked ( bool ) ) );
204 connect ( InfoDockWidget , SIGNAL ( visibilityChanged ( bool ) ), DisplayMessages,
205 SLOT ( setChecked ( bool ) ) );
206 connect ( MainToolBar , SIGNAL ( visibilityChanged ( bool ) ), DisplayToolbar,
207 SLOT ( setChecked ( bool ) ) );
208
209
210 connect ( LoadDefaultSettings, SIGNAL ( triggered() ), this,
211 SLOT ( reload_default_settings() ) );
212 connect ( CreateDatabase, SIGNAL ( triggered() ), this, SLOT ( slot_create_newdb() ) );
213 //connect ( OpenOracleDB, SIGNAL ( triggered() ), this, SLOT ( slot_oracle_prepare() ) );
214
215 connect ( WhatThisAction, SIGNAL ( triggered() ), this, SLOT ( slot_whatisthis() ) );
216 connect ( UserGuide, SIGNAL ( triggered() ), this, SLOT ( slot_show_userguide() ) );
217 connect ( UserChanges, SIGNAL ( triggered() ), this, SLOT ( slot_show_userchanges() ) );
218
219 connect ( TreeView, SIGNAL ( activated ( QModelIndex ) ), this,
220 SLOT ( slot_edit_object_from_class_view ( QModelIndex ) ) );
221
222 connect( &confaccessor::ref(), SIGNAL(db_committed(const std::list<std::string>&, const std::string&)), this,
223 SLOT(slot_update_committed_files(const std::list<std::string>&, const std::string&)));
224
225 connect ( confaccessor::gethandler().get(), SIGNAL ( FetchMoreData ( const treenode * ) ),
226 this,
227 SLOT ( slot_fetch_data ( const treenode * ) ) );
228
229 connect( &confaccessor::ref(), SIGNAL(object_created(QString, dref)), this,
231 connect( &confaccessor::ref(), SIGNAL(object_renamed(QString, dref)), this,
233 connect( &confaccessor::ref(), SIGNAL(object_changed(QString, dref)), this,
235 connect( &confaccessor::ref(), SIGNAL(object_deleted(QString, dref)), this,
237 connect( &confaccessor::ref(), SIGNAL(db_committed(const std::list<std::string>&, const std::string&)), this,
239 connect( &confaccessor::ref(), SIGNAL(IncludeFileDone()), this,
241 connect( &confaccessor::ref(), SIGNAL(RemoveFileDone()), this,
243 connect( &confaccessor::ref(), SIGNAL(ExternalChangesDetected()), this,
245 connect( &confaccessor::ref(), SIGNAL(ExternalChangesAccepted()), this,
247 connect( this, SIGNAL(signal_batch_change_stopped(const QList<QPair<QString, QString>>&)), this,
249
250 connect ( &confaccessor::ref(), SIGNAL ( IncludeFileDone() ), this,
251 SLOT ( slot_model_rebuild() ) );
252 connect ( &confaccessor::ref(), SIGNAL ( RemoveFileDone() ), this,
253 SLOT ( slot_model_rebuild() ) );
254 connect ( &confaccessor::ref(), SIGNAL ( ExternalChangesAccepted() ), this,
255 SLOT ( slot_process_externalchanges() ) );
256
257
258 connect ( SearchBox, SIGNAL ( currentIndexChanged(int) ), this,
259 SLOT ( slot_filter_query() ) );
260 connect ( SearchTreeLine, SIGNAL ( textChanged ( const QString & ) ), this,
261 SLOT ( slot_filter_textchange ( const QString & ) ) );
262 connect ( SearchTreeLine, SIGNAL ( textEdited ( const QString & ) ), this,
263 SLOT ( slot_filter_query() ) );
264 connect ( SearchTreeLine, SIGNAL ( returnPressed() ), this, SLOT ( slot_filter_query() ) );
265 connect ( SearchLineTable, SIGNAL ( textChanged ( const QString & ) ), this,
266 SLOT ( slot_filter_table_textchange ( const QString & ) ) );
267 connect ( CaseSensitiveCheckBoxTree, SIGNAL ( clicked ( bool ) ), this,
268 SLOT ( slot_toggle_casesensitive_for_treeview ( bool ) ) );
269 //connect ( ConnectToRdb, SIGNAL ( triggered ( QAction * ) ), this,
270 // SLOT ( slot_rdb_selected ( QAction * ) ) );
271
272 connect ( information_about_dbe, SIGNAL ( triggered() ), this,
274
275 // Connect to signals from the messenger system
276
278 SIGNAL ( signal_debug ( QString const, QString const ) ), this,
279 SLOT ( slot_information_message ( QString , QString ) ), Qt::QueuedConnection );
280
282 SIGNAL ( signal_info ( QString const, QString const ) ), this,
283 SLOT ( slot_information_message ( QString , QString ) ), Qt::QueuedConnection );
284
286 SIGNAL ( signal_note ( QString const, QString const ) ), this,
287 SLOT ( slot_information_message ( QString , QString ) ), Qt::QueuedConnection );
288
290 SIGNAL ( signal_warn ( QString const, QString const ) ), this,
291 SLOT ( slot_warning_message ( QString , QString ) ), Qt::QueuedConnection );
292
294 SIGNAL ( signal_error ( QString const, QString const ) ), this,
295 SLOT ( slot_error_message ( QString, QString ) ), Qt::QueuedConnection );
296
298 SIGNAL ( signal_fail ( QString const, QString const ) ), this,
299 SLOT ( slot_error_message ( QString, QString ) ), Qt::QueuedConnection );
300
301 // connect ( this, SIGNAL ( signal_rdb_found(const QString&, const RDBMap& ) ),
302 // this, SLOT ( slot_rdb_found(const QString&, const RDBMap&) ), Qt::AutoConnection );
303}
void slot_fetch_data(treenode const *)
void slot_information_message(QString const, QString const)
void slot_show_userchanges()
void slot_update_committed_files(const std::list< std::string > &, const std::string &)
void slot_warning_message(QString const, QString const)
void slot_process_externalchanges()
void slot_toggle_casesensitive_for_treeview(bool)
void slot_launch_batchchange_on_table()
void slot_toggle_commit_button()
bool slot_commit_database(bool Exit=false)
void slot_launch_batchchange()
void slot_error_message(QString const, QString const)
void slot_open_database_from_file()
void slot_create_newdb()
void slot_show_userguide()
void slot_undo_allchanges()
void slot_model_rebuild()
void slot_edit_object_from_class_view(QModelIndex const &)
void slot_filter_table_textchange(const QString &)
void slot_filter_textchange(const QString &)
void signal_batch_change_stopped(const QList< QPair< QString, QString > > &)
void reload_default_settings()
void slot_launch_preferences()
void slot_show_information_about_dbe()
static cptr< datahandler > gethandler()
static confaccessor & ref()
static messenger_proxy & ref()
config_object_description dref

◆ build_class_tree_model()

void dbe::MainWindow::build_class_tree_model ( )
private

Creating new Main Model

Resetting attached models

Definition at line 305 of file MainWindow.cpp.

306{
307 QStringList Headers
308 { "Class Name", "# Objects" };
309
310 if ( this_classes != nullptr )
311 {
312 delete this_classes;
313 delete this_treefilter;
314 }
316 this_classes = new dbe::models::tree ( Headers );
318 this_treefilter = new models::treeselection();
319 this_treefilter->setFilterRegExp ( "" );
320
321 connect ( this_classes, SIGNAL ( ObjectFile ( QString ) ),
322 this, SLOT ( slot_loaded_db_file ( QString ) ) );
323
324 this_treefilter->setDynamicSortFilter ( true );
325 this_treefilter->setSourceModel ( this_classes );
327 TreeView->setModel ( this_treefilter );
328 TreeView->setSortingEnabled ( true );
329 TreeView->resizeColumnToContents ( 0 );
330 TreeView->resizeColumnToContents ( 1 );
331
332 connect ( HideCheckBox, SIGNAL ( toggled ( bool ) ), this_treefilter,
333 SLOT ( ToggleEmptyClasses ( bool ) ) );
334
335 connect ( ShowDerivedObjects, SIGNAL ( toggled ( bool ) ), this_classes,
336 SLOT ( ToggleAbstractClassesSelectable ( bool ) ) );
337
339}
void slot_loaded_db_file(QString)
void update_total_objects()

◆ build_file_model()

void dbe::MainWindow::build_file_model ( )

Changed -> Now accepting rdbconfig this means || !ConfigWrapper::GetInstance().GetDatabaseImplementation().contains("rdbconfig") was removed

Definition at line 410 of file MainWindow.cpp.

411{
413
414 if ( !confaccessor::db_implementation_name().contains ( "roksconflibs" ) )
415 {
416 if ( this_files != nullptr ) {
417 delete this_files;
418 }
419 this_files = new FileModel();
420
421 this_filesort.setSourceModel ( this_files );
422 FileView->setModel ( &this_filesort );
423
424 FileView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
425 FileView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
426 FileView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
427 FileView->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
428
430 }
431}
void signal_new_file_model()
static QString db_implementation_name()

◆ build_table_model()

void dbe::MainWindow::build_table_model ( )
private

Displaying table widgets

Definition at line 341 of file MainWindow.cpp.

342{
344 SearchLineTable->clear();
345 SearchLineTable->show();
346 SearchLineTable->setProperty ( "placeholderText", QVariant ( QString ( "Table Filter" ) ) );
347 CaseSensitiveCheckBoxTable->show();
348}

◆ check_close()

bool dbe::MainWindow::check_close ( )
private

Definition at line 1366 of file MainWindow.cpp.

1367{
1368 bool OK = true;
1369
1370 foreach ( QWidget * widget, QApplication::allWidgets() )
1371 {
1372 ObjectCreator * ObjectCreatorInstance = dynamic_cast<ObjectCreator *> ( widget );
1373 ObjectEditor * ObjectEditorInstance = dynamic_cast<ObjectEditor *> ( widget );
1374
1375 if ( ObjectEditorInstance )
1376 {
1377 OK = ObjectEditorInstance->CanCloseWindow();
1378 }
1379
1380 if ( !OK )
1381 {
1382 return false;
1383 }
1384
1385 if ( ObjectCreatorInstance )
1386 {
1387 OK = ObjectCreatorInstance->CanClose();
1388 }
1389
1390 if ( !OK )
1391 {
1392 return false;
1393 }
1394 }
1395
1396 {
1397 cptr<QUndoStack> undo_stack ( confaccessor::get_commands() );
1398
1399 if ( undo_stack->isClean() )
1400 {
1401 if ( undo_stack->count() == 0 )
1402 {
1403 return true;
1404 }
1405 else
1406 {
1408 return true;
1409 }
1410 }
1411 else
1412 {
1413 int ret =
1414 QMessageBox::question (
1415 0,
1416 tr ( "DBE" ),
1417 QString (
1418 "There are unsaved changes.\n\nDo you want to save and commit them to the DB?\n" ),
1419 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
1420 QMessageBox::Save );
1421
1422 if ( ret == QMessageBox::Discard )
1423 {
1425 return true;
1426 }
1427 else if ( ret == QMessageBox::Save )
1428 {
1429 return slot_commit_database ( true );
1430 }
1431 else if ( ret == QMessageBox::Cancel )
1432 {
1433 return false;
1434 }
1435 else
1436 {
1437 return true;
1438 }
1439 }
1440 }
1441}
void slot_abort_changes()
static t_undo_stack_cptr get_commands()

◆ check_ready()

bool dbe::MainWindow::check_ready ( ) const
nodiscard

Definition at line 1842 of file MainWindow.cpp.

1843{
1844 return not m_batch_change_in_progress;
1845}

◆ closeEvent()

void dbe::MainWindow::closeEvent ( QCloseEvent * event)
private

Definition at line 1303 of file MainWindow.cpp.

1304{
1305 if ( isArchivedConf || check_close() )
1306 {
1307 WriteSettings();
1308
1309 foreach ( QWidget * widget, QApplication::allWidgets() ) widget->close();
1310
1311 event->accept();
1312 }
1313 else
1314 {
1315 event->ignore();
1316 }
1317}

◆ dbload()

bool dbe::MainWindow::dbload ( )
private

Definition at line 757 of file MainWindow.cpp.

758{
759 // For issues related to loading the configuration in a separate thread, see ATLASDBE-229
760
761 const bool alreadyLoaded = confaccessor::is_database_loaded();
762
763 // The QueuedConnection is mandatory to let the loop receive the signal even if
764 // it is emitted before "exec" is called
765 QEventLoop loop;
766 connect(this, SIGNAL(signal_db_loaded()), &loop, SLOT(quit()), Qt::QueuedConnection);
767
768 // Make life of the progress dialog longer
769 // Show only the first time, when the configuration is not loaded
770 // In other cases, just show a busy cursor
771 std::unique_ptr<QProgressDialog> progress_bar;
772 if(!alreadyLoaded) {
773 progress_bar.reset(new QProgressDialog( "Loading Configuration...", QString(), 0, 0, this ));
774 progress_bar->setWindowModality ( Qt::WindowModal );
775 progress_bar->show();
776 }
777
778 BOOST_SCOPE_EXIT(void)
779 {
780 QApplication::restoreOverrideCursor();
781 }
782 BOOST_SCOPE_EXIT_END
783
784 QApplication::setOverrideCursor ( QCursor ( Qt::WaitCursor ) );
785
786 // Close widgets
787 for ( QWidget * widget : QApplication::allWidgets() )
788 {
789 if ( dynamic_cast<ObjectEditor *> ( widget ) )
790 {
791 widget->close();
792 }
793 else if ( dynamic_cast<widgets::editors::base *> ( widget ) )
794 {
795 widget->close();
796 }
797 }
798
799 // Asynchronous execution only the first time the configuration is loaded
800 std::future<bool> waiter = std::async ( alreadyLoaded ? std::launch::deferred : std::launch::async, [this]
801 {
802 const bool result = confaccessor::load(!isArchivedConf);
803 emit signal_db_loaded(); // "loop.exec()" will return now
804 return result;
805 } );
806
807
808 // Do not call "exec" if the previous call is not asynchronous
809 if(!alreadyLoaded) {
810 loop.exec(QEventLoop::ExcludeUserInputEvents);
811 }
812
813 // If "deferred", the async call is executed now and here
814 return waiter.get();
815}
void signal_db_loaded()
static bool is_database_loaded()
static bool load(bool subscribeToChanges=true)

◆ dbopen()

bool dbe::MainWindow::dbopen ( QString const & dbpath,
dbinfo const & loadtype )
private

Takes necessary actions to load a database from a file provided

Parameters
dbpathis the path (absolute or relative to the DUNEDAQ_DB_PATH) of the associated file
Returns

Definition at line 1453 of file MainWindow.cpp.

1454{
1455 if ( dbreload() )
1456 {
1457 confaccessor::setdbinfo ( dbpath, loadtype );
1458
1459 BOOST_SCOPE_EXIT(void)
1460 {
1461 QApplication::restoreOverrideCursor();
1462 }
1463 BOOST_SCOPE_EXIT_END
1464
1465 QApplication::setOverrideCursor(Qt::WaitCursor);
1466
1467 if ( dbload() )
1468 {
1469 setinternals();
1471 // build_partition_tree_model();
1472 // build_resource_tree_model();
1474 }
1475 }
1476
1477 return true;
1478}
void build_class_tree_model()
void build_file_model()
static void setdbinfo(QString const &location, dbinfo const itype=dbinfo::oks)

◆ dbreload()

bool dbe::MainWindow::dbreload ( )
private

Definition at line 727 of file MainWindow.cpp.

728{
730 {
731 QMessageBox MessageBox;
732 MessageBox.setText (
733 "Do you really wish to abandon the current database and load a new one ?" );
734 MessageBox.setStandardButtons ( QMessageBox::Yes | QMessageBox::Cancel );
735 MessageBox.setDefaultButton ( QMessageBox::Cancel );
736 int UserOption = MessageBox.exec();
737
738 switch ( UserOption )
739 {
740
741 case QMessageBox::Yes:
742 return true;
743
744 case QMessageBox::Cancel:
745 return false;
746
747 default:
748 return false;
749 }
750 }
751 else
752 {
753 return true;
754 }
755}

◆ display_message_box()

void dbe::MainWindow::display_message_box ( const QString & title,
const QString & msg,
const QMessageBox::Icon & icon )
private

Definition at line 1705 of file MainWindow.cpp.

1706 {
1707 QMessageBox mb(this);
1708 mb.setIcon(icon);
1709 mb.setWindowTitle(title);
1710 mb.setStandardButtons(QMessageBox::Ok);
1711 if(msg.length() > MAX_MESSAGE_LENGTH) {
1712 QString&& truncated_msg = msg.left(MAX_MESSAGE_LENGTH);
1713 truncated_msg.append("...");
1714 mb.setText("<b>The message has been truncated because it is too long, look at the details for the full message</b>");
1715 mb.setInformativeText(truncated_msg);
1716 mb.setDetailedText(msg);
1717 } else {
1718 mb.setText(msg);
1719 }
1720
1721 mb.exec();
1722}

◆ edit_object_at()

void dbe::MainWindow::edit_object_at ( const QModelIndex & Index)
private

Definition at line 350 of file MainWindow.cpp.

351{
352 treenode * tree_node = this_classes->getnode ( Index );
353
354 /*
355 * If an object node is linked to this index then launch the object editor
356 * else build a table for the class , showing all objects
357 */
358
359 if ( dynamic_cast<ObjectNode *> ( tree_node ) )
360 {
361 ObjectNode * NodeObject = dynamic_cast<ObjectNode *> ( tree_node );
362 tref ObjectToBeEdited = NodeObject->GetObject();
363 slot_launch_object_editor ( ObjectToBeEdited );
364 }
365 else
366 {
367 // Class node
368 QString const cname = tree_node->GetData ( 0 ).toString();
369 dunedaq::conffwk::class_t cinfo = dbe::config::api::info::onclass::definition (
370 cname.toStdString(),
371 false );
372
373 if ( not cinfo.p_abstract or ShowDerivedObjects->isChecked() )
374 {
375 if ( TableTab * CurrentTab = dynamic_cast<TableTab *> ( tableholder->currentWidget() ) )
376 {
377 CurrentTab->CreateModels();
378 dbe::models::table * CurrentTabModel = CurrentTab->GetTableModel();
379 CustomDelegate * CurrentDelegate = CurrentTab->GetTableDelegate();
380 CustomTableView * CurrentView = CurrentTab->GetTableView();
381
382 connect ( CurrentView, SIGNAL ( OpenEditor ( tref ) ), this,
383 SLOT ( slot_launch_object_editor ( tref ) ), Qt::UniqueConnection );
384 connect ( CurrentDelegate, SIGNAL ( CreateObjectEditorSignal ( tref ) ), this,
385 SLOT ( slot_launch_object_editor ( tref ) ), Qt::UniqueConnection );
386
387 if ( dynamic_cast<ClassNode *> ( tree_node ) )
388 {
389 BOOST_SCOPE_EXIT(CurrentTabModel)
390 {
391 emit CurrentTabModel->layoutChanged();
392 }
393 BOOST_SCOPE_EXIT_END
394
395 emit CurrentTabModel->layoutAboutToBeChanged();
396
397 CurrentTabModel->BuildTableFromClass ( cname, ShowDerivedObjects->isChecked() );
399 tableholder->setTabText ( tableholder->currentIndex(), cname );
400 CurrentTab->ResetTableView();
401 }
402
403 CurrentTab->ResizeHeaders();
404 }
405 }
406 }
407}
void slot_launch_object_editor(tref)
void build_table_model()
static dunedaq::conffwk::class_t definition(std::string const &cn, bool direct_only)
bool BuildTableFromClass(const QString &ClassName, bool BuildSubClasses=false)
Definition table.cpp:282
inner::configobject::tref tref
Definition tref.hpp:35

◆ eventFilter()

bool dbe::MainWindow::eventFilter ( QObject * Target,
QEvent * Event )
private

Definition at line 1352 of file MainWindow.cpp.

1353{
1354 if ( Target == SearchBox->lineEdit() && Event->type() == QEvent::MouseButtonRelease )
1355 {
1356 if ( !SearchBox->lineEdit()->hasSelectedText() )
1357 {
1358 SearchBox->lineEdit()->selectAll();
1359 return true;
1360 }
1361 }
1362
1363 return false;
1364}

◆ find_db_repository_dir()

QString dbe::MainWindow::find_db_repository_dir ( )
nodiscard

Definition at line 664 of file MainWindow.cpp.

665{
666 if (confaccessor::dbfullname().isEmpty()) {
667 return "";
668 }
669
671 for(QString f : allFiles) {
672 for(const QString& j : incs) {
673 if(f.endsWith(j)) {
674 return f.remove(j);
675 }
676 }
677 }
678
679 return "";
680}
QSet< QString > allFiles
static QString dbfullname()
static QStringList inclusions(QStringList const &candidates, QStringList files={ })

◆ findthis()

dbe::MainWindow * dbe::MainWindow::findthis ( )
static

Permits to retrieve the main window pointer throughout the application

Returns
a pointer of type MainWindow to the first class of type MainWindow

Definition at line 1676 of file MainWindow.cpp.

1677{
1678 QWidgetList allwidgets = QApplication::topLevelWidgets();
1679
1680 QWidgetList::iterator it = allwidgets.begin();
1681 MainWindow * main_win = qobject_cast<MainWindow *> ( *it );
1682
1683 for ( ; it != allwidgets.end() and main_win == nullptr; ++it )
1684 {
1685 main_win = qobject_cast<MainWindow *> ( *it );
1686 }
1687
1688 return main_win;
1689}
MainWindow(QMap< QString, QString > const &CommandLine, QWidget *parent=nullptr)

◆ get_view()

cptr< dbe::CustomTreeView > dbe::MainWindow::get_view ( ) const
nodiscard

Definition at line 1763 of file MainWindow.cpp.

1764{
1765 return cptr<CustomTreeView> ( TreeView );
1766}

◆ init()

void dbe::MainWindow::init ( )
private

Window Settings

Table Settings

Menus Settings

Commands Settings

Search Box Settings

What is this

Definition at line 140 of file MainWindow.cpp.

141{
143 setWindowTitle ( "DUNE DAQ Configuration Database Editor (DBE)" );
145 UndoView->setStack ( confaccessor::get_commands().get() );
146 SearchLineTable->hide();
147 SearchLineTable->setClearButtonEnabled(true);
148 SearchTreeLine->setClearButtonEnabled(true);
149 CaseSensitiveCheckBoxTable->hide();
150 tableholder->removeTab ( 1 );
151
153 HelpMenu->setEnabled ( false ); // Until help is updated to be useful!!!
154
156 Commit->setEnabled ( false );
157 UndoAction->setEnabled ( true );
158 RedoAction->setEnabled ( true );
159
161 SearchBox->setFocusPolicy ( Qt::ClickFocus );
162
164 TreeView->setWhatsThis ( "This view shows the classes and objects of the database" );
165 FileView->setWhatsThis ( "This view shows the file structure of the database" );
166 UndoView->setWhatsThis ( "This view shows the commands in the Undo Command stack" );
167
168 CommittedTable->setHorizontalHeaderLabels(QStringList() << "File" << "Comment" << "Date");
169 CommittedTable->setAlternatingRowColors(true);
170 CommittedTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
171 CommittedTable->horizontalHeader()->setDefaultSectionSize(250);
172 CommittedTable->setWordWrap(true);
173 CommittedTable->setTextElideMode(Qt::ElideRight);
174 CommittedTable->setItemDelegate(new DummyEditorDelegate());
175
176 // Make Files the current tab
177 InfoWidget->setCurrentIndex (0);
178}

◆ init_tabs()

void dbe::MainWindow::init_tabs ( )
private

Definition at line 102 of file MainWindow.cpp.

103{
104 tableholder->addTab ( new TableTab ( tableholder ), "Table View" );
105 tableholder->removeTab ( 0 );
106
107 QPushButton * addtab_button = new QPushButton ( "+" );
108 tableholder->setCornerWidget ( addtab_button, Qt::TopLeftCorner );
109 connect ( addtab_button, SIGNAL ( clicked() ), this, SLOT ( slot_add_tab() ) );
110
111 tableholder->setTabsClosable ( true );
112 connect ( tableholder, SIGNAL ( tabCloseRequested ( int ) ), this,
113 SLOT ( slot_remove_tab ( int ) ) );
114}
void slot_remove_tab(int i)

◆ load_default_settings()

void dbe::MainWindow::load_default_settings ( )
private

Definition at line 657 of file MainWindow.cpp.

658{
659 QSettings defaults(":theme/DBE_Default_User_Settings.conf",
660 QSettings::NativeFormat);
661 apply_settings(defaults);
662}

◆ ProcessQuery()

std::vector< dbe::tref > dbe::MainWindow::ProcessQuery ( QString const & Tmp)
private

Definition at line 1319 of file MainWindow.cpp.

1320{
1321 if ( not Tmp.isEmpty() )
1322 {
1323 QString const Query = QString ( "(this (object-id \".*%1.*\" ~=))" ).arg ( Tmp );
1324
1325 try
1326 {
1327 std::vector<dbe::tref> result;
1328
1329 for ( std::string const & cname : dbe::config::api::info::onclass::allnames <
1330 std::vector<std::string >> () )
1331 {
1332 std::vector<dbe::tref> class_matching_objects = inner::dbcontroller::gets (
1333 cname, Query.toStdString() );
1334
1335 result.insert ( result.end(), class_matching_objects.begin(),
1336 class_matching_objects.end() );
1337 }
1338
1339 return result;
1340 }
1341 catch ( dunedaq::conffwk::Exception const & ex )
1342 {
1343 ers::error ( ex );
1344 ERROR ( "Query process error", dbe::config::errors::parse ( ex ).c_str() );
1345 }
1346 }
1347
1348 return
1349 {};
1350}
static std::vector< configobject::tref > gets(std::string const &cname, std::string const &query="")
#define ERROR(...)
Definition messenger.hpp:93
std::string const parse(ers::Issue const &)
void error(const Issue &issue)
Definition ers.hpp:92

◆ reload_default_settings

void dbe::MainWindow::reload_default_settings ( )
privateslot

Definition at line 651 of file MainWindow.cpp.

652{
653 QSettings settings;
654 settings.clear();
656}

◆ setinternals()

void dbe::MainWindow::setinternals ( )
private

Disconnecting models from views

Definition at line 817 of file MainWindow.cpp.

818{
820 confaccessor::gethandler()->ResetData();
822
824
825 for ( int i = 0; i < tableholder->count(); i++ )
826 {
827 TableTab * CurrentTab = dynamic_cast<TableTab *> ( tableholder->widget ( i ) );
828 if ( CurrentTab ) {
829 CurrentTab->DisconnectView();
830 }
831 }
832
833 FileView->setModel ( NULL );
834}
static void set_total_objects(int const i)
static void clear_commands()

◆ signal_batch_change_stopped

void dbe::MainWindow::signal_batch_change_stopped ( const QList< QPair< QString, QString > > & )
signal

◆ signal_db_loaded

void dbe::MainWindow::signal_db_loaded ( )
signal

◆ signal_externalchanges_processed

void dbe::MainWindow::signal_externalchanges_processed ( )
signal

◆ signal_new_file_model

void dbe::MainWindow::signal_new_file_model ( )
signal

◆ slot_abort_changes

void dbe::MainWindow::slot_abort_changes ( )
privateslot

Definition at line 522 of file MainWindow.cpp.

523{
524 try
525 {
527 {
530 }
531 }
532 catch ( dunedaq::conffwk::Exception const & e )
533 {
534 ERROR ( "Database changes aborted", dbe::config::errors::parse ( e ).c_str() );
535 ers::error ( e );
536 }
537}
static void abort()

◆ slot_abort_external_changes

void dbe::MainWindow::slot_abort_external_changes ( )
privateslot

Definition at line 539 of file MainWindow.cpp.

540{
541 try
542 {
544 {
546 }
547 }
548 catch ( dunedaq::conffwk::Exception const & e )
549 {
550 ERROR ( "External changes aborted", dbe::config::errors::parse ( e ).c_str() );
551 ers::error ( e );
552 }
553}

◆ slot_add_tab

void dbe::MainWindow::slot_add_tab ( )
privateslot

Definition at line 116 of file MainWindow.cpp.

117{
118 tableholder->addTab ( new TableTab ( tableholder ), "Table View" );
119 tableholder->setCurrentIndex ( tableholder->count()-1 );
120 tableholder->show();
121}

◆ slot_batch_change_start

void dbe::MainWindow::slot_batch_change_start ( )
slot

Definition at line 1768 of file MainWindow.cpp.

1769{
1771}

◆ slot_batch_change_stop

void dbe::MainWindow::slot_batch_change_stop ( const QList< QPair< QString, QString > > & objs)
slot

Definition at line 1773 of file MainWindow.cpp.

1774{
1775 std::vector<dbe::dref> objects;
1776 for(const auto& o : objs) {
1777 objects.push_back(inner::dbcontroller::get({o.second.toStdString(), o.first.toStdString()}));
1778 }
1779
1780 // This allows to not reset the main tree
1781 this_classes->objectsUpdated(objects);
1782
1783 // In this case the corresponding trees are reset
1784 // In order to apply the same policy as in the class tree
1785 // the subtree_proxy class needs to be completed with proper
1786 // implementation of slots when objects are modified
1787
1788 // Proper "refresh" of table tabs
1789 for ( int i = 0; i < tableholder->count(); i++ )
1790 {
1791 TableTab * CurrentTab = dynamic_cast<TableTab *> ( tableholder->widget ( i ) );
1792 if ( CurrentTab ) {
1793 dbe::models::table* m = CurrentTab->GetTableModel();
1794 if ( m ) {
1795 m->objectsUpdated(objects);
1796 }
1797 }
1798 }
1799
1800 emit signal_batch_change_stopped(objs);
1801
1803}
static configobject::tref get(dbe::cokey const &desc)

◆ slot_commit_database

bool dbe::MainWindow::slot_commit_database ( bool Exit = false)
privateslot

Definition at line 443 of file MainWindow.cpp.

444{
445 CommitDialog * SaveDialog = new CommitDialog();
446 int DialogResult = SaveDialog->exec();
447
448 if ( DialogResult )
449 {
451 for (auto file : dbe::confaccessor::uncommitted_files()) {
452 auto message = FileInfo::check_file_includes(QString::fromStdString(file));
453 if (!message.isEmpty()) {
454 QMessageBox::warning ( 0, "Save database", message );
455 FileInfo::show_file_info(QString::fromStdString(file));
456 return false;
457 }
458 }
459
460 QString CommitMessage = SaveDialog->GetCommitMessage();
461
462 try
463 {
464 std::list<std::string> const & modified = confaccessor::save ( CommitMessage );
466
468
469 if ( not modified.empty() )
470 {
471 std::string msg;
472
473 for ( std::string const & f : modified )
474 {
475 msg += "\n" + f;
476 }
477
478 INFO ( "List of modified files committed to the database ", "Program execution success",
479 msg );
480 }
481 else
482 {
483 WARN ( "Changes where committed successfully but list of modified files could not be retrieved",
484 "Unexpected program execution" );
485 }
486
487 }
488 catch ( dunedaq::conffwk::Exception const & e )
489 {
490 WARN ( "The changes could not be committed", dbe::config::errors::parse ( e ).c_str() )
491 ers::error ( e );
492 return false;
493 }
494 // Gaahhh confaccessor catches dunedaq::conffwk::Exception and
495 // rethrows it as daq::dbe::CouldNotCommitChanges!!
496 catch (daq::dbe::CouldNotCommitChanges const& exc)
497 {
498 std::string reason{exc.what()};
499 auto cause = exc.cause();
500 while (cause != nullptr) {
501 reason = cause->what();
502 cause = cause->cause();
503 }
504 WARN ("The changes could not be committed",
505 // dbe::config::errors::parse(exc).c_str(),
506 reason,
507 "\n\nTry fixing includes from File Info window")
508 ers::error (exc);
509 return false;
510 }
511 }
512 else
513 {
514 if ( Exit )
515 {
517 }
518 }
519 return true;
520}
static void parse_all_objects()
Definition FileInfo.cpp:116
static QString check_file_includes(const QString &file)
Definition FileInfo.cpp:133
static void show_file_info(const QString &filename)
Definition FileInfo.cpp:466
static std::list< std::string > uncommitted_files()
static std::list< std::string > save(QString const &)
#define WARN(...)
Definition messenger.hpp:85
#define INFO(...)
Only Configuration DB opened by rdbconfig or oksconflibs plug in can be message
std::string const reason(ers::Issue const &)
Factory couldn t std::string alg_name Invalid configuration error
Definition Issues.hpp:34

◆ slot_create_newdb

void dbe::MainWindow::slot_create_newdb ( )
privateslot

Definition at line 682 of file MainWindow.cpp.

683{
684
685 CreateDatabaseWidget * CreateDatabaseW = new CreateDatabaseWidget(nullptr, false, find_db_repository_dir());
686 CreateDatabaseW->show();
687 connect ( CreateDatabaseW, SIGNAL ( CanLoadDatabase ( const QString & ) ), this,
688 SLOT ( slot_load_db_from_create_widget ( const QString & ) ) );
689}
void slot_load_db_from_create_widget(const QString &)
QString find_db_repository_dir()

◆ slot_edit_object_from_class_view

void dbe::MainWindow::slot_edit_object_from_class_view ( QModelIndex const & ProxyIndex)
privateslot

Definition at line 1443 of file MainWindow.cpp.

1444{
1445 edit_object_at ( this_treefilter->mapToSource ( ProxyIndex ) );
1446}
void edit_object_at(const QModelIndex &Index)

◆ slot_error_message

void dbe::MainWindow::slot_error_message ( QString const title,
QString const msg )
slot

This method permits to propagate and display messages from the messaging subsytem.

It is important that the arguments are pass-by-copy because references will become invalid, even if they are bound to consted temporaries, once the deleter from the other thread is called.

Definition at line 1744 of file MainWindow.cpp.

1745{
1746 display_message_box(title, msg, QMessageBox::Icon::Critical);
1747}
void display_message_box(const QString &title, const QString &msg, const QMessageBox::Icon &icon)

◆ slot_fetch_data

void dbe::MainWindow::slot_fetch_data ( treenode const * ClassNode)
privateslot

Definition at line 434 of file MainWindow.cpp.

435{
436 if ( this_classes->canFetchMore ( this_classes->index ( ClassNode->GetRow(), 0,
437 QModelIndex() ) ) )
438 {
439 this_classes->fetchMore ( this_classes->index ( ClassNode->GetRow(), 0, QModelIndex() ) );
440 }
441}

◆ slot_filter_query

void dbe::MainWindow::slot_filter_query ( )
privateslot

Definition at line 1199 of file MainWindow.cpp.

1200{
1201 if ( this_treefilter == nullptr )
1202 {
1203 return;
1204 }
1205
1206 QString Tmp = SearchTreeLine->text();
1207 if ( SearchBox->currentIndex() == 1 )
1208 {
1210 std::vector<dbe::tref> Objects = ProcessQuery ( Tmp );
1211
1212 this_treefilter->SetQueryObjects ( Objects );
1213 this_treefilter->setFilterRegExp ( Tmp );
1215 }
1216 else {
1217 this_treefilter->ResetQueryObjects ( );
1219 }
1220}
std::vector< dbe::tref > ProcessQuery(QString const &)

◆ slot_filter_table_textchange

void dbe::MainWindow::slot_filter_table_textchange ( const QString & FilterText)
privateslot

Definition at line 1222 of file MainWindow.cpp.

1223{
1224 TableTab * CurrentTab = dynamic_cast<TableTab *> ( tableholder->currentWidget() );
1225
1226 if ( CurrentTab )
1227 {
1228 dbe::models::tableselection * TableFilter = CurrentTab->GetTableFilter();
1229
1230 if ( TableFilter == nullptr )
1231 {
1232 return;
1233 }
1234
1236
1237 if ( CaseSensitiveCheckBoxTable->isChecked() )
1238 TableFilter->setFilterCaseSensitivity (
1239 Qt::CaseSensitive );
1240 else
1241 {
1242 TableFilter->setFilterCaseSensitivity ( Qt::CaseInsensitive );
1243 }
1244
1245 TableFilter->setFilterRegExp ( FilterText );
1246 }
1247}
void SetFilterType(FilterType Filter)

◆ slot_filter_textchange

void dbe::MainWindow::slot_filter_textchange ( const QString & FilterText)
privateslot

Definition at line 1178 of file MainWindow.cpp.

1179{
1180 if ( this_treefilter != nullptr and SearchBox->currentIndex() != 1 )
1181 {
1183
1184 if ( SearchBox->currentIndex() == 2 )
1185 {
1186 this_treefilter->SetFilterRestrictionLevel ( 1000 );
1187 }
1188 else
1189 {
1190 this_treefilter->SetFilterRestrictionLevel ( 1 );
1191 }
1192
1193 this_treefilter->setFilterRegExp ( FilterText );
1194 }
1195
1197}

◆ slot_information_message

void dbe::MainWindow::slot_information_message ( QString const title,
QString const msg )
slot

This method permits to propagate and display messages from the messaging subsytem.

It is important that the arguments are pass-by-copy because references will become invalid, even if they are bound to consted temporaries, once the deleter from the other thread is called.

Definition at line 1732 of file MainWindow.cpp.

1733{
1734 display_message_box(title, msg, QMessageBox::Icon::Information);
1735}

◆ slot_launch_batchchange

void dbe::MainWindow::slot_launch_batchchange ( )
privateslot

Definition at line 582 of file MainWindow.cpp.

583{
585 {
586 BatchChangeWidget * Batch = new BatchChangeWidget ( nullptr );
587 Batch->setWindowModality ( Qt::WindowModal );
588 Batch->show();
589 }
590 else
591 {
592 ERROR ( "Database must have been loaded", "No database loaded" );
593 }
594}

◆ slot_launch_batchchange_on_table

void dbe::MainWindow::slot_launch_batchchange_on_table ( )
privateslot

Definition at line 596 of file MainWindow.cpp.

597{
599 {
600 ERROR ( "Database must have been loaded", "No database loaded" );
601 return;
602 }
603
604 dbe::models::table * CurrentTableModel = nullptr;
605 TableTab * CurrentTab = dynamic_cast<TableTab *> ( tableholder->currentWidget() );
606 if ( CurrentTab ) {
607 CurrentTableModel = CurrentTab->GetTableModel();
608 }
609
610 std::vector<dref> TableObject;
611
612 if ( !CurrentTab || !CurrentTableModel )
613 {
614 ERROR ( "Table cannot be processed", "Table is empty" );
615 return;
616 }
617
618 if ( ( *CurrentTableModel->GetTableObjects() ).isEmpty() )
619 {
620 ERROR ( "Table cannot be processed", "Table is empty" );
621 return;
622 }
623
624 QString Filter = SearchLineTable->text();
625
626 for ( dref Object : *CurrentTableModel->GetTableObjects() )
627 {
628 if ( Filter.isEmpty() )
629 {
630 TableObject.push_back ( Object );
631 }
632 else
633 {
634 QString ObjectString = QString::fromStdString ( Object.UID() );
635
636 if ( ObjectString.contains ( Filter, Qt::CaseInsensitive ) )
637 {
638 TableObject.push_back ( Object );
639 }
640 }
641 }
642
643 BatchChangeWidget * Batch = new BatchChangeWidget (
644 true,
645 CurrentTableModel->get_class_name(),
646 TableObject, nullptr );
647 Batch->setWindowModality ( Qt::WindowModal );
648 Batch->show();
649}
QList< dbe::dref > * GetTableObjects()
Definition table.cpp:490
QString get_class_name() const
Definition table.cpp:480

◆ slot_launch_object_editor

void dbe::MainWindow::slot_launch_object_editor ( tref Object)
privateslot

Definition at line 555 of file MainWindow.cpp.

556{
557 bool WidgetFound = false;
558 QString ObjectEditorName = QString ( "%1@%2" ).arg ( Object.UID().c_str() ).arg (
559 Object.class_name().c_str() );
560
561 for ( QWidget * Editor : QApplication::allWidgets() )
562 {
563 ObjectEditor * Widget = dynamic_cast<ObjectEditor *> ( Editor );
564
565 if ( Widget != nullptr )
566 {
567 if ( ( Widget->objectName() ).compare ( ObjectEditorName ) == 0 )
568 {
569 Widget->raise();
570 Widget->setVisible ( true );
571 WidgetFound = true;
572 }
573 }
574 }
575
576 if ( !WidgetFound )
577 {
578 ( new ObjectEditor ( Object ) )->show();
579 }
580}

◆ slot_launch_preferences

void dbe::MainWindow::slot_launch_preferences ( )
privateslot

Definition at line 1852 of file MainWindow.cpp.

1852 {
1853 auto prefs = new Preferences();
1854 prefs->show();
1855}

◆ slot_load_db_from_create_widget

void dbe::MainWindow::slot_load_db_from_create_widget ( const QString & DatabaseName)
privateslot

Definition at line 691 of file MainWindow.cpp.

692{
693 if ( !DatabaseName.isEmpty() )
694 {
695 QFileInfo DatabaseFile = QFileInfo ( DatabaseName );
696
697 if ( DatabaseFile.exists() )
698 {
699 QString Path = QString ( DatabaseFile.absoluteFilePath() );
700
701 if ( dbreload() )
702 {
704
705 if ( dbload() )
706 {
707 setinternals();
709 // // build_partition_tree_model();
710 // build_resource_tree_model();
712 }
713 }
714 }
715 else
716 {
717 WARN ( "File not found during database load", "File does not exist", "\n\n Filename:",
718 DatabaseFile.fileName().toStdString() );
719 }
720 }
721 else
722 {
723 ERROR ( "Database load error", "File was not selected" );
724 }
725}

◆ slot_loaded_db_file

void dbe::MainWindow::slot_loaded_db_file ( QString file)
privateslot

Definition at line 1847 of file MainWindow.cpp.

1848{
1849 allFiles.insert(file);
1850}

◆ slot_model_rebuild

void dbe::MainWindow::slot_model_rebuild ( )
privateslot

Preparing data

Disconnecting models from views

Definition at line 1157 of file MainWindow.cpp.

1158{
1160 confaccessor::gethandler()->ResetData();
1163
1164 for ( int i = 0; i < tableholder->count(); i++ )
1165 {
1166 TableTab * CurrentTab = dynamic_cast<TableTab *> ( tableholder->widget ( i ) );
1167 if( CurrentTab ) {
1168 CurrentTab->DisconnectView();
1169 }
1170 }
1171
1172 FileView->setModel ( NULL );
1173
1176}

◆ slot_open_database_from_file

void dbe::MainWindow::slot_open_database_from_file ( )
privateslot

Definition at line 1480 of file MainWindow.cpp.

1481{
1482 QFileDialog FileDialog ( this, tr ( "Open File" ), ".", tr ( "XML files (*.xml)" ) );
1483 FileDialog.setAcceptMode ( QFileDialog::AcceptOpen );
1484 FileDialog.setFileMode ( QFileDialog::ExistingFile );
1485 FileDialog.setViewMode ( QFileDialog::Detail );
1486
1487 if ( FileDialog.exec() )
1488 {
1489 QStringList FilesSelected = FileDialog.selectedFiles();
1490
1491 if ( FilesSelected.size() )
1492 {
1493 QString DatabasePath = FilesSelected.value ( 0 );
1494 dbopen ( DatabasePath, dbinfo::oks );
1495 }
1496 }
1497}

◆ slot_process_externalchanges

void dbe::MainWindow::slot_process_externalchanges ( )
privateslot

The purpose of this method is to replay local changes after the database has been externally modified.

It is called when there is a callback from config layer.

The user is being given the option to ignore the external change and proceed without bringing his current database to a consistent state. This will cause the database to be overwritten when local changes are going to be applied.

"Emptying" the command so it does nothing at all

Definition at line 1510 of file MainWindow.cpp.

1511{
1512 auto user_confirmation = [] ( QString const & msg )
1513 {
1514 QMessageBox ExternalMessageBox;
1515 ExternalMessageBox.setText ( msg );
1516 ExternalMessageBox.setStandardButtons ( QMessageBox::Yes | QMessageBox::No );
1517 ExternalMessageBox.setDefaultButton ( QMessageBox::Yes );
1518 return ExternalMessageBox.exec() == QMessageBox::Yes;
1519 };
1520
1522
1523 auto rewind_stack = [&undo_stack] ()
1524 {
1525 std::vector<bool > commands_original_undo_state;
1526
1527 // Loop over the commands and set their undo-state to false such that when the undostack
1528 // index is rewind to zero they will not be undone. The purpose is to replay them on top of
1529 // current changes.
1530
1531 for ( int i = 0; i < undo_stack->count(); ++i )
1532 {
1533 if ( dbe::actions::onobject const * Command =
1534 dynamic_cast<dbe::actions::onobject const *> ( undo_stack->command ( i ) )
1535 )
1536 {
1537 commands_original_undo_state.push_back ( Command->undoable() );
1538 Command->setundoable ( false );
1539 }
1540 }
1541
1542 // Rewind the command stack by setting the index to zero
1543 // Commands will not be replayed since we have set their state to false
1544 undo_stack->setIndex ( 0 );
1545
1546 // Reset the state of all commands one by one
1547 {
1548 auto cmdstate = commands_original_undo_state.begin();
1549
1550 for ( int i = 0; i != undo_stack->count(); ++i )
1551 {
1552 if ( dbe::actions::onobject const * Command =
1553 dynamic_cast<dbe::actions::onobject const *> ( undo_stack->command ( i ) )
1554 )
1555 {
1556 Command->setundoable ( *cmdstate++ );
1557 }
1558 }
1559 }
1560 };
1561
1562 // Close active editor widgets before replaying changes
1563 for ( QWidget * widget : QApplication::allWidgets() )
1564 {
1565 if ( dynamic_cast<widgets::editors::relation *> ( widget ) )
1566 {
1567 widget->close();
1568 }
1569 }
1570
1571
1572 if ( undo_stack->count() != 0 )
1573 {
1574 const QString msg = QString("External changes to the database have been applied. Do you want to replay your changes on top? ")
1575 + QString(" Otherwise any local change will be lost.\n");
1576 if ( user_confirmation ( msg ) )
1577 {
1578 rewind_stack();
1579
1580 // Empty the internal stack and place the changes in a reverse order in a local stack
1581 confaccessor::t_internal_changes_stack internal_changes_reverse_copy;
1582 auto internal_changes = confaccessor::get_internal_change_stack();
1583
1584 while ( not internal_changes->empty() )
1585 {
1586 internal_changes_reverse_copy.push ( internal_changes->top() );
1587 internal_changes->pop();
1588 }
1589
1590 // Replay the commands one by one
1591 for ( int i = 0; i < undo_stack->count(); ++i )
1592 {
1593 config_internal_change Change = internal_changes_reverse_copy.top();
1594 internal_changes_reverse_copy.pop();
1595 internal_changes->push ( Change );
1596
1597 try
1598 {
1599
1600 dbe::actions::onobject const * Command =
1601 dynamic_cast<dbe::actions::onobject const *> ( undo_stack->command ( i ) );
1602
1603 if ( not Command->redoable() )
1604 {
1605 undo_stack->redo();
1606 }
1607 else
1608 {
1609 // If the object we are trying to make the changes to does not exist it means it was deleted
1610
1611 if ( ( dbe::config::api::info::has_obj ( Change.classname, Change.uid ) and Change
1612 .request
1614 or Change.request == config_internal_change::FILE_INCLUDED
1615 or Change.request == config_internal_change::FILE_DELETED )
1616 {
1617 // If in virtue of external modification the object still exists and our action was not a creation
1618 Command->reload();
1619 undo_stack->redo();
1620 }
1621 else if ( not dbe::config::api::info::has_obj ( Change.classname, Change.uid ) and Change
1622 .request
1624 {
1625 // If the external changes have removed the object and we have created it
1626 undo_stack->redo();
1627 Command->reload();
1628 }
1629 else
1630 {
1632 Command->setredoable ( false );
1633 Command->setundoable ( false );
1634
1635 // Advance the stack by redoing an non-redoable (i.e. the redo action has no effect) command
1636 undo_stack->redo();
1637 }
1638 }
1639
1640 }
1641 catch ( dunedaq::conffwk::Exception const & e )
1642 {
1643 WARN ( "Object reference could not be changed",
1644 dbe::config::errors::parse ( e ).c_str(), "for object with UID:", Change.uid,
1645 "of class", Change.classname );
1646 }
1647 catch ( ... )
1648 {
1649 WARN ( "Unknown exception during object modification", "s",
1650 "\n\nFor object with UID:", Change.uid.c_str(), "of class:",
1651 Change.classname.c_str() );
1652 }
1653 }
1654 } else {
1656 }
1657 }
1658 else
1659 {
1660 INFO ( "Database reloaded due external changes", "Database consistency enforcement" );
1662 }
1663
1666
1667 // Emit the signal for connected listeners (e.g., the object editors)
1669}
void signal_externalchanges_processed()
void setundoable(bool s=true) const
Definition Command.cpp:553
void reload() const
Definition Command.cpp:588
void setredoable(bool s=true) const
Definition Command.cpp:558
bool redoable() const
Definition Command.cpp:568
cptr< t_undo_stack > t_undo_stack_cptr
std::stack< t_internal_change, std::vector< t_internal_change > > t_internal_changes_stack
static t_internal_changes_stack_cptr get_internal_change_stack()
bool has_obj(std::string const &classname, std::string const &object_uid)

◆ slot_remove_tab

void dbe::MainWindow::slot_remove_tab ( int i)
privateslot

Definition at line 123 of file MainWindow.cpp.

124{
125 if ( i == -1 || ( ( tableholder->count() == 1 ) && i == 0 ) )
126 {
127 return;
128 }
129
130 QWidget * Widget = tableholder->widget ( i );
131
132 tableholder->removeTab ( i );
133
134 delete Widget;
135
136 Widget = nullptr;
137}

◆ slot_show_information_about_dbe

void dbe::MainWindow::slot_show_information_about_dbe ( )
privateslot

Definition at line 1113 of file MainWindow.cpp.

1114{
1115 static QString const title ( "About DBE" );
1116 static QString const msg = QString().
1117 append ( "DBE is an editor to work with OKS and RDB backends that manages most of the hard work for you in editing the configuration database\n" ).
1118 append ( "\n\nMaintained :\t\tC&C Working group \n\t\t\t(atlas-tdaq-cc-wg@cern.ch)" ).
1119 append ( "\nProgram version:\t\t" ).append ( dbe_compiled_version ).
1120 append ( "\nLibraries version:\t" ).
1121 append ( "\n\t\t\tdbecore(" ).append ( dbe_lib_core_version ).
1122 append ( "),\n\t\t\tdbe_config_api(" ).append ( dbe_lib_config_api_version ).
1123 append ( "),\n\t\t\tdbe_structure(" ).append ( dbe_lib_structure_version ).
1124 append ( "),\n\t\t\tdbe_internal(" ).append ( dbe_lib_internal_version ).append ( ')' ).
1125 append ( "\nRepo commit hash:\t" ).append ( dbe_compiled_commit );
1126
1127 QMessageBox::about ( this, title, msg );
1128}
char const *const dbe_lib_core_version
Including DBE.
char const *const dbe_lib_internal_version
char const *const dbe_lib_config_api_version
char const *const dbe_lib_structure_version
Including QT Headers.
Definition tree.cpp:17
#define dbe_compiled_version
Definition version.hpp:22
#define dbe_compiled_commit
Definition version.hpp:28

◆ slot_show_userchanges

void dbe::MainWindow::slot_show_userchanges ( )
privateslot

Definition at line 1135 of file MainWindow.cpp.

1136{
1137 InfoWidget->setCurrentIndex ( InfoWidget->indexOf ( CommitedTab ) );
1138}

◆ slot_show_userguide

void dbe::MainWindow::slot_show_userguide ( )
privateslot

Definition at line 1130 of file MainWindow.cpp.

1131{
1132 QDesktopServices::openUrl ( QUrl ( "https://atlasdaq.cern.ch/dbe/" ) );
1133}

◆ slot_toggle_casesensitive_for_treeview

void dbe::MainWindow::slot_toggle_casesensitive_for_treeview ( bool )
privateslot

Definition at line 1145 of file MainWindow.cpp.

1146{
1147 if ( CaseSensitiveCheckBoxTree->isChecked() )
1148 this_treefilter->setFilterCaseSensitivity (
1149 Qt::CaseSensitive );
1150 else
1151 {
1152 this_treefilter->setFilterCaseSensitivity ( Qt::CaseInsensitive );
1153 }
1155}

◆ slot_toggle_commit_button

void dbe::MainWindow::slot_toggle_commit_button ( )
privateslot

Definition at line 1805 of file MainWindow.cpp.

1806{
1807 if(isArchivedConf == false) {
1808 const auto& uncommittedFiles = confaccessor::uncommitted_files();
1809
1810 if(uncommittedFiles.empty() == true) {
1811 Commit->setEnabled(false);
1812 Commit->setToolTip("There is nothing to commit");
1813 } else {
1814 Commit->setEnabled(true);
1815
1816 std::string l;
1817 for(const std::string& f : uncommittedFiles) {
1818 l += " " + f + "\n";
1819 }
1820
1821 Commit->setToolTip(QString::fromStdString("Commit changes.\nHere are the uncommitted files:\n" + l));
1822 }
1823
1825
1826 } else {
1827 Commit->setEnabled(false);
1828 }
1829}

◆ slot_tree_reset

void dbe::MainWindow::slot_tree_reset ( )
privateslot

Definition at line 1249 of file MainWindow.cpp.

1250{
1251 // Keep track of the selected tab
1252 int IndexOfCurrentTab = tableholder->currentIndex();
1253
1254 // Here are the all the open tabs
1255 std::vector<QModelIndex> idxs;
1256
1257 for(int i = 0; i < tableholder->count(); ++i) {
1258 TableTab * CurrentTab = dynamic_cast<TableTab *>(tableholder->widget(i));
1259 if(CurrentTab) {
1260 if(CurrentTab->GetTableModel()) {
1261 const QString& TableClassName = CurrentTab->GetTableModel()->get_class_name();
1262 if(!TableClassName.isEmpty()) {
1263 treenode * NodeClass = confaccessor::gethandler()->getnode(TableClassName);
1264 if(NodeClass != nullptr) {
1265 idxs.push_back(this_classes->getindex(NodeClass));
1266 }
1267 }
1268 }
1269 }
1270 }
1271
1272 // Remove all the tabs
1273 while(tableholder->count() != 0) {
1274 tableholder->widget(0)->deleteLater();
1275 tableholder->removeTab(0);
1276 }
1277
1278 // Disconnecting models from views
1280
1281 // Re-create all the tabs
1282 for(const auto& idx : idxs) {
1283 slot_add_tab();
1284 edit_object_at(idx);
1285 }
1286
1287 // Set the current tab
1288 tableholder->setCurrentIndex ( IndexOfCurrentTab );
1289}

◆ slot_undo_allchanges

void dbe::MainWindow::slot_undo_allchanges ( )
privateslot

Definition at line 1140 of file MainWindow.cpp.

1141{
1142 UndoView->stack()->setIndex ( 0 );
1143}

◆ slot_update_committed_files

void dbe::MainWindow::slot_update_committed_files ( const std::list< std::string > & files,
const std::string & msg )
privateslot

Definition at line 1831 of file MainWindow.cpp.

1831 {
1832 for(const std::string& f : files) {
1833 CommittedTable->insertRow(0);
1834 CommittedTable->setItem(0, 0, new QTableWidgetItem(QString::fromStdString(f)));
1835 CommittedTable->setItem(0, 1, new QTableWidgetItem(QString::fromStdString(msg)));
1836 CommittedTable->setItem(0, 2, new QTableWidgetItem(QDate::currentDate().toString() + " " + QTime::currentTime().toString()));
1837 }
1838
1839 CommittedTable->resizeColumnsToContents();
1840}

◆ slot_warning_message

void dbe::MainWindow::slot_warning_message ( QString const title,
QString const msg )
slot

This method permits to propagate and display messages from the messaging subsytem.

It is important that the arguments are pass-by-copy because references will become invalid, even if they are bound to consted temporaries, once the deleter from the other thread is called.

Definition at line 1756 of file MainWindow.cpp.

1757{
1758 display_message_box(title, msg, QMessageBox::Icon::Warning);
1759}

◆ slot_whatisthis

void dbe::MainWindow::slot_whatisthis ( )
privateslot

Definition at line 1108 of file MainWindow.cpp.

1109{
1110 QWhatsThis::enterWhatsThisMode();
1111}

◆ update_total_objects()

void dbe::MainWindow::update_total_objects ( )
private

Definition at line 1291 of file MainWindow.cpp.

1292{
1293 int total=0;
1294 for (int item=0; item<this_treefilter->rowCount(); item++) {
1295 auto index = this_treefilter->index(item, 1);
1296 auto data = this_treefilter->data(index);
1297 total += data.toInt();
1298 }
1299 TotalObjectsLabel->setText (
1300 QString ( "Total Objects: %1" ).arg ( total ) );
1301}

◆ WriteSettings()

void dbe::MainWindow::WriteSettings ( )
private

Definition at line 876 of file MainWindow.cpp.

877{
878 QSettings Settings("dunedaq", "dbe_main");
879 Settings.beginGroup ( "MainWindow-layout" );
880 Settings.setValue ( "size", size() );
881 Settings.setValue ( "pos", pos() );
882 Settings.setValue ( "TableView", DisplayTableView->isChecked() );
883 Settings.setValue ( "ClassView", DisplayClassView->isChecked() );
884
885 Settings.setValue ( "Messages", DisplayMessages->isChecked() );
886 Settings.setValue ( "geometry", saveGeometry() );
887 Settings.setValue ( "state", saveState() );
888 Settings.endGroup();
889
890 Settings.beginGroup ( "MainWindow-checkboxes" );
891 Settings.setValue ( "tree-case-sensitive", CaseSensitiveCheckBoxTree->isChecked() );
892 Settings.setValue ( "table-case-sensitive", CaseSensitiveCheckBoxTable->isChecked() );
893 Settings.endGroup();
894}
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size

Member Data Documentation

◆ allFiles

QSet<QString> dbe::MainWindow::allFiles
private

Definition at line 68 of file MainWindow.hpp.

◆ isArchivedConf

std::atomic<bool> dbe::MainWindow::isArchivedConf
private

Definition at line 79 of file MainWindow.hpp.

◆ m_batch_change_in_progress

bool dbe::MainWindow::m_batch_change_in_progress
private

Definition at line 70 of file MainWindow.hpp.

◆ this_classes

dbe::models::tree* dbe::MainWindow::this_classes
private

Definition at line 74 of file MainWindow.hpp.

◆ this_files

FileModel* dbe::MainWindow::this_files
private

Definition at line 71 of file MainWindow.hpp.

◆ this_filesort

QSortFilterProxyModel dbe::MainWindow::this_filesort
private

Definition at line 72 of file MainWindow.hpp.

◆ this_treefilter

models::treeselection* dbe::MainWindow::this_treefilter
private

Definition at line 75 of file MainWindow.hpp.


The documentation for this class was generated from the following files: