Commit 27aa6409 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

started with workspaces

parent 43d88c86
......@@ -44,6 +44,7 @@ include_directories(
add_executable(in20
tools/in20/main.cpp tools/in20/mainwnd.cpp tools/in20/mainwnd.h
tools/in20/filebrowser.cpp tools/in20/filebrowser.h
tools/in20/workspace.cpp tools/in20/workspace.h
ext/tlibs/log/log.cpp ext/tlibs/file/loadinstr.cpp
......
......@@ -10,6 +10,7 @@
#include <QtCore/QDirIterator>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QFileDialog>
#include <algorithm>
......@@ -29,20 +30,27 @@ FileBrowserWidget::FileBrowserWidget(QWidget *pParent, QSettings *pSettings)
// ------------------------------------------------------------------------
// layout
auto *pBtnFolders = new QPushButton("Folder...", this);
auto *pBtnTransfer = new QPushButton("To Workspace", this);
auto *pCheckMultiSelect = new QCheckBox("Multi-Select", this);
auto *pGrid = new QGridLayout(this);
pGrid->addWidget(pBtnFolders, 0, 0, 1, 1);
pGrid->addWidget(m_pEditFolder, 0, 1, 1, 1);
pGrid->addWidget(m_pListFiles, 1, 0, 2, 2);
pGrid->addWidget(m_pPlotter, 3, 0, 1, 2);
pGrid->addWidget(pCheckMultiSelect, 3, 0, 1, 1);
pGrid->addWidget(pBtnTransfer, 3, 1, 1, 1);
pGrid->addWidget(m_pPlotter, 4, 0, 1, 2);
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// connections
connect(pBtnFolders, &QPushButton::clicked, this, &FileBrowserWidget::SelectFolder);
connect(pCheckMultiSelect, &QCheckBox::stateChanged, this, &FileBrowserWidget::SetMultiSelect);
connect(pBtnTransfer, &QPushButton::clicked, this, &FileBrowserWidget::TransferSelectedToWorkspace);
connect(m_pEditFolder, &QLineEdit::textChanged, this, &FileBrowserWidget::SetFolder);
connect(m_pListFiles, &QListWidget::currentItemChanged, this, &FileBrowserWidget::SetFile);
connect(m_pListFiles, &QListWidget::itemDoubleClicked, this, &FileBrowserWidget::FileDoubleClicked);
// ------------------------------------------------------------------------
......@@ -267,6 +275,38 @@ void FileBrowserWidget::SetFile(QListWidgetItem* pCur)
m_pPlotter->replot();
}
}
void FileBrowserWidget::SetMultiSelect(int checked)
{
bool bMultiSel = checked != 0;
m_pListFiles->setSelectionMode(bMultiSel ? QAbstractItemView::MultiSelection : QAbstractItemView::SingleSelection);
}
/**
* a file in the list was double-clicked
*/
void FileBrowserWidget::FileDoubleClicked(QListWidgetItem *pItem)
{
QList lst({ pItem });
TransferToWorkspace(lst);
}
void FileBrowserWidget::TransferSelectedToWorkspace()
{
TransferToWorkspace(m_pListFiles->selectedItems());
}
/**
* load selected file(s) into workspace
*/
void FileBrowserWidget::TransferToWorkspace(const QList<QListWidgetItem*>& lst)
{
}
// ----------------------------------------------------------------------------
......
......@@ -40,7 +40,12 @@ public:
void SetFolder(const QString& str);
protected:
void SetFile(QListWidgetItem* pCur);
void SetFile(QListWidgetItem *pCur);
void SetMultiSelect(int checked);
void FileDoubleClicked(QListWidgetItem *pItem);
void TransferSelectedToWorkspace();
void TransferToWorkspace(const QList<QListWidgetItem*>&);
};
......
......@@ -11,8 +11,8 @@
MainWnd::MainWnd(QSettings* pSettings)
: QMainWindow(), m_pSettings(pSettings),
m_pBrowser(new FileBrowser(this, pSettings)
)
m_pBrowser(new FileBrowser(this, pSettings)),
m_pWS(new WorkSpace(this, pSettings))
{
this->setObjectName("in20");
this->setWindowTitle("IN20 Tool");
......@@ -28,6 +28,11 @@ MainWnd::MainWnd(QSettings* pSettings)
connect(pShowFileBrowser, &QAction::triggered, m_pBrowser, &FileBrowser::show);
pMenuView->addAction(pShowFileBrowser);
QAction *pShowWorkSpace = new QAction("Show Workspace", pMenuView);
pShowWorkSpace->setChecked(m_pWS->isVisible());
connect(pShowWorkSpace, &QAction::triggered, m_pWS, &FileBrowser::show);
pMenuView->addAction(pShowWorkSpace);
m_pMenu->addMenu(pMenuView);
this->setMenuBar(m_pMenu);
// ------------------------------------------------------------------------
......@@ -36,6 +41,7 @@ MainWnd::MainWnd(QSettings* pSettings)
this->setStatusBar(m_pStatus);
this->setCentralWidget(m_pMDI);
this->addDockWidget(Qt::LeftDockWidgetArea, m_pBrowser);
this->addDockWidget(Qt::RightDockWidgetArea, m_pWS);
// ------------------------------------------------------------------------
......
......@@ -15,6 +15,7 @@
#include <QtWidgets/QStatusBar>
#include "filebrowser.h"
#include "workspace.h"
class MainWnd : public QMainWindow
......@@ -25,6 +26,7 @@ private:
QStatusBar *m_pStatus = new QStatusBar(this);
QMdiArea *m_pMDI = new QMdiArea(this);
FileBrowser *m_pBrowser = nullptr;
WorkSpace *m_pWS = nullptr;
private:
virtual void showEvent(QShowEvent *pEvt) override;
......
/**
* data file browser
* @author Tobias Weber <tweber@ill.fr>
* @date 9-Apr-2018
* @license see 'LICENSE' file
*/
#include "workspace.h"
#include <QtCore/QDirIterator>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QFileDialog>
#include <algorithm>
#include "tlibs/file/loadinstr.h"
using t_real = double;
// ----------------------------------------------------------------------------
WorkSpaceWidget::WorkSpaceWidget(QWidget *pParent, QSettings *pSettings)
: QWidget(pParent), m_pSettings(pSettings)
{
m_pListFiles->setAlternatingRowColors(true);
// ------------------------------------------------------------------------
auto *pGrid = new QGridLayout(this);
pGrid->addWidget(m_pListFiles, 1, 0, 2, 2);
pGrid->addWidget(m_pPlotter, 3, 0, 1, 2);
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// connections
connect(m_pListFiles, &QListWidget::currentItemChanged, this, &WorkSpaceWidget::ItemSelected);
connect(m_pListFiles, &QListWidget::itemDoubleClicked, this, &WorkSpaceWidget::ItemDoubleClicked);
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// settings
if(m_pSettings)
{
}
// ------------------------------------------------------------------------
}
WorkSpaceWidget::~WorkSpaceWidget()
{
}
/**
* an item in the list was selected
*/
void WorkSpaceWidget::ItemSelected(QListWidgetItem* pCur)
{
}
/**
* an item in the list was double-clicked
*/
void WorkSpaceWidget::ItemDoubleClicked(QListWidgetItem* pCur)
{
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
WorkSpace::WorkSpace(QWidget* pParent, QSettings *pSettings)
: QDockWidget(pParent), m_pWS(std::make_unique<WorkSpaceWidget>(this, pSettings))
{
this->setObjectName("workSpace");
this->setWindowTitle("Workspace");
this->setWidget(m_pWS.get());
}
WorkSpace::~WorkSpace()
{
}
// ----------------------------------------------------------------------------
/**
* data file browser
* @author Tobias Weber <tweber@ill.fr>
* @date 9-Apr-2018
* @license see 'LICENSE' file
*/
#ifndef __WORKSPACE_H__
#define __WORKSPACE_H__
#include <QtCore/QSettings>
#include <QtWidgets/QWidget>
#include <QtWidgets/QDockWidget>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QListWidget>
#include <memory>
#include "qcp/qcustomplot.h"
/**
* work space widget
*/
class WorkSpaceWidget : public QWidget
{
private:
QSettings *m_pSettings = nullptr;
QListWidget *m_pListFiles = new QListWidget(this);
QCustomPlot *m_pPlotter = new QCustomPlot(this);
public:
WorkSpaceWidget(QWidget *pParent = nullptr, QSettings *pSettings = nullptr);
virtual ~WorkSpaceWidget();
protected:
void ItemSelected(QListWidgetItem* pCur);
void ItemDoubleClicked(QListWidgetItem* pCur);
};
/**
* the dock which contains the workspace widget
*/
class WorkSpace : public QDockWidget
{
private:
std::unique_ptr<WorkSpaceWidget> m_pWS;
public:
WorkSpace(QWidget* pParent = nullptr, QSettings *pSettings = nullptr);
virtual ~WorkSpace();
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment