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

korganizer

  • sources
  • kde-4.12
  • kdepim
  • korganizer
koapp.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 1999 Preston Brown <pbrown@kde.org>
5  Copyright (c) 2000,2001,2003 Cornelius Schumacher <schumacher@kde.org>
6  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License along
19  with this program; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 
22  As a special exception, permission is given to link this program
23  with any edition of Qt, and distribute the resulting executable,
24  without including the source code for Qt in the source distribution.
25 */
26 
27 #include "koapp.h"
28 #include "actionmanager.h"
29 #include "calendarview.h"
30 #include "korganizer.h"
31 #include "reminderclient.h"
32 #include "version.h"
33 
34 #include <KCalCore/CalFormat>
35 
36 #include <KCmdLineArgs>
37 #include <KDebug>
38 #include <KStandardDirs>
39 #include <KStartupInfo>
40 
41 KOrganizerApp::KOrganizerApp() : KontactInterface::PimUniqueApplication()
42 {
43  QString prodId = QLatin1String("-//K Desktop Environment//NONSGML KOrganizer %1//EN");
44  KCalCore::CalFormat::setApplication( QLatin1String("KOrganizer"), prodId.arg( QLatin1String(korgVersion) ) );
45 
46  // icons shared by the KDE PIM applications
47  KGlobal::dirs()->addResourceType( "appicon", "data", "/kdepim/icons/" );
48 }
49 
50 KOrganizerApp::~KOrganizerApp()
51 {
52 }
53 
54 int KOrganizerApp::newInstance()
55 {
56  kDebug();
57  static bool first = true;
58  if ( isSessionRestored() && first ) {
59  KOrg::MainWindow *korg = ActionManager::findInstance( KUrl() );
60  if ( korg ) {
61  korg->view()->updateCategories();
62  korg->view()->updateView();
63  }
64  first = false;
65  return 0;
66  }
67  first = false;
68 
69  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
70 
71  KPIM::ReminderClient::startDaemon();
72 
73  // No filenames given => all other args are meaningless, show main Window
74  if ( args->count() <= 0 ) {
75  processCalendar( KUrl() );
76  return 0;
77  }
78 
79  // If filenames were given as arguments, load them as calendars, one per window.
80  // Import, merge, or ask => we need the resource calendar window anyway.
81  processCalendar( KUrl() );
82  KOrg::MainWindow *korg = ActionManager::findInstance( KUrl() );
83  if ( !korg ) {
84  kError() << "Unable to find default calendar resources view.";
85  return -1;
86  }
87  // Check for import, merge or ask
88  if ( args->isSet( "import" ) ) {
89  for ( int i = 0; i < args->count(); ++i ) {
90  korg->actionManager()->importURL( args->url( i ), false );
91  }
92  } else if ( args->isSet( "merge" ) ) {
93  for ( int i = 0; i < args->count(); ++i ) {
94  korg->actionManager()->importURL( args->url( i ), true );
95  }
96  } else {
97  for ( int i = 0; i < args->count(); ++i ) {
98  korg->actionManager()->importCalendar( args->url( i ) );
99  }
100  }
101 
102  return 0;
103 }
104 
105 void KOrganizerApp::processCalendar( const KUrl &url )
106 {
107  KOrg::MainWindow *korg = ActionManager::findInstance( url );
108  if ( !korg ) {
109  bool hasDocument = !url.isEmpty();
110  korg = new KOrganizer();
111  korg->init( hasDocument );
112  korg->topLevelWidget()->show();
113 
114  kDebug() << url.url();
115 
116  if ( hasDocument ) {
117  korg->openURL( url );
118  } else {
119  korg->view()->updateCategories();
120  // korg->view()->updateView();
121  }
122  } else {
123  korg->topLevelWidget()->show();
124  }
125 
126  // Handle window activation
127 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
128  KStartupInfo::setNewStartupId( korg->topLevelWidget(), startupId() );
129 #endif
130 }
131 
132 #include "koapp.moc"
KOrg::CalendarViewBase::updateCategories
virtual void updateCategories()=0
ActionManager::importCalendar
void importCalendar(const KUrl &url)
Definition: actionmanager.cpp:1854
ActionManager::importURL
bool importURL(const KUrl &url, bool merge)
Definition: actionmanager.cpp:937
KOrg::CalendarViewBase::updateView
virtual void updateView()=0
korgVersion
static const char korgVersion[]
Definition: version.h:30
KOrg::MainWindow::init
virtual void init(bool hasDocument)
Definition: mainwindow.cpp:34
KOrganizer
This is the main class for KOrganizer.
Definition: korganizer.h:52
actionmanager.h
KOrg::MainWindow::openURL
virtual bool openURL(const KUrl &url, bool merge=false)=0
Load calendar file from URL.
KOrg::MainWindow::actionManager
virtual ActionManager * actionManager()=0
Return ActionManager of this main window.
koapp.h
ActionManager::findInstance
static KOrg::MainWindow * findInstance(const KUrl &url)
Is there a instance with this URL?
Definition: actionmanager.cpp:1273
korganizer.h
KOrganizerApp::KOrganizerApp
KOrganizerApp()
Definition: koapp.cpp:41
KOrganizerApp::newInstance
int newInstance()
Create new instance of KOrganizer.
Definition: koapp.cpp:54
KOrganizerApp::~KOrganizerApp
~KOrganizerApp()
Definition: koapp.cpp:50
KOrg::MainWindow
interface for korganizer main window
Definition: mainwindow.h:44
KOrg::MainWindow::view
virtual CalendarViewBase * view() const =0
version.h
KOrg::MainWindow::topLevelWidget
virtual QWidget * topLevelWidget()=0
Return widget whcih represents this main window.
calendarview.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

korganizer

Skip menu "korganizer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal