• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

ktimetracker

karmutility.cpp

Go to the documentation of this file.
00001 /*
00002  *     Copyright (C) 2007 by Thorsten Staerk <dev@staerk.de>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation; either version 2 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License along
00015  *   with this program; if not, write to the
00016  *      Free Software Foundation, Inc.
00017  *      51 Franklin Street, Fifth Floor
00018  *      Boston, MA  02110-1301  USA.
00019  *
00020  */
00021 
00022 #include "karmutility.h"
00023 
00024 #include <KGlobal>
00025 #include <KLocale>
00026 
00027 #include <math.h>
00028 #include <stdlib.h>
00029 #include <X11/Xlib.h>
00030 #include <fixx11h.h>
00031 
00032 QString getFocusWindow()
00033 {
00034   Display *display = XOpenDisplay( 0 );
00035   char *name;
00036   Window window = 0;
00037   int i = 0;
00038   XGetInputFocus( display, &window, &i );
00039   XFetchName( display, window, &name );
00040   XCloseDisplay( display );
00041 
00042   return QString( name );
00043 }
00044 
00045 QString formatTime( double minutes, bool decimal )
00046 /* 
00047 Delivers a formatted time. E.g. 30 seconds are 0.5 minutes. 
00048 The output of formatTiMe(0.5,true) is 0.008333, because 0.5 minutes are 0.008333 hours.
00049 The output of formatTiMe(0.5,false) is 0:01, because 0.5 minutes are 0:01 hours rounded.
00050 */
00051 {
00052   kDebug(5970) << "Entering function(minutes=" << minutes << ",decimal=" << decimal << ");";
00053   QString time;
00054   if ( decimal ) 
00055   {
00056     time.sprintf( "%.2f", minutes / 60.0 );
00057     time.replace( '.', KGlobal::locale()->decimalSymbol() );
00058   }
00059   else time.sprintf("%s%ld:%02ld",
00060     (minutes < 0) ? KGlobal::locale()->negativeSign().toUtf8().data() : "",
00061     labs(minutes / 60), labs(((int) round(minutes)) % 60));
00062   return time;
00063 }

ktimetracker

Skip menu "ktimetracker"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal