Bug 71189 - show day number and number of remaining days in year
Summary: show day number and number of remaining days in year
Status: RESOLVED FIXED
Alias: None
Product: korganizer
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Cornelius Schumacher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-24 21:20 UTC by Cornelius Schumacher
Modified: 2004-01-16 15:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cornelius Schumacher 2003-12-24 21:20:22 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

Chuck Davis <cjdavis@attglobal.net> writes:

I work in the construction industry.  One thing we have to do occasionally is 
know which day this is and how many are left in the year or how many days 
between given dates.  For instance (except for leap year) April 14 is 
104/261.
Comment 1 Cornelius Schumacher 2003-12-24 21:22:08 UTC
This can be implemented in the daynum plugin by adding a configuration option to also show the remaining days. Showing the difference between dates could be an additional menu item or an item in the context menu of the datenum widget.

Comment 2 cjdavis 2003-12-24 22:54:18 UTC
Subject: Re:  show day number and number of remaining days in year

I've been all over the site but find no reference to plug-ins.  Can you 
tell me where to find them?

Thanks.

Chuck Davis
Seattle,  WA

>This can be implemented in the daynum plugin by adding a configuration option to also show the remaining days. Showing the difference between dates could be an additional menu item or an item in the context menu of the datenum widget.
>
>  
>


Comment 3 Reinhold Kainhofer 2004-01-16 15:33:47 UTC
Subject: osnabrueck_branch: kdepim/korganizer/plugins/datenums

CVS commit by kainhofe: 

Extend korganizer's day number plugin to show not only the day of year, but also the number of days until the end of the year (e.g. 15 Jan 2005 would have: 15/351). Optionally, only one of them can be shown (default is to display only the day of year). This also meant adding a config dialog for the plugin.

CCMAIL: 71189-done@bugs.kde.org


  A            configdialog.cpp   1.1.2.1 [GPL (v2+)]
  A            configdialog.h   1.1.2.1 [GPL (v2+)]
  M +3 -3      Makefile.am   1.4.4.1
  M +32 -2     datenums.cpp   1.6.4.1
  M +1 -1      datenums.desktop   1.73.2.1
  M +5 -2      datenums.h   1.4.4.1


--- kdepim/korganizer/plugins/datenums/Makefile.am  #1.4:1.4.4.1
@@ -5,7 +5,7 @@
 kde_module_LTLIBRARIES = libkorg_datenums.la
 
-libkorg_datenums_la_SOURCES = datenums.cpp
+libkorg_datenums_la_SOURCES = configdialog.cpp datenums.cpp
 libkorg_datenums_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) 
-libkorg_datenums_la_LIBADD = $(LIB_KDECORE) $(top_builddir)/korganizer/libkorganizer.la
+libkorg_datenums_la_LIBADD = $(LIB_KDECORE) $(LIB_KDEUI) $(top_builddir)/korganizer/libkorganizer.la
 
 noinst_HEADERS = datenums.h

--- kdepim/korganizer/plugins/datenums/datenums.cpp  #1.6:1.6.4.1
@@ -22,5 +22,8 @@
 #include "datenums.h"
 #include "koglobals.h"
+#include <kconfig.h>
+#include <kstandarddirs.h>
 
+#include "configdialog.h"
 #include <kcalendarsystem.h>
 
@@ -37,8 +40,35 @@ extern "C" {
 }
 
+Datenums::Datenums()
+{
+  KConfig config( locateLocal( "config", "korganizerrc" ));
+  config.setGroup("Calendar/DateNum Plugin");
+  mDateNum = config.readNumEntry( "ShowDayNumbers", 0 );
+}
+
+void Datenums::configure(QWidget *parent)
+{
+  ConfigDialog *dlg = new ConfigDialog(parent);
+  dlg->exec();
+  delete dlg;
+}
+
 
 QString Datenums::shortText(const QDate &date)
 {
-  return QString::number(KOGlobals::self()->calendarSystem()->dayOfYear(date));
+  int doy = KOGlobals::self()->calendarSystem()->dayOfYear(date);
+  switch (mDateNum) {
+    case 1: // only days until end of year
+        return QString::number( KOGlobals::self()->calendarSystem()->daysInYear(date) - doy );
+        break;
+    case 2: // both day of year and days till end of year
+        return i18n("dayOfYear / daysTillEndOfYear", "%1 / %2").arg( doy )
+               .arg(KOGlobals::self()->calendarSystem()->daysInYear(date) - doy);
+        break;
+    case 0: // only day of year
+    default:
+        return QString::number( doy );
+  }
+  return QString::number( doy );
 }
 

--- kdepim/korganizer/plugins/datenums/datenums.desktop  #1.73:1.73.2.1
@@ -51,3 +51,3 @@
 Type=Service
 ServiceTypes=Calendar/Plugin,Calendar/Decoration
-X-KDE-KOrganizer-HasSettings=false
+X-KDE-KOrganizer-HasSettings=true

--- kdepim/korganizer/plugins/datenums/datenums.h  #1.4:1.4.4.1
@@ -29,10 +29,13 @@ using namespace KOrg;
 class Datenums : public CalendarDecoration {
   public:
-    Datenums() {}
+    Datenums();
     ~Datenums() {}
     
+    void configure(QWidget *parent);
     QString shortText(const QDate &);
     
     QString info();
+  protected:
+    int mDateNum;
 };