mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
Little corrections for history handling
This commit is contained in:
parent
e00415e4d2
commit
78d450e1ca
19
config.cc
19
config.cc
|
@ -650,9 +650,6 @@ Class load() throw( exError )
|
|||
if ( !preferences.namedItem( "maxStringsInHistory" ).isNull() )
|
||||
c.preferences.maxStringsInHistory = preferences.namedItem( "maxStringsInHistory" ).toElement().text().toUInt() ;
|
||||
|
||||
if ( !preferences.namedItem( "historyExportPath" ).isNull() )
|
||||
c.preferences.historyExportPath = preferences.namedItem( "historyExportPath" ).toElement().text();
|
||||
|
||||
if ( !preferences.namedItem( "storeHistory" ).isNull() )
|
||||
c.preferences.storeHistory = preferences.namedItem( "storeHistory" ).toElement().text().toUInt() ;
|
||||
}
|
||||
|
@ -697,6 +694,9 @@ Class load() throw( exError )
|
|||
if ( !root.namedItem( "maxDictionaryRefsInContextMenu" ).isNull() )
|
||||
c.maxDictionaryRefsInContextMenu = root.namedItem( "maxDictionaryRefsInContextMenu" ).toElement().text().toUShort();
|
||||
|
||||
if ( !root.namedItem( "historyExportPath" ).isNull() )
|
||||
c.historyExportPath = root.namedItem( "historyExportPath" ).toElement().text();
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -1218,12 +1218,6 @@ void save( Class const & c ) throw( exError )
|
|||
opt.appendChild( dd.createTextNode( QString::number( c.preferences.storeHistory ) ) );
|
||||
preferences.appendChild( opt );
|
||||
|
||||
if( !c.preferences.historyExportPath.isEmpty() )
|
||||
{
|
||||
opt = dd.createElement( "historyExportPath" );
|
||||
opt.appendChild( dd.createTextNode( c.preferences.historyExportPath ) );
|
||||
preferences.appendChild( opt );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1274,6 +1268,13 @@ void save( Class const & c ) throw( exError )
|
|||
opt = dd.createElement( "maxDictionaryRefsInContextMenu" );
|
||||
opt.appendChild( dd.createTextNode( QString::number( c.maxDictionaryRefsInContextMenu ) ) );
|
||||
root.appendChild( opt );
|
||||
|
||||
if( !c.historyExportPath.isEmpty() )
|
||||
{
|
||||
opt = dd.createElement( "historyExportPath" );
|
||||
opt.appendChild( dd.createTextNode( c.historyExportPath ) );
|
||||
root.appendChild( opt );
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray result( dd.toByteArray() );
|
||||
|
|
|
@ -181,7 +181,6 @@ struct Preferences
|
|||
int wordsZoomLevel;
|
||||
|
||||
unsigned maxStringsInHistory;
|
||||
QString historyExportPath;
|
||||
unsigned storeHistory;
|
||||
|
||||
Preferences();
|
||||
|
@ -372,6 +371,8 @@ struct Class
|
|||
QByteArray popupWindowState; // Binary state saved by QMainWindow
|
||||
QByteArray popupWindowGeometry; // Geometry saved by QMainWindow
|
||||
|
||||
QString historyExportPath; // Path for export/import history
|
||||
|
||||
bool pinPopupWindow; // Last pin status
|
||||
|
||||
QByteArray mainWindowState; // Binary state saved by QMainWindow
|
||||
|
|
|
@ -2705,11 +2705,11 @@ static bool needHideSearchPane;
|
|||
void MainWindow::on_exportHistory_activated()
|
||||
{
|
||||
QString exportPath;
|
||||
if( cfg.preferences.historyExportPath.isEmpty() )
|
||||
if( cfg.historyExportPath.isEmpty() )
|
||||
exportPath = QDir::homePath();
|
||||
else
|
||||
{
|
||||
exportPath = QDir::fromNativeSeparators( cfg.preferences.historyExportPath );
|
||||
exportPath = QDir::fromNativeSeparators( cfg.historyExportPath );
|
||||
if( !QDir( exportPath ).exists() )
|
||||
exportPath = QDir::homePath();
|
||||
}
|
||||
|
@ -2720,7 +2720,7 @@ void MainWindow::on_exportHistory_activated()
|
|||
if( fileName.size() == 0)
|
||||
return;
|
||||
|
||||
cfg.preferences.historyExportPath = QDir::toNativeSeparators( QFileInfo( fileName ).absoluteDir().absolutePath() );
|
||||
cfg.historyExportPath = QDir::toNativeSeparators( QFileInfo( fileName ).absoluteDir().absolutePath() );
|
||||
QFile file( fileName );
|
||||
|
||||
for(;;)
|
||||
|
@ -2766,11 +2766,11 @@ void MainWindow::on_exportHistory_activated()
|
|||
void MainWindow::on_importHistory_activated()
|
||||
{
|
||||
QString importPath;
|
||||
if( cfg.preferences.historyExportPath.isEmpty() )
|
||||
if( cfg.historyExportPath.isEmpty() )
|
||||
importPath = QDir::homePath();
|
||||
else
|
||||
{
|
||||
importPath = QDir::fromNativeSeparators( cfg.preferences.historyExportPath );
|
||||
importPath = QDir::fromNativeSeparators( cfg.historyExportPath );
|
||||
if( !QDir( importPath ).exists() )
|
||||
importPath = QDir::homePath();
|
||||
}
|
||||
|
@ -2782,7 +2782,7 @@ void MainWindow::on_importHistory_activated()
|
|||
return;
|
||||
|
||||
QFileInfo fileInfo( fileName );
|
||||
cfg.preferences.historyExportPath = QDir::toNativeSeparators( fileInfo.absoluteDir().absolutePath() );
|
||||
cfg.historyExportPath = QDir::toNativeSeparators( fileInfo.absoluteDir().absolutePath() );
|
||||
QString errStr;
|
||||
QFile file( fileName );
|
||||
|
||||
|
@ -2884,8 +2884,10 @@ void MainWindow::forceAddWordToHistory( const QString & word )
|
|||
|
||||
fillWordListFromHistory();
|
||||
|
||||
if( index < 0 || index >= ui.wordList->count() || currentWord.compare( ui.wordList->item( index )->text() ) != 0 )
|
||||
if( index < 0 || index >= ui.wordList->count() )
|
||||
index = 0;
|
||||
if( index && currentWord.compare( ui.wordList->item( index )->text() ) != 0 )
|
||||
index = currentWord.compare( ui.wordList->item( index - 1 )->text() ) == 0 ? index - 1 : 0;
|
||||
|
||||
if( index )
|
||||
disconnect( ui.wordList, SIGNAL( itemSelectionChanged() ),
|
||||
|
|
Loading…
Reference in a new issue