2 This file is part of KAddressBook.
4 Copyright (c) 2009-2015 Laurent Montel <montel@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "kaddressbookpart.h"
22 #include "mainwidget.h"
23 #include "kaddressbookmigrateapplication.h"
25 #include "kaddressbook_debug.h"
26 #include <KIconLoader>
27 #include <KLocalizedString>
28 #include <KPluginFactory>
29 #include <KParts/StatusBarExtension>
31 #include <KActionCollection>
34 #include <QVBoxLayout>
36 K_PLUGIN_FACTORY(KAddressBookFactory
, registerPlugin
<KAddressBookPart
>();)
38 KAddressBookPart::KAddressBookPart(QWidget
*parentWidget
, QObject
*parent
,
40 : KParts::ReadOnlyPart(parent
)
42 setComponentName(QStringLiteral("kaddressbook"), QStringLiteral("kaddressbook"));
43 KAddressBookMigrateApplication migrate
;
46 KIconLoader::global()->addAppDir(QStringLiteral("kaddressbook"));
47 // create a canvas to insert our widget
48 QWidget
*canvas
= new QWidget(parentWidget
);
49 canvas
->setFocusPolicy(Qt::ClickFocus
);
51 QVBoxLayout
*topLayout
= new QVBoxLayout(canvas
);
53 mMainWidget
= new MainWidget(this, canvas
);
56 topLayout
->addWidget(mMainWidget
);
57 topLayout
->setMargin(0);
58 setXMLFile(QStringLiteral("kaddressbookui.rc"));
61 void KAddressBookPart::updateQuickSearchText()
63 mMainWidget
->updateQuickSearchText();
66 void KAddressBookPart::initAction()
68 QAction
*action
= new QAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("&Configure KAddressBook..."), this);
69 actionCollection()->addAction(QStringLiteral("kaddressbook_configure"), action
);
70 connect(action
, &QAction::triggered
, mMainWidget
, &MainWidget::configure
);
73 void KAddressBookPart::newContact()
75 mMainWidget
->newContact();
78 void KAddressBookPart::newGroup()
80 mMainWidget
->newGroup();
83 KAddressBookPart::~KAddressBookPart()
87 bool KAddressBookPart::openFile()
92 void KAddressBookPart::guiActivateEvent(KParts::GUIActivateEvent
*e
)
94 qCDebug(KADDRESSBOOK_LOG
);
95 KParts::ReadOnlyPart::guiActivateEvent(e
);
98 #include "kaddressbookpart.moc"