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

ktimetracker

karm_part.cpp

Go to the documentation of this file.
00001 /*
00002  *     Copyright (C) 2005 by Thorsten Staerk <kde@staerk.de>
00003  *                   2007 the ktimetracker developers
00004  *
00005  *   This program is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License along
00016  *   with this program; if not, write to the
00017  *      Free Software Foundation, Inc.
00018  *      51 Franklin Street, Fifth Floor
00019  *      Boston, MA  02110-1301  USA.
00020  *
00021  */
00022 
00023 #include "karm_part.h"
00024 
00025 #include <QMenu>
00026 
00027 #include <KAboutData>
00028 #include <KAction>
00029 #include <KComponentData>
00030 #include <KGlobal>
00031 #include <KLocale>
00032 #include <KStandardAction>
00033 #include <KStandardDirs>
00034 #include <KXMLGUIFactory>
00035 #include <KActionCollection>
00036 
00037 #include <kdemacros.h>
00038 #include <kparts/genericfactory.h>
00039 #include "mainwindow.h"
00040 #include "karmerrors.h"
00041 #include "task.h"
00042 #include "preferences.h"
00043 #include "tray.h"
00044 #include "version.h"
00045 #include "ktimetracker.h"
00046 #include "timetrackerwidget.h"
00047 
00048 K_PLUGIN_FACTORY(karmPartFactory, registerPlugin<karmPart>();)
00049 K_EXPORT_PLUGIN( karmPartFactory("ktimetracker","ktimetracker") )
00050 
00051 karmPart::karmPart( QWidget *parentWidget, QObject *parent, const QVariantList& )
00052     : KParts::ReadWritePart(parent)
00053 {
00054   KGlobal::locale()->insertCatalog("ktimetracker");
00055 
00056   // we need an instance
00057   setComponentData( karmPartFactory::componentData() );
00058 
00059   mMainWidget = new TimetrackerWidget( parentWidget );
00060   setWidget( mMainWidget );
00061   setXMLFile( "karmui.rc" );
00062   makeMenus();
00063   mMainWidget->openFile( KStandardDirs::locateLocal( "data", 
00064                         QString::fromLatin1( "ktimetracker/ktimetracker.ics" ) ) );
00065   emit setWindowCaption( KStandardDirs::locateLocal( "data", QString::fromLatin1( "ktimetracker/ktimetracker.ics" ) ) );
00066   // connections
00067   connect( mMainWidget, SIGNAL( totalTimesChanged( long, long ) ),
00068            this, SLOT( updateTime( long, long ) ) );
00069   connect( mMainWidget, SIGNAL( statusBarTextChangeRequested( QString ) ),
00070                  this, SLOT( setStatusBar( QString ) ) );
00071   connect( mMainWidget, SIGNAL( setCaption( const QString& ) ),
00072                  this, SIGNAL( setWindowCaption( const QString& ) ) );
00073   // Setup context menu request handling
00074   connect( mMainWidget,
00075            SIGNAL( contextMenuRequested( const QPoint& ) ),
00076            this,
00077            SLOT( taskViewCustomContextMenuRequested( const QPoint& ) ) );
00078 
00079   if ( KTimeTrackerSettings::trayIcon() ) mTray = new TrayIcon( this );
00080   else mTray = new TrayIcon( );
00081 
00082   connect( mTray, SIGNAL( quitSelected() ), SLOT( quit() ) );
00083 
00084   connect( mMainWidget, SIGNAL( timersActive() ), mTray, SLOT( startClock() ) );
00085   connect( mMainWidget, SIGNAL( timersInactive() ), mTray, SLOT( stopClock() ) );
00086   connect( mMainWidget, SIGNAL( tasksChanged( const QList<Task*>& ) ),
00087            mTray, SLOT( updateToolTip( QList<Task*> ) ));
00088 }
00089 
00090 karmPart::~karmPart()
00091 {
00092 }
00093 
00094 KAboutData *karmPart::createAboutData()
00095 {
00096   const QByteArray& ba=QByteArray("test");
00097   const KLocalizedString name=ki18n("myName");
00098   KAboutData* aboutData=new KAboutData( ba, ba, name, ba, name);
00099   return aboutData;
00100   //return KABCore::createAboutData();
00101   #warning not implemented
00102 }
00103 
00104 void karmPart::makeMenus()
00105 {
00106   mMainWidget->setupActions( actionCollection() );
00107   KAction *actionKeyBindings;
00108 
00109   actionKeyBindings = KStandardAction::keyBindings( this, SLOT( keyBindings() ),
00110       actionCollection() );
00111 
00112   setXMLFile( QString::fromLatin1( "karmui.rc" ) );
00113 
00114   // Tool tops must be set after the createGUI.
00115   actionKeyBindings->setToolTip( i18n("Configure key bindings") );
00116   actionKeyBindings->setWhatsThis( i18n("This will let you configure key"
00117                                         "bindings which are specific to ktimetracker") );
00118 }
00119 
00120 void karmPart::setStatusBar(const QString & qs)
00121 {
00122   kDebug(5970) << "Entering function";
00123   emit setStatusBarText(qs);
00124 }
00125 
00126 bool karmPart::openFile()
00127 {
00128   mMainWidget->openFile();
00129 
00130   return true;
00131 }
00132 
00133 bool karmPart::saveFile()
00134 {
00135   mMainWidget->saveFile();
00136 
00137   return true;
00138 }
00139 
00140 void karmPart::taskViewCustomContextMenuRequested( const QPoint& point )
00141 {
00142     QMenu* pop = dynamic_cast<QMenu*>(
00143                           factory()->container( i18n( "task_popup" ), this ) );
00144     if ( pop )
00145       pop->popup( point );
00146 }
00147 
00148 #include "karm_part.moc"

ktimetracker

Skip menu "ktimetracker"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal