Add ProgressInfoBlocker and add to unit tests

This commit is contained in:
Gaute Lindkvist
2019-03-22 13:16:42 +01:00
parent e40b3aa6e8
commit de2920c7c2
3 changed files with 56 additions and 13 deletions

View File

@@ -348,18 +348,6 @@ namespace caf {
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
static bool isUpdatePossible()
{
if (!qApp) return false;
if (!progressDialog()) return false;
return progressDialog()->thread() == QThread::currentThread();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -440,6 +428,23 @@ namespace caf {
}
}
//==================================================================================================
///
/// \class caf::ProgressInfoBlocker
///
/// Used to disable progress info on a temporary basis
///
//==================================================================================================
ProgressInfoBlocker::ProgressInfoBlocker()
{
ProgressInfoStatic::s_disabled = true;
}
ProgressInfoBlocker::~ProgressInfoBlocker()
{
ProgressInfoStatic::s_disabled = false;
}
//==================================================================================================
///
@@ -449,6 +454,7 @@ namespace caf {
///
//==================================================================================================
bool ProgressInfoStatic::s_disabled = false;
//--------------------------------------------------------------------------------------------------
///
@@ -491,7 +497,6 @@ namespace caf {
//if (progressDialog()) progressDialog()->repaint();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -636,4 +641,19 @@ namespace caf {
//if (progressDialog()) progressDialog()->repaint();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool ProgressInfoStatic::isUpdatePossible()
{
if (s_disabled) return false;
if (!qApp) return false;
if (!progressDialog()) return false;
return progressDialog()->thread() == QThread::currentThread();
}
} // namespace caf