• 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_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 "impl/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 
85  mStatusBarExtension = new KParts::StatusBarExtension( this );
86 
87  setComponentData( KOrganizerFactory::componentData() );
88 
89  QVBoxLayout *topLayout = new QVBoxLayout( canvas );
90  topLayout->addWidget( mView );
91  topLayout->setMargin( 0 );
92 
93  connect( mView, SIGNAL(incidenceSelected(Akonadi::Item,QDate)),
94  SLOT(slotChangeInfo(Akonadi::Item,QDate)) );
95 
96  mActionManager->init();
97  mActionManager->readSettings();
98 
99  setXMLFile( QLatin1String("korganizer_part.rc"), true );
100  mActionManager->loadParts();
101  setTitle();
102 }
103 
104 KOrganizerPart::~KOrganizerPart()
105 {
106  mActionManager->writeSettings();
107 
108  delete mActionManager;
109  mActionManager = 0;
110 
111  KOCore::self()->removeXMLGUIClient( mTopLevelWidget );
112 }
113 
114 void KOrganizerPart::slotChangeInfo( const Akonadi::Item &item, const QDate &date )
115 {
116  Q_UNUSED( date );
117  const KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( item );
118  if ( incidence ) {
119  emit textChanged( incidence->summary() + QLatin1String(" / ") +
120  KCalUtils::IncidenceFormatter::timeToString( incidence->dtStart() ) );
121  } else {
122  emit textChanged( QString() );
123  }
124 }
125 
126 QWidget *KOrganizerPart::topLevelWidget()
127 {
128  return mView->topLevelWidget();
129 }
130 
131 ActionManager *KOrganizerPart::actionManager()
132 {
133  return mActionManager;
134 }
135 
136 void KOrganizerPart::showStatusMessage( const QString &message )
137 {
138  KStatusBar *statusBar = mStatusBarExtension->statusBar();
139  if ( statusBar ) {
140  statusBar->showMessage( message );
141  }
142 }
143 
144 KOrg::CalendarViewBase *KOrganizerPart::view() const
145 {
146  return mView;
147 }
148 
149 bool KOrganizerPart::openURL( const KUrl &url, bool merge )
150 {
151  return mActionManager->importURL( url, merge );
152 }
153 
154 bool KOrganizerPart::saveURL()
155 {
156  return mActionManager->saveURL();
157 }
158 
159 bool KOrganizerPart::saveAsURL( const KUrl &kurl )
160 {
161  return mActionManager->saveAsURL( kurl );
162 }
163 
164 KUrl KOrganizerPart::getCurrentURL() const
165 {
166  return mActionManager->url();
167 }
168 
169 bool KOrganizerPart::openFile()
170 {
171  mActionManager->importCalendar( localFilePath() );
172  return true;
173 }
174 
175 // FIXME: This is copied verbatim from the KOrganizer class. Move it to the common base class!
176 void KOrganizerPart::setTitle()
177 {
178 // kDebug(5850) <<"KOrganizer::setTitle";
179 // FIXME: Inside kontact we want to have different titles depending on the
180 // type of view (calendar, to-do, journal). How can I add the filter
181 // name in that case?
182 /*
183  QString title;
184  if ( !hasDocument() ) {
185  title = i18n("Calendar");
186  } else {
187  KUrl url = mActionManager->url();
188 
189  if ( !url.isEmpty() ) {
190  if ( url.isLocalFile() ) title = url.fileName();
191  else title = url.prettyUrl();
192  } else {
193  title = i18n("New Calendar");
194  }
195 
196  if ( mView->isReadOnly() ) {
197  title += " [" + i18n("read-only") + ']';
198  }
199  }
200 
201  title += " - <" + mView->currentFilterName() + "> ";
202 
203  emit setWindowCaption( title );*/
204 }
205 
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:126
ActionManager::importURL
bool importURL(const KUrl &url, bool merge)
Definition: actionmanager.cpp:937
QWidget
KOrganizerPart::openFile
virtual bool openFile()
Definition: korganizer_part.cpp:169
QWidget::setFocusPolicy
void setFocusPolicy(Qt::FocusPolicy policy)
KOrganizerPart::setTitle
void setTitle()
Set window title.
Definition: korganizer_part.cpp:176
actionmanager.h
KOrganizerPart::view
virtual KOrg::CalendarViewBase * view() const
Definition: korganizer_part.cpp:144
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:131
KOrganizerPart::textChanged
void textChanged(const QString &)
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
CalendarView
This is the main calendar widget.
Definition: calendarview.h:99
KOrganizerIfaceImpl
Definition: korganizerifaceimpl.h:42
QWidget::topLevelWidget
QWidget * topLevelWidget() const
QObject
KOrganizerPart::saveURL
virtual bool saveURL()
Save calendar file to URL of current calendar.
Definition: korganizer_part.cpp:154
aboutdata.h
QVBoxLayout
KAboutData
QDate
QString
QLayout::setMargin
void setMargin(int margin)
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:149
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:164
KOrganizerPart::~KOrganizerPart
virtual ~KOrganizerPart()
Definition: korganizer_part.cpp:104
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:136
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:114
QLatin1String
korganizer_part.h
KOCore::addXMLGUIClient
void addXMLGUIClient(QWidget *, KXMLGUIClient *guiclient)
Definition: kocore.cpp:183
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:188
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
QObject::isWidgetType
bool isWidgetType() const
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:159
kocore.h
KOCore::self
static KOCore * self()
Definition: kocore.cpp:37
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