30 #include <KStandardDirs>
31 #include <KFileDialog>
32 #include <KUrlRequester>
34 #include <Soprano/Model>
35 #include <Soprano/QueryResultIterator>
37 #include <QtGui/QVBoxLayout>
38 #include <QtGui/QGroupBox>
39 #include <QtGui/QLineEdit>
45 setTitle( i18n(
"Nepomuk Backup") );
46 setSubTitle( i18n(
"Please choose one of the following options") );
51 if( m_backup->isChecked() )
53 else if( m_restore->isChecked() )
67 QVBoxLayout* layout =
new QVBoxLayout(
this );
68 m_progressBar =
new QProgressBar(
this );
69 m_progressBar->setMinimum( 0 );
70 m_progressBar->setMaximum( 100 );
72 m_status =
new QLabel(
this );
74 layout->addWidget( m_progressBar );
75 layout->addWidget( m_status );
77 setTitle( i18n(
"Nepomuk Backup") );
78 setSubTitle( i18n(
"Performing backup") );
81 m_backupManager =
new BackupManager( QLatin1String(
"org.kde.NepomukStorage"),
82 QLatin1String(
"/backupmanager"),
83 QDBusConnection::sessionBus(),
this);
84 connect( m_backupManager, SIGNAL(backupDone()),
this, SLOT(slotBackupDone()) );
85 connect( m_backupManager, SIGNAL(backupPercent(
int)), m_progressBar, SLOT(setValue(
int)) );
91 KUrl backupUrl = field(QLatin1String(
"backupUrl")).value<KUrl>();
92 kDebug() << backupUrl;
93 m_status->setText( i18nc(
"@info",
"Writing Nepomuk database backup to <filename>%1</filename>...",
94 field(QLatin1String(
"backupUrl")).value<KUrl>().pathOrUrl()));
95 m_backupManager->backupTagsAndRatings( backupUrl.toLocalFile() );
108 void Nepomuk2::BackupPage::slotBackupDone()
111 m_status->setText( i18nc(
"@info",
"Backup of the Nepomuk database successfully written to <filename>%1</filename>.",
112 field(QLatin1String(
"backupUrl")).value<KUrl>().pathOrUrl()) );
113 setSubTitle( i18n(
"Backup completed successfully") );
115 emit completeChanged();
129 QDir dir( KStandardDirs::locateLocal(
"data",
"nepomuk/backupsync/backups/" ) );
130 QStringList backupFiles = dir.entryList( QDir::Files | QDir::NoDotAndDotDot, QDir::Name );
132 foreach(
const QString & backup, backupFiles ) {
133 m_listWidget->addItem( backup );
136 if( backupFiles.isEmpty() ) {
137 QLabel * errorLabel =
new QLabel( i18nc(
"@info",
"No system backups found. Please select a custom backup path.") ,
this);
138 QGridLayout* layout =
new QGridLayout(m_listWidget);
139 layout->addWidget(errorLabel, 1, 1);
140 layout->setRowStretch(0,1);
141 layout->setRowStretch(2,1);
142 layout->setColumnStretch(0,1);
143 layout->setColumnStretch(2,1);
146 connect( m_customBackupButton, SIGNAL(clicked(
bool)),
this, SLOT(slotCustomBackupUrl()) );
147 connect( m_listWidget, SIGNAL(itemSelectionChanged()),
148 this, SLOT(slotSelectionChanged()) );
150 registerField(
"backupToRestorePath",
this,
"backupFilePath" );
155 return QFile::exists(m_backupFilePath);
164 void Nepomuk2::RestoreSelectionPage::slotSelectionChanged()
166 if( QListWidgetItem* item = m_listWidget->currentItem() )
167 m_backupFilePath = KStandardDirs::locateLocal(
"data", QLatin1String(
"nepomuk/backupsync/backups/") + item->data( Qt::DisplayRole ).toString() );
169 m_backupFilePath.truncate(0);
170 kDebug() << m_backupFilePath;
171 emit completeChanged();
174 void Nepomuk2::RestoreSelectionPage::slotCustomBackupUrl()
176 m_backupFilePath = KFileDialog::getOpenFileName( KUrl(), QString(),
this );
177 kDebug() <<
"NEW BACKUP URL : " << m_backupFilePath;
191 QVBoxLayout* layout =
new QVBoxLayout(
this );
193 m_progressBar =
new QProgressBar(
this );
194 m_progressBar->setMinimum( 0 );
195 m_progressBar->setMaximum( 100 );
197 m_status =
new QLabel( i18n(
"Restoring Backup"),
this );
198 m_restoreDone =
false;
200 layout->addWidget( m_progressBar );
201 layout->addWidget( m_status );
204 setTitle( i18n(
"Restoring Backup") );
205 setSubTitle( i18n(
"The backup is being restored...") );
207 m_backupManager =
new BackupManager( QLatin1String(
"org.kde.NepomukStorage"),
209 QDBusConnection::sessionBus(),
this);
215 QString backupUrl = field(
"backupToRestorePath").toString();
217 kDebug() <<
"Restoring " << backupUrl;
218 m_backupManager->restore( backupUrl );
220 connect( m_backupManager, SIGNAL(restoreDone()),
this, SLOT(slotRestoreDone()) );
221 connect( m_backupManager, SIGNAL(restorePercent(
int)), m_progressBar, SLOT(setValue(
int)) );
224 void Nepomuk2::RestorePage::slotRestoreDone()
226 m_restoreDone =
true;
251 setTitle( i18n(
"Nepomuk Backup") );
252 setSubTitle( i18n(
"Please configure the Nepomuk backup") );
253 connect(m_editBackupUrl, SIGNAL(textChanged(QString)),
254 this, SIGNAL(completeChanged()));
255 connect(m_editBackupUrl, SIGNAL(urlSelected(KUrl)),
256 this, SIGNAL(completeChanged()));
258 registerField(QLatin1String(
"backupUrl"),
this,
"backupUrl");
263 return m_editBackupUrl->url();
268 const KUrl url = m_editBackupUrl->url();
269 return QDir( url.directory() ).exists() && url.isValid();
287 m_labelPixmap->setPixmap(KIcon(QLatin1String(
"dialog-error")).pixmap(48,48));
288 registerField( QLatin1String(
"errorMessage"),
this,
"errorMessage" );
293 return m_labelMessage->text();
298 m_labelMessage->setText(s);
307 setTitle( i18n(
"Nepomuk Backup") );
308 setSubTitle( i18n(
"The following files were not found. Please either discard them or find them manually") );
314 if( m_conflictWidget->isEmpty() ) {
319 QVBoxLayout* layout =
new QVBoxLayout(
this );
320 layout->addWidget( m_conflictWidget );
341 setTitle( i18n(
"Nepomuk Backup") );
342 setSubTitle( i18n(
"The Backup has been successfully restored") );
344 setFinalPage(
true );
356 #include "backupwizardpages.moc"
ErrorPage(QWidget *parent=0)
RestorePage(QWidget *parent)
RestoreSelectionPage(QWidget *parent=0)
FileConflictPage(QWidget *parent=0)
RestoreEndPage(QWidget *parent=0)
void setMessage(const QString &s)
BackupSettingsPage(QWidget *parent=0)
IntroPage(QWidget *parent=0)
org::kde::nepomuk::BackupManager BackupManager
BackupPage(QWidget *parent=0)