diff options
author | Arno <am@disconnect.de> | 2010-10-31 13:41:52 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2010-10-31 13:41:52 +0100 |
commit | 78d26758184cd23b0ea27ab714a9e1d1c3aeba9b (patch) | |
tree | 0dd48b7e5038ca8ede582dab2a2e2dd131127d78 /consistencycheck.h | |
parent | 31bc791cb48e110db8f7b994931c1879974168a1 (diff) | |
download | SheMov-78d26758184cd23b0ea27ab714a9e1d1c3aeba9b.tar.gz SheMov-78d26758184cd23b0ea27ab714a9e1d1c3aeba9b.tar.bz2 SheMov-78d26758184cd23b0ea27ab714a9e1d1c3aeba9b.zip |
First try on ConsistencyChecker
Well, it works, so let's shit it :) Unfortunately the database is
inconsistent, so add a checker for that. Still needs some work, though.
Eg. display errors seperately and make it possible to delete stray
files. Also the Filesystem check must be implemented.
Diffstat (limited to 'consistencycheck.h')
-rw-r--r-- | consistencycheck.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/consistencycheck.h b/consistencycheck.h new file mode 100644 index 0000000..15d0da7 --- /dev/null +++ b/consistencycheck.h @@ -0,0 +1,73 @@ +/* + 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. +*/ + +#ifndef CONSISTENCYCHECK_H +#define CONSISTENCYCHECK_H + +#include <QDialog> +#include <QThread> +#include <QSqlDatabase> +#include <QMutex> + +class QPushButton; +class QTextEdit; +class QLabel; +class QString; +class ConsistencyChecker; + +class ConsistencyCheck : public QDialog { + Q_OBJECT + public: + enum Mode { DbCheck, FsCheck }; + explicit ConsistencyCheck(QWidget *parent = 0, Qt::WindowFlags f = 0); + + private slots: + void startChecker(int checkerType); + void addMessage(const QString &message); + void cancelExit(); + + private: + QPushButton *mCancelExit; + QPushButton *mCheckDb; + QPushButton *mCheckFs; + QTextEdit *mDisplay; + QLabel *mCheckLabel; + ConsistencyChecker *mChecker; +}; + +class ConsistencyChecker : public QThread { + Q_OBJECT + public: + enum Status { Ok, Fail }; + explicit ConsistencyChecker(QObject *parent = 0); + ~ConsistencyChecker(); + int mode() const { return mMode; } + void setMode(int mode) { mMode = mode; } + int status() const { return mStatus; } + void setStatus(int status) { mStatus = status; } + void check(); + + public slots: + void cancel(bool cancel); + + signals: + void consistencyMsg(const QString &msg); + + protected: + void run(); + + private: + void dbCheck(); + QString archivePath(const QString &fileName, const QString &md5sum) const; + bool mCanceled; + int mMode; + int mStatus; + QSqlDatabase mDb; + QMutex mCancelMutex; +}; + +#endif // CONSISTENCYCHECK_H |