mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Cleanup
- 'measure' now accepts unsigned ints for 'minimum' and 'maximum' args.
This commit is contained in:
parent
40f2afeb8e
commit
19cc9177b9
42 changed files with 54 additions and 55 deletions
|
@ -136,11 +136,9 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
|||
break;
|
||||
|
||||
// Determine minimum and ideal width for this column.
|
||||
int min_;
|
||||
int ideal_;
|
||||
(*i)->measure (data[sequence[s]], min_, ideal_);
|
||||
unsigned int min = min_;
|
||||
unsigned int ideal = ideal_;
|
||||
unsigned int min;
|
||||
unsigned int ideal;
|
||||
(*i)->measure (data[sequence[s]], min, ideal);
|
||||
|
||||
if (min > global_min) global_min = min;
|
||||
if (ideal > global_ideal) global_ideal = ideal;
|
||||
|
|
|
@ -128,11 +128,9 @@ std::string ViewText::render ()
|
|||
for (unsigned int row = 0; row < _data.size (); ++row)
|
||||
{
|
||||
// Determine minimum and ideal width for this column.
|
||||
int min_;
|
||||
int ideal_;
|
||||
_columns[col]->measure (_data[row][col], min_, ideal_);
|
||||
unsigned int min = min_;
|
||||
unsigned int ideal = ideal_;
|
||||
unsigned int min;
|
||||
unsigned int ideal;
|
||||
_columns[col]->measure (_data[row][col], min, ideal);
|
||||
|
||||
if (min > global_min) global_min = min;
|
||||
if (ideal > global_ideal) global_ideal = ideal;
|
||||
|
|
|
@ -74,7 +74,7 @@ bool ColumnDate::validate (std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnDate::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
minimum = maximum = 0;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnDate ();
|
||||
|
||||
virtual bool validate (std::string&);
|
||||
virtual void measure (Task&, int&, int&);
|
||||
virtual void measure (Task&, unsigned int&, unsigned int&);
|
||||
virtual void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
};
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void ColumnDepends::setStyle (const std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnDepends::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
std::vector <Task> blocking;
|
||||
dependencyGetBlocking (task, blocking);
|
||||
|
@ -101,7 +101,7 @@ void ColumnDepends::measure (Task& task, int& minimum, int& maximum)
|
|||
join (all, " ", blocking_ids);
|
||||
maximum = all.length ();
|
||||
|
||||
int length;
|
||||
unsigned int length;
|
||||
for (i = blocking.begin (); i != blocking.end (); ++i)
|
||||
{
|
||||
length = format (i->id).length ();
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
bool validate (std::string&);
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -88,7 +88,7 @@ bool ColumnDescription::validate (std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnDescription::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
std::string description = task.get (_name);
|
||||
|
||||
|
@ -113,7 +113,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
|
|||
std::map <std::string, std::string>::iterator i;
|
||||
for (i = annos.begin (); i != annos.end (); i++)
|
||||
{
|
||||
int len = min_anno + 1 + i->second.length ();
|
||||
unsigned int len = min_anno + 1 + i->second.length ();
|
||||
if (len > maximum)
|
||||
maximum = len;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnDescription ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -74,7 +74,7 @@ void ColumnDue::setStyle (const std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnDue::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnDue::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
minimum = maximum = 0;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
bool validate (std::string&);
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
};
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ bool ColumnID::validate (std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnID::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnID::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
int length;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnID ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -62,7 +62,7 @@ bool ColumnIMask::validate (std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnIMask::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
minimum = maximum = task.get ("imask").length ();
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnIMask ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -62,7 +62,7 @@ bool ColumnMask::validate (std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnMask::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
minimum = maximum = task.get ("mask").length ();
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnMask ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -64,7 +64,7 @@ bool ColumnParent::validate (std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnParent::measure (Task&, int& minimum, int& maximum)
|
||||
void ColumnParent::measure (Task&, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
if (_style == "default" || _style == "long") minimum = maximum = 36;
|
||||
else if (_style == "short") minimum = maximum = 8;
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnParent ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -81,7 +81,7 @@ void ColumnPriority::setStyle (const std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnPriority::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnPriority::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
std::string priority = task.get (_name);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
bool validate (std::string&);
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -67,7 +67,7 @@ bool ColumnProject::validate (std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnProject::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
std::string project = task.get (_name);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnProject ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -78,7 +78,7 @@ void ColumnRecur::setStyle (const std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnRecur::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
if (_style == "default" ||
|
||||
_style == "duration")
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
bool validate (std::string&);
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -74,7 +74,7 @@ void ColumnScheduled::setStyle (const std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnScheduled::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnScheduled::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
minimum = maximum = 0;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
bool validate (std::string&);
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
};
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ void ColumnStart::setStyle (const std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnStart::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnStart::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
minimum = maximum = 0;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
bool validate (std::string&);
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
};
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void ColumnStatus::setStyle (const std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnStatus::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnStatus::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
Task::status status = task.getStatus ();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
bool validate (std::string&);
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -71,7 +71,7 @@ void ColumnString::setReport (const std::string& value)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
//
|
||||
void ColumnString::measure (const std::string& value, int& minimum, int& maximum)
|
||||
void ColumnString::measure (const std::string& value, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
if (_style == "left" ||
|
||||
_style == "right" ||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnString ();
|
||||
|
||||
void setReport (const std::string&);
|
||||
void measure (const std::string&, int&, int&);
|
||||
void measure (const std::string&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, const std::string&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -83,7 +83,7 @@ void ColumnTags::setStyle (const std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnTags::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
|
||||
if (_style == "indicator") minimum = maximum = context.config.get ("tag.indicator").length ();
|
||||
|
@ -101,10 +101,13 @@ void ColumnTags::measure (Task& task, int& minimum, int& maximum)
|
|||
split (all, tags, ',');
|
||||
std::vector <std::string>::iterator i;
|
||||
for (i = all.begin (); i != all.end (); ++i)
|
||||
if ((int)i->length () > minimum)
|
||||
{
|
||||
unsigned int length_ = i->length ();
|
||||
if (length_ > minimum)
|
||||
minimum = i->length () + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
bool validate (std::string&);
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -77,7 +77,7 @@ bool ColumnUDA::validate (std::string& value)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
//
|
||||
void ColumnUDA::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnUDA::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
minimum = maximum = 0;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnUDA ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
public:
|
||||
|
|
|
@ -64,7 +64,7 @@ bool ColumnUUID::validate (std::string& value)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnUUID::measure (Task&, int& minimum, int& maximum)
|
||||
void ColumnUUID::measure (Task&, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
if (_style == "default" || _style == "long") minimum = maximum = 36;
|
||||
else if (_style == "short") minimum = maximum = 8;
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
~ColumnUUID ();
|
||||
|
||||
bool validate (std::string&);
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -56,7 +56,7 @@ ColumnUrgency::~ColumnUrgency ()
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnUrgency::measure (Task& task, int& minimum, int& maximum)
|
||||
void ColumnUrgency::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
if (_style == "default" ||
|
||||
_style == "real")
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
ColumnUrgency ();
|
||||
~ColumnUrgency ();
|
||||
|
||||
void measure (Task&, int&, int&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
|
|
|
@ -299,14 +299,14 @@ bool Column::validate (std::string& input)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// No L10N.
|
||||
void Column::measure (const std::string&, int&, int&)
|
||||
void Column::measure (const std::string&, unsigned int&, unsigned int&)
|
||||
{
|
||||
throw std::string ("Virtual method Column::measure not overriden.");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// No L10N.
|
||||
void Column::measure (Task&, int&, int&)
|
||||
void Column::measure (Task&, unsigned int&, unsigned int&)
|
||||
{
|
||||
throw std::string ("Virtual method Column::measure not overriden.");
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ public:
|
|||
virtual void setReport (const std::string& value) { _report = value; }
|
||||
|
||||
virtual bool validate (std::string&);
|
||||
virtual void measure (const std::string&, int&, int&);
|
||||
virtual void measure (Task&, int&, int&);
|
||||
virtual void measure (const std::string&, unsigned int&, unsigned int&);
|
||||
virtual void measure (Task&, unsigned int&, unsigned int&);
|
||||
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&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue