25 : QTableView ( parent ),
26 ContextMenu ( nullptr ),
27 FindObject ( nullptr ),
28 editObject ( nullptr ),
29 deleteObjectAc ( nullptr ),
31 refByAcOnlyComp ( nullptr ),
32 copyObjectAc ( nullptr ),
33 FindFileDialog ( nullptr ),
35 NextButton ( nullptr ),
39 verticalHeader()->setVisible(
true);
40 verticalHeader()->setSectionResizeMode ( QHeaderView::Interactive );
41 verticalHeader()->setMinimumSectionSize(40);
42 horizontalHeader()->setSectionResizeMode( QHeaderView::Interactive );
43 horizontalHeader()->setDefaultSectionSize(250);
44 setSortingEnabled (
true );
45 setAlternatingRowColors (
true );
46 setSelectionMode ( SelectionMode::SingleSelection );
47 setHorizontalScrollMode(ScrollMode::ScrollPerPixel);
48 setVerticalScrollMode(ScrollMode::ScrollPerPixel);
50 setTextElideMode(Qt::ElideRight);
75 if ( FindFileDialog !=
nullptr )
77 delete FindFileDialog;
78 FindFileDialog =
nullptr;
81 FindFileDialog =
new QDialog (
this );
82 FindFileDialog->setSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Preferred );
83 FindFileDialog->setToolTip (
"Type string to edit line and press Enter." );
84 FindFileDialog->setWindowTitle (
"Search for an object in the table" );
86 QHBoxLayout * Layout =
new QHBoxLayout ( FindFileDialog );
87 QLabel * Label =
new QLabel ( QString (
"Find Object:" ), FindFileDialog );
89 NextButton =
new QPushButton (
"Next" );
90 GoButton =
new QPushButton (
"Go !" );
92 LineEdit =
new QLineEdit ( FindFileDialog );
93 LineEdit->setToolTip (
"Type string and press Enter" );
95 Layout->addWidget ( Label );
96 Layout->addWidget ( LineEdit );
97 Layout->addWidget ( GoButton );
98 Layout->addWidget ( NextButton );
100 FindFileDialog->setLayout ( Layout );
101 FindFileDialog->show();
102 NextButton->setDisabled (
true );
104 connect ( LineEdit, SIGNAL ( textEdited ( QString ) ),
this,
105 SLOT ( EditedSearchString ( QString ) ) );
106 connect ( LineEdit, SIGNAL ( returnPressed() ),
this, SLOT ( GoToFile() ) );
107 connect ( GoButton, SIGNAL ( clicked() ),
this, SLOT ( GoToFile() ) );
108 connect ( NextButton, SIGNAL ( clicked() ),
this, SLOT ( GoToNext() ) );
118 QString UserType = LineEdit->text();
120 if ( UserType.isEmpty() )
125 QAbstractItemModel * Model = model();
127 if ( Model !=
nullptr )
129 QVariant StringCriterium = QVariant ( UserType );
130 QModelIndex WhereToStartSearch = Model->index ( 0, 0 );
131 ListOfMatch = Model->match ( WhereToStartSearch, Qt::DisplayRole, StringCriterium, 1000,
132 Qt::MatchContains | Qt::MatchWrap );
134 if ( ListOfMatch.size() > 0 )
137 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
138 selectRow ( ListOfMatch.value ( ListIndex ).row() );
139 resizeColumnToContents ( ListIndex );
141 GoButton->setDisabled (
true );
142 NextButton->setEnabled (
true );
144 disconnect ( LineEdit, SIGNAL ( returnPressed() ),
this, SLOT ( GoToFile() ) );
145 connect ( LineEdit, SIGNAL ( returnPressed() ),
this, SLOT ( GoToNext() ) );
154 if ( ( LineEdit->text() ).isEmpty() )
161 if ( ListOfMatch.size() > 0 )
163 if ( ( ++ListIndex ) < ListOfMatch.size() )
165 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
166 selectRow ( ListOfMatch.value ( ListIndex ).row() );
167 resizeColumnToContents ( ListIndex );
172 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
173 selectRow ( ListOfMatch.value ( ListIndex ).row() );
174 resizeColumnToContents ( ListIndex );
293 if ( this->model() !=
nullptr )
295 QModelIndexList qindices = this->selectedIndexes();
296 std::vector<QModelIndex> indices;
298 for ( QModelIndex q : qindices )
302 indices.push_back ( q );
309 casted->delete_objects ( indices.begin(), indices.end() );
314 casted->delete_objects ( indices.begin(), indices.end() );
318 WARN (
"Object Deleting",
319 "Object deletion failed due to the internal model being in invalid state",
320 "You are advised to restart the application before proceeding any further" );
330 FindObject =
new QAction ( tr (
"Find Object" ),
this );
331 FindObject->setShortcutContext ( Qt::WidgetShortcut );
332 connect ( FindObject, SIGNAL ( triggered() ),
this, SLOT ( FindObjectSlot() ) );
333 ContextMenu->addAction ( FindObject );
335 editObject =
new QAction ( tr (
"&Edit Object" ),
this );
336 editObject->setShortcut ( tr (
"Ctrl+E" ) );
337 editObject->setShortcutContext ( Qt::WidgetShortcut );
338 connect ( editObject, SIGNAL ( triggered() ),
this, SLOT ( slot_edit_object() ) );
339 ContextMenu->addAction ( editObject );
341 deleteObjectAc =
new QAction ( tr (
"&Delete Object" ),
this );
342 deleteObjectAc->setShortcut ( tr (
"Ctrl+D" ) );
343 deleteObjectAc->setShortcutContext ( Qt::WidgetShortcut );
344 connect ( deleteObjectAc, SIGNAL ( triggered() ),
this, SLOT ( slot_delete_objects() ) );
345 ContextMenu->addAction ( deleteObjectAc );
347 refByAc =
new QAction ( tr (
"Referenced B&y (All objects)" ),
this );
348 refByAc->setShortcut ( tr (
"Ctrl+Y" ) );
349 refByAc->setShortcutContext ( Qt::WidgetShortcut );
350 refByAc->setToolTip (
"Find all objects which reference the selected object" );
351 refByAc->setStatusTip ( refByAc->toolTip() );
352 connect ( refByAc, SIGNAL ( triggered() ),
this, SLOT ( referencedBy_All() ) );
353 ContextMenu->addAction ( refByAc );
355 refByAcOnlyComp =
new QAction ( tr (
"Referenced B&y (Only Composite)" ),
this );
356 refByAcOnlyComp->setShortcut ( tr (
"Ctrl+Shift+Y" ) );
357 refByAcOnlyComp->setShortcutContext ( Qt::WidgetShortcut );
358 refByAcOnlyComp->setToolTip (
359 "Find objects (ONLY Composite ones) which reference the selected object" );
360 refByAcOnlyComp->setStatusTip ( refByAcOnlyComp->toolTip() );
361 connect ( refByAcOnlyComp, SIGNAL ( triggered() ),
this,
362 SLOT ( referencedBy_OnlyComposite() ) );
363 ContextMenu->addAction ( refByAcOnlyComp );
365 copyObjectAc =
new QAction ( tr (
"Copy This Object Into A &New One" ),
this );
366 copyObjectAc->setShortcut ( tr (
"Ctrl+Shift+N" ) );
367 copyObjectAc->setShortcutContext ( Qt::WidgetShortcut );
368 connect ( copyObjectAc, SIGNAL ( triggered() ),
this, SLOT ( slot_copy_object() ) );
369 ContextMenu->addAction ( copyObjectAc );
cptr< dbe::CustomTreeView > get_view() const
static MainWindow * findthis()