summaryrefslogtreecommitdiffstats
path: root/kcron/ktlisttasks.cpp
blob: 65e909b6d2f48caa002dbc260266200892ec4906 (plain)
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
/***************************************************************************
 *   KT list view item tasks implementation.                               *
 *   --------------------------------------------------------------------  *
 *   Copyright (C) 1999, Gary Meyer <[email protected]>                       *
 *   --------------------------------------------------------------------  *
 *   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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#include "ktlisttasks.h"

#include <tqstring.h>

#include <tdelocale.h>  // i18n()
#include <tdeglobalsettings.h>

#include "ctcron.h"
#include "cttask.h"

#include "kticon.h"
#include "ktlisttask.h"
#include "kttask.h"
#include "ktprint.h"

KTListTasks::KTListTasks(KTListItem* parent, CTCron* _ctcron) :
  KTListItem(parent, 0, _ctcron)
{
  refresh();
}

KTListTasks::KTListTasks(TQListView* parent, CTCron* _ctcron) :
  KTListItem(parent, 0, _ctcron)
{
  refresh();
}

TQString KTListTasks::getDescription()
{
  return i18n("Tasks");
}

void KTListTasks::create()
{
  CTTask* temptask = new CTTask ("", "", getCTCron()->syscron);
  KTTask* kttask = new KTTask(temptask,i18n("Edit Task"));
  kttask->exec();
  delete kttask;
  if (temptask->dirty())
  {
    getCTCron()->task.push_back(temptask);
    new KTListTask(this, getCTCron(), temptask); // TQt will clean up
  }
  else
  {
    delete temptask;
  }
}

void KTListTasks::refresh()
{
  setText(0, getDescription());
  setPixmap(0, KTIcon::tasks(true));
}

void KTListTasks::print (KTPrint& printer) const
{
  TQFont stnd;

  stnd = printer.getFont();

  printer.setFont(TQFont( TDEGlobalSettings::generalFont().family(), 10, TQFont::Bold ));
  printer.print (i18n("Task name:"), 1, KTPrint::alignTextLeft);
  printer.print (i18n("Program:"), 2, KTPrint::alignTextCenter);
  printer.print (i18n("Description:"),3,KTPrint::alignTextRight);

  printer.setFont(stnd);

  //firstChild() does not return null if there are no children, therefore
  //we need to check the validation of the pointer without terminating
  //the application. This maybe a bug in QT 1.44

  if (this->childCount() ==0) {
    printer.print(i18n("No tasks..."),1,KTPrint::alignTextLeft, false);
    printer.levelColumns(20);
    return;
  }

  KTListItem* ktli = (KTListItem*)this->firstChild();
  TQ_CHECK_PTR(ktli);

  while (ktli) {
    ktli->print(printer);
    ktli = (KTListItem*)ktli->nextSibling();
    printer.levelColumns();
  }
  printer.levelColumns(20);
}