From 2403bf93f3fc88f0ca9042482f0a0379f193939e Mon Sep 17 00:00:00 2001 From: hama Date: Thu, 2 Jun 2016 00:16:23 +0200 Subject: [PATCH] ReComboBox, store/restore * new ReComboBox: History in list, signal if edit finished * storage of comboboxes in file --- appl/rebackgui/BackupUtils.cpp | 1 + appl/rebackgui/mainwindow.cpp | 28 ++++- appl/rebackgui/mainwindow.hpp | 1 + appl/rebackgui/mainwindow.ui | 19 ++-- appl/rebackgui/rebackgui.de.qm | Bin 22859 -> 23350 bytes appl/rebackgui/rebackgui.de.ts | 180 +++++++++++++++++++-------------- appl/rebackgui/rebackgui.pro | 6 +- base/ReFileUtils.cpp | 1 - base/rebase.hpp | 1 + gui/ReComboBox.cpp | 78 ++++++++++++++ gui/ReComboBox.hpp | 34 +++++++ gui/regui.hpp | 1 + 12 files changed, 259 insertions(+), 91 deletions(-) create mode 100644 gui/ReComboBox.cpp create mode 100644 gui/ReComboBox.hpp diff --git a/appl/rebackgui/BackupUtils.cpp b/appl/rebackgui/BackupUtils.cpp index ed7a9d8..41e5d13 100644 --- a/appl/rebackgui/BackupUtils.cpp +++ b/appl/rebackgui/BackupUtils.cpp @@ -43,6 +43,7 @@ QString BackupUtils::findAbstractTarget(const QString& path, ReLogger* logger) { QString rc; #if defined __linux__ + (void) logger; QStringList args; ReMountInfo& mountInfo = ReMountInfo::instance(true); QString device = mountInfo.findDevice(path); diff --git a/appl/rebackgui/mainwindow.cpp b/appl/rebackgui/mainwindow.cpp index 8960a11..1f41ef4 100644 --- a/appl/rebackgui/mainwindow.cpp +++ b/appl/rebackgui/mainwindow.cpp @@ -16,7 +16,7 @@ #include "base/retrace.hpp" DECLARE_TRACER(s_traceMain, "/tmp/bup_main.log"); -const QString VERSION("2016.05.17"); +const QString VERSION("2016.06.01"); /** * Constructor. @@ -202,7 +202,10 @@ void MainWindow::onGuiTimerUpdate() */ void MainWindow::initializeGui(){ ui->setupUi(this); + ui->comboBoxDirPatterns->setHistorySize(20); + ui->comboBoxFilePatterns->setHistorySize(20); initializeGuiElements(); + restoreState(); m_guiIsInitialized = false; initializeGuiLanguage(ui->actionEnglish, ui->actionGerman); startStop(false); @@ -248,10 +251,15 @@ void MainWindow::initializeGui(){ connect(ui->actionEnglish, SIGNAL(triggered()), this, SLOT(onEnglish())); connect(ui->actionGerman, SIGNAL(triggered()), this, SLOT(onGerman())); connect(ui->lineEditName, SIGNAL(editingFinished()), this, SLOT(onUpdateConfig())); - connect(ui->comboBoxDirPatterns, SIGNAL(editTextChanged(const QString&)), this, SLOT(onDirPatternTextChanged(const QString&))); - connect(ui->comboBoxFilePatterns, SIGNAL(editTextChanged(const QString&)), this, SLOT(onFilePatternTextChanged(const QString&))); + connect(ui->lineEditTarget, SIGNAL(editingFinished()), this, SLOT(onUpdateConfig())); + //connect(ui->comboBoxDirPatterns, SIGNAL(editTextChanged(const QString&)), this, SLOT(onDirPatternTextChanged(const QString&))); + //connect(ui->comboBoxFilePatterns, SIGNAL(editTextChanged(const QString&)), this, SLOT(onFilePatternTextChanged(const QString&))); connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(onCurrentTabChanged(int))); + connect(ui->comboBoxDirPatterns, SIGNAL(comboTextEdited(const QString&, const QString&)), + this, SLOT(onComboTextEdited(const QString&, const QString&))); + connect(ui->comboBoxFilePatterns, SIGNAL(comboTextEdited(const QString&, const QString&)), + this, SLOT(onComboTextEdited(const QString&, const QString&))); m_configuration.load(""); ui->tableWidgetConfiguration->selectRow(0); updateTable(); @@ -260,7 +268,6 @@ void MainWindow::initializeGui(){ ui->actionEnglish->setChecked(true); else ui->actionGerman->setChecked(true); - m_guiIsInitialized = true; // Active Name Target Last Sources ui->tableWidget->setColumnWidth(0, 50); ui->tableWidget->setColumnWidth(1, 125); @@ -271,6 +278,7 @@ void MainWindow::initializeGui(){ ui->tableWidgetConfiguration->setColumnWidth(1, 175); ui->tableWidgetConfiguration->setColumnWidth(2, 160); ui->tableWidgetConfiguration->selectRow(0); + m_guiIsInitialized = true; } /** @@ -492,6 +500,17 @@ void MainWindow::onClearFileList() ui->listWidgetFile->clear(); } +/** + * Updates the table because the combobox text has changed. + * @param oldText the text before the focus has come + * @param newText the current text of the combobox + */ +void MainWindow::onComboTextEdited(const QString& oldText, const QString& newText){ + (void) oldText; + (void) newText; + onUpdateConfig(); +} + /** * The current row has been changed. * @@ -938,7 +957,6 @@ void MainWindow::updateTableRow(int row, BackupItem& item, QTableWidget* target) } } - /** * Write the current settings into the configuration file of the target. * diff --git a/appl/rebackgui/mainwindow.hpp b/appl/rebackgui/mainwindow.hpp index f6a2fff..ffc2893 100644 --- a/appl/rebackgui/mainwindow.hpp +++ b/appl/rebackgui/mainwindow.hpp @@ -62,6 +62,7 @@ private slots: void onClearFileList(); void onClearErrorList(); void onClearLog(); + void onComboTextEdited(const QString& oldText, const QString& newText); void onCurrentChanged(const QModelIndex& current, const QModelIndex& previous); void onCurrentTabChanged(int index); void onDeleteItem(); diff --git a/appl/rebackgui/mainwindow.ui b/appl/rebackgui/mainwindow.ui index 6c4bdf1..5bbe079 100644 --- a/appl/rebackgui/mainwindow.ui +++ b/appl/rebackgui/mainwindow.ui @@ -570,7 +570,7 @@ - + <html><head/><body><p>A comma (',') separated list of filename patterns. A prefix of '-' means inversion: if a filename matches it will not be found.</p><p>Example: *.txt,*.odt</p></body></html> @@ -579,12 +579,12 @@ - *,*~,*.bak + *,-*~,-*.bak - * + * @@ -603,7 +603,7 @@ - + <html><head/><body><p>A comma (',') separated list of directory name patterns. A prefix of '-' means inversion: if a directory name matches it will not be found.</p><p>Example: *,-.git,-*cache*</p></body></html> @@ -612,12 +612,12 @@ - *,-*cache*,*thumbnails* + *,-*cache*,-*thumbnails* - * + * @@ -932,6 +932,13 @@ + + + ReComboBox + QComboBox +
gui/ReComboBox.hpp
+
+
diff --git a/appl/rebackgui/rebackgui.de.qm b/appl/rebackgui/rebackgui.de.qm index 8bda667832aa9decb021abce9f2f7b0eae927fae..495c549dae543fc8b104309b7836c51c54941b2b 100644 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ebackgui.de.ts index 3c5b081..534f7d4 100644 --- a/appl/rebackgui/rebackgui.de.ts +++ b/appl/rebackgui/rebackgui.de.ts @@ -209,7 +209,7 @@ p, li { white-space: pre-wrap; } - + Calculates checksums for source and target files and reports differences Berechnet Prüfsummen für Quell- und Zieldateien und meldet Unterschiede @@ -236,8 +236,8 @@ p, li { white-space: pre-wrap; } - - + + Clear Löschen @@ -305,170 +305,196 @@ p, li { white-space: pre-wrap; } <html><head/><body><p>Eine Liste von Dateinamensmustern, getrennt mit Komma (',') . Ein Präfix '-' bedeuted Umkehrung: Wenn ein Dateiname passt, wird er nicht gefunden.</p><p>Beispiel: *.txt,*.odt</p></body></html> - + + *,*~,*.bak + *,*~,*.bak + + + + + * + * + + + Dir patterns: Verzeichnismuster: - + <html><head/><body><p>A comma (',') separated list of directory name patterns. A prefix of '-' means inversion: if a directory name matches it will not be found.</p><p>Example: *,-.git,-*cache*</p></body></html> <html><head/><body><p>Eine Liste von Verzeichnisnamensmustern, getrennt mit Komma (',') . Ein Präfix '-' bedeuted Umkehrung: Wenn ein Verzeichnisname passt, wird er nicht gefunden.</p><p>Beispiel: *,-.git,-*cache*</p></body></html> - + + *,-*cache*,*thumbnails* + *,-*cache*,*thumbnails* + + + Source dirs: Quelldateien: - + Add source Hinzufügen - + Delete source Löschen - + Files Dateien - + File log: Dateiliste: - + Errors Fehler - + Error log: Fehlerprotokoll: - + Fi&le File Bearbeiten Datei - + Edi&t Edit Bearbeiten - + Hel&p Help Hilfe - + A&ction Aktion - + &Load Config Load Config Konfiguration laden - + &Save Config Save Config Konfiguration sichern - + &Exit Exit Beenden - + &Start backup Start backup Sicherung starten - + St&op Halt - + &About About Über - + &Checksums Prüfsummen - + C&lean Löschen - + &English English Englisch - + &German German Deutsch - + &Autosave &Autom. speichern - - - + + + no backup item selected Kein Sicherungselement ausgewählt - - - + + + Target not available Ziel nicht vorhanden - + Select Source Directory Quellverzeichnis auswählen - + Select Target Directory Zielverzeichnis auswählen - + target initialized with %1 Ziel mit %1 vorbelegt - + Aborted by the user Abbruch durch den Benutzer + + + device %1 successfully unmounted + Gerät %1 erfolgreich entfernt + + + + cannot unmount device %1: %2 + Kann das Gerät nicht entfernen: %1: %2 + QObject @@ -483,142 +509,142 @@ p, li { white-space: pre-wrap; } kann Verzeichnis nicht anlegen (%1): %2 - - + + %1 of %2 (%3 of %4) %5 MB/sec runtime: %6 %1 von %2 (%3 von %4) %5 MB/sec Laufzeit: %6 - + backup complete after %1. Errors: %2 Sicherung nach %1 fertiggestellt Fehler: %2 - + cannot build checksum: %1 Kann Prüfsumme nicht ermitteln: %1 - + Building source checksum complete after %1. Processed: %2 Erzeugen der Prüfsummen für die Quelldateien fertig nach %1. Bearbeitet: %2 - + checksum differs: Prüfsummen unterscheiden sich: - + Building target checksums complete after %1. Processed: %2 Errors: %3 Erzeugen der Prüfsummen für die Zieldateien fertig nach %1. Bearbeitet: %2 Fehler: %3 - + cannot delete (%1): %2 Kann nicht löschen (%1): %2 - + cannot remove directory (%1): %2 Kann Verzeichnis nicht erstellen (%1): %2 - + cannot create the shadow directory: %1 Kann das Schattenverzeichnis nicht erstellen: %1 - + cannot delete shadow file (%1): %2 Kann Schattendatei nicht löschen (%1): %2 - + cannot rename target file (%1): %2 -> %3 Kann Zieldatei nicht umbenennen (%1): %2 -> %3 - + %1 of %2 files %3 files/sec runtime: %6 %1 von %2 Dateien %3 Dateien/sec Laufzeit: %6 - + clean complete after %1. Errors: %2 Bereinigen fertig nach %1. Fehler: %2 - + Search finished: to process: %1 with %2 matching: %3 total: %4 subdirs: %5 runtime: %6 Suche beendet: zu behandeln: %1 mit %2 passend: %3 gesamt: %4 Unterverz: %5 Laufzeit: %6 - + kann Schattenverzeichnis nicht umbenennen: %1 -> %2 kann Schattenverzeichnis nicht umbenennen: %1 -> %2 - + cannot create shadow directory (%1): %2 Kann Schattenverzeichnis nicht erstellen (%1): %2 - + cannot move to shadow directory (%1): %2 -> %3 Kann Datei nicht in Schattenverzeichnis verschieben (%1): %2 -> %3 - + Search in target finished: to process: %1 with %2 dirs to delete: %3 total: %4 subdirs: %5 runtime: %6 Suche im Ziel bendet: zu behandeln: %1 mit %2 zu löschende Verzeichnisse: %3 gesamt: %4 Unterverz.: %5 Laufzeit: %6 - + item Element - - - - + + + + cannot open (%1): %2 Kann nicht öffnen (%1): %2 - + unknown format in %1-%2: %3 Unbekanntes Format in %1-%2: %3 - + cannot write (%1): %2 Kann nicht schreiben (%1): %2 - + configuration saved: %1 configuration changed: %1 Konfiguration gespeichert: %1 - + Search started... Suche gestartet... - + yes Ja - + no nein - + not found: %1 Nicht gefunden: %1 @@ -627,47 +653,47 @@ p, li { white-space: pre-wrap; } Kann nicht schreiben(%1): %2 [%3/%4] - + copy file failed (%1): %2 Dateikopieren missglückt (%1): %2 - + not a regular file: %1 Keine normale Datei: %1 - + cannot write (%1): %2 [%3/%4] Kann nicht schreiben(%1): %2 [%3/%4] - + file can be read only partitionally: %1 [%2/%3] Datei kann nur teilweise gelesen werden: %1 [%2/%3] - + cannot set date/time (%1): %2 Kann Datum/Zeit nicht setzen (%1): %2 - + cannot set permissions (%1): %2 Kann Dateirechte nicht setzen (%1): %2 - + cannot set user/gid [%1/%2] (%3): %4 Kann Benutzer/Gruppe nicht setzen [%1/%2] (%3): %4 - + can't create directory (%1): %2 Kann Verzeichnis nicht erzeugen (%1): %2 - + can't create directory (is a file): Kann Verzeichnis nicht erzeugen (ist eine Datei): diff --git a/appl/rebackgui/rebackgui.pro b/appl/rebackgui/rebackgui.pro index ba86e1c..9e7410b 100644 --- a/appl/rebackgui/rebackgui.pro +++ b/appl/rebackgui/rebackgui.pro @@ -33,7 +33,8 @@ SOURCES += main.cpp\ aboutdialog.cpp \ Configuration.cpp \ BackupEngine.cpp \ - BackupUtils.cpp + BackupUtils.cpp \ + ../../gui/ReComboBox.cpp HEADERS += mainwindow.hpp \ ../../base/rebase.hpp \ @@ -46,7 +47,8 @@ HEADERS += mainwindow.hpp \ Configuration.hpp \ backupgui.hpp \ BackupEngine.hpp \ - BackupUtils.hpp + BackupUtils.hpp \ + ../../gui/ReComboBox.hpp FORMS += mainwindow.ui \ aboutdialog.ui diff --git a/base/ReFileUtils.cpp b/base/ReFileUtils.cpp index 99a8b24..5815b74 100644 --- a/base/ReFileUtils.cpp +++ b/base/ReFileUtils.cpp @@ -949,7 +949,6 @@ ReSuccess_t ReFileUtils::setTimes(const char* filename, const QDateTime& modifie // QT solution: QString filename2(filename); QDir info(filename2); - if (info.set struct utimbuf times; times.actime = time_t(accessed.currentMSecsSinceEpoch() / 1000); times.modtime = time_t(modified.currentMSecsSinceEpoch() / 1000); diff --git a/base/rebase.hpp b/base/rebase.hpp index 986fa58..2f93a66 100644 --- a/base/rebase.hpp +++ b/base/rebase.hpp @@ -88,6 +88,7 @@ typedef int mode_t; #define _rmdir rmdir #define _unlink unlink #define _snprintf snprintf +#define _strnicmp strnicmp //typedef qint64 uint64_t; #else #define S_ISDIR(mode) (((mode) & _S_IFDIR) != 0) diff --git a/gui/ReComboBox.cpp b/gui/ReComboBox.cpp new file mode 100644 index 0000000..2eea037 --- /dev/null +++ b/gui/ReComboBox.cpp @@ -0,0 +1,78 @@ +/* + * Licence: + * You can use and modify this file without any restriction. + * There is no warranty. + * You also can use the licence from http://www.wtfpl.net/. + * The original sources can be found on https://github.com/republib. +*/ +#include "base/rebase.hpp" +#include "gui/regui.hpp" + +/** + * Constructor. + * + * @param parent the widget which destroys the instance or NULL + */ +ReComboBox::ReComboBox(QWidget *parent) : + QComboBox(parent), + m_oldString(), + m_historySize(0) +{ +} + +/** + * Event thrown if the focus comes to the instance. + * + * @param event the event + */ +void ReComboBox::focusInEvent(QFocusEvent* event) +{ + if (event->gotFocus()) + m_oldString = currentText(); + QComboBox::focusInEvent(event); +} + +/** + * Event thrown if the focus leaves the instance. + * + * @param event the event + */ +void ReComboBox::focusOutEvent(QFocusEvent* event) +{ + if (event->lostFocus()){ + QString current = currentText(); + if (current != m_oldString){ + if (m_historySize > 0){ + int ix = findText(current); + if (ix >= 0) + removeItem(ix); + insertItem(0, current); + if (count() > m_historySize) + removeItem(m_historySize); + + } + comboTextEdited(m_oldString, current); + } + } + QComboBox::focusOutEvent(event); +} + +/** + * Returns the number of history entries in the combobox list. + * + * @return 0: the history is not stored in the combobox list + * otherwise: the maximal number of entries + */ +int ReComboBox::historySize() const +{ + return m_historySize; +} + +/** + * @brief ReComboBox::setHistorySize + * @param size + */ +void ReComboBox::setHistorySize(int size) +{ + m_historySize = size; +} diff --git a/gui/ReComboBox.hpp b/gui/ReComboBox.hpp new file mode 100644 index 0000000..5cfa16c --- /dev/null +++ b/gui/ReComboBox.hpp @@ -0,0 +1,34 @@ +/* + * Licence: + * You can use and modify this file without any restriction. + * There is no warranty. + * You also can use the licence from http://www.wtfpl.net/. + * The original sources can be found on https://github.com/republib. +*/ + +#ifndef RECOMBOBOX_HPP +#define RECOMBOBOX_HPP + +#include +#include + +class ReComboBox : public QComboBox +{ + Q_OBJECT +public: + explicit ReComboBox(QWidget *parent = 0); +public: + int historySize() const; + void setHistorySize(int size); + +signals: + void comboTextEdited(const QString& oldText, const QString& newText); +private: + virtual void focusInEvent(QFocusEvent* event); + virtual void focusOutEvent(QFocusEvent* event); +private: + QString m_oldString; + int m_historySize; +}; + +#endif // RECOMBOBOX_HPP diff --git a/gui/regui.hpp b/gui/regui.hpp index 6fb6451..566e3c6 100644 --- a/gui/regui.hpp +++ b/gui/regui.hpp @@ -26,6 +26,7 @@ #include "gui/ReEdit.hpp" #include "gui/ReSettings.hpp" #include "gui/ReFileTree.hpp" +#include "gui/ReComboBox.hpp" /** * Tests whether a point is inside the rectangle (including border). -- 2.39.5