summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-11-01 20:25:59 +0100
committerArno <am@disconnect.de>2010-11-01 20:25:59 +0100
commitb8a793f4a1afcd27cf03da7b620dd7a4f7f5813f (patch)
tree7940c9614e0d5608c0fa05716ccf6d8a81b46571
parent78d26758184cd23b0ea27ab714a9e1d1c3aeba9b (diff)
downloadSheMov-b8a793f4a1afcd27cf03da7b620dd7a4f7f5813f.tar.gz
SheMov-b8a793f4a1afcd27cf03da7b620dd7a4f7f5813f.tar.bz2
SheMov-b8a793f4a1afcd27cf03da7b620dd7a4f7f5813f.zip
Finished database consistency check
Made the database consistency check work and added a filter to only show error messages in the output. The cause of the inconsistency still has to be investigated, though.
-rw-r--r--consistencycheck.cpp35
-rw-r--r--consistencycheck.h7
2 files changed, 36 insertions, 6 deletions
diff --git a/consistencycheck.cpp b/consistencycheck.cpp
index 38aa4a1..b281942 100644
--- a/consistencycheck.cpp
+++ b/consistencycheck.cpp
@@ -7,7 +7,7 @@
#include <QLabel>
#include <QPushButton>
-#include <QTextEdit>
+#include <QPlainTextEdit>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QSqlQuery>
@@ -18,6 +18,10 @@
#include <QMutex>
#include <QTextCharFormat>
#include <QBrush>
+#include <QTextBlock>
+#include <QCheckBox>
+
+#include <QDebug>
#include "consistencycheck.h"
#include "helper.h"
@@ -25,10 +29,13 @@
ConsistencyCheck::ConsistencyCheck(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), mChecker(0){
// setup widget
mCheckLabel = new QLabel(tr("Checking database consistency"));
- mDisplay = new QTextEdit;
+ mDisplay = new QPlainTextEdit;
+ mDisplay->setReadOnly(true);
mCancelExit = new QPushButton(tr("Cancel"));
mCheckDb = new QPushButton(tr("Check database"));
mCheckFs = new QPushButton(tr("Check Filesystem"));
+ mErrorsOnly = new QCheckBox(tr("Show only errors"));
+ connect(mErrorsOnly, SIGNAL(stateChanged(int)), this, SLOT(showErrorsChanged(int)));
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addWidget(mCheckDb);
buttonLayout->addWidget(mCheckFs);
@@ -48,6 +55,7 @@ ConsistencyCheck::ConsistencyCheck(QWidget *parent, Qt::WindowFlags f) : QDialog
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(mCheckLabel);
mainLayout->addWidget(mDisplay);
+ mainLayout->addWidget(mErrorsOnly);
mainLayout->addLayout(buttonLayout);
setWindowTitle(tr("Checking consistency"));
setLayout(mainLayout);
@@ -80,7 +88,10 @@ void ConsistencyCheck::addMessage(const QString &message){
}else{
fmt.setForeground(QBrush(Qt::red));
}
- cursor.insertBlock();
+ QTextBlock curBlock = cursor.block();
+ if(!curBlock.text().isEmpty()){
+ cursor.insertBlock();
+ }
cursor.setCharFormat(fmt);
cursor.insertText(message);
}
@@ -95,6 +106,21 @@ void ConsistencyCheck::cancelExit(){
}
}
+void ConsistencyCheck::showErrorsChanged(int state){
+ QTextDocument *doc = mDisplay->document();
+ for(QTextBlock it = doc->begin(); it != doc->end(); it = it.next()){
+ if(it.text().startsWith("OK")){
+ if(state == Qt::Checked){
+ qDebug() << it.text();
+ it.setVisible(false);
+ }else{
+ it.setVisible(true);
+ }
+ }
+ }
+ mDisplay->viewport()->update();
+}
+
ConsistencyChecker::ConsistencyChecker(QObject *parent) : QThread(parent), mCanceled(false), mMode(-1), mStatus(Ok){
mDb = QSqlDatabase::cloneDatabase(QSqlDatabase::database("treedb"), "checkerDb");
if(!mDb.open()){
@@ -155,7 +181,8 @@ void ConsistencyChecker::dbCheck(){
if(mimeType.startsWith("image")){
emit consistencyMsg(QString(tr("OK: %1")).arg(fileName));
}else{
- emit consistencyMsg(QString(tr("FOUND: %1")).arg(fileName));
+ QString msg = QString(tr("FOUND: %1 (DVD: %2)")).arg(fullPath).arg(dvdNo);
+ emit consistencyMsg(msg);
}
}
}
diff --git a/consistencycheck.h b/consistencycheck.h
index 15d0da7..49b9a8e 100644
--- a/consistencycheck.h
+++ b/consistencycheck.h
@@ -14,9 +14,10 @@
#include <QMutex>
class QPushButton;
-class QTextEdit;
+class QPlainTextEdit;
class QLabel;
class QString;
+class QCheckBox;
class ConsistencyChecker;
class ConsistencyCheck : public QDialog {
@@ -29,13 +30,15 @@ class ConsistencyCheck : public QDialog {
void startChecker(int checkerType);
void addMessage(const QString &message);
void cancelExit();
+ void showErrorsChanged(int state);
private:
QPushButton *mCancelExit;
QPushButton *mCheckDb;
QPushButton *mCheckFs;
- QTextEdit *mDisplay;
+ QPlainTextEdit *mDisplay;
QLabel *mCheckLabel;
+ QCheckBox *mErrorsOnly;
ConsistencyChecker *mChecker;
};