• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • services
  • storage
  • migrator
wizard.cpp
Go to the documentation of this file.
1 /*
2  * <one line to give the library's name and an idea of what it does.>
3  * Copyright 2013 Vishesh Handa <me@vhanda.in>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of
8  * the License or (at your option) version 3 or any later version
9  * accepted by the membership of KDE e.V. (or its successor approved
10  * by the membership of KDE e.V.), which shall act as a proxy
11  * defined in Section 14 of version 3 of the license.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #include "wizard.h"
24 
25 #include <KGlobal>
26 #include <KIcon>
27 #include <KLocalizedString>
28 #include <KComponentData>
29 #include <KAboutData>
30 #include <KTemporaryFile>
31 #include <KDebug>
32 
33 #include <QBoxLayout>
34 #include <QRadioButton>
35 #include <QGroupBox>
36 
37 using namespace Nepomuk2;
38 
39 MigrationWizard::MigrationWizard(QWidget* parent, Qt::WindowFlags flags)
40  : QWizard(parent, flags)
41 {
42  setPixmap(LogoPixmap, KIcon(QLatin1String("nepomuk")).pixmap(32, 32));
43  setWindowIcon( KIcon(QLatin1String("nepomuk")) );
44  setWindowTitle( KGlobal::activeComponent().aboutData()->shortDescription() );
45 
46  setOption( HaveFinishButtonOnEarlyPages, false );
47  setOption( HaveNextButtonOnLastPage, false );
48 
49  // No Back button
50  QList<QWizard::WizardButton> layout;
51  layout << QWizard::Stretch << QWizard::NextButton << QWizard::CancelButton << QWizard::FinishButton;
52  setButtonLayout( layout );
53 
54  setPage( Id_MainPage, new MainPage(this) );
55  setPage( Id_MigrationPage, new MigrationPage(this) );
56  setPage( Id_FinishPage, new FinishPage(this) );
57  setPage( Id_ErrorPage, new ErrorPage(this) );
58 
59 
60  setStartId( Id_MainPage );
61 }
62 
63 void MigrationWizard::showError(const QString& error)
64 {
65  setField(QLatin1String("errorMessage"), error);
66  setStartId(Id_ErrorPage);
67 }
68 
69 //
70 // Main Page
71 //
72 
73 MainPage::MainPage(QWidget* parent): QWizardPage(parent)
74 {
75  setTitle( i18n("Nepomuk Data Migration") );
76 
77  QLabel* label = new QLabel( this );
78  label->setTextFormat( Qt::RichText );
79  label->setWordWrap( true );
80  label->setText( i18n("With this new release Nepomuk has migrated its internal data format. "
81  "You have launched this wizard because you wish to migrate your data and "
82  "not go with the recommended method of backup and restore. "
83  "This migration can take several hours") );
84 
85  QVBoxLayout* layout = new QVBoxLayout( this );
86  layout->addWidget( label );
87 }
88 
89 int MainPage::nextId() const
90 {
91  return MigrationWizard::Id_MigrationPage;
92 }
93 
94 
95 //
96 // Migration Page
97 //
98 
99 MigrationPage::MigrationPage(QWidget* parent)
100  : QWizardPage(parent)
101  , m_done(false)
102 {
103 }
104 
105 void MigrationPage::initializePage()
106 {
107  setTitle( i18n("The internal data is being migrated") );
108  setSubTitle( i18n("This process could take a while") );
109 
110  QVBoxLayout* layout = new QVBoxLayout( this );
111  m_progressBar = new QProgressBar( this );
112  m_progressBar->setMaximum( 100 );
113 
114  layout->addWidget( m_progressBar );
115 
116  m_storageService = new StorageService( QLatin1String("org.kde.NepomukStorage"),
117  QLatin1String("/nepomukstorage"),
118  QDBusConnection::sessionBus(), this);
119  connect( m_storageService, SIGNAL(migrateGraphsDone()), this, SLOT(slotMigrationDone()) );
120  connect( m_storageService, SIGNAL(migrateGraphsPercent(int)), this, SLOT(slotMigrationPercent(int)) );
121 
122  m_storageService->migrateGraphs();
123 }
124 
125 
126 void MigrationPage::slotMigrationDone()
127 {
128  m_done = true;
129  emit completeChanged();
130 
131  wizard()->next();
132 }
133 
134 void MigrationPage::slotMigrationPercent(int percent)
135 {
136  kDebug() << percent;
137  m_progressBar->setValue( percent );
138 }
139 
140 
141 bool MigrationPage::isComplete() const
142 {
143  return m_done;
144 }
145 
146 int MigrationPage::nextId() const
147 {
148  return MigrationWizard::Id_FinishPage;
149 }
150 
151 
152 //
153 // Finish Page
154 //
155 
156 FinishPage::FinishPage(QWidget* parent): QWizardPage(parent)
157 {
158  setTitle( i18n("Data has been successfully migrated") );
159 }
160 
161 int FinishPage::nextId() const
162 {
163  return -1;
164 }
165 
166 //
167 // Error Page
168 //
169 
170 ErrorPage::ErrorPage(QWidget* parent): QWizardPage(parent)
171 {
172  setupUi(this);
173  setFinalPage(true);
174  m_labelPixmap->setPixmap(KIcon(QLatin1String("dialog-error")).pixmap(48,48));
175  registerField( QLatin1String("errorMessage"), this, "errorMessage" );
176 }
177 
178 QString Nepomuk2::ErrorPage::message() const
179 {
180  return m_labelMessage->text();
181 }
182 
183 void Nepomuk2::ErrorPage::setMessage(const QString& s)
184 {
185  m_labelMessage->setText(s);
186 }
187 
188 
189 #include "wizard.moc"
Nepomuk2::FinishPage
Definition: wizard.h:81
QWizardPage
Nepomuk2::MigrationWizard::Id_ErrorPage
Definition: wizard.h:49
Nepomuk2::MigrationWizard::Id_MigrationPage
Definition: wizard.h:47
Nepomuk2::ErrorPage::ErrorPage
ErrorPage(QWidget *parent=0)
Definition: backupwizardpages.cpp:282
QWidget
Nepomuk2::FinishPage::FinishPage
FinishPage(QWidget *parent=0)
Definition: wizard.cpp:156
Nepomuk2::MigrationPage::isComplete
virtual bool isComplete() const
Definition: wizard.cpp:141
Nepomuk2::MainPage::nextId
virtual int nextId() const
Definition: wizard.cpp:89
Nepomuk2::MainPage
Definition: wizard.h:55
Nepomuk2::MigrationPage::initializePage
virtual void initializePage()
Definition: wizard.cpp:105
wizard.h
Nepomuk2::MigrationPage
Definition: wizard.h:62
Nepomuk2::ErrorPage::setMessage
void setMessage(const QString &s)
Definition: backupwizardpages.cpp:296
Nepomuk2::ErrorPage::message
QString message() const
Definition: backupwizardpages.cpp:291
Nepomuk2::MainPage::MainPage
MainPage(QWidget *parent=0)
Definition: wizard.cpp:73
Nepomuk2::MigrationPage::nextId
virtual int nextId() const
Definition: wizard.cpp:146
Nepomuk2::MigrationWizard::Id_MainPage
Definition: wizard.h:46
Nepomuk2::FinishPage::nextId
virtual int nextId() const
Definition: wizard.cpp:161
Nepomuk2::ErrorPage
Definition: backupwizardpages.h:136
StorageService
org::kde::nepomuk::Storage StorageService
Definition: systray.h:29
Nepomuk2::MigrationWizard::showError
void showError(const QString &error)
Definition: wizard.cpp:63
Nepomuk2::MigrationPage::MigrationPage
MigrationPage(QWidget *parent=0)
Definition: wizard.cpp:99
Nepomuk2::MigrationWizard::MigrationWizard
MigrationWizard(QWidget *parent=0, Qt::WindowFlags flags=0)
Definition: wizard.cpp:39
Nepomuk2::MigrationWizard::Id_FinishPage
Definition: wizard.h:48
QWizard
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

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