• 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_part.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org>
5  Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 
26 #include "korganizer_part.h"
27 #include "aboutdata.h"
28 #include "actionmanager.h"
29 #include "calendarview.h"
30 #include "kocore.h"
31 #include "korganizerifaceimpl.h"
32 
33 #include <calendarsupport/utils.h>
34 
35 #include <KCalUtils/IncidenceFormatter>
36 
37 #include <KStatusBar>
38 #include <KParts/StatusBarExtension>
39 
40 #include <QVBoxLayout>
41 
42 static const KAboutData &createAboutData()
43 {
44  static KOrg::AboutData about;
45  return about;
46 }
47 
48 K_PLUGIN_FACTORY( KOrganizerFactory, registerPlugin<KOrganizerPart>(); )
49 K_EXPORT_PLUGIN( KOrganizerFactory( createAboutData() ) )
50 
51 KOrganizerPart::KOrganizerPart( QWidget *parentWidget, QObject *parent, const QVariantList & )
52  : KParts::ReadOnlyPart( parent )
53 {
54  if ( parentWidget ) {
55  mTopLevelWidget = parentWidget->topLevelWidget();
56  } else if ( parent && parent->isWidgetType() ) {
57  mTopLevelWidget = (QWidget *)parent;
58  } else {
59  kError() << "Cannot initialize the part without a top level widget.";
60  }
61 
62  KGlobal::locale()->insertCatalog( QLatin1String("libkcalutils") );
63  KGlobal::locale()->insertCatalog( QLatin1String("calendarsupport") );
64  KGlobal::locale()->insertCatalog( QLatin1String("libkdepim") );
65  KGlobal::locale()->insertCatalog( QLatin1String("kdgantt2") );
66  KGlobal::locale()->insertCatalog( QLatin1String("libakonadi") );
67  KGlobal::locale()->insertCatalog( QLatin1String("libincidenceeditors") );
68  KGlobal::locale()->insertCatalog( QLatin1String("libkpimutils") );
69  KGlobal::locale()->insertCatalog( QLatin1String("libpimcommon") );
70 
71  KOCore::self()->addXMLGUIClient( mTopLevelWidget, this );
72 
73  // create a canvas to insert our widget
74  QWidget *canvas = new QWidget( parentWidget );
75  canvas->setFocusPolicy( Qt::ClickFocus );
76  setWidget( canvas );
77  mView = new CalendarView( canvas );
78 
79  mActionManager = new ActionManager( this, mView, this, this, true );
80  (void)new KOrganizerIfaceImpl( mActionManager, this, "IfaceImpl" );
81 
82  mActionManager->createCalendarAkonadi();
83  setHasDocument( false );
84  mView->updateCategories();
85 
86  mStatusBarExtension = new KParts::StatusBarExtension( this );
87 
88  setComponentData( KOrganizerFactory::componentData() );
89 
90  QVBoxLayout *topLayout = new QVBoxLayout( canvas );
91  topLayout->addWidget( mView );
92  topLayout->setMargin( 0 );
93 
94  connect( mView, SIGNAL(incidenceSelected(Akonadi::Item,QDate)),
95  SLOT(slotChangeInfo(Akonadi::Item,QDate)) );
96 
97  mActionManager->init();
98  mActionManager->readSettings();
99 
100  setXMLFile( QLatin1String("korganizer_part.rc"), true );
101  mActionManager->loadParts();
102  setTitle();
103 }
104 
105 KOrganizerPart::~KOrganizerPart()
106 {
107  mActionManager->writeSettings();
108 
109  delete mActionManager;
110  mActionManager = 0;
111 
112  KOCore::self()->removeXMLGUIClient( mTopLevelWidget );
113 }
114 
115 void KOrganizerPart::slotChangeInfo( const Akonadi::Item &item, const QDate &date )
116 {
117  Q_UNUSED( date );
118  const KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( item );
119  if ( incidence ) {
120  emit textChanged( incidence->summary() + QLatin1String(" / ") +
121  KCalUtils::IncidenceFormatter::timeToString( incidence->dtStart() ) );
122  } else {
123  emit textChanged( QString() );
124  }
125 }
126 
127 QWidget *KOrganizerPart::topLevelWidget()
128 {
129  return mView->topLevelWidget();
130 }
131 
132 ActionManager *KOrganizerPart::actionManager()
133 {
134  return mActionManager;
135 }
136 
137 void KOrganizerPart::showStatusMessage( const QString &message )
138 {
139  KStatusBar *statusBar = mStatusBarExtension->statusBar();
140  if ( statusBar ) {
141  statusBar->showMessage( message );
142  }
143 }
144 
145 KOrg::CalendarViewBase *KOrganizerPart::view() const
146 {
147  return mView;
148 }
149 
150 bool KOrganizerPart::openURL( const KUrl &url, bool merge )
151 {
152  return mActionManager->importURL( url, merge );
153 }
154 
155 bool KOrganizerPart::saveURL()
156 {
157  return mActionManager->saveURL();
158 }
159 
160 bool KOrganizerPart::saveAsURL( const KUrl &kurl )
161 {
162  return mActionManager->saveAsURL( kurl );
163 }
164 
165 KUrl KOrganizerPart::getCurrentURL() const
166 {
167  return mActionManager->url();
168 }
169 
170 bool KOrganizerPart::openFile()
171 {
172  mActionManager->importCalendar( localFilePath() );
173  return true;
174 }
175 
176 // FIXME: This is copied verbatim from the KOrganizer class. Move it to the common base class!
177 void KOrganizerPart::setTitle()
178 {
179 // kDebug(5850) <<"KOrganizer::setTitle";
180 // FIXME: Inside kontact we want to have different titles depending on the
181 // type of view (calendar, to-do, journal). How can I add the filter
182 // name in that case?
183 /*
184  QString title;
185  if ( !hasDocument() ) {
186  title = i18n("Calendar");
187  } else {
188  KUrl url = mActionManager->url();
189 
190  if ( !url.isEmpty() ) {
191  if ( url.isLocalFile() ) title = url.fileName();
192  else title = url.prettyUrl();
193  } else {
194  title = i18n("New Calendar");
195  }
196 
197  if ( mView->isReadOnly() ) {
198  title += " [" + i18n("read-only") + ']';
199  }
200  }
201 
202  title += " - <" + mView->currentFilterName() + "> ";
203 
204  emit setWindowCaption( title );*/
205 }
206 
207 #include "korganizer_part.moc"
ActionManager::importCalendar
void importCalendar(const KUrl &url)
Definition: actionmanager.cpp:1854
KOrganizerPart::topLevelWidget
virtual QWidget * topLevelWidget()
Return widget whcih represents this main window.
Definition: korganizer_part.cpp:127
ActionManager::importURL
bool importURL(const KUrl &url, bool merge)
Definition: actionmanager.cpp:937
KOrganizerPart::openFile
virtual bool openFile()
Definition: korganizer_part.cpp:170
QWidget
KOrganizerPart::setTitle
void setTitle()
Set window title.
Definition: korganizer_part.cpp:177
actionmanager.h
QObject
KOrganizerPart::view
virtual KOrg::CalendarViewBase * view() const
Definition: korganizer_part.cpp:145
createAboutData
static const KAboutData & createAboutData()
Definition: korganizer_part.cpp:42
KOrganizerPart::actionManager
virtual ActionManager * actionManager()
Return ActionManager of this main window.
Definition: korganizer_part.cpp:132
KOrganizerPart::textChanged
void textChanged(const QString &)
CalendarView
This is the main calendar widget.
Definition: calendarview.h:99
KOrganizerIfaceImpl
Definition: korganizerifaceimpl.h:42
KOrganizerPart::saveURL
virtual bool saveURL()
Save calendar file to URL of current calendar.
Definition: korganizer_part.cpp:155
aboutdata.h
KAboutData
KOrganizerPart::openURL
virtual bool openURL(const KUrl &url, bool merge=false)
Load calendar file from URL and merge it into the current calendar.
Definition: korganizer_part.cpp:150
ActionManager::saveAsURL
bool saveAsURL(const KUrl &kurl)
Save calendar file to URL.
Definition: actionmanager.cpp:1097
KOrganizerPart::getCurrentURL
virtual KUrl getCurrentURL() const
Get current URL.
Definition: korganizer_part.cpp:165
KOrganizerPart::~KOrganizerPart
virtual ~KOrganizerPart()
Definition: korganizer_part.cpp:105
korganizerifaceimpl.h
KOrg::AboutData
Definition: aboutdata.h:32
KOrganizerPart::showStatusMessage
virtual void showStatusMessage(const QString &message)
Show status message in status bar.
Definition: korganizer_part.cpp:137
ActionManager
The ActionManager creates all the actions in KOrganizer.
Definition: actionmanager.h:66
KOrganizerPart::slotChangeInfo
void slotChangeInfo(const Akonadi::Item &, const QDate &date)
Definition: korganizer_part.cpp:115
korganizer_part.h
KOCore::addXMLGUIClient
void addXMLGUIClient(QWidget *, KXMLGUIClient *guiclient)
Definition: kocore.cpp:216
K_EXPORT_PLUGIN
K_EXPORT_PLUGIN(KOrganizerFactory(createAboutData())) KOrganizerPart
Definition: korganizer_part.cpp:49
ActionManager::saveURL
bool saveURL()
Save calendar file to URL of current calendar.
Definition: actionmanager.cpp:960
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
KOrganizerPart::KOrganizerPart
KOrganizerPart(QWidget *parentWidget, QObject *parent, const QVariantList &)
ActionManager::url
KUrl url() const
Get current URL.
Definition: actionmanager.h:111
KOrg::CalendarViewBase
interface for main calendar view widget
Definition: calendarviewbase.h:35
KOrganizerPart::saveAsURL
virtual bool saveAsURL(const KUrl &kurl)
Save calendar file to URL.
Definition: korganizer_part.cpp:160
kocore.h
KOCore::self
static KOCore * self()
Definition: kocore.cpp:37
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