forked from qt-creator/qt-creator
Core: Static pattern for ProgressManager, clean up all users
Change-Id: I4af8793ca69a3af9e99baeb7c31dad3864266f91 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -348,7 +348,7 @@ void ProgressManagerPrivate::init()
|
||||
initInternal();
|
||||
}
|
||||
|
||||
void ProgressManagerPrivate::cancelTasks(const QString &type)
|
||||
void ProgressManagerPrivate::doCancelTasks(const QString &type)
|
||||
{
|
||||
bool found = false;
|
||||
QMap<QFutureWatcher<void> *, QString>::iterator task = m_runningTasks.begin();
|
||||
@@ -412,7 +412,7 @@ void ProgressManagerPrivate::cancelAllRunningTasks()
|
||||
updateSummaryProgressBar();
|
||||
}
|
||||
|
||||
FutureProgress *ProgressManagerPrivate::addTask(const QFuture<void> &future, const QString &title,
|
||||
FutureProgress *ProgressManagerPrivate::doAddTask(const QFuture<void> &future, const QString &title,
|
||||
const QString &type, ProgressFlags flags)
|
||||
{
|
||||
// watch
|
||||
@@ -717,3 +717,36 @@ void ToggleButton::paintEvent(QPaintEvent *event)
|
||||
arrowOpt.rect = QRect(rect().center().x() - 3, rect().center().y() - 6, 9, 9);
|
||||
s->drawPrimitive(QStyle::PE_IndicatorArrowUp, &arrowOpt, &p, this);
|
||||
}
|
||||
|
||||
|
||||
static ProgressManager *m_instance = 0;
|
||||
|
||||
ProgressManager::ProgressManager(QObject *parent)
|
||||
{
|
||||
m_instance = this;
|
||||
}
|
||||
|
||||
ProgressManager::~ProgressManager()
|
||||
{
|
||||
m_instance = 0;
|
||||
}
|
||||
|
||||
QObject *ProgressManager::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
FutureProgress *ProgressManager::addTask(const QFuture<void> &future, const QString &title, const QString &type, ProgressFlags flags)
|
||||
{
|
||||
return m_instance->doAddTask(future, title, type, flags);
|
||||
}
|
||||
|
||||
void ProgressManager::setApplicationLabel(const QString &text)
|
||||
{
|
||||
m_instance->doSetApplicationLabel(text);
|
||||
}
|
||||
|
||||
void ProgressManager::cancelTasks(const QString &type)
|
||||
{
|
||||
m_instance->doCancelTasks(type);
|
||||
}
|
||||
|
||||
@@ -50,20 +50,28 @@ public:
|
||||
};
|
||||
Q_DECLARE_FLAGS(ProgressFlags, ProgressFlag)
|
||||
|
||||
virtual FutureProgress *addTask(const QFuture<void> &future, const QString &title,
|
||||
const QString &type, ProgressFlags flags = 0) = 0;
|
||||
virtual void setApplicationLabel(const QString &text) = 0;
|
||||
static QObject *instance();
|
||||
|
||||
static FutureProgress *addTask(const QFuture<void> &future, const QString &title,
|
||||
const QString &type, ProgressFlags flags = 0);
|
||||
static void setApplicationLabel(const QString &text);
|
||||
|
||||
public slots:
|
||||
virtual void cancelTasks(const QString &type) = 0;
|
||||
static void cancelTasks(const QString &type);
|
||||
|
||||
signals:
|
||||
void taskStarted(const QString &type);
|
||||
void allTasksFinished(const QString &type);
|
||||
|
||||
protected:
|
||||
virtual void doCancelTasks(const QString &type) = 0;
|
||||
virtual FutureProgress *doAddTask(const QFuture<void> &future, const QString &title,
|
||||
const QString &type, ProgressFlags flags = 0) = 0;
|
||||
virtual void doSetApplicationLabel(const QString &text) = 0;
|
||||
|
||||
private:
|
||||
ProgressManager(QObject *parent = 0) : QObject(parent) {}
|
||||
virtual ~ProgressManager() {}
|
||||
ProgressManager(QObject *parent = 0);
|
||||
~ProgressManager();
|
||||
|
||||
friend class Core::Internal::ProgressManagerPrivate;
|
||||
};
|
||||
|
||||
@@ -125,7 +125,7 @@ static ApplicationProgressView *sharedProgressView = nil;
|
||||
|
||||
@end
|
||||
|
||||
void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text)
|
||||
void Core::Internal::ProgressManagerPrivate::doSetApplicationLabel(const QString &text)
|
||||
{
|
||||
NSString *cocoaString = [[NSString alloc] initWithUTF8String:text.toUtf8().constData()];
|
||||
[[NSApp dockTile] setBadgeLabel:cocoaString];
|
||||
|
||||
@@ -58,14 +58,14 @@ public:
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
FutureProgress *addTask(const QFuture<void> &future, const QString &title, const QString &type,
|
||||
FutureProgress *doAddTask(const QFuture<void> &future, const QString &title, const QString &type,
|
||||
ProgressFlags flags);
|
||||
|
||||
void setApplicationLabel(const QString &text);
|
||||
void doSetApplicationLabel(const QString &text);
|
||||
ProgressView *progressView();
|
||||
|
||||
public slots:
|
||||
void cancelTasks(const QString &type);
|
||||
void doCancelTasks(const QString &type);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
@@ -174,7 +174,7 @@ void Core::Internal::ProgressManagerPrivate::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text)
|
||||
void Core::Internal::ProgressManagerPrivate::doSetApplicationLabel(const QString &text)
|
||||
{
|
||||
Q_UNUSED(text)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void Core::Internal::ProgressManagerPrivate::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text)
|
||||
void Core::Internal::ProgressManagerPrivate::doSetApplicationLabel(const QString &text)
|
||||
{
|
||||
Q_UNUSED(text)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user