SVN_SILENT made messages (.desktop file)
[kdeadmin.git] / kcron / ktlisttasks.cpp
blobeff6021324ed2dc9bf2543a42d7faa94302cbff9
1 /***************************************************************************
2 * KT list view item tasks implementation. *
3 * -------------------------------------------------------------------- *
4 * Copyright (C) 1999, Gary Meyer <gary@meyer.net> *
5 * -------------------------------------------------------------------- *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 ***************************************************************************/
12 #include "ktlisttasks.h"
16 #include <klocale.h> // i18n()
17 #include <kglobalsettings.h>
19 #include "ctcron.h"
20 #include "cttask.h"
22 #include "kticon.h"
23 #include "ktlisttask.h"
24 #include "kttask.h"
25 #include "ktprint.h"
27 KTListTasks::KTListTasks(KTListItem* parent, CTCron* _ctcron) :
28 KTListItem(parent, 0, _ctcron)
30 refresh();
33 KTListTasks::KTListTasks(Q3ListView* parent, CTCron* _ctcron) :
34 KTListItem(parent, 0, _ctcron)
36 refresh();
39 QString KTListTasks::getDescription()
41 return i18n("Tasks");
44 void KTListTasks::create()
46 CTTask* temptask = new CTTask ("", "", getCTCron()->syscron);
47 KTTask* kttask = new KTTask(temptask,i18n("Edit Task"));
48 kttask->exec();
49 delete kttask;
50 if (temptask->dirty())
52 getCTCron()->task.push_back(temptask);
53 new KTListTask(this, getCTCron(), temptask); // Qt will clean up
55 else
57 delete temptask;
61 void KTListTasks::refresh()
63 setText(0, getDescription());
64 setPixmap(0, KTIcon::tasks(true));
67 void KTListTasks::print (KTPrint& printer) const
69 QFont stnd;
71 stnd = printer.getFont();
73 printer.setFont(QFont( KGlobalSettings::generalFont().family(), 10, QFont::Bold ));
74 printer.print (i18n("Task name:"), 1, KTPrint::alignTextLeft);
75 printer.print (i18n("Program:"), 2, KTPrint::alignTextCenter);
76 printer.print (i18n("Description:"),3,KTPrint::alignTextRight);
78 printer.setFont(stnd);
80 //firstChild() does not return null if there are no children, therefore
81 //we need to check the validation of the pointer without terminating
82 //the application. This maybe a bug in QT 1.44
84 if (this->childCount() ==0) {
85 printer.print(i18n("No tasks..."),1,KTPrint::alignTextLeft, false);
86 printer.levelColumns(20);
87 return;
90 KTListItem* ktli = (KTListItem*)this->firstChild();
91 Q_CHECK_PTR(ktli);
93 while (ktli) {
94 ktli->print(printer);
95 ktli = (KTListItem*)ktli->nextSibling();
96 printer.levelColumns();
98 printer.levelColumns(20);