Mercurial > hg > svgui
changeset 798:6eb0b20c940f tonioni
Merge
author | Chris Cannam |
---|---|
date | Fri, 13 Jun 2014 17:44:58 +0100 |
parents | edada332c374 (diff) 7717751f4407 (current diff) |
children | d6b79166ae0d 102ffad481e6 |
files | |
diffstat | 2 files changed, 43 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/view/View.cpp Fri Jun 13 16:50:17 2014 +0100 +++ b/view/View.cpp Fri Jun 13 17:44:58 2014 +0100 @@ -26,6 +26,8 @@ #include "data/model/PowerOfSqrtTwoZoomConstraint.h" #include "data/model/RangeSummarisableTimeValueModel.h" +#include "widgets/IconLoader.h" + #include <QPainter> #include <QPaintEvent> #include <QRect> @@ -34,6 +36,7 @@ #include <QTextStream> #include <QFont> #include <QMessageBox> +#include <QPushButton> #include <iostream> #include <cassert> @@ -517,11 +520,6 @@ else return Qt::white; } -View::LayerProgressBar::LayerProgressBar(QWidget *parent) : - QProgressBar(parent) -{ -} - void View::addLayer(Layer *layer) { @@ -539,7 +537,14 @@ pb->setFixedWidth(80); pb->setTextVisible(false); + QPushButton *cancel = new QPushButton(this); + cancel->setIcon(IconLoader().load("fileclose")); + cancel->setFlat(true); + cancel->setFixedSize(QSize(20, 20)); + connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); + ProgressBarRec pbr; + pbr.cancel = cancel; pbr.bar = pb; pbr.lastCheck = 0; pbr.checkTimer = new QTimer(); @@ -552,6 +557,8 @@ int fs = Preferences::getInstance()->getViewFontSize(); f.setPointSize(std::min(fs, int(ceil(fs * 0.85)))); + cancel->hide(); + pb->setFont(f); pb->hide(); @@ -594,6 +601,7 @@ m_layers.erase(i); if (m_progressBars.find(layer) != m_progressBars.end()) { delete m_progressBars[layer].bar; + delete m_progressBars[layer].cancel; delete m_progressBars[layer].checkTimer; m_progressBars.erase(layer); } @@ -1460,6 +1468,25 @@ } void +View::cancelClicked() +{ + QPushButton *cancel = qobject_cast<QPushButton *>(sender()); + if (!cancel) return; + + for (ProgressMap::iterator i = m_progressBars.begin(); + i != m_progressBars.end(); ++i) { + + if (i->second.cancel == cancel) { + + Layer *layer = i->first; + Model *model = layer->getModel(); + + if (model) model->abandon(); + } + } +} + +void View::checkProgress(void *object) { if (!m_showProgress) return; @@ -1470,6 +1497,7 @@ i != m_progressBars.end(); ++i) { QProgressBar *pb = i->second.bar; + QPushButton *cancel = i->second.cancel; if (i->first == object) { @@ -1516,6 +1544,7 @@ if (completion >= 100) { pb->hide(); + cancel->hide(); timer->stop(); } else { @@ -1528,8 +1557,11 @@ timer->start(); } + cancel->move(0, ph - pb->height()/2 - 10); + cancel->show(); + pb->setValue(completion); - pb->move(0, ph - pb->height()); + pb->move(20, ph - pb->height()); pb->show(); pb->update();
--- a/view/View.h Fri Jun 13 16:50:17 2014 +0100 +++ b/view/View.h Fri Jun 13 17:44:58 2014 +0100 @@ -29,6 +29,8 @@ class Layer; class ViewPropertyContainer; +class QPushButton; + #include <map> #include <set> @@ -309,6 +311,8 @@ virtual void overlayModeChanged(); virtual void zoomWheelsEnabledChanged(); + virtual void cancelClicked(); + virtual void progressCheckStalledTimerElapsed(); protected: @@ -373,16 +377,8 @@ mutable LayerList m_lastScrollableBackLayers; mutable LayerList m_lastNonScrollableBackLayers; - class LayerProgressBar : public QProgressBar { - public: - LayerProgressBar(QWidget *parent); - virtual QString text() const { return m_text; } - virtual void setText(QString text) { m_text = text; } - protected: - QString m_text; - }; - struct ProgressBarRec { + QPushButton *cancel; QProgressBar *bar; int lastCheck; QTimer *checkTimer;