Commit 3cefdcdc authored by Stephan Kulow's avatar Stephan Kulow
Browse files

Coolo: imported karm

svn path=/trunk/kdeutils/karm/; revision=278
parent 25a52f26
BUGS
----
Lots.
please report bugs to taj@kde.org or to kde-bugs@kde.org.
# This is a sample Makefile.in
# @CXXFLAGS@ : is set to -g -Wall (when debuging) or -O2 -Wall (when not)
# @all_includes@ : is set to all needed include paths for QT, KDE and X11
# -I.. : needed for config.h
CXXFLAGS= @CXXFLAGS@ @all_includes@ -DHAVE_CONFIG_H -I..
# @LDFLAGS@ : is set to -s (when not debuging) for stripping
# @all_libra.@ : is set to all needed libraries paths for QT, KDE and X11
# you need also @LIBSOCKET@, if you link with -lkfm
LDFLAGS = @LDFLAGS@ @all_libraries@ -lkdecore -lkdeui -lqt -lXext -lX11
# both are clear, I think
CXX = @CXX@
MOC = @MOC@
############# INSTALL #################
install = @INSTALL@
INSTALL = $(install) -m 0755
INSTALL_DATA = $(install) -m 0644
INSTALL_DIR = $(install) -d -m 0755
INSTALL_DIR_PRIVATE = $(install) -d -m 0700
prefix = @prefix@
KDEINC = $(prefix)/include
BINDIR = $(prefix)/bin
LIBDIR = $(prefix)/lib
PICSDIR = $(LIBDIR)/pics
APPSDIR = $(prefix)/apps
########### File Formats ###########
.SUFFIXES: .cpp
.cpp.o:
$(CXX) -c $(CXXFLAGS) $<
%.moc: %.h
$(MOC) $< -o $@
########## Files #####################
OBJECTS = adddata.o adddlg.o karm.o main.o task.o top.o
SRCMETA = adddata.moc adddlg.moc karm.moc task.moc top.moc
TARGET = karm
DOCDIR = $(prefix)/doc/HTML/$(TARGET)
DOCFILES= karm.html scrn.html karm.gif
######### build rules ################
all: Makefile $(TARGET)
Makefile: Makefile.in
cd .. && CONFIG_FILES=karm/$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(TARGET): $(SRCMETA) $(OBJECTS)
$(CXX) $(OBJECTS) -o $(TARGET) $(LDFLAGS)
clean:
rm -f *.o *.bak *~ *% #*
rm -f $(SRCMETA) $(TARGET)
distclean: clean
rm -f Makefile
install: all
$(INSTALL_DIR) $(BINDIR)
$(INSTALL) $(TARGET) $(BINDIR)
$(INSTALL_DIR) $(DOCDIR)
@for i in $(DOCFILES) ; do \
echo $(INSTALL_DATA) ./doc/$$i $(DOCDIR) ; \
$(INSTALL_DATA) ./doc/$$i $(DOCDIR) ; \
done
$(INSTALL_DATA) support/clock.xpm $(PICSDIR)
$(INSTALL_DIR) $(APPSDIR)/Utilities
$(INSTALL_DATA) support/KArm.kdelnk $(APPSDIR)/Utilities
# DO NOT DELETE THIS LINE -- make depend depends on it.
KArm 0.1
--------
In my day, I may have to work on several different projects and keep track
separately of how much time I spent working on each project. If you are
like me, then KArm is for you.
KArm is a time tracker. You can enter a list of "tasks", start KArm's clock,
and it will count the number of minutes you spend on the highlighted task.
KArm was inspired by Harald Tveit Alvestrand's very useful utility called
titrax, the only failing of which is that it is based on the Xt toolkit. One
day KArm will do all that titrax does, but not today.
The word "karm", in my mother tongue Punjabi, means "work".
There is a screenshot at
http://www.ph.unimelb.edu.au/~ssk/kde/karm/karm.gif
and is installed with the included (sparse) documentation.
/**********************************************************************
--- Dlgedit generated file ---
File: adddata.cpp
Last generated: Fri Jun 20 07:42:44 1997
DO NOT EDIT!!! This file will be automatically
regenerated by dlgedit. All changes will be lost.
*********************************************************************/
#include "adddata.h"
#define Inherited QDialog
#include <qframe.h>
#include <qlabel.h>
KAddDlgData::KAddDlgData
(
QWidget* parent,
const char* name
)
:
Inherited( parent, name )
{
QFrame* tmpQFrame;
tmpQFrame = new QFrame( this, "Frame_1" );
tmpQFrame->setGeometry( 10, 10, 280, 90 );
tmpQFrame->setFrameStyle( 34 );
QLabel* tmpQLabel;
tmpQLabel = new QLabel( this, "Label_1" );
tmpQLabel->setGeometry( 20, 20, 100, 30 );
tmpQLabel->setText( "Task Name" );
tmpQLabel->setAlignment( 265 );
tmpQLabel->setMargin( -1 );
tmpQLabel = new QLabel( this, "Label_2" );
tmpQLabel->setGeometry( 20, 60, 100, 30 );
tmpQLabel->setText( "Accumutated time (in minutes)" );
tmpQLabel->setAlignment( 1289 );
tmpQLabel->setMargin( -1 );
_taskName = new QLineEdit( this, "LineEdit_1" );
_taskName->setGeometry( 130, 20, 150, 30 );
_taskName->setText( "" );
_taskName->setMaxLength( 32767 );
_taskName->setEchoMode( QLineEdit::Normal );
_taskName->setFrame( TRUE );
_taskTime = new QLineEdit( this, "LineEdit_2" );
_taskTime->setGeometry( 130, 60, 150, 30 );
_taskTime->setText( "" );
_taskTime->setMaxLength( 32767 );
_taskTime->setEchoMode( QLineEdit::Normal );
_taskTime->setFrame( TRUE );
_okButton = new QPushButton( this, "PushButton_1" );
_okButton->setGeometry( 40, 110, 100, 30 );
connect( _okButton, SIGNAL(clicked()), SLOT(okClicked()) );
_okButton->setText( "&Ok" );
_okButton->setAutoRepeat( FALSE );
_okButton->setAutoResize( FALSE );
_cancelButton = new QPushButton( this, "PushButton_2" );
_cancelButton->setGeometry( 160, 110, 100, 30 );
connect( _cancelButton, SIGNAL(clicked()), SLOT(cancelClicked()) );
_cancelButton->setText( "&Cancel" );
_cancelButton->setAutoRepeat( FALSE );
_cancelButton->setAutoResize( FALSE );
resize( 300, 150 );
}
KAddDlgData::~KAddDlgData()
{
}
void KAddDlgData::okClicked()
{
}
void KAddDlgData::cancelClicked()
{
}
/**********************************************************************
--- Dlgedit generated file ---
File: adddata.h
Last generated: Fri Jun 20 07:42:44 1997
DO NOT EDIT!!! This file will be automatically
regenerated by dlgedit. All changes will be lost.
*********************************************************************/
#ifndef KAddDlgData_included
#define KAddDlgData_included
#include <qdialog.h>
#include <qlined.h>
#include <qpushbt.h>
class KAddDlgData : public QDialog
{
Q_OBJECT
public:
KAddDlgData
(
QWidget* parent = NULL,
const char* name = NULL
);
virtual ~KAddDlgData();
public slots:
virtual void cancelClicked();
virtual void okClicked();
protected slots:
protected:
QLineEdit* _taskName;
QLineEdit* _taskTime;
QPushButton* _okButton;
QPushButton* _cancelButton;
};
#endif // KAddDlgData_included
/**********************************************************************
--- Dlgedit generated file ---
File: adddlg.cpp
Last generated: Fri Jun 20 07:29:11 1997
*********************************************************************/
#include "adddlg.moc"
#include "adddata.moc"
#define Inherited KAddDlgData
KarmAddDlg::KarmAddDlg
(
QWidget* parent,
const char* name
)
:
Inherited( parent, name )
{
setCaption( "Karm: New Task" );
}
KarmAddDlg::~KarmAddDlg()
{
}
void KarmAddDlg::setTask( const char *name, long time )
{
QString timeStr;
_taskName->setText( name );
_taskTime->setText( timeStr.setNum( time ) );
}
/**********************************************************************
--- Dlgedit generated file ---
File: adddlg.h
Last generated: Fri Jun 20 07:29:11 1997
*********************************************************************/
#ifndef KarmAddDlg_included
#define KarmAddDlg_included
#include<stdlib.h>
#include "adddata.h"
///
class KarmAddDlg : public KAddDlgData
{
Q_OBJECT
public:
KarmAddDlg
(
QWidget* parent = NULL,
const char* name = NULL
);
virtual ~KarmAddDlg();
///
void setTask(const char *name, long time);
///
const char *taskName() const
{ return _taskName->text(); };
///
long taskTime() const
{ return atol( _taskTime->text() ); };
signals:
/** raised on click of Ok or Cancel.
* TRUE if Ok clicked, FALSE if Cancel clicked.
*/
void finished( bool );
protected slots:
///
void cancelClicked()
{ emit finished( FALSE ); };
///
void okClicked()
{ emit finished( TRUE ); };
};
#endif // KarmAddDlg_included
<!DOCTYPE HTML PUBLIC "-//SoftQuad//DTD HTML 3.2 + extensions for HoTMetaL PRO 3.0(U) 19961211//EN"
"hmpro3.dtd">
<HTML>
<HEAD>
<TITLE>KArm</TITLE></HEAD>
<BODY>
<TABLE BORDER="0" WIDTH="100%">
<TR>
<TD VALIGN="BASELINE" ALIGN="LEFT">
<H2>KArm Help</H2></TD>
<TD VALIGN="BASELINE" ALIGN="RIGHT"><SMALL>KArm 0.1</SMALL></TD></TR></TABLE>
<HR>
<OL>
<LI><A HREF="#what">What is KArm?</A></LI>
<LI><A HREF="#where">From where do I get KArm?</A></LI>
<LI><A HREF="#using">Using KArm</A></LI>
<LI><A HREF="#contact">Contact Info</A></LI></OL>
<HR>
<OL>
<LI><STRONG><A NAME="what">What is KArm?</A></STRONG>
<P>In my day, I may have to work on several different project and keep track
separately of how much time I spent working on each project. If you are like me,
then KArm is for you.</P>
<P>KArm is a <I>time tracker</I>. You can enter a list of &quot;tasks&quot;,
start KArm's clock, and it will count the number of minutes you spend on the
highlighted task.</P>
<P>KArm was inspired by <A HREF="http://domen.uninett.no/~hta/">Harald Tveit
Alvestrand's</A> very useful utility called
<A HREF="http://domen.uninett.no/~hta/titrax/TimeTracker.html">titrax</A>, the
only failing of which is that it is based on the Xt toolkit. One day KArm will
do all that titrax does, but not today.</P>
<P>The word <I>karm</I>, in my mother-tongue Punjabi, means <I>work</I>.</P>
<P>Image: <A HREF="scrn.html">A KArm screenshot</A></P></LI>
<LI><STRONG><A NAME="where">From where do I get KArm?</A></STRONG>
<P>The latest version of KArm is <I>0.1</I>. It can be fetched from</P>
<UL>
<LI>...the <A HREF="http://www.kde.org/">KDE</A> FTP site and mirrors, in
<A HREF="ftp://ftp.kde.org/pub/kde/apps/pim/">/pub/kde/apps/pim</A>.</LI>
<LI>...the author's FTP repository, at
<A HREF="ftp://ftp.ph.unimelb.edu.au/pub/users/taj/kde/">ftp://ftp.ph.unimelb.edu.au/pub/users/taj/kde</A></LI></UL>
<P>You will also require a computer running the X Window System, UNIX and the
<A HREF="http://www.kde.org/">KDE</A> and <A HREF="http://www.troll.no/">Qt</A>
libraries. </P>
<P>So far, KArm has only been tested on Linux/x86 with XFree86, but it should
work on most other KDE-enabled platforms without much tinkering.</P></LI>
<LI><STRONG><A NAME="using">Using KArm</A></STRONG>
<P>Tasks can be created by clicking the New Task tool on the toolbar, or
selecting the Task/New menu option. </P>
<P>Start the clock by clicking the clock icon on the toolbar or selecting the
Task/New menu option.</P>
<P>Tasks and their time summaries will be automatically saved on normal
termination of the program.</P> </LI>
<LI><STRONG>Contact Info</STRONG>
<P>Author and Maintainer: Sirtaj Singh Kang</P>
<UL>
<LI>email: <A HREF="mailto:taj@kde.org">taj@kde.org</A></LI>
<LI>web:<A HREF="http://www.ph.unimelb.edu.au/~ssk/">http://www.ph.unimelb.edu.au/~ssk/</A></LI></UL></LI></OL></BODY></HTML>
<!DOCTYPE HTML PUBLIC "-//SoftQuad//DTD HTML 3.2 + extensions for HoTMetaL PRO 3.0(U) 19961211//EN"
"hmpro3.dtd">
<HTML>
<HEAD>
<TITLE>KArm 0.1 Screenshot</TITLE></HEAD>
<BODY><IMG SRC="karm.gif" ALT="KArm Screenshot"></BODY></HTML>
Begin3
Title: karm
Version: 0.1
Entered-Date: Fri, 20 June 1997
Description: KDE/Qt based personal time tracker
Keywords: KDE Qt X11 PIM time tracker titrax
Author: Sirtaj Singh Kang (ssk@physics.unimelb.edu.au)
Maintained-by: Sirtaj Singh Kang (ssk@physics.unimelb.edu.au)
Primary-site: ftp://ftp.ph.unimelb.edu.au/pub/users/taj/kde/
Alternate-site: ftp://ftp.kde.org/pub/kde/apps/pim/
Original-site: ftp://ftp.ph.unimelb.edu.au/pub/users/taj/kde/
Platform: KDE-enabled platforms (X11, UNIX, KDE and Qt libs)
End
#include <stdlib.h>
#include <qlistbox.h>
#include <qfileinf.h>
#include <qlayout.h>
#include<kpanner.h>
#include<kmenubar.h>
#include<ktoolbar.h>
#include<kapp.h>
#include<Kconfig.h>
#include<kmsgbox.h>
#include "task.h"
#include "karm.moc"
#include "adddlg.h"
Karm::Karm( QWidget *parent )
: KPanner( parent )
{
QBoxLayout *layout;
_timerRunning = FALSE;
_addDlg = 0;
_editDlg = 0;
_broker = new TaskBroker;
layout = new QBoxLayout( child0(), QBoxLayout::LeftToRight );
_timeList = new QListBox( child0() );
layout->addWidget( _timeList );
layout = new QBoxLayout( child1(), QBoxLayout::LeftToRight );
_nameList = new QListBox( child1() );
layout->addWidget( _nameList );
_timeStr = new char[50];
_broker->moveCursor( 0 );
connect(_nameList, SIGNAL( highlighted(int) ), this, SLOT(moveTo(int)));
connect(_timeList, SIGNAL( highlighted(int) ), this, SLOT(moveTo(int)));
setSeparator( 10 );
startClock();
}
Karm::~Karm()
{
save();
delete _broker;
delete[] _timeStr;
}
void Karm::load()
{
QFileInfo info;
KConfig *config = KApplication::getKApplication()->getConfig();
config->setGroup( "Karm" );
if( !config->hasKey("DataPath") ) {
QString defaultPath( getenv("HOME") );
defaultPath += "/.kde/karmdata.txt";
// save it
config->writeEntry("DataPath", defaultPath, true );
config->sync();
}
info.setFile( config->readEntry( "DataPath" ) );
if( info.exists() ) {
_broker->readFromFile( info.filePath() );
fillListBoxes();
return;
}
}
void Karm::save()
{
KConfig *config = KApplication::getKApplication()->getConfig();
config->setGroup("Karm");
if( !_broker->writeToFile( config->readEntry("DataPath") ) ) {
KMsgBox::message(0, "Karm: Save error",
"There was an error trying to save your data file.\n"
"Time accumulated this session will NOT be saved!\n",
KMsgBox::STOP, "Oh No!");
}
}
void Karm::stopClock()
{
if( _timerRunning ) {
killTimer( _timerId );
_timerRunning = FALSE;
emit timerStopped();
}
}
void Karm::startClock()
{
if( !_timerRunning && (_broker->count() > 0)) {
_timerId = startTimer( 60000 );
_timerRunning = TRUE;
emit timerStarted();
}
}
void Karm::moveTo( int position )
{
_nameList->setCurrentItem( position );
_timeList->setCurrentItem( position );
_broker->moveTo( position );
}
void Karm::fillListBoxes()
{
int taskCount = _broker->count();
_timeList->clear();
_nameList->clear();
if( taskCount == 0 )
return;
_broker->top();
do {
Task *task = _broker->currentTask();
formatTime( _timeStr, task->time() );
_timeList->insertItem( _timeStr );
_nameList->insertItem( task->name() );
_broker->next();
} while( --taskCount );
_broker->top();
_nameList->setCurrentItem( 0 );
_timeList->setCurrentItem( 0 );
}
void Karm::timerEvent( QTimerEvent *ev )
{
KPanner::timerEvent( ev );
if ( _timerRunning && ev->timerId() == _timerId ) {
_broker->currentTask()->incrementTime( 1 );
updateCurrentItem();
emit timerTick();
}
}
void Karm::updateCurrentItem()
{
formatTime( _timeStr, _broker->currentTask()->time() );
_timeList->changeItem( _timeStr, _broker->current() );
_nameList->changeItem( _broker->currentTask()->name(),
_broker->current() );
}
void Karm::newTask()
{
if( _addDlg == 0 ) {
// popup a dialog asking for info
_addDlg = new KarmAddDlg;
connect( _addDlg, SIGNAL( finished( bool ) ),
this, SLOT( createNewTask( bool ) ) );
}
_addDlg->show();
}
void Karm::createNewTask( bool retVal )
{
if( _addDlg == 0 ) {
warning("Karm::createNewTask called and there's no dialog!");
return;
}
if( retVal && strlen( _addDlg->taskName()) > 0) {
// create the new task
_broker->addTask( _addDlg->taskName(),
_addDlg->taskTime() );
fillListBoxes();