File: TimerBoxControl.hh

package info (click to toggle)
workrave 1.10.54-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,992 kB
  • sloc: cpp: 46,596; ansic: 9,760; sh: 2,754; javascript: 1,935; makefile: 1,452; python: 973; xml: 672; objc: 455; perl: 113; cs: 70; sed: 16
file content (123 lines) | stat: -rw-r--r-- 3,516 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// TimerBoxControl.hh --- All timers
//
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2012, 2013 Rob Caelers & Raymond Penners
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

#ifndef TIMERBOXCONTROL_HH
#define TIMERBOXCONTROL_HH

#include <string>

#include "ICore.hh"
#include "IConfiguratorListener.hh"
#include "ITimerBoxView.hh"

using namespace workrave;

class TimerBoxControl : public IConfiguratorListener
{
public:
  TimerBoxControl(std::string name, ITimerBoxView &view);
  virtual ~TimerBoxControl();

  void init();
  void update();
  void force_cycle();
  void set_force_empty(bool s);

  static const std::string get_timer_config_key(std::string name, BreakId timer, const std::string &key);
  static int get_cycle_time(std::string name);
  static void set_cycle_time(std::string name, int time);
  static int get_timer_imminent_time(std::string name, BreakId timer);
  static void set_timer_imminent_time(std::string name, BreakId timer, int time);
  static int get_timer_slot(std::string name, BreakId timer);
  static void set_timer_slot(std::string name, BreakId timer, int slot);
  static int get_timer_flags(std::string name, BreakId timer);
  static void set_timer_flags(std::string name, BreakId timer, int flags);
  static bool is_enabled(std::string name);
  static void set_enabled(std::string name, bool enabled);

public:
  static const std::string CFG_KEY_TIMERBOX;
  static const std::string CFG_KEY_TIMERBOX_HORIZONTAL;
  static const std::string CFG_KEY_TIMERBOX_CYCLE_TIME;
  static const std::string CFG_KEY_TIMERBOX_POSITION;
  static const std::string CFG_KEY_TIMERBOX_FLAGS;
  static const std::string CFG_KEY_TIMERBOX_IMMINENT;
  static const std::string CFG_KEY_TIMERBOX_ENABLED;

  enum SlotType
  {
    BREAK_WHEN_IMMINENT = 1,
    BREAK_WHEN_FIRST = 2,
    BREAK_SKIP = 4,
    BREAK_EXCLUSIVE = 8,
    BREAK_DEFAULT = 16,
    BREAK_HIDE = 32
  };

private:
  // IConfiguratorListener
  void config_changed_notify(const std::string &key);
  void update_widgets();
  void init_table();
  void init_icon();

  void read_configuration();

  void init_slot(int slot);
  void cycle_slots();

private:
  //! View
  ITimerBoxView *view;

  //! Reconfigure the panel.
  bool reconfigure;

  //! Duration of each cycle.
  int cycle_time;

  //! Positions for the break timers.
  int break_position[BREAK_ID_SIZEOF];

  //! Flags for the break timers.
  int break_flags[BREAK_ID_SIZEOF];

  //! Imminent threshold for the timers.
  int break_imminent_time[BREAK_ID_SIZEOF];

  //! Computed slot contents.
  int break_slots[BREAK_ID_SIZEOF][BREAK_ID_SIZEOF];

  //! Current cycle for each slot.
  int break_slot_cycle[BREAK_ID_SIZEOF];

  //! Name
  std::string name;

  //! Last known operation mode
  OperationMode operation_mode;

  //!
  int force_duration;

  //! Never show any timers.
  bool force_empty;
};

#endif // TIMERBOXCONTROL_HH