Code Cleanup
- Merging Record and Task objects, step 4.
This commit is contained in:
@@ -39,18 +39,3 @@
|
|||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Record::Record ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Record::Record (const std::string& input)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Record::~Record ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,6 @@
|
|||||||
|
|
||||||
class Record : public std::map <std::string, Att>
|
class Record : public std::map <std::string, Att>
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
Record (); // Default constructor
|
|
||||||
Record (const std::string&); // Copy constructor
|
|
||||||
virtual ~Record (); // Destructor
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
24
src/Task.cpp
24
src/Task.cpp
@@ -28,6 +28,7 @@
|
|||||||
#define L10N // Localization complete.
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Nibbler.h>
|
#include <Nibbler.h>
|
||||||
@@ -55,11 +56,8 @@ Task::Task ()
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Task::Task (const Task& other)
|
Task::Task (const Task& other)
|
||||||
: Record (other)
|
|
||||||
, id (other.id)
|
|
||||||
, urgency_value (other.urgency_value)
|
|
||||||
, recalc_urgency (other.recalc_urgency)
|
|
||||||
{
|
{
|
||||||
|
*this = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -67,7 +65,8 @@ Task& Task::operator= (const Task& other)
|
|||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
Record::operator= (other);
|
std::map <std::string, Att>::operator= (other);
|
||||||
|
|
||||||
id = other.id;
|
id = other.id;
|
||||||
urgency_value = other.urgency_value;
|
urgency_value = other.urgency_value;
|
||||||
recalc_urgency = other.recalc_urgency;
|
recalc_urgency = other.recalc_urgency;
|
||||||
@@ -83,7 +82,7 @@ bool Task::operator== (const Task& other)
|
|||||||
if (size () != other.size ())
|
if (size () != other.size ())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::map <std::string, Att>::iterator att;
|
Task::iterator att;
|
||||||
for (att = this->begin (); att != this->end (); ++att)
|
for (att = this->begin (); att != this->end (); ++att)
|
||||||
if (att->second.name () != "uuid")
|
if (att->second.name () != "uuid")
|
||||||
if (att->second.value () != other.get (att->second.name ()))
|
if (att->second.value () != other.get (att->second.name ()))
|
||||||
@@ -174,7 +173,7 @@ bool Task::has (const std::string& name) const
|
|||||||
std::vector <Att> Task::all ()
|
std::vector <Att> Task::all ()
|
||||||
{
|
{
|
||||||
std::vector <Att> all;
|
std::vector <Att> all;
|
||||||
std::map <std::string, Att>::iterator i;
|
Task::iterator i;
|
||||||
for (i = this->begin (); i != this->end (); ++i)
|
for (i = this->begin (); i != this->end (); ++i)
|
||||||
all.push_back (i->second);
|
all.push_back (i->second);
|
||||||
|
|
||||||
@@ -269,7 +268,7 @@ void Task::setStatus (Task::status status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Attempt an FF4 parse first, using Record::parse, and in the event of an error
|
// Attempt an FF4 parse first, using Task::parse, and in the event of an error
|
||||||
// try a legacy parse (F3, FF2). Note that FF1 is no longer supported.
|
// try a legacy parse (F3, FF2). Note that FF1 is no longer supported.
|
||||||
//
|
//
|
||||||
// start --> [ --> Att --> ] --> end
|
// start --> [ --> Att --> ] --> end
|
||||||
@@ -286,7 +285,6 @@ void Task::parse (const std::string& input)
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Record::parse (copy);
|
|
||||||
clear ();
|
clear ();
|
||||||
|
|
||||||
Nibbler n (copy);
|
Nibbler n (copy);
|
||||||
@@ -510,7 +508,7 @@ std::string Task::composeF4 () const
|
|||||||
std::string ff4 = "[";
|
std::string ff4 = "[";
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
std::map <std::string, Att>::const_iterator it;
|
Task::const_iterator it;
|
||||||
for (it = this->begin (); it != this->end (); ++it)
|
for (it = this->begin (); it != this->end (); ++it)
|
||||||
{
|
{
|
||||||
if (it->second.value () != "")
|
if (it->second.value () != "")
|
||||||
@@ -632,7 +630,7 @@ std::string Task::composeJSON (bool include_id /*= false*/) const
|
|||||||
// First the non-annotations.
|
// First the non-annotations.
|
||||||
int attributes_written = 0;
|
int attributes_written = 0;
|
||||||
int annotation_count = 0;
|
int annotation_count = 0;
|
||||||
std::map <std::string, Att>::const_iterator i;
|
Task::const_iterator i;
|
||||||
for (i = this->begin (); i != this->end (); ++i)
|
for (i = this->begin (); i != this->end (); ++i)
|
||||||
{
|
{
|
||||||
if (attributes_written)
|
if (attributes_written)
|
||||||
@@ -727,7 +725,7 @@ void Task::getAnnotations (std::vector <Att>& annotations) const
|
|||||||
{
|
{
|
||||||
annotations.clear ();
|
annotations.clear ();
|
||||||
|
|
||||||
Record::const_iterator ci;
|
Task::const_iterator ci;
|
||||||
for (ci = this->begin (); ci != this->end (); ++ci)
|
for (ci = this->begin (); ci != this->end (); ++ci)
|
||||||
if (ci->first.substr (0, 11) == "annotation_")
|
if (ci->first.substr (0, 11) == "annotation_")
|
||||||
annotations.push_back (ci->second);
|
annotations.push_back (ci->second);
|
||||||
@@ -762,7 +760,7 @@ void Task::addAnnotation (const std::string& description)
|
|||||||
void Task::removeAnnotations ()
|
void Task::removeAnnotations ()
|
||||||
{
|
{
|
||||||
// Erase old annotations.
|
// Erase old annotations.
|
||||||
Record::iterator i = this->begin ();
|
Task::iterator i = this->begin ();
|
||||||
while (i != this->end ())
|
while (i != this->end ())
|
||||||
{
|
{
|
||||||
if (i->first.substr (0, 11) == "annotation_")
|
if (i->first.substr (0, 11) == "annotation_")
|
||||||
|
|||||||
@@ -28,10 +28,13 @@
|
|||||||
#define INCLUDED_TASK
|
#define INCLUDED_TASK
|
||||||
#define L10N // Localization complete.
|
#define L10N // Localization complete.
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Record.h>
|
#include <stdio.h>
|
||||||
|
#include <Att.h>
|
||||||
|
|
||||||
class Task : public Record
|
class Task : public std::map <std::string, Att>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Task (); // Default constructor
|
Task (); // Default constructor
|
||||||
|
|||||||
Reference in New Issue
Block a user