| 5 | |
| 6 | |
| 7 | TriageFilePicker::TriageFilePicker(UIContext* context) |
| 8 | { |
| 9 | m_context = context; |
| 10 | m_contextMenuManager = new ContextMenuManager(this); |
| 11 | m_actionHandler.setupActionHandler(this); |
| 12 | |
| 13 | QVBoxLayout* layout = new QVBoxLayout(); |
| 14 | layout->setContentsMargins(0, 0, 0, 0); |
| 15 | SettingsRef settings = BinaryNinja::Settings::Instance(); |
| 16 | bool hiddenFiles = settings->Get<bool>("triage.hiddenFiles"); |
| 17 | |
| 18 | m_model = new QFileSystemModel(); |
| 19 | m_model->setRootPath(""); |
| 20 | if (hiddenFiles) |
| 21 | m_model->setFilter(QDir::Hidden | QDir::AllEntries | QDir::System); |
| 22 | m_tree = new QTreeView(this); |
| 23 | m_tree->setModel(m_model); |
| 24 | m_tree->setSelectionMode(QAbstractItemView::ExtendedSelection); |
| 25 | m_tree->setColumnWidth(0, 500); |
| 26 | layout->addWidget(m_tree, 1); |
| 27 | |
| 28 | setLayout(layout); |
| 29 | |
| 30 | connect(m_tree, &QTreeView::doubleClicked, this, &TriageFilePicker::onDoubleClick); |
| 31 | |
| 32 | QString recentFile = QSettings().value("triage/recentFile", QDir::homePath()).toString(); |
| 33 | while (recentFile.size() > 0) |
| 34 | { |
| 35 | QModelIndex f = m_model->index(recentFile); |
| 36 | if (f.isValid()) |
| 37 | { |
| 38 | m_tree->scrollTo(f); |
| 39 | m_tree->setExpanded(f, true); |
| 40 | break; |
| 41 | } |
| 42 | QString parentDir = QFileInfo(recentFile).path(); |
| 43 | if (parentDir == recentFile) |
| 44 | break; |
| 45 | recentFile = parentDir; |
| 46 | } |
| 47 | |
| 48 | m_actionHandler.bindAction( |
| 49 | "Open Selected Files", UIAction([=]() { openSelectedFiles(); }, [=]() { return areFilesSelected(); })); |
| 50 | m_contextMenu.addAction("Open Selected Files", "Open"); |
| 51 | } |
| 52 | |
| 53 | |
| 54 | void TriageFilePicker::contextMenuEvent(QContextMenuEvent*) |