18 : QTableView ( parent ),
19 ContextMenu ( nullptr ),
20 LaunchIncludeEditor ( nullptr ),
21 HideReadOnlyFiles ( nullptr ),
23 FindFileDialog ( nullptr ),
25 NextButton ( nullptr ),
30 setSelectionBehavior ( SelectionBehavior::SelectRows );
31 horizontalHeader()->setSectionResizeMode ( QHeaderView::ResizeMode::Stretch );
32 setSortingEnabled (
true );
34 connect (
this, SIGNAL(activated(QModelIndex)),
42 FindFile =
new QAction ( tr (
"Find File" ),
this );
43 FindFile->setShortcut ( QKeySequence ( tr (
"Ctrl+F" ) ) );
44 FindFile->setShortcutContext ( Qt::WidgetShortcut );
45 connect ( FindFile, SIGNAL ( triggered() ),
this, SLOT ( FindFileSlot() ) );
47 ContextMenu->addAction ( FindFile );
49 LaunchIncludeEditor =
new QAction ( tr (
"Add/Remove Files" ),
this );
50 LaunchIncludeEditor->setShortcutContext ( Qt::WidgetShortcut );
51 connect ( LaunchIncludeEditor, SIGNAL ( triggered() ),
this,
52 SLOT ( LaunchIncludeEditorSlot() ) );
53 ContextMenu->addAction ( LaunchIncludeEditor );
55 HideReadOnlyFiles =
new QAction ( tr (
"Hide Read Only Files" ),
this );
56 HideReadOnlyFiles->setShortcutContext ( Qt::WidgetShortcut );
57 HideReadOnlyFiles->setCheckable (
true );
58 HideReadOnlyFiles->setChecked (
false );
59 connect ( HideReadOnlyFiles, SIGNAL ( triggered (
bool ) ),
this,
60 SLOT ( HideReadOnlyFilesSlot (
bool ) ) );
61 ContextMenu->addAction ( HideReadOnlyFiles );
63 m_file_info_action =
new QAction (tr (
"File &information"));
64 connect ( m_file_info_action, SIGNAL(triggered()),
65 this, SLOT(file_info_slot()) );
66 ContextMenu->addAction ( m_file_info_action );
86 QModelIndex index = indexAt ( Event->pos() );
88 if ( index.isValid() )
90 if ( model()->data ( model()->index ( index.row(), 2 ) ).toString() ==
"RO" ) {
91 ContextMenu->actions().at ( 1 )->setVisible (
false );
94 ContextMenu->actions().at ( 1 )->setVisible (
true );
97 setCurrentIndex ( index );
98 selectionModel()->setCurrentIndex ( index, QItemSelectionModel::NoUpdate );
99 ContextMenu->exec ( Event->globalPos() );
108 QString UserType = LineEdit->text();
110 if ( UserType.isEmpty() )
115 QAbstractItemModel * Model = model();
117 if ( Model !=
nullptr )
119 QVariant StringCriterium = QVariant ( UserType );
121 QModelIndex find_by_name = Model->index ( 0, 0 );
122 QModelIndex find_by_path = Model->index ( 0, 1 );
124 Qt::MatchFlags options = Qt::MatchContains;
126 if ( CaseSensitiveCheckBox->isChecked() )
128 options = options | Qt::MatchCaseSensitive;
131 if ( WholeWordCheckBox->isChecked() )
133 options = Qt::MatchExactly;
136 ListOfMatch = Model->match ( find_by_name, Qt::DisplayRole, StringCriterium, 1000,
140 Model->match ( find_by_path, Qt::DisplayRole, StringCriterium, 1000, options ) );
142 if ( ListOfMatch.size() > 0 )
145 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
146 selectRow ( ListOfMatch.value ( ListIndex ).row() );
147 resizeColumnToContents ( ListIndex );
149 GoButton->setDisabled (
true );
150 NextButton->setEnabled (
true );
152 disconnect ( LineEdit, SIGNAL ( returnPressed() ),
this, SLOT ( GoToFile() ) );
153 connect ( LineEdit, SIGNAL ( returnPressed() ),
this, SLOT ( GoToNext() ) );
154 ChangeSelection ( ListOfMatch.at ( ListIndex ) );
161 if ( ( LineEdit->text() ).isEmpty() )
168 if ( ListOfMatch.size() > 0 )
170 if ( ( ++ListIndex ) < ListOfMatch.size() )
172 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
173 selectRow ( ListOfMatch.value ( ListIndex ).row() );
174 resizeColumnToContents ( ListIndex );
175 ChangeSelection ( ListOfMatch.at ( ListIndex ) );
180 scrollTo ( ListOfMatch.value ( ListIndex ), QAbstractItemView::EnsureVisible );
181 selectRow ( ListOfMatch.value ( ListIndex ).row() );
182 resizeColumnToContents ( ListIndex );
183 ChangeSelection ( ListOfMatch.at ( ListIndex ) );
190 if ( FindFileDialog !=
nullptr )
192 delete FindFileDialog;
193 FindFileDialog =
nullptr;
196 FindFileDialog =
new QDialog (
this );
197 FindFileDialog->setSizePolicy ( QSizePolicy::Preferred, QSizePolicy::Preferred );
198 FindFileDialog->setToolTip (
"Type string to edit line and press Enter." );
199 FindFileDialog->setWindowTitle (
"Search for a file name in the table" );
201 QHBoxLayout * FileLayout =
new QHBoxLayout();
202 QLabel * Label =
new QLabel ( QString (
"Find File:" ) );
203 NextButton =
new QPushButton (
"Next" );
204 GoButton =
new QPushButton (
"Go !" );
205 LineEdit =
new QLineEdit();
206 LineEdit->setToolTip (
"Type string and press Enter" );
208 FileLayout->addWidget ( Label );
209 FileLayout->addWidget ( LineEdit );
210 FileLayout->addWidget ( GoButton );
211 FileLayout->addWidget ( NextButton );
213 QHBoxLayout * ButtonsLayout =
new QHBoxLayout();
214 WholeWordCheckBox =
new QCheckBox (
"Whole String" );
215 CaseSensitiveCheckBox =
new QCheckBox (
"Case Sensitive" );
217 ButtonsLayout->addWidget ( WholeWordCheckBox );
218 ButtonsLayout->addWidget ( CaseSensitiveCheckBox );
220 QVBoxLayout * FindDialogLayout =
new QVBoxLayout();
221 FindDialogLayout->addItem ( FileLayout );
222 FindDialogLayout->addItem ( ButtonsLayout );
224 FindFileDialog->setLayout ( FindDialogLayout );
225 FindFileDialog->show();
228 connect ( LineEdit, SIGNAL ( textEdited ( QString ) ),
this,
229 SLOT ( EditedSearchString ( QString ) ) );
230 connect ( WholeWordCheckBox, SIGNAL ( clicked() ),
this, SLOT ( EditedSearchString() ) );
231 connect ( CaseSensitiveCheckBox, SIGNAL ( clicked() ),
this,
232 SLOT ( EditedSearchString() ) );
234 connect ( LineEdit, SIGNAL ( returnPressed() ),
this, SLOT ( GoToFile() ) );
235 connect ( GoButton, SIGNAL ( clicked() ),
this, SLOT ( GoToFile() ) );
236 connect ( NextButton, SIGNAL ( clicked() ),
this, SLOT ( GoToNext() ) );
244 QString file = model()->data ( model()->index ( index.row(), 0,
245 index.parent() ) ).toString();
246 QString path = model()->data ( model()->index ( index.row(), 1,
247 index.parent() ) ).toString();
248 auto full_name = path +
"/" + file;
252 QString message{
"Files included by " + file +
"\n"};
254 for (
auto inc: includes) {
255 if (schema && !inc.endsWith(
".schema.xml")) {
256 message.append(
"\nData files:");
259 if (inc.endsWith(
".schema.xml")) {
261 message.append(
"\nSchema files:");
265 message.append(
"\n " + inc);
268 QMessageBox mbox(
this);
269 mbox.setWindowTitle(QString{
"File information for " + file});
270 mbox.setStandardButtons(QMessageBox::Ok);
271 mbox.setText(message);
277 QModelIndex index = currentIndex();
278 QString file = model()->data ( model()->index ( index.row(), 0,
279 index.parent() ) ).toString();
280 QString path = model()->data ( model()->index ( index.row(), 1,
281 index.parent() ) ).toString();
282 auto full_name = path +
"/" + file;
325 QString file = model()->data ( model()->index ( index.row(), 0,
326 index.parent() ) ).toString();
327 QString path = model()->data ( model()->index ( index.row(), 1,
328 index.parent() ) ).toString();
329 auto full_name = path +
"/" + file;
330 emit stateChanged ( full_name );