• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GothenburgBitFactory / taskwarrior / 12343201393

15 Dec 2024 11:30PM UTC coverage: 84.419% (-1.1%) from 85.522%
12343201393

Pull #3724

github

web-flow
Merge 532931b9f into ddae5c4ba
Pull Request #3724: Support importing Taskwarrior v2.x data files

15 of 145 new or added lines in 4 files covered. (10.34%)

183 existing lines in 48 files now uncovered.

19289 of 22849 relevant lines covered (84.42%)

23168.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

24.24
/src/columns/ColRType.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included
13
// in all copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
//
23
// https://www.opensource.org/licenses/mit-license.php
24
//
25
////////////////////////////////////////////////////////////////////////////////
26

27
#include <cmake.h>
28
// cmake.h include header must come first
29

30
#include <ColRType.h>
31
#include <Context.h>
32
#include <format.h>
33
#include <shared.h>
34

35
#include <cctype>
36

37
////////////////////////////////////////////////////////////////////////////////
38
ColumnRType::ColumnRType() {
4,495✔
39
  _name = "rtype";
4,495✔
40
  _style = "default";
4,495✔
41
  _label = "Recurrence type";
4,495✔
42
  _modifiable = false;
4,495✔
43
  _styles = {"default", "indicator"};
13,485✔
44
  _examples = {"periodic", "chained"};
13,485✔
45
}
22,475✔
46

47
////////////////////////////////////////////////////////////////////////////////
48
// Overriden so that style <----> label are linked.
49
// Note that you can not determine which gets called first.
50
void ColumnRType::setStyle(const std::string& value) {
×
51
  Column::setStyle(value);
×
52

53
  if (_style == "indicator" && _label == "Recurrence type")
×
54
    _label = _label.substr(0, Context::getContext().config.get("rtype.indicator").length());
×
UNCOV
55
}
×
56

57
////////////////////////////////////////////////////////////////////////////////
58
// Set the minimum and maximum widths for the value.
59
void ColumnRType::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
×
60
  minimum = maximum = 0;
×
61
  if (task.has(_name)) {
×
62
    if (_style == "default")
×
63
      minimum = maximum = task.get(_name).length();
×
64
    else if (_style == "indicator")
×
65
      minimum = maximum = 1;
×
66
  }
UNCOV
67
}
×
68

69
////////////////////////////////////////////////////////////////////////////////
70
void ColumnRType::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
×
71
  if (task.has(_name)) {
×
72
    if (_style == "default")
×
73
      renderStringRight(lines, width, color, task.get(_name));
×
74

75
    else if (_style == "indicator") {
×
76
      std::string value{" "};
×
77
      value[0] = toupper(task.get(_name)[0]);
×
78
      renderStringRight(lines, width, color, value);
×
UNCOV
79
    }
×
80
  }
UNCOV
81
}
×
82

83
////////////////////////////////////////////////////////////////////////////////
84
bool ColumnRType::validate(const std::string& input) const {
×
85
  return input == "periodic" || input == "chained";
×
86
}
87

88
////////////////////////////////////////////////////////////////////////////////
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc