source: branches/release-0.3.0-rc1/src/MediaDBLib/dbbackupdialog.cpp @ 217

Last change on this file since 217 was 217, checked in by Joachim Langenbach, 11 years ago
  • closes #100
  • DBBackup
    • renamed from DBDump, because it should contain also Restoring functionality later on
    • supports the export of views
    • supports the export of Integer, BLOB and Strings (all other than int and blobs are also treated as strings)
    • provides a static function to escape all MySQL-Specialchars
  • SetupObjectDBDump
    • is inserted as first widget into SetupWizard?, if a DBInit widget is present
    • this way it should made sure, that the user backedup his database before we manipulate it
File size: 2.4 KB
Line 
1/*
2    MediaDB - A media management software
3    Copyright (C) 2010  Joachim Langenbach
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18*/
19
20#include "dbbackupdialog.h"
21
22#include "dbbackup.h"
23#include <mpushbutton.h>
24
25#include <QVBoxLayout>
26#include <QHBoxLayout>
27
28DBBackupDialog::DBBackupDialog(QWidget* parent, Qt::WindowFlags flags)
29        : MDialog(parent, flags)
30{
31        inProgress = false;
32       
33        setObjectName("DBBackupDialog");
34        setWindowTitle(tr("Database Backups"));
35       
36        QVBoxLayout *ml = new QVBoxLayout(this);
37        setLayout(ml);
38       
39        dbBackup = new DBBackup(0, this);
40        ml->addWidget(dbBackup);
41        connectByPass(dbBackup);
42        connect(dbBackup, SIGNAL(exportStarted()), this, SLOT(exportStarted()));
43        connect(dbBackup, SIGNAL(exportFinished(bool)), this, SLOT(exportFinished(bool)));
44       
45        QHBoxLayout *bl = new QHBoxLayout();
46        ml->addLayout(bl);
47       
48        MPushButton *button = new MPushButton(this);
49        bl->addWidget(button);
50        setHelp("keyword:DBBackup", button);
51       
52        bl->addStretch();
53       
54        exportButton = new MPushButton(tr("Export"), this);
55        bl->addWidget(exportButton);
56        connect(exportButton, SIGNAL(clicked()), this, SLOT(finish()));
57       
58        closeButton = new MPushButton(this);
59        bl->addWidget(closeButton);
60        connect(closeButton, SIGNAL(clicked()), this, SLOT(abort()));
61        exportFinished(false);
62}
63
64void DBBackupDialog::finish()
65{
66        dbBackup->finish();
67}
68
69void DBBackupDialog::abort()
70{
71        if(inProgress){
72                dbBackup->abort();
73        }
74        else{
75                if(doneSuccessfully){
76                        accept();
77                }
78                else{
79                        reject();
80                }
81        }
82}
83
84void DBBackupDialog::exportStarted()
85{
86        inProgress = true;
87        exportButton->setEnabled(false);
88        closeButton->setText(tr("Cancel"));
89}
90
91void DBBackupDialog::exportFinished(bool result)
92{
93        inProgress = false;
94        exportButton->setEnabled(true);
95        closeButton->setText(tr("Close"));
96        doneSuccessfully = result;
97}
98
99#include "dbbackupdialog.moc"
Note: See TracBrowser for help on using the repository browser.