90 connect ( ui->OpenFileSchema, SIGNAL ( triggered() ),
this, SLOT ( OpenSchemaFile() ) );
91 connect ( ui->CreateNewSchema, SIGNAL ( triggered() ),
this, SLOT ( CreateNewSchema() ) );
92 connect ( ui->ShowSchema, SIGNAL ( triggered() ),
this, SLOT ( show_file_info_active_schema() ) );
93 connect ( ui->SaveSchema, SIGNAL ( triggered() ),
this, SLOT ( SaveSchema() ) );
94 connect ( ui->SetRelationship, SIGNAL ( triggered (
bool ) ),
this,
95 SLOT ( ChangeCursorRelationship (
bool ) ) );
96 connect ( ui->SetInheritance, SIGNAL ( triggered (
bool ) ),
this,
97 SLOT ( ChangeCursorInheritance (
bool ) ) );
98 connect ( ui->AddClass, SIGNAL ( triggered() ),
this, SLOT ( AddNewClass() ) );
99 connect ( ui->SaveView, SIGNAL ( triggered() ),
this, SLOT ( SaveView() ) );
100 connect ( ui->SaveViewAs, SIGNAL ( triggered() ),
this, SLOT ( SaveViewAs() ) );
101 connect ( ui->LoadView, SIGNAL ( triggered() ),
this, SLOT ( LoadView() ) );
102 connect ( ui->NameView, SIGNAL ( triggered() ),
this, SLOT ( NameView() ) );
103 connect ( ui->Exit, SIGNAL ( triggered() ),
this, SLOT ( close() ) );
105 connect ( ui->actionSettings, SIGNAL (triggered() ),
this, SLOT ( edit_settings() ));
107 connect ( ui->ClassTableView, SIGNAL ( activated ( QModelIndex ) ),
this,
108 SLOT ( LaunchClassEditor ( QModelIndex ) ) );
109 connect ( ui->close_tab, SIGNAL ( triggered() ),
this, SLOT ( close_tab() ) );
112 SLOT ( update_models() ) );
114 SLOT ( update_models() ) );
116 SLOT ( update_models() ) );
118 SLOT ( update_models() ) );
119 connect ( ui->TabWidget, SIGNAL ( tabCloseRequested (
int ) ),
this,
120 SLOT ( RemoveTab (
int ) ) );
122 connect ( ui->FileView, SIGNAL ( customContextMenuRequested ( QPoint ) ),
this,
123 SLOT ( CustomContextMenuFileView ( QPoint ) ) );
124 connect ( ui->FileView, SIGNAL ( activated(QModelIndex) ),
this, SLOT ( show_file_info(QModelIndex) ) );
127 connect ( ui->ClassTableView, SIGNAL ( customContextMenuRequested ( QPoint ) ),
this,
128 SLOT ( CustomContextMenuTableView ( QPoint ) ) );
129 connect ( ui->PrintView, SIGNAL ( triggered() ),
this, SLOT ( PrintCurrentView() ) );
130 connect ( ui->exportView, SIGNAL ( triggered() ),
this, SLOT ( export_current_view() ) );
131 connect ( ui->ClassTableSearchLine, SIGNAL( textChanged ( QString ) ), m_proxyModel, SLOT( setFilterRegExp( QString ) ) );
132 connect ( ui->case_sensitive, SIGNAL ( stateChanged(
int) ),
this,
133 SLOT (toggle_case_sensitive(
int)) );
343 std::string
filename = qfilename.toStdString();
344 std::set<std::string> includes;
347 QString advice{
"<br><br>Use the File info window to fix the problem."};
349 auto relationships = cls->direct_relationships();
350 if (relationships !=
nullptr) {
351 for (
auto rel: *relationships) {
352 auto rel_class = rel->get_class_type();
353 if (rel_class ==
nullptr) {
354 QString warning =
"<b>Warning</b> class <i>"
355 + QString::fromStdString(cls->get_name())
356 +
"</i> has relationship "
357 + QString::fromStdString(rel->get_name())
358 +
" referring to class <i>"
359 + QString::fromStdString(rel->get_type())
360 +
"</i> which is not loaded<br>";
361 QMessageBox::warning(0,
365 show_file_info(qfilename);
368 auto file = rel_class->get_file()->get_full_file_name();
369 if (file !=
filename && !includes.contains(file)) {
370 QString warning =
"<b>Warning</b> class <i>"
371 + QString::fromStdString(cls->get_name())
372 +
"</i> has relationship "
373 + QString::fromStdString(rel->get_name())
374 +
" referring to class <i>"
375 + QString::fromStdString(rel->get_class_type()->get_name())
376 +
"</i> from " + QString::fromStdString(file)
377 +
" which is not included by " + qfilename;
378 QMessageBox::warning(0,
382 show_file_info(qfilename);
388 auto super_classes = cls->direct_super_classes();
389 if (super_classes !=
nullptr) {
390 for (
auto sc: *super_classes) {
392 if (sclass ==
nullptr) {
393 QString warning =
"<b>Warning</b> class <i>"
394 + QString::fromStdString(cls->get_name())
395 +
"</i> refers to super class <i>" + QString::fromStdString(*sc)
396 +
"</i> which is not known<br>";
397 QMessageBox::warning(0,
401 show_file_info(qfilename);
404 auto file = sclass->get_file()->get_full_file_name();
405 if (file !=
filename && !includes.contains(file)) {
406 QString warning =
"<b>Warning</b> class <i>"
407 + QString::fromStdString(cls->get_name())
408 +
"</i> refers to super class <i>" + QString::fromStdString(*sc)
409 +
"</i> from " + QString::fromStdString(file)
410 +
" which is not included by" + qfilename;
411 QMessageBox::warning(0,
415 show_file_info(qfilename);
842 QString ViewPath = QFileDialog::getOpenFileName (
844 tr (
"Open view file"),
846 tr(
"View files (*.view);;All files (*)"));
848 if ( !ViewPath.isEmpty() )
850 auto spos = ViewPath.lastIndexOf(
'/');
852 m_view_dir = ViewPath;
853 m_view_dir.truncate(spos);
855 QFile ViewFile ( ViewPath );
856 ViewFile.open ( QIODevice::ReadOnly );
858 auto text = QFileInfo(ViewPath).baseName();
859 auto tab =
dynamic_cast<SchemaTab *
> ( ui->TabWidget->currentWidget() );
860 if (!tab->getName().isEmpty() || tab->GetScene()->IsModified()) {
862 tab =
dynamic_cast<SchemaTab *
> ( ui->TabWidget->currentWidget() );
864 auto index = ui->TabWidget->currentIndex();
865 ui->TabWidget->setTabText(index, text);
867 tab->setFileName(ViewPath);
869 QStringList ClassesNames;
870 QList<QPointF> Positions;
871 QList<QPointF> note_positions;
873 while ( !ViewFile.atEnd() )
875 QString Line ( ViewFile.readLine() );
876 if (!Line.isEmpty()) {
877 QStringList ObjectDescription = Line.split (
"," );
879 Position.setX ( ObjectDescription.at ( 1 ).toInt() );
880 Position.setY ( ObjectDescription.at ( 2 ).toInt() );
881 if (ObjectDescription.at ( 0 ) ==
"#") {
882 note_positions.append (Position);
883 auto note_text = ObjectDescription.at(3);
884 if (note_text.back() ==
'\n') {
887 note_text = note_text.replace(
"<br>",
"\n");
888 note_text = note_text.replace(
"<comma>",
",");
889 notes.append ( note_text );
892 ClassesNames.append ( ObjectDescription.at ( 0 ) );
893 Positions.append ( Position );
899 auto message = QString(
"Loaded view from %1").arg(ViewPath);
900 ui->StatusBar->showMessage( message );
902 auto scene = tab->GetScene();
903 scene->CleanItemMap();
904 auto missing = scene->AddItemsToScene ( ClassesNames, Positions );
905 if (!missing.empty()) {
906 QString warning_text{
"The following classes in "};
907 warning_text.append(QFileInfo(ViewPath).fileName());
908 warning_text.append(
" are not present in the loaded schema:\n ");
909 warning_text.append(missing.join(
",\n "));
910 QMessageBox::warning(
this, tr(
"Load View"), warning_text);
912 scene->ClearModified();
914 scene->add_notes(notes, note_positions);
955 if ( ContextMenuFileView ==
nullptr )
957 ContextMenuFileView =
new QMenu (
this );
959 QAction * Act =
new QAction ( tr (
"Set as Active Schema" ),
this );
960 connect ( Act, SIGNAL ( triggered() ),
this, SLOT ( SetSchemaFileActive() ) );
961 QAction * Sav =
new QAction ( tr (
"Save Schema File" ),
this );
962 connect ( Sav, SIGNAL ( triggered() ),
this, SLOT ( SaveSchemaFile() ) );
963 QAction * info =
new QAction ( tr (
"Show file info" ),
this );
964 connect ( info, SIGNAL ( triggered() ),
this, SLOT ( show_file_info() ) );
966 ContextMenuFileView->addAction ( info );
967 ContextMenuFileView->addAction ( Act );
968 ContextMenuFileView->addAction ( Sav );
971 QModelIndex index = ui->FileView->currentIndex();
973 if ( index.isValid() )
975 QStringList row = FileModel->getRowFromIndex ( index );
976 if (row.at(1) ==
"RW") {
977 ContextMenuFileView->actions().at(2)->setVisible(
true);
978 if (!row.at(2).contains(
"Active")) {
979 ContextMenuFileView->actions().at(1)->setVisible(
true);
982 ContextMenuFileView->actions().at(1)->setVisible(
false);
986 ContextMenuFileView->actions().at(2)->setVisible(
false);
987 ContextMenuFileView->actions().at(1)->setVisible(
false);
989 ContextMenuFileView->exec ( ui->FileView->mapToGlobal ( Pos ) );
995 if ( ContextMenuTableView ==
nullptr )
997 ContextMenuTableView =
new QMenu (
this );
999 QAction * add =
new QAction ( tr (
"&Add New Class" ),
this );
1000 connect ( add, SIGNAL ( triggered() ),
this, SLOT ( AddNewClass() ) );
1002 QAction * remove =
new QAction ( tr (
"&Remove Selected Class" ),
this );
1003 connect ( remove, SIGNAL ( triggered() ),
this, SLOT ( RemoveClass() ) );
1005 QAction * edit =
new QAction ( tr (
"&Edit Selected Class" ),
this );
1006 connect ( edit, SIGNAL ( triggered() ),
this, SLOT ( editClass() ) );
1008 ContextMenuTableView->addAction ( add );
1009 ContextMenuTableView->addAction ( edit );
1010 ContextMenuTableView->addAction ( remove );
1013 QModelIndex Index = ui->ClassTableView->currentIndex();
1015 if ( Index.isValid() )
1017 ContextMenuTableView->exec ( ui->ClassTableView->mapToGlobal ( Pos ) );