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

korganizer

  • sources
  • kde-4.14
  • 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 
33 #include <KCalCore/CalFormat>
34 
35 #include <KCmdLineArgs>
36 #include <KDebug>
37 #include <KStandardDirs>
38 #include <KStartupInfo>
39 #include "kdepim-version.h"
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(KDEPIM_VERSION) ) );
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()->updateView();
62  }
63  first = false;
64  return 0;
65  }
66  first = false;
67 
68  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
69 
70  KPIM::ReminderClient::startDaemon();
71 
72  // No filenames given => all other args are meaningless, show main Window
73  if ( args->count() <= 0 ) {
74  processCalendar( KUrl() );
75  return 0;
76  }
77 
78  // If filenames were given as arguments, load them as calendars, one per window.
79  // Import, merge, or ask => we need the resource calendar window anyway.
80  processCalendar( KUrl() );
81  KOrg::MainWindow *korg = ActionManager::findInstance( KUrl() );
82  if ( !korg ) {
83  kError() << "Unable to find default calendar resources view.";
84  return -1;
85  }
86  // Check for import, merge or ask
87  if ( args->isSet( "import" ) ) {
88  for ( int i = 0; i < args->count(); ++i ) {
89  korg->actionManager()->importURL( args->url( i ), false );
90  }
91  } else if ( args->isSet( "merge" ) ) {
92  for ( int i = 0; i < args->count(); ++i ) {
93  korg->actionManager()->importURL( args->url( i ), true );
94  }
95  } else {
96  for ( int i = 0; i < args->count(); ++i ) {
97  korg->actionManager()->importCalendar( args->url( i ) );
98  }
99  }
100 
101  return 0;
102 }
103 
104 void KOrganizerApp::processCalendar( const KUrl &url )
105 {
106  KOrg::MainWindow *korg = ActionManager::findInstance( url );
107  if ( !korg ) {
108  bool hasDocument = !url.isEmpty();
109  korg = new KOrganizer();
110  korg->init( hasDocument );
111  korg->topLevelWidget()->show();
112 
113  kDebug() << url.url();
114 
115  if ( hasDocument ) {
116  korg->openURL( url );
117  } else {
118  // korg->view()->updateView();
119  }
120  } else {
121  korg->topLevelWidget()->show();
122  }
123 
124  // Handle window activation
125 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
126  KStartupInfo::setNewStartupId( korg->topLevelWidget(), startupId() );
127 #endif
128 }
129 
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
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
QString
KOrg::MainWindow
interface for korganizer main window
Definition: mainwindow.h:44
KOrg::MainWindow::view
virtual CalendarViewBase * view() const =0
KOrg::MainWindow::topLevelWidget
virtual QWidget * topLevelWidget()=0
Return widget whcih represents this main window.
QLatin1String
calendarview.h
QWidget::show
void show()
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:59 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
  • pimprint

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