-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update chigraph, add module selection dialog, and module tree model
- Loading branch information
Showing
8 changed files
with
426 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "moduleselectiondialog.hpp" | ||
|
||
#include <QVBoxLayout> | ||
#include <QDialogButtonBox> | ||
#include <QHeaderView> | ||
#include <QTreeView> | ||
|
||
#include <cassert> | ||
|
||
ModuleSelectionDialog::ModuleSelectionDialog(chi::Context& ctx, boost::filesystem::path* toFill, QWidget* parent) : QDialog{parent} | ||
{ | ||
assert(toFill != nullptr); | ||
|
||
auto layout = new QVBoxLayout; | ||
setLayout(layout); | ||
|
||
auto treeView = new QTreeView; | ||
layout->addWidget(treeView); | ||
|
||
// get model and set it | ||
mModel = ModuleTreeModel::createFromContext(ctx, ModuleTreeModel::Modules); | ||
treeView->setModel(mModel.get()); | ||
|
||
treeView->setAnimated(true); | ||
treeView->setSortingEnabled(true); | ||
treeView->header()->close(); | ||
|
||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel); | ||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); | ||
|
||
layout->addWidget(buttonBox); | ||
|
||
|
||
connect(treeView, &QTreeView::doubleClicked, this, [toFill, this](const QModelIndex& index) { | ||
if (!index.isValid()) { | ||
return; | ||
} | ||
|
||
auto item = static_cast<WorkspaceTree*>(index.internalPointer()); | ||
|
||
if (item->type == WorkspaceTree::MODULE) { | ||
*toFill = item->fullName(); | ||
accept(); | ||
} | ||
|
||
}); | ||
} | ||
|
||
|
||
boost::filesystem::path ModuleSelectionDialog::getModule(QWidget* parent, chi::Context& ctx) | ||
{ | ||
boost::filesystem::path ret; | ||
auto dialog = new ModuleSelectionDialog(ctx, &ret, parent); | ||
|
||
dialog->exec(); | ||
|
||
|
||
return ret; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#ifndef CHIGRAPHGUI_MODULE_SELECTION_DIALOG_HPP | ||
#define CHIGRAPHGUI_MODULE_SELECTION_DIALOG_HPP | ||
|
||
#include <QDialog> | ||
|
||
#include "moduletreemodel.hpp" | ||
|
||
#include <boost/filesystem/path.hpp> | ||
|
||
class ModuleSelectionDialog : public QDialog { | ||
public: | ||
ModuleSelectionDialog(chi::Context& ctx, boost::filesystem::path* toFill, QWidget* parent = nullptr); | ||
|
||
static boost::filesystem::path getModule(QWidget* parent, chi::Context& ctx); | ||
|
||
private: | ||
std::unique_ptr<ModuleTreeModel> mModel; | ||
}; | ||
|
||
#endif // CHIGRAPHGUI_MODULE_SELECTION_DIALOG_HPP |
Oops, something went wrong.