• 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
korganizer.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 1997, 1998, 1999 Preston Brown <preston.brown@yale.edu>
5  Fester Zigterman <F.J.F.ZigtermanRustenburg@student.utwente.nl>
6  Ian Dawes <iadawes@globalserve.net>
7  Laszlo Boloni <boloni@cs.purdue.edu>
8 
9  Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org>
10  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
11 
12  This program is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 2 of the License, or
15  (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License along
23  with this program; if not, write to the Free Software Foundation, Inc.,
24  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 
26  As a special exception, permission is given to link this program
27  with any edition of Qt, and distribute the resulting executable,
28  without including the source code for Qt in the source distribution.
29 */
30 
31 #include "korganizer.h"
32 #include "actionmanager.h"
33 #include "calendarview.h"
34 #include "kocore.h"
35 #include "koglobals.h"
36 #include "impl/korganizerifaceimpl.h"
37 
38 #include "libkdepim/progresswidget/progressstatusbarwidget.h"
39 #include "libkdepim/progresswidget/statusbarprogresswidget.h"
40 
41 
42 
43 #include <KAction>
44 #include <KActionCollection>
45 #include <KDebug>
46 #include <KShortcutsDialog>
47 #include <KStandardAction>
48 #include <KStatusBar>
49 
50 KOrganizer::KOrganizer() : KParts::MainWindow(), KOrg::MainWindow()
51 {
52  // Set this to be the group leader for all subdialogs - this means
53  // modal subdialogs will only affect this dialog, not the other windows
54  setAttribute( Qt::WA_GroupLeader );
55 
56  kDebug();
57  KOCore::self()->addXMLGUIClient( this, this );
58 // setMinimumSize(600,400); // make sure we don't get resized too small...
59 
60  mCalendarView = new CalendarView( this );
61  mCalendarView->setObjectName( QLatin1String("KOrganizer::CalendarView") );
62  setCentralWidget( mCalendarView );
63 
64  mActionManager = new ActionManager( this, mCalendarView, this, this, false, menuBar() );
65  (void)new KOrganizerIfaceImpl( mActionManager, this, "IfaceImpl" );
66 }
67 
68 KOrganizer::~KOrganizer()
69 {
70  delete mActionManager;
71 
72  KOCore::self()->removeXMLGUIClient( this );
73 }
74 
75 void KOrganizer::init( bool document )
76 {
77  setHasDocument( document );
78 
79  setComponentData( KGlobal::mainComponent() );
80 
81  // Create calendar object, which manages all calendar information associated
82  // with this calendar view window.
83  mActionManager->createCalendarAkonadi();
84 
85  mActionManager->init();
86  /*connect( mActionManager, SIGNAL(actionNewMainWindow(KUrl)),
87  SLOT(newMainWindow(KUrl)) );*/
88 
89  mActionManager->loadParts();
90 
91  initActions();
92  readSettings();
93 
94  KStatusBar *bar = statusBar();
95 
96  bar->insertItem( QString(), ID_GENERAL, 10 );
97  connect( bar, SIGNAL(pressed(int)), SLOT(statusBarPressed(int)) );
98 
99  KPIM::ProgressStatusBarWidget *progressBar = new KPIM::ProgressStatusBarWidget( statusBar(), this);
100 
101  bar->addPermanentWidget( progressBar->littleProgress() );
102 
103  connect( mActionManager->view(), SIGNAL(statusMessage(QString)),
104  SLOT(showStatusMessage(QString)) );
105 
106  setStandardToolBarMenuEnabled( true );
107  setTitle();
108 }
109 
110 void KOrganizer::newMainWindow( const KUrl &url )
111 {
112  KOrganizer *korg = new KOrganizer();
113  if ( url.isValid() || url.isEmpty() ) {
114  korg->init( true );
115  if ( mActionManager->importURL( url, false ) || url.isEmpty() ) {
116  korg->show();
117  } else {
118  delete korg;
119  }
120  } else {
121  korg->init( false );
122  korg->show();
123  }
124 }
125 
126 void KOrganizer::readSettings()
127 {
128  // read settings from the KConfig, supplying reasonable
129  // defaults where none are to be found
130 
131  KConfig *config = KOGlobals::self()->config();
132 
133  mActionManager->readSettings();
134 
135  config->sync();
136 }
137 
138 void KOrganizer::writeSettings()
139 {
140  kDebug();
141 
142  KConfig *config = KOGlobals::self()->config();
143 
144  mActionManager->writeSettings();
145  config->sync();
146 }
147 
148 void KOrganizer::initActions()
149 {
150  setStandardToolBarMenuEnabled( true );
151  createStandardStatusBarAction();
152 
153  KStandardAction::keyBindings( this, SLOT(slotEditKeys()), actionCollection() );
154  KStandardAction::configureToolbars( this, SLOT(configureToolbars()), actionCollection() );
155  KStandardAction::quit( this, SLOT(close()), actionCollection() );
156 
157  setXMLFile( QLatin1String("korganizerui.rc"), true );
158  createGUI( 0 );
159 
160  setAutoSaveSettings();
161 }
162 
163 void KOrganizer::slotEditKeys()
164 {
165  KShortcutsDialog::configure( actionCollection(),
166  KShortcutsEditor::LetterShortcutsAllowed );
167 }
168 
169 bool KOrganizer::queryClose()
170 {
171  kDebug();
172 
173  bool close = mActionManager->queryClose();
174 
175  // Write configuration. I don't know if it really makes sense doing it this
176  // way, when having opened multiple calendars in different CalendarViews.
177  if ( close ) {
178  writeSettings();
179  }
180 
181  return close;
182 }
183 
184 void KOrganizer::statusBarPressed( int id )
185 {
186  Q_UNUSED( id );
187 }
188 
189 void KOrganizer::showStatusMessage( const QString &message )
190 {
191  statusBar()->showMessage( message, 2000 );
192 }
193 
194 bool KOrganizer::openURL( const KUrl &url, bool merge )
195 {
196  return mActionManager->importURL( url, merge );
197 }
198 
199 bool KOrganizer::saveURL()
200 {
201  return mActionManager->saveURL();
202 }
203 
204 bool KOrganizer::saveAsURL( const KUrl & kurl )
205 {
206  return mActionManager->saveAsURL( kurl ) ;
207 }
208 
209 KUrl KOrganizer::getCurrentURL() const
210 {
211  return mActionManager->url();
212 }
213 
214 void KOrganizer::saveProperties( KConfigGroup &config )
215 {
216  return mActionManager->saveProperties( config );
217 }
218 
219 void KOrganizer::readProperties( const KConfigGroup &config )
220 {
221  return mActionManager->readProperties( config );
222 }
223 
224 KOrg::CalendarViewBase *KOrganizer::view() const
225 {
226  return mActionManager->view();
227 }
228 
229 void KOrganizer::setTitle()
230 {
231  QString title;
232  if ( !hasDocument() ) {
233  title = i18n( "Calendar" );
234  } else {
235  KUrl url = mActionManager->url();
236 
237  if ( !url.isEmpty() ) {
238  if ( url.isLocalFile() ) {
239  title = url.fileName();
240  } else {
241  title = url.prettyUrl();
242  }
243  } else {
244  title = i18n( "New Calendar" );
245  }
246 
247  if ( mCalendarView->isReadOnly() ) {
248  title += QLatin1String(" [") + i18nc( "the calendar is read-only", "read-only" ) + QLatin1Char(']');
249  }
250  }
251  if ( mCalendarView->isFiltered() ) {
252  title += QLatin1String(" - <") + mCalendarView->currentFilterName() + QLatin1String("> ");
253  }
254 
255  setCaption( title, false );
256 }
257 
ActionManager::importURL
bool importURL(const KUrl &url, bool merge)
Definition: actionmanager.cpp:937
koglobals.h
KOrganizer::saveURL
bool saveURL()
Save calendar file to URL of current calendar.
Definition: korganizer.cpp:199
ActionManager::readProperties
void readProperties(const KConfigGroup &)
Definition: actionmanager.cpp:1220
KOrganizer::getCurrentURL
KUrl getCurrentURL() const
Get current URL.
Definition: korganizer.cpp:209
KOrganizer::setTitle
void setTitle()
Sets title of window according to filename and modification state.
Definition: korganizer.cpp:229
ActionManager::saveProperties
void saveProperties(KConfigGroup &)
Definition: actionmanager.cpp:1210
KOrganizer
This is the main class for KOrganizer.
Definition: korganizer.h:52
actionmanager.h
CalendarView::isReadOnly
bool isReadOnly() const
query if the calendar is read-only.
Definition: calendarview.cpp:1747
CalendarView::currentFilterName
QString currentFilterName() const
Returns the name of the current filter.
Definition: calendarview.cpp:2045
CalendarView
This is the main calendar widget.
Definition: calendarview.h:99
KOrganizerIfaceImpl
Definition: korganizerifaceimpl.h:42
ActionManager::loadParts
void loadParts()
Definition: actionmanager.cpp:1599
korganizer.h
KOrganizer::slotEditKeys
void slotEditKeys()
Definition: korganizer.cpp:163
QObject::setObjectName
void setObjectName(const QString &name)
ActionManager::view
CalendarView * view() const
Definition: actionmanager.h:78
KOrganizer::saveProperties
void saveProperties(KConfigGroup &)
Definition: korganizer.cpp:214
QString
KOrg::MainWindow
interface for korganizer main window
Definition: mainwindow.h:44
KOrg::MainWindow::setHasDocument
void setHasDocument(bool d)
Definition: mainwindow.cpp:39
KOrg::MainWindow::hasDocument
bool hasDocument() const
Definition: mainwindow.cpp:44
KOrganizer::writeSettings
void writeSettings()
write current state to config file.
Definition: korganizer.cpp:138
KOrganizer::newMainWindow
void newMainWindow(const KUrl &)
Definition: korganizer.cpp:110
KOrganizer::showStatusMessage
void showStatusMessage(const QString &)
show status message
Definition: korganizer.cpp:189
ActionManager::saveAsURL
bool saveAsURL(const KUrl &kurl)
Save calendar file to URL.
Definition: actionmanager.cpp:1097
QLatin1Char
KOrganizer::readProperties
void readProperties(const KConfigGroup &)
Definition: korganizer.cpp:219
KOrganizer::KOrganizer
KOrganizer()
Definition: korganizer.cpp:50
KOGlobals::self
static KOGlobals * self()
Definition: koglobals.cpp:43
korganizerifaceimpl.h
ActionManager
The ActionManager creates all the actions in KOrganizer.
Definition: actionmanager.h:66
KOrganizer::readSettings
void readSettings()
using the KConfig associated with the kapp variable, read in the settings from the config file...
Definition: korganizer.cpp:126
ActionManager::readSettings
void readSettings()
Using the KConfig associated with the kapp variable, read in the settings from the config file...
Definition: actionmanager.cpp:791
QLatin1String
KOrganizer::saveAsURL
bool saveAsURL(const KUrl &kurl)
Save calendar file to URL.
Definition: korganizer.cpp:204
KOrganizer::queryClose
bool queryClose()
supplied so that close events close calendar properly.
Definition: korganizer.cpp:169
KOrganizer::initActions
void initActions()
Definition: korganizer.cpp:148
KOrganizer::init
void init(bool hasDocument)
Definition: korganizer.cpp:75
KOrganizer::~KOrganizer
virtual ~KOrganizer()
Definition: korganizer.cpp:68
KOCore::addXMLGUIClient
void addXMLGUIClient(QWidget *, KXMLGUIClient *guiclient)
Definition: kocore.cpp:183
CalendarView::isFiltered
bool isFiltered() const
Returns true if there's a filter applied.
Definition: calendarview.cpp:2040
ActionManager::saveURL
bool saveURL()
Save calendar file to URL of current calendar.
Definition: actionmanager.cpp:960
ActionManager::queryClose
bool queryClose()
Definition: actionmanager.cpp:1849
calendarview.h
KOCore::removeXMLGUIClient
void removeXMLGUIClient(QWidget *)
Definition: kocore.cpp:188
ActionManager::writeSettings
void writeSettings()
Write current state to config file.
Definition: actionmanager.cpp:806
ActionManager::url
KUrl url() const
Get current URL.
Definition: actionmanager.h:111
KOrg::CalendarViewBase
interface for main calendar view widget
Definition: calendarviewbase.h:35
KOrganizer::openURL
bool openURL(const KUrl &url, bool merge=false)
Open calendar file from URL.
Definition: korganizer.cpp:194
KOGlobals::config
KConfig * config() const
Definition: koglobals.cpp:54
ActionManager::createCalendarAkonadi
void createCalendarAkonadi()
Create Calendar object based on the akonadi framework and set it on the view.
Definition: actionmanager.cpp:210
KOrganizer::statusBarPressed
void statusBarPressed(int id)
Definition: korganizer.cpp:184
ActionManager::init
void init()
Peform initialization that requires this* to be full constructed.
Definition: actionmanager.cpp:152
kocore.h
KOCore::self
static KOCore * self()
Definition: kocore.cpp:37
KOrganizer::view
KOrg::CalendarViewBase * view() const
Definition: korganizer.cpp:224
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