ui: Indexing UI
* Added DialogView with QtDialogView implementation to handle information dialogs * Implemented QtIndexingDialog class that covers all different dialogs for indexing * Directly communicate with DialogView from Prpject and all Tasks involved in indexing * Block QtMainWindow UI while indexing
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
#include "TimePoint.h"
|
||||
|
||||
TimePoint TimePoint::now()
|
||||
{
|
||||
return TimePoint(boost::posix_time::microsec_clock::local_time());
|
||||
}
|
||||
|
||||
TimePoint::TimePoint()
|
||||
: m_time(boost::posix_time::not_a_date_time)
|
||||
{
|
||||
@@ -37,4 +42,9 @@ std::string TimePoint::toString() const
|
||||
stream.imbue(std::locale(std::locale::classic(), facet));
|
||||
stream << m_time;
|
||||
return stream.str();
|
||||
}
|
||||
}
|
||||
|
||||
size_t TimePoint::deltaMS(const TimePoint& other) const
|
||||
{
|
||||
return (m_time - other.m_time).total_milliseconds();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
class TimePoint
|
||||
{
|
||||
public:
|
||||
static TimePoint now();
|
||||
|
||||
TimePoint();
|
||||
TimePoint(boost::posix_time::ptime t);
|
||||
//TimePoint(time_t t);
|
||||
@@ -22,7 +24,9 @@ public:
|
||||
inline bool operator<=(const TimePoint& rhs){ return m_time <= rhs.m_time; }
|
||||
inline bool operator>=(const TimePoint& rhs){ return m_time >= rhs.m_time; }
|
||||
|
||||
inline float operator-(const TimePoint& rhs){ return (m_time - rhs.m_time).total_milliseconds() / 1000.0f; }
|
||||
inline float operator-(const TimePoint& rhs){ return deltaMS(rhs) / 1000.0f; }
|
||||
|
||||
size_t deltaMS(const TimePoint& other) const;
|
||||
|
||||
private:
|
||||
boost::posix_time::ptime m_time;
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
#ifndef MESSAGE_FINISHED_PARSING_H
|
||||
#define MESSAGE_FINISHED_PARSING_H
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "data/ErrorCountInfo.h"
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
|
||||
class MessageFinishedParsing
|
||||
: public Message<MessageFinishedParsing>
|
||||
{
|
||||
public:
|
||||
MessageFinishedParsing(size_t fileCount, size_t totalFileCount, float parseTime, bool loadedOnly = false)
|
||||
: fileCount(fileCount)
|
||||
, totalFileCount(totalFileCount)
|
||||
, parseTime(parseTime)
|
||||
, loadedOnly(loadedOnly)
|
||||
MessageFinishedParsing()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,55 +15,6 @@ public:
|
||||
{
|
||||
return "MessageFinishedParsing";
|
||||
}
|
||||
|
||||
std::string getStatusStr() const
|
||||
{
|
||||
if (loadedOnly)
|
||||
{
|
||||
return "Finished loading";
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Finished indexing: ";
|
||||
ss << fileCount << "/" << totalFileCount << " files; ";
|
||||
|
||||
float secondsLeft = parseTime;
|
||||
int hours = int(secondsLeft / 3600);
|
||||
secondsLeft -= hours * 3600;
|
||||
int minutes = int(secondsLeft / 60);
|
||||
secondsLeft -= minutes * 60;
|
||||
int seconds = int(secondsLeft);
|
||||
secondsLeft -= seconds;
|
||||
int milliSeconds = secondsLeft * 1000;
|
||||
|
||||
if (hours > 9)
|
||||
{
|
||||
ss << hours;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << std::setw(2) << std::setfill('0') << hours;
|
||||
}
|
||||
ss << ":" << std::setw(2) << std::setfill('0') << minutes;
|
||||
ss << ":" << std::setw(2) << std::setfill('0') << seconds;
|
||||
|
||||
if (!hours && !minutes)
|
||||
{
|
||||
ss << ":" << std::setw(3) << std::setfill('0') << milliSeconds;
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << getStatusStr();
|
||||
}
|
||||
|
||||
size_t fileCount;
|
||||
size_t totalFileCount;
|
||||
float parseTime;
|
||||
bool loadedOnly;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_FINISHED_PARSING_H
|
||||
|
||||
@@ -62,6 +62,8 @@ Task::TaskState Task::interruptTask()
|
||||
switch (m_state)
|
||||
{
|
||||
case STATE_NEW:
|
||||
abort();
|
||||
break;
|
||||
case STATE_CANCELED:
|
||||
break;
|
||||
case STATE_RUNNING:
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
|
||||
virtual void interrupt() = 0;
|
||||
virtual void revert() = 0;
|
||||
virtual void abort() = 0;
|
||||
|
||||
protected:
|
||||
void setState(TaskState state);
|
||||
|
||||
@@ -62,6 +62,11 @@ void TaskGroupParallel::revert()
|
||||
m_interrupt = true;
|
||||
}
|
||||
|
||||
void TaskGroupParallel::abort()
|
||||
{
|
||||
m_interrupt = true;
|
||||
}
|
||||
|
||||
|
||||
void TaskGroupParallel::processTaskThreaded(std::shared_ptr<Task> task)
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
void processTaskThreaded(std::shared_ptr<Task> task);
|
||||
|
||||
@@ -43,12 +43,9 @@ void TaskGroupSequential::exit()
|
||||
|
||||
void TaskGroupSequential::interrupt()
|
||||
{
|
||||
if (m_taskIndex >= 0 && size_t(m_taskIndex) < m_tasks.size())
|
||||
for (size_t i = 0; i < m_tasks.size(); i++)
|
||||
{
|
||||
for (int i = m_taskIndex; i >= 0; i--)
|
||||
{
|
||||
m_tasks[i]->interruptTask();
|
||||
}
|
||||
m_tasks[i]->interruptTask();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,3 +56,8 @@ void TaskGroupSequential::revert()
|
||||
m_tasks[i]->interruptTask();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskGroupSequential::abort()
|
||||
{
|
||||
interrupt();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
int m_taskIndex;
|
||||
|
||||
@@ -30,3 +30,7 @@ void TaskLambda::interrupt()
|
||||
void TaskLambda::revert()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskLambda::abort()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
|
||||
virtual void interrupt();
|
||||
virtual void revert();
|
||||
virtual void abort();
|
||||
|
||||
private:
|
||||
std::function<void()> m_func;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#include "utility/utility.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include "boost/date_time/time_clock.hpp"
|
||||
|
||||
TimePoint utility::durationStart()
|
||||
{
|
||||
return TimePoint(boost::posix_time::microsec_clock::local_time());
|
||||
return TimePoint::now();
|
||||
}
|
||||
|
||||
float utility::duration(const TimePoint& start)
|
||||
@@ -33,6 +37,37 @@ std::string utility::timeToString(const boost::posix_time::ptime time)
|
||||
return TimePoint(time).toString();
|
||||
}
|
||||
|
||||
std::string utility::timeToString(float secondsTotal)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
int hours = int(secondsTotal / 3600);
|
||||
secondsTotal -= hours * 3600;
|
||||
int minutes = int(secondsTotal / 60);
|
||||
secondsTotal -= minutes * 60;
|
||||
int seconds = int(secondsTotal);
|
||||
secondsTotal -= seconds;
|
||||
int milliSeconds = secondsTotal * 1000;
|
||||
|
||||
if (hours > 9)
|
||||
{
|
||||
ss << hours;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << std::setw(2) << std::setfill('0') << hours;
|
||||
}
|
||||
ss << ":" << std::setw(2) << std::setfill('0') << minutes;
|
||||
ss << ":" << std::setw(2) << std::setfill('0') << seconds;
|
||||
|
||||
if (!hours && !minutes)
|
||||
{
|
||||
ss << ":" << std::setw(3) << std::setfill('0') << milliSeconds;
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool utility::intersectionPoint(Vec2f a1, Vec2f b1, Vec2f a2, Vec2f b2, Vec2f* i)
|
||||
{
|
||||
Vec2f p = a1;
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace utility
|
||||
|
||||
std::string timeToString(const time_t time);
|
||||
std::string timeToString(const boost::posix_time::ptime time);
|
||||
std::string timeToString(float seconds);
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> concat(const std::vector<T>& a, const std::vector<T>& b);
|
||||
|
||||
Reference in New Issue
Block a user