MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , m_ui(new Ui::MainWindow) , m_ignoreTableSelection(false) { m_fileModel = new FileSystemModel(this); m_model = new QSortFilterProxyModel(m_fileModel); m_model->setSourceModel(m_fileModel); m_ui->setupUi(this); m_ui->m_fileTree->setModel(m_model); for (int i = 1; i < m_model->columnCount(QModelIndex()); ++i) m_ui->m_fileTree->hideColumn(i); m_ui->m_fileTable->setModel(m_model); QAbstractItemDelegate * proxyDelegate = new ProxyItemDelegate(m_ui->m_fileTable->itemDelegate(), m_ui->m_fileTable); m_ui->m_fileTable->setItemDelegate(proxyDelegate); m_ui->m_fileTable->setRootIndex(QModelIndex()); m_ui->m_fileTable->verticalHeader()->setDefaultSectionSize(18); QHeaderView * tableHeader = m_ui->m_fileTable->horizontalHeader(); tableHeader->resizeSections(QHeaderView::Interactive); QAction * resizeToContent = new QAction(QStringLiteral("Resize to content"), tableHeader); VERIFY(QObject::connect(resizeToContent, &QAction::triggered, this, &MainWindow::onResizeColumns)); tableHeader->setContextMenuPolicy(Qt::ActionsContextMenu); tableHeader->addAction(resizeToContent); VERIFY(QObject::connect(m_ui->m_rootEditor, SIGNAL(returnPressed()), this, SLOT(onRootSpecified()))); VERIFY(QObject::connect(m_ui->m_rootDlgButton, SIGNAL(clicked()), this, SLOT(onRootDialogCall()))); VERIFY(QObject::connect(m_ui->m_fileTree->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::onTreeSelectionChanged)); VERIFY(QObject::connect(m_ui->m_fileTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::onTableSelectionChanged)); QAction * regExpAction = new QAction(QStringLiteral("Set filter regexp"), this); m_ui->m_fileTable->addAction(regExpAction); m_ui->m_fileTree->addAction(regExpAction); VERIFY(QObject::connect(regExpAction, &QAction::triggered, this, &MainWindow::onSetRegExp)); LoadState(); }