~adamreichold/qpdfview/trunk

« back to all changes in this revision

Viewing changes to sources/database.cpp

  • Committer: Adam Reichold
  • Date: 2015-01-02 11:17:40 UTC
  • Revision ID: adam.reichold@t-online.de-20150102111740-d67h9wbucjtcs5jd
Replace the signal-slot mechanism for restoring tabs by an explicit closure and hence move most of the logic for restoring properties into the database class to improve performance and consistency with the per-file settings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
    return instanceNames;
142
142
}
143
143
 
144
 
void Database::restoreTabs()
 
144
void Database::restoreTabs(const RestoreTab& restoreTab)
145
145
{
146
146
#ifdef WITH_SQL
147
147
 
164
164
                return;
165
165
            }
166
166
 
167
 
            emit tabRestored(query.value(0).toString(),
168
 
                             static_cast< bool >(query.value(2).toUInt()),
169
 
                             static_cast< LayoutMode >(query.value(3).toUInt()),
170
 
                             query.value(4).toBool(),
171
 
                             static_cast< ScaleMode >(query.value(5).toUInt()),
172
 
                             query.value(6).toReal(),
173
 
                             static_cast< Rotation >(query.value(7).toUInt()),
174
 
                             query.value(1).toInt());
 
167
            DocumentView* newTab = restoreTab(query.value(0).toString());
 
168
 
 
169
            if(newTab != 0)
 
170
            {
 
171
                newTab->setContinuousMode(query.value(2).toBool());
 
172
                newTab->setLayoutMode(static_cast< LayoutMode >(query.value(3).toUInt()));
 
173
                newTab->setRightToLeftMode(query.value(4).toBool());
 
174
 
 
175
                newTab->setScaleMode(static_cast< ScaleMode >(query.value(5).toUInt()));
 
176
                newTab->setScaleFactor(query.value(6).toReal());
 
177
 
 
178
                newTab->setRotation(static_cast< Rotation >(query.value(7).toUInt()));
 
179
 
 
180
                newTab->jumpToPage(query.value(1).toInt());
 
181
            }
175
182
        }
176
183
 
177
184
        transaction.commit();
212
219
            query.bindValue(1, instanceName());
213
220
            query.bindValue(2, tab->currentPage());
214
221
 
215
 
            query.bindValue(3, static_cast< uint >(tab->continuousMode()));
 
222
            query.bindValue(3, tab->continuousMode());
216
223
            query.bindValue(4, static_cast< uint >(tab->layoutMode()));
217
 
            query.bindValue(5, static_cast< uint >(tab->rightToLeftMode()));
 
224
            query.bindValue(5, tab->rightToLeftMode());
218
225
 
219
226
            query.bindValue(6, static_cast< uint >(tab->scaleMode()));
220
227
            query.bindValue(7, tab->scaleFactor());
458
465
        query.bindValue(1, QCryptographicHash::hash(tab->fileInfo().absoluteFilePath().toUtf8(), QCryptographicHash::Sha1).toBase64());
459
466
        query.bindValue(2, tab->currentPage());
460
467
 
461
 
        query.bindValue(3, static_cast< uint >(tab->continuousMode()));
 
468
        query.bindValue(3, tab->continuousMode());
462
469
        query.bindValue(4, static_cast< uint >(tab->layoutMode()));
463
 
        query.bindValue(5, static_cast< uint >(tab->rightToLeftMode()));
 
470
        query.bindValue(5, tab->rightToLeftMode());
464
471
 
465
472
        query.bindValue(6, static_cast< uint >(tab->scaleMode()));
466
473
        query.bindValue(7, tab->scaleFactor());