cutter/src/widgets/OverviewWidget.cpp
2019-03-18 08:34:30 +02:00

47 lines
1.1 KiB
C++

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