• 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
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 "korganizerifaceimpl.h"
37 
38 #include <libkdepim/progresswidget/progressdialog.h>
39 #include <libkdepim/progresswidget/statusbarprogresswidget.h>
40 
41 #include <KAction>
42 #include <KActionCollection>
43 #include <KDebug>
44 #include <KShortcutsDialog>
45 #include <KStandardAction>
46 #include <KStatusBar>
47 
48 KOrganizer::KOrganizer() : KParts::MainWindow(), KOrg::MainWindow()
49 {
50  // Set this to be the group leader for all subdialogs - this means
51  // modal subdialogs will only affect this dialog, not the other windows
52  setAttribute( Qt::WA_GroupLeader );
53 
54  kDebug();
55  KOCore::self()->addXMLGUIClient( this, this );
56 // setMinimumSize(600,400); // make sure we don't get resized too small...
57 
58  mCalendarView = new CalendarView( this );
59  mCalendarView->setObjectName( QLatin1String("KOrganizer::CalendarView") );
60  setCentralWidget( mCalendarView );
61 
62  mActionManager = new ActionManager( this, mCalendarView, this, this, false, menuBar() );
63  (void)new KOrganizerIfaceImpl( mActionManager, this, "IfaceImpl" );
64 }
65 
66 KOrganizer::~KOrganizer()
67 {
68  delete mActionManager;
69 
70  KOCore::self()->removeXMLGUIClient( this );
71 }
72 
73 void KOrganizer::init( bool document )
74 {
75  setHasDocument( document );
76 
77  setComponentData( KGlobal::mainComponent() );
78 
79  // Create calendar object, which manages all calendar information associated
80  // with this calendar view window.
81  mActionManager->createCalendarAkonadi();
82 
83  mActionManager->init();
84  /*connect( mActionManager, SIGNAL(actionNewMainWindow(KUrl)),
85  SLOT(newMainWindow(KUrl)) );*/
86 
87  mActionManager->loadParts();
88 
89  initActions();
90  readSettings();
91 
92  KStatusBar *bar = statusBar();
93 
94  bar->insertItem( QString(), ID_GENERAL, 10 );
95  connect( bar, SIGNAL(pressed(int)), SLOT(statusBarPressed(int)) );
96 
97  KPIM::ProgressDialog *progressDialog = new KPIM::ProgressDialog( bar, this );
98  progressDialog->hide();
99 
100  KPIM::StatusbarProgressWidget *progressWidget;
101  progressWidget = new KPIM::StatusbarProgressWidget( progressDialog, bar );
102  progressWidget->show();
103 
104  bar->addPermanentWidget( progressWidget );
105 
106  connect( mActionManager->view(), SIGNAL(statusMessage(QString)),
107  SLOT(showStatusMessage(QString)) );
108 
109  setStandardToolBarMenuEnabled( true );
110  setTitle();
111 }
112 
113 void KOrganizer::newMainWindow( const KUrl &url )
114 {
115  KOrganizer *korg = new KOrganizer();
116  if ( url.isValid() || url.isEmpty() ) {
117  korg->init( true );
118  if ( mActionManager->importURL( url, false ) || url.isEmpty() ) {
119  korg->show();
120  } else {
121  delete korg;
122  }
123  } else {
124  korg->init( false );
125  korg->show();
126  }
127 }
128 
129 void KOrganizer::readSettings()
130 {
131  // read settings from the KConfig, supplying reasonable
132  // defaults where none are to be found
133 
134  KConfig *config = KOGlobals::self()->config();
135 
136  mActionManager->readSettings();
137 
138  config->sync();
139 }
140 
141 void KOrganizer::writeSettings()
142 {
143  kDebug();
144 
145  KConfig *config = KOGlobals::self()->config();
146 
147  mActionManager->writeSettings();
148  config->sync();
149 }
150 
151 void KOrganizer::initActions()
152 {
153  setStandardToolBarMenuEnabled( true );
154  createStandardStatusBarAction();
155 
156  KStandardAction::keyBindings( this, SLOT(slotEditKeys()), actionCollection() );
157  KStandardAction::configureToolbars( this, SLOT(configureToolbars()), actionCollection() );
158  KStandardAction::quit( this, SLOT(close()), actionCollection() );
159 
160  setXMLFile( QLatin1String("korganizerui.rc"), true );
161  createGUI( 0 );
162 
163  setAutoSaveSettings();
164 }
165 
166 void KOrganizer::slotEditKeys()
167 {
168  KShortcutsDialog::configure( actionCollection(),
169  KShortcutsEditor::LetterShortcutsAllowed );
170 }
171 
172 bool KOrganizer::queryClose()
173 {
174  kDebug();
175 
176  bool close = mActionManager->queryClose();
177 
178  // Write configuration. I don't know if it really makes sense doing it this
179  // way, when having opened multiple calendars in different CalendarViews.
180  if ( close ) {
181  writeSettings();
182  }
183 
184  return close;
185 }
186 
187 bool KOrganizer::queryExit()
188 {
189  // Don't call writeSettings here, because filename isn't valid anymore.
190  // It is now called in queryClose.
191 // writeSettings();
192  return true;
193 }
194 
195 void KOrganizer::statusBarPressed( int id )
196 {
197  Q_UNUSED( id );
198 }
199 
200 void KOrganizer::showStatusMessage( const QString &message )
201 {
202  statusBar()->showMessage( message, 2000 );
203 }
204 
205 bool KOrganizer::openURL( const KUrl &url, bool merge )
206 {
207  return mActionManager->importURL( url, merge );
208 }
209 
210 bool KOrganizer::saveURL()
211 {
212  return mActionManager->saveURL();
213 }
214 
215 bool KOrganizer::saveAsURL( const KUrl & kurl )
216 {
217  return mActionManager->saveAsURL( kurl ) ;
218 }
219 
220 KUrl KOrganizer::getCurrentURL() const
221 {
222  return mActionManager->url();
223 }
224 
225 void KOrganizer::saveProperties( KConfigGroup &config )
226 {
227  return mActionManager->saveProperties( config );
228 }
229 
230 void KOrganizer::readProperties( const KConfigGroup &config )
231 {
232  return mActionManager->readProperties( config );
233 }
234 
235 KOrg::CalendarViewBase *KOrganizer::view() const
236 {
237  return mActionManager->view();
238 }
239 
240 void KOrganizer::setTitle()
241 {
242  QString title;
243  if ( !hasDocument() ) {
244  title = i18n( "Calendar" );
245  } else {
246  KUrl url = mActionManager->url();
247 
248  if ( !url.isEmpty() ) {
249  if ( url.isLocalFile() ) {
250  title = url.fileName();
251  } else {
252  title = url.prettyUrl();
253  }
254  } else {
255  title = i18n( "New Calendar" );
256  }
257 
258  if ( mCalendarView->isReadOnly() ) {
259  title += QLatin1String(" [") + i18nc( "the calendar is read-only", "read-only" ) + QLatin1Char(']');
260  }
261  }
262  if ( mCalendarView->isFiltered() ) {
263  title += QLatin1String(" - <") + mCalendarView->currentFilterName() + QLatin1String("> ");
264  }
265 
266  setCaption( title, false );
267 }
268 
269 #include "korganizer.moc"
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:210
ActionManager::readProperties
void readProperties(const KConfigGroup &)
Definition: actionmanager.cpp:1220
KOrganizer::getCurrentURL
KUrl getCurrentURL() const
Get current URL.
Definition: korganizer.cpp:220
KOrganizer::setTitle
void setTitle()
Sets title of window according to filename and modification state.
Definition: korganizer.cpp:240
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:1733
CalendarView::currentFilterName
QString currentFilterName() const
Returns the name of the current filter.
Definition: calendarview.cpp:2031
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:166
ActionManager::view
CalendarView * view() const
Definition: actionmanager.h:78
KOrganizer::saveProperties
void saveProperties(KConfigGroup &)
Definition: korganizer.cpp:225
KOrganizer::queryExit
bool queryExit()
Definition: korganizer.cpp:187
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:141
KOrganizer::newMainWindow
void newMainWindow(const KUrl &)
Definition: korganizer.cpp:113
KOrganizer::showStatusMessage
void showStatusMessage(const QString &)
show status message
Definition: korganizer.cpp:200
ActionManager::saveAsURL
bool saveAsURL(const KUrl &kurl)
Save calendar file to URL.
Definition: actionmanager.cpp:1097
KOrganizer::readProperties
void readProperties(const KConfigGroup &)
Definition: korganizer.cpp:230
KOrganizer::KOrganizer
KOrganizer()
Definition: korganizer.cpp:48
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:129
ActionManager::readSettings
void readSettings()
Using the KConfig associated with the kapp variable, read in the settings from the config file...
Definition: actionmanager.cpp:791
KOrganizer::saveAsURL
bool saveAsURL(const KUrl &kurl)
Save calendar file to URL.
Definition: korganizer.cpp:215
KOrganizer::queryClose
bool queryClose()
supplied so that close events close calendar properly.
Definition: korganizer.cpp:172
KOrganizer::initActions
void initActions()
Definition: korganizer.cpp:151
KOrganizer::init
void init(bool hasDocument)
Definition: korganizer.cpp:73
KOrganizer::~KOrganizer
virtual ~KOrganizer()
Definition: korganizer.cpp:66
KOCore::addXMLGUIClient
void addXMLGUIClient(QWidget *, KXMLGUIClient *guiclient)
Definition: kocore.cpp:216
CalendarView::isFiltered
bool isFiltered() const
Returns true if there's a filter applied.
Definition: calendarview.cpp:2026
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:221
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:205
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:211
KOrganizer::statusBarPressed
void statusBarPressed(int id)
Definition: korganizer.cpp:195
ActionManager::init
void init()
Peform initialization that requires this* to be full constructed.
Definition: actionmanager.cpp:153
kocore.h
KOCore::self
static KOCore * self()
Definition: kocore.cpp:37
KOrganizer::view
KOrg::CalendarViewBase * view() const
Definition: korganizer.cpp:235
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