Store path for history export/import

This commit is contained in:
Abs62 2012-09-10 22:00:29 +04:00
parent 54bba79c60
commit d33c1fb34a
3 changed files with 35 additions and 2 deletions

View file

@ -648,6 +648,9 @@ 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();
}
c.lastMainGroupId = root.namedItem( "lastMainGroupId" ).toElement().text().toUInt();
@ -1206,6 +1209,13 @@ void save( Class const & c ) throw( exError )
opt = dd.createElement( "maxStringsInHistory" );
opt.appendChild( dd.createTextNode( QString::number( c.preferences.maxStringsInHistory ) ) );
preferences.appendChild( opt );
if( !c.preferences.historyExportPath.isEmpty() )
{
opt = dd.createElement( "historyExportPath" );
opt.appendChild( dd.createTextNode( c.preferences.historyExportPath ) );
preferences.appendChild( opt );
}
}
{

View file

@ -181,6 +181,7 @@ struct Preferences
int wordsZoomLevel;
unsigned maxStringsInHistory;
QString historyExportPath;
Preferences();
};

View file

@ -2683,12 +2683,23 @@ static bool needHideSearchPane;
void MainWindow::on_exportHistory_activated()
{
QString exportPath;
if( cfg.preferences.historyExportPath.isEmpty() )
exportPath = QDir::homePath();
else
{
exportPath = QDir::fromNativeSeparators( cfg.preferences.historyExportPath );
if( !QDir( exportPath ).exists() )
exportPath = QDir::homePath();
}
QString fileName = QFileDialog::getSaveFileName( this, tr( "Export history to file" ),
QDir::homePath(),
exportPath,
tr( "Text files (*.txt);;All files (*.*)" ) );
if( fileName.size() == 0)
return;
cfg.preferences.historyExportPath = QDir::toNativeSeparators( QFileInfo( fileName ).absoluteDir().absolutePath() );
QFile file( fileName );
for(;;)
@ -2733,12 +2744,23 @@ void MainWindow::on_exportHistory_activated()
void MainWindow::on_importHistory_activated()
{
QString importPath;
if( cfg.preferences.historyExportPath.isEmpty() )
importPath = QDir::homePath();
else
{
importPath = QDir::fromNativeSeparators( cfg.preferences.historyExportPath );
if( !QDir( importPath ).exists() )
importPath = QDir::homePath();
}
QString fileName = QFileDialog::getOpenFileName( this, tr( "Import history from file" ),
QDir::homePath(),
importPath,
tr( "Text files (*.txt);;All files (*.*)" ) );
if( fileName.size() == 0)
return;
cfg.preferences.historyExportPath = QDir::toNativeSeparators( QFileInfo( fileName ).absoluteDir().absolutePath() );
QString errStr;
QFile file( fileName );