File indexing completed on 2024-05-19 05:21:53

0001 /*
0002  * Copyright (C) 2007 by Thorsten Staerk <dev@staerk.de>
0003  * Copyright (C) 2019  Alexander Potashev <aspotashev@gmail.com>
0004  *
0005  *   This program is free software; you can redistribute it and/or modify
0006  *   it under the terms of the GNU General Public License as published by
0007  *   the Free Software Foundation; either version 2 of the License, or
0008  *   (at your option) any later version.
0009  *
0010  *   This program is distributed in the hope that it will be useful,
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  *   GNU General Public License for more details.
0014  *
0015  *   You should have received a copy of the GNU General Public License along
0016  *   with this program; if not, write to the
0017  *      Free Software Foundation, Inc.
0018  *      51 Franklin Street, Fifth Floor
0019  *      Boston, MA  02110-1301  USA.
0020  *
0021  */
0022 
0023 #ifndef KTIMETRACKERUTILITY_H
0024 #define KTIMETRACKERUTILITY_H
0025 
0026 #include <QString>
0027 
0028 #include <KCalendarCore/Incidence>
0029 
0030 /**
0031   Format time for output.  All times output on screen or report output go
0032   through this function.
0033   If the second argument is true, the time is output as a two-place decimal.
0034   Otherwise the format is hh:mi.
0035   Examples:
0036   30 seconds are 0.5 minutes.
0037   The output of formatTiMe(0.5,true) is 0.008333, because 0.5 minutes are 0.008333 hours.
0038   The output of formatTiMe(0.5,false) is 0:01, because 0.5 minutes are 0:01 hours rounded.
0039  */
0040 QString formatTime(double minutes, bool decimal = false);
0041 
0042 const int secsPerMinute = 60;
0043 
0044 enum KTIMETRACKER_Errors {
0045     KTIMETRACKER_ERR_GENERIC_SAVE_FAILED = 1,
0046     KTIMETRACKER_ERR_COULD_NOT_MODIFY_RESOURCE,
0047     KTIMETRACKER_ERR_MEMORY_EXHAUSTED,
0048     KTIMETRACKER_ERR_UID_NOT_FOUND,
0049     KTIMETRACKER_ERR_INVALID_DATE,
0050     KTIMETRACKER_ERR_INVALID_TIME,
0051     KTIMETRACKER_ERR_INVALID_DURATION,
0052 
0053     KTIMETRACKER_MAX_ERROR_NO = KTIMETRACKER_ERR_INVALID_DURATION
0054 };
0055 
0056 QString getCustomProperty(const KCalendarCore::Incidence::Ptr &incident, const QString &name);
0057 
0058 #endif