@@ -48,29 +48,14 @@ VersionDialog::VersionDialog(const QJSValue &versions, QWidget *parent)
4848    QString itemName;
4949    QString diffHtml;
5050    ui->versionListWidget ->clear ();
51-     diffList  = new  QStringList ();
52-     dataList  = new  QStringList ();
53-     auto  currentNote = MainWindow::instance ()->getCurrentNote ();
51+     _diffList  = new  QStringList ();
52+     _dataList  = new  QStringList ();
53+     const   auto  currentNote = MainWindow::instance ()->getCurrentNote ();
5454    bool  canDecryptNoteText = currentNote.canDecryptNoteText ();
5555
56-     qDebug () << __func__
57-              << "  - 'currentNote.canDecryptNoteText()': " canDecryptNoteText ();
58- 
59-     //     if (currentNote.canDecryptNoteText()) {
60-     //         const QSignalBlocker blocker(ui->encryptedNoteTextEdit);
61-     //         Q_UNUSED(blocker)
62-     // 
63-     //         ui->noteTextEdit->hide();
64-     //         const auto text = currentNote.fetchDecryptedNoteText();
65- 
6656    //  Init the iterator for the versions
6757    QJSValueIterator versionsIterator (versions);
6858
69-     //  This seems to report a hasNext even if there aren't any items
70-     if  (!versionsIterator.hasNext ()) {
71-         return ;
72-     }
73- 
7459    //  Iterate over the versions
7560    while  (versionsIterator.hasNext ()) {
7661        versionsIterator.next ();
@@ -93,19 +78,21 @@ VersionDialog::VersionDialog(const QJSValue &versions, QWidget *parent)
9378        diffHtml.replace (QLatin1String (" \n " QLatin1String (" <br />" 
9479
9580        ui->versionListWidget ->addItem (itemName);
96-         diffList ->append (diffHtml);
81+         _diffList ->append (diffHtml);
9782        QString noteText = versionsIterator.value ().property (QStringLiteral (" data" toString ();
9883
9984        //  Decrypt the note text if possible
10085        if  (canDecryptNoteText) {
10186            noteText = currentNote.getDecryptedNoteText (Note::parseEncryptedNoteText (noteText));
10287        }
10388
104-         dataList ->append (noteText);
89+         _dataList ->append (noteText);
10590    }
10691
107-     ui->versionListWidget ->setCurrentRow (0 );
108-     ui->diffBrowser ->setHtml (diffList->at (0 ));
92+     if  (!_diffList->isEmpty ()) {
93+         ui->versionListWidget ->setCurrentRow (0 );
94+         ui->diffBrowser ->setHtml (_diffList->at (0 ));
95+     }
10996}
11097
11198void  VersionDialog::setupMainSplitter () {
@@ -131,16 +118,16 @@ void VersionDialog::storeSettings() {
131118VersionDialog::~VersionDialog () { delete  ui; }
132119
133120void  VersionDialog::on_versionListWidget_currentRowChanged (int  currentRow) {
134-     ui->diffBrowser ->setHtml (diffList ->value (currentRow));
135-     ui->noteTextEdit ->setPlainText (dataList ->value (currentRow));
121+     ui->diffBrowser ->setHtml (_diffList ->value (currentRow));
122+     ui->noteTextEdit ->setPlainText (_dataList ->value (currentRow));
136123}
137124
138125void  VersionDialog::dialogButtonClicked (QAbstractButton *button) {
139126    int  actionRole = button->property (" ActionRole" toInt ();
140127
141128    if  (actionRole == Restore) {
142129        MainWindow::instance ()->setCurrentNoteText (
143-             dataList ->value (ui->versionListWidget ->currentRow ()));
130+             _dataList ->value (ui->versionListWidget ->currentRow ()));
144131    }
145132
146133    this ->close ();
0 commit comments