diff --git a/harbour-sailotp.pro b/harbour-sailotp.pro index ec6222f..2ca910d 100644 --- a/harbour-sailotp.pro +++ b/harbour-sailotp.pro @@ -13,8 +13,7 @@ DEFINES += APP_BUILDNUM=\\\"$$RELEASE\\\" CONFIG += sailfishapp -SOURCES += src/harbour-sailotp.cpp \ - src/fileio.cpp +SOURCES += src/harbour-sailotp.cpp OTHER_FILES += qml/harbour-sailotp.qml \ qml/cover/CoverPage.qml \ diff --git a/qml/pages/AddOTP.qml b/qml/pages/AddOTP.qml index e72e286..782f7a6 100644 --- a/qml/pages/AddOTP.qml +++ b/qml/pages/AddOTP.qml @@ -148,7 +148,8 @@ Dialog { // There were no parameters -> Add new entry DB.addOTP(otpLabel.text, otpSecret.text, paramType, otpCounter.text, appWin.listModel.count); } - // Refresh the main Page + + // Refresh the main Page parentPage.refreshOTPList(); } } diff --git a/qml/pages/MainView.qml b/qml/pages/MainView.qml index 9a0d80c..2a7e540 100644 --- a/qml/pages/MainView.qml +++ b/qml/pages/MainView.qml @@ -54,9 +54,11 @@ Page { // Reload the List of OTPs from storage function refreshOTPList() { otpList.visible = false; + otpList.model = null; // Hack to prevent unaccessible pulley after List refresh appWin.listModel.clear(); DB.getOTP(); refreshOTPValues(); + otpList.model = appWin.listModel; // Hack to prevent unaccessible pulley after List refresh otpList.visible = true; } @@ -186,8 +188,8 @@ Page { } } } else { - DB.resetFav(title, secret) - appWin.setCover(-1) + DB.resetFav(title, secret); + appWin.setCover(-1); appWin.listModel.setProperty(index, "fav", 0); } } diff --git a/rpm/harbour-sailotp.yaml b/rpm/harbour-sailotp.yaml index 02fe2c0..65a9844 100644 --- a/rpm/harbour-sailotp.yaml +++ b/rpm/harbour-sailotp.yaml @@ -1,7 +1,7 @@ Name: harbour-sailotp Summary: SailOTP Version: 1.0 -Release: 1 +Release: 2 Group: Security URL: https://github.com/seiichiro0185/sailotp/ License: "BSD\t" diff --git a/src/fileio.cpp b/src/fileio.cpp deleted file mode 100644 index 9793d60..0000000 --- a/src/fileio.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "fileio.h" -#include -#include - -FileIO::FileIO(QObject *parent) : - QObject(parent) -{ - -} - -QString FileIO::read() -{ - if (mSource.isEmpty()){ - emit error("source is empty"); - return QString(); - } - - QFile file(mSource); - QString fileContent; - if ( file.open(QIODevice::ReadOnly) ) { - QString line; - QTextStream t( &file ); - do { - line = t.readLine(); - fileContent += line; - } while (!line.isNull()); - - file.close(); - } else { - emit error("Unable to open the file"); - return QString(); - } - return fileContent; -} - -bool FileIO::write(const QString& data) -{ - if (mSource.isEmpty()) - return false; - - QFile file(mSource); - if (!file.open(QFile::WriteOnly | QFile::Truncate)) - return false; - - QTextStream out(&file); - out << data; - - file.close(); - - return true; -} - -bool FileIO::exists() -{ - if (mSource.isEmpty()) { - emit error("Source is empty!"); - return false; - } - - QFile file(mSource); - return file.exists(); -} - -bool FileIO::exists(const QString& filename) -{ - if (filename.isEmpty()) { - emit error("Source is empty!"); - return false; - } - - QFile file(filename); - return file.exists(); -} diff --git a/src/fileio.h b/src/fileio.h deleted file mode 100644 index e8c67c2..0000000 --- a/src/fileio.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef FILEIO_H -#define FILEIO_H - -#include - -class FileIO : public QObject -{ - Q_OBJECT - -public: - Q_PROPERTY(QString source - READ source - WRITE setSource - NOTIFY sourceChanged) - explicit FileIO(QObject *parent = 0); - - Q_INVOKABLE QString read(); - Q_INVOKABLE bool write(const QString& data); - Q_INVOKABLE bool exists(); - Q_INVOKABLE bool exists(const QString& filename); - - QString source() { return mSource; }; - -public slots: - void setSource(const QString& source) { mSource = source; }; - -signals: - void sourceChanged(const QString& source); - void error(const QString& msg); - -private: - QString mSource; -}; - -#endif // FILEIO_H