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)) );
745 QString ViewPath = QFileDialog::getOpenFileName (
747 tr (
"Open view file"),
749 tr(
"View files (*.view);;All files (*)"));
751 if ( !ViewPath.isEmpty() )
753 auto spos = ViewPath.lastIndexOf(
'/');
755 m_view_dir = ViewPath;
756 m_view_dir.truncate(spos);
758 QFile ViewFile ( ViewPath );
759 ViewFile.open ( QIODevice::ReadOnly );
761 auto text = QFileInfo(ViewPath).baseName();
762 auto tab =
dynamic_cast<SchemaTab *
> ( ui->TabWidget->currentWidget() );
763 if (!tab->getName().isEmpty() || tab->GetScene()->IsModified()) {
765 tab =
dynamic_cast<SchemaTab *
> ( ui->TabWidget->currentWidget() );
767 auto index = ui->TabWidget->currentIndex();
768 ui->TabWidget->setTabText(index, text);
770 tab->setFileName(ViewPath);
772 QStringList ClassesNames;
773 QList<QPointF> Positions;
774 QList<QPointF> note_positions;
776 while ( !ViewFile.atEnd() )
778 QString Line ( ViewFile.readLine() );
779 if (!Line.isEmpty()) {
780 QStringList ObjectDescription = Line.split (
"," );
782 Position.setX ( ObjectDescription.at ( 1 ).toInt() );
783 Position.setY ( ObjectDescription.at ( 2 ).toInt() );
784 if (ObjectDescription.at ( 0 ) ==
"#") {
785 note_positions.append (Position);
786 auto note_text = ObjectDescription.at(3);
787 if (note_text.back() ==
'\n') {
790 note_text = note_text.replace(
"<br>",
"\n");
791 note_text = note_text.replace(
"<comma>",
",");
792 notes.append ( note_text );
795 ClassesNames.append ( ObjectDescription.at ( 0 ) );
796 Positions.append ( Position );
802 auto message = QString(
"Loaded view from %1").arg(ViewPath);
803 ui->StatusBar->showMessage( message );
805 auto scene = tab->GetScene();
806 scene->CleanItemMap();
807 auto missing = scene->AddItemsToScene ( ClassesNames, Positions );
808 if (!missing.empty()) {
809 QString warning_text{
"The following classes in "};
810 warning_text.append(QFileInfo(ViewPath).fileName());
811 warning_text.append(
" are not present in the loaded schema:\n ");
812 warning_text.append(missing.join(
",\n "));
813 QMessageBox::warning(
this, tr(
"Load View"), warning_text);
815 scene->ClearModified();
817 scene->add_notes(notes, note_positions);
858 if ( ContextMenuFileView ==
nullptr )
860 ContextMenuFileView =
new QMenu (
this );
862 QAction * Act =
new QAction ( tr (
"Set as Active Schema" ),
this );
863 connect ( Act, SIGNAL ( triggered() ),
this, SLOT ( SetSchemaFileActive() ) );
864 QAction * Sav =
new QAction ( tr (
"Save Schema File" ),
this );
865 connect ( Sav, SIGNAL ( triggered() ),
this, SLOT ( SaveSchemaFile() ) );
866 QAction * info =
new QAction ( tr (
"Show file info" ),
this );
867 connect ( info, SIGNAL ( triggered() ),
this, SLOT ( show_file_info() ) );
869 ContextMenuFileView->addAction ( info );
870 ContextMenuFileView->addAction ( Act );
871 ContextMenuFileView->addAction ( Sav );
874 QModelIndex index = ui->FileView->currentIndex();
876 if ( index.isValid() )
878 QStringList row = FileModel->getRowFromIndex ( index );
879 if (row.at(1) ==
"RW") {
880 ContextMenuFileView->actions().at(2)->setVisible(
true);
881 if (!row.at(2).contains(
"Active")) {
882 ContextMenuFileView->actions().at(1)->setVisible(
true);
885 ContextMenuFileView->actions().at(1)->setVisible(
false);
889 ContextMenuFileView->actions().at(2)->setVisible(
false);
890 ContextMenuFileView->actions().at(1)->setVisible(
false);
892 ContextMenuFileView->exec ( ui->FileView->mapToGlobal ( Pos ) );
898 if ( ContextMenuTableView ==
nullptr )
900 ContextMenuTableView =
new QMenu (
this );
902 QAction * add =
new QAction ( tr (
"&Add New Class" ),
this );
903 connect ( add, SIGNAL ( triggered() ),
this, SLOT ( AddNewClass() ) );
905 QAction * remove =
new QAction ( tr (
"&Remove Selected Class" ),
this );
906 connect ( remove, SIGNAL ( triggered() ),
this, SLOT ( RemoveClass() ) );
908 QAction * edit =
new QAction ( tr (
"&Edit Selected Class" ),
this );
909 connect ( edit, SIGNAL ( triggered() ),
this, SLOT ( editClass() ) );
911 ContextMenuTableView->addAction ( add );
912 ContextMenuTableView->addAction ( edit );
913 ContextMenuTableView->addAction ( remove );
916 QModelIndex Index = ui->ClassTableView->currentIndex();
918 if ( Index.isValid() )
920 ContextMenuTableView->exec ( ui->ClassTableView->mapToGlobal ( Pos ) );