kaddressbookpart.cpp 2.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
/*
    This file is part of KAddressBook.

    Copyright (c) 2009 Laurent Montel <montel@kde.org>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "kaddressbookpart.h"
#include "aboutdata.h"
#include "mainwidget.h"

#include <QtGui/QVBoxLayout>

#include <kcomponentdata.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kparts/genericfactory.h>
#include <kparts/statusbarextension.h>

K_PLUGIN_FACTORY( KAddressBookFactory, registerPlugin<KAddressBookPart>(); )
K_EXPORT_PLUGIN( KAddressBookFactory( AboutData() ) )

KAddressBookPart::KAddressBookPart( QWidget *parentWidget, QObject *parent,
                                    const QVariantList & )
  : KParts::ReadOnlyPart( parent )
{
  setComponentData( KAddressBookFactory::componentData() );

  KIconLoader::global()->addAppDir( "kaddressbook" );
  setXMLFile( "kaddressbookui.rc" );
  // create a canvas to insert our widget
  QWidget *canvas = new QWidget( parentWidget );
  canvas->setFocusPolicy( Qt::ClickFocus );
  setWidget( canvas );
  QVBoxLayout *topLayout = new QVBoxLayout( canvas );

50
  mMainWidget = new MainWidget( this, canvas );
51 52 53 54 55

  topLayout->addWidget( mMainWidget );
  topLayout->setMargin(0);
}

56 57 58 59 60 61 62 63 64 65
void KAddressBookPart::newContact()
{
  mMainWidget->newContact();
}

void KAddressBookPart::newGroup()
{
  mMainWidget->newGroup();
}

66 67 68 69 70 71 72 73 74 75 76 77 78 79
KAddressBookPart::~KAddressBookPart()
{
}

bool KAddressBookPart::openFile()
{
  return false;
}

void KAddressBookPart::guiActivateEvent(KParts::GUIActivateEvent *e)
{
   kDebug();
   KParts::ReadOnlyPart::guiActivateEvent(e);
}