cutter/src/widgets/OverviewWidget.cpp

61 lines
1.3 KiB
C++
Raw Normal View History

#include "core/MainWindow.h"
#include "OverviewWidget.h"
#include "OverviewView.h"
OverviewWidget::OverviewWidget(MainWindow *main, QAction *action) :
CutterDockWidget(main, action)
{
setWindowTitle("Graph Overview");
setObjectName("Graph Overview");
setAllowedAreas(Qt::AllDockWidgetAreas);
graphView = new OverviewView(this);
setWidget(graphView);
refreshDeferrer = createRefreshDeferrer([this]() {
updateContents();
});
connect(this, &QDockWidget::visibilityChanged, this, [ = ](bool visibility) {
if (visibility) {
updateContents();
}
});
}
OverviewWidget::~OverviewWidget() {}
2019-01-24 18:04:39 +00:00
void OverviewWidget::resizeEvent(QResizeEvent *event)
{
graphView->refreshView();
QDockWidget::resizeEvent(event);
emit resized();
2019-01-24 18:04:39 +00:00
}
void OverviewWidget::updateContents()
{
if (!refreshDeferrer->attemptRefresh(nullptr)) {
return;
}
graphView->refreshView();
}
void OverviewWidget::closeEvent(QCloseEvent *event)
{
CutterDockWidget::closeEvent(event);
emit graphClose();
}
void OverviewWidget::setUserClosed(bool value)
{
userClosed = value;
}
bool OverviewWidget::getUserClosed() const
{
return userClosed;
}
OverviewView *OverviewWidget::getGraphView() const
{
return graphView;
}