mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Integrated Priority column modification to the ColPriority object, from Task core.
This commit is contained in:
parent
55a8b157b1
commit
f39120dd73
6 changed files with 46 additions and 7 deletions
|
@ -27,6 +27,11 @@ Features
|
|||
+ The 'debug.tls' configuration variable takes an integer which corresponds to
|
||||
the GnuTLS log level. For debugging.
|
||||
+ File format 2 (used in version 0.9.3 - 1.5.0) is no longer supported.
|
||||
+ Migrated column processing code into Task.cpp for future use within each
|
||||
individual column object. Legacy code left in Task.cpp for column objects
|
||||
that are not yet modified.
|
||||
+ ColPriority.cpp - Migration of column modification code out of Task.cpp and
|
||||
into the individual column object.
|
||||
|
||||
Bugs
|
||||
+ #1196 Now builds on Hurd (thanks to Jakub Wilk).
|
||||
|
|
18
src/Task.cpp
18
src/Task.cpp
|
@ -1804,12 +1804,6 @@ void Task::modify (
|
|||
}
|
||||
}
|
||||
|
||||
// Priorities are converted to upper case.
|
||||
else if (name == "priority")
|
||||
{
|
||||
(*this).set (name, upperCase (value));
|
||||
}
|
||||
|
||||
// Dates are special, maybe.
|
||||
else if (column->type () == "date")
|
||||
{
|
||||
|
@ -1879,9 +1873,19 @@ void Task::modify (
|
|||
throw format (STRING_UDA_NUMERIC, result);
|
||||
}
|
||||
|
||||
// By default, just add/remove it.
|
||||
// Try to use modify method, otherwise just continue to the final option.
|
||||
else if (column->can_modify ())
|
||||
{
|
||||
// column->modify () contains the logic for the specific column
|
||||
// and returns the appropriate value for (*this).set ()
|
||||
if (column->validate (value))
|
||||
(*this).set (name, column->modify (value));
|
||||
else
|
||||
throw format (STRING_INVALID_MOD, name, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Final default action
|
||||
if (column->validate (value))
|
||||
(*this).set (name, value);
|
||||
else
|
||||
|
|
|
@ -119,3 +119,15 @@ void ColumnPriority::render (
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string ColumnPriority::modify (std::string& value)
|
||||
{
|
||||
return upperCase (value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnPriority::can_modify ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -44,6 +44,8 @@ public:
|
|||
void setStyle (const std::string&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
std::string modify (std::string&);
|
||||
bool can_modify ();
|
||||
|
||||
private:
|
||||
};
|
||||
|
|
|
@ -323,3 +323,17 @@ void Column::render (std::vector <std::string>&, Task&, int, Color&)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// No L10N.
|
||||
bool Column::can_modify ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// No L10N.
|
||||
std::string Column::modify (std::string& value)
|
||||
{
|
||||
throw std::string ("Virtual method Column::modify not overridden.");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -64,6 +64,8 @@ public:
|
|||
virtual void renderHeader (std::vector <std::string>&, int, Color&);
|
||||
virtual void render (std::vector <std::string>&, const std::string&, int, Color&);
|
||||
virtual void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
virtual bool can_modify ();
|
||||
virtual std::string modify (std::string&);
|
||||
|
||||
protected:
|
||||
std::string _name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue