ui: file not up to date display

* the codeview now displays a hatched background for a filename when the file's content has changed or the file does not exist anymore.
* added TimePoint class to encapsulate boost.
This commit is contained in:
malte_langkabel
2015-11-03 10:29:29 +01:00
parent 42ab36fbad
commit a524a7a71c
18 changed files with 161 additions and 20 deletions
+21
View File
@@ -0,0 +1,21 @@
#include "TimePoint.h"
TimePoint::TimePoint()
: m_time(boost::posix_time::not_a_date_time)
{
}
TimePoint::TimePoint(boost::posix_time::ptime t)
: m_time(t)
{
}
//TimePoint::TimePoint(time_t t)
//{
// needs an implementation
//}
TimePoint::TimePoint(std::string s)
{
m_time = boost::posix_time::time_from_string(s);
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef TIME_POINT_H
#define TIME_POINT_H
#include "boost/date_time/posix_time/posix_time.hpp"
class TimePoint
{
public:
TimePoint();
TimePoint(boost::posix_time::ptime t);
//TimePoint(time_t t);
TimePoint(std::string s);
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 bool operator<(const TimePoint& rhs){ return m_time < rhs.m_time; }
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 bool operator>=(const TimePoint& rhs){ return m_time >= rhs.m_time; }
private:
boost::posix_time::ptime m_time;
};
#endif // TIME_POINT_H
+11
View File
@@ -94,6 +94,17 @@ std::vector<FileInfo> FileSystem::getFileInfosFromPaths(
return files;
}
TimePoint FileSystem::getLastWriteTime(const FilePath& filePath)
{
boost::posix_time::ptime lastWriteTime;
if (FileSystem::exists(filePath.str()))
{
std::time_t t = boost::filesystem::last_write_time(filePath.path());
lastWriteTime = boost::posix_time::from_time_t(t);
}
return TimePoint(lastWriteTime);
}
std::string FileSystem::getTimeStringNow() // TODO: move to utility
{
return boost::posix_time::to_iso_string(boost::posix_time::second_clock::universal_time());
+2
View File
@@ -5,6 +5,7 @@
#include <vector>
#include "utility/file/FileInfo.h"
#include "utility/TimePoint.h"
class FileSystem
{
@@ -19,6 +20,7 @@ public:
static std::vector<FileInfo> getFileInfosFromPaths(
const std::vector<FilePath>& paths, const std::vector<std::string>& fileExtensions);
static TimePoint getLastWriteTime(const FilePath& filePath);
static std::string getTimeStringNow();
static std::vector<FilePath> getSubDirectories(const FilePath& path);