summaryrefslogtreecommitdiff
path: root/core/pim/today/plugins/todolist/todopluginwidget.cpp
Unidiff
Diffstat (limited to 'core/pim/today/plugins/todolist/todopluginwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/plugins/todolist/todopluginwidget.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/pim/today/plugins/todolist/todopluginwidget.cpp b/core/pim/today/plugins/todolist/todopluginwidget.cpp
index 15081ec..0364f94 100644
--- a/core/pim/today/plugins/todolist/todopluginwidget.cpp
+++ b/core/pim/today/plugins/todolist/todopluginwidget.cpp
@@ -54,66 +54,73 @@ TodolistPluginWidget::~TodolistPluginWidget() {
54 delete todoLabel; 54 delete todoLabel;
55 delete layoutTodo; 55 delete layoutTodo;
56} 56}
57 57
58 58
59void TodolistPluginWidget::readConfig() { 59void TodolistPluginWidget::readConfig() {
60 Config cfg( "todaytodoplugin" ); 60 Config cfg( "todaytodoplugin" );
61 cfg.setGroup( "config" ); 61 cfg.setGroup( "config" );
62 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 ); 62 m_maxLinesTask = cfg.readNumEntry( "maxlinestask", 5 );
63 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 ); 63 m_maxCharClip = cfg.readNumEntry( "maxcharclip", 38 );
64} 64}
65 65
66void TodolistPluginWidget:: refresh() { 66void TodolistPluginWidget:: refresh() {
67 todo->reload();
68 getTodo();
69}
70
71void TodolistPluginWidget::reinitialize() {
72 readConfig();
73 todo->reload();
67 getTodo(); 74 getTodo();
68} 75}
69 76
70/** 77/**
71 * Get the todos 78 * Get the todos
72 */ 79 */
73void TodolistPluginWidget::getTodo() { 80void TodolistPluginWidget::getTodo() {
74 81
75 82
76 QString output; 83 QString output;
77 QString tmpout; 84 QString tmpout;
78 int count = 0; 85 int count = 0;
79 int ammount = 0; 86 int ammount = 0;
80 87
81 // get overdue todos first 88 // get overdue todos first
82 m_list = todo->overDue(); 89 m_list = todo->sorted( true, 3, 2, 1);
83 90
84 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 91 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
85 if (!(*m_it).isCompleted() && ( ammount < m_maxLinesTask ) ) { 92 if (!(*m_it).isCompleted() && ( ammount < m_maxLinesTask ) ) {
86 QString desc = (*m_it).summary(); 93 QString desc = (*m_it).summary();
87 if( desc.isEmpty() ) { 94 if( desc.isEmpty() ) {
88 desc = (*m_it).description(); 95 desc = (*m_it).description();
89 } 96 }
90 tmpout += "<font color=#e00000><b>-" + desc.mid( 0, m_maxCharClip ) + "</b></font><br>"; 97 tmpout += "<font color=#e00000><b>[" + QString("%1").arg((*m_it).priority() ) + "]" + desc.mid( 0, m_maxCharClip ) + "</b></font><br>";
91 ammount++ ; 98 ammount++ ;
92 } 99 }
93 } 100 }
94 101
95 // get total number of still open todos 102 // get total number of still open todos
96 m_list = todo->sorted( true, 1, 4, 1); 103 m_list = todo->sorted( true, 1, 4, 1);
97 104
98 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { 105 for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) {
99 count +=1; 106 count +=1;
100 // not the overdues, we allready got them, and not if we are 107 // not the overdues, we allready got them, and not if we are
101 // over the maxlines 108 // over the maxlines
102 if ( !(*m_it).isOverdue() && ( ammount < m_maxLinesTask ) ) { 109 if ( !(*m_it).isOverdue() && ( ammount < m_maxLinesTask ) ) {
103 QString desc = (*m_it).summary(); 110 QString desc = (*m_it).summary();
104 if( desc.isEmpty() ) { 111 if( desc.isEmpty() ) {
105 desc = (*m_it).description(); 112 desc = (*m_it).description();
106 } 113 }
107 tmpout += "<b>-</b>" + desc.mid( 0, m_maxCharClip ) + "<br>"; 114 tmpout += "<b> [" + QString("%1").arg((*m_it).priority() ) + "] </b>" + desc.mid( 0, m_maxCharClip ) + "<br>";
108 ammount++; 115 ammount++;
109 } 116 }
110 } 117 }
111 118
112 if ( count > 0 ) { 119 if ( count > 0 ) {
113 if( count == 1 ) { 120 if( count == 1 ) {
114 output += QObject::tr( "There is <b> 1</b> active task: <br>" ); 121 output += QObject::tr( "There is <b> 1</b> active task: <br>" );
115 } else { 122 } else {
116 output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count ); 123 output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count );
117 } 124 }
118 output += tmpout; 125 output += tmpout;
119 } else { 126 } else {