1717#include " CipherDialog.h"
1818#include " ExportSqlDialog.h"
1919#include " SqlUiLexer.h"
20+ #include " FileDialog.h"
2021
21- #include < QFileDialog>
2222#include < QFile>
2323#include < QApplication>
2424#include < QTextStream>
@@ -198,10 +198,9 @@ bool MainWindow::fileOpen(const QString& fileName, bool dontAddToRecentFiles)
198198 QString wFile = fileName;
199199 if (!QFile::exists (wFile))
200200 {
201- wFile = QFileDialog ::getOpenFileName (
201+ wFile = FileDialog ::getOpenFileName (
202202 this ,
203- tr (" Choose a database file" ),
204- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString ()
203+ tr (" Choose a database file" )
205204#ifndef Q_OS_MAC // Filters on OS X are buggy
206205 , tr (" SQLite database files (*.db *.sqlite *.sqlite3 *.db3);;All files (*)" )
207206#endif
@@ -243,7 +242,7 @@ bool MainWindow::fileOpen(const QString& fileName, bool dontAddToRecentFiles)
243242
244243void MainWindow::fileNew ()
245244{
246- QString fileName = QFileDialog ::getSaveFileName (this , tr (" Choose a filename to save under" ), PreferencesDialog::getSettingsValue ( " db " , " defaultlocation " ). toString ( ));
245+ QString fileName = FileDialog ::getSaveFileName (this , tr (" Choose a filename to save under" ));
247246 if (!fileName.isEmpty ())
248247 {
249248 if (QFile::exists (fileName))
@@ -826,10 +825,9 @@ void MainWindow::mainTabSelected(int tabindex)
826825
827826void MainWindow::importTableFromCSV ()
828827{
829- QString wFile = QFileDialog ::getOpenFileName (
828+ QString wFile = FileDialog ::getOpenFileName (
830829 this ,
831830 tr (" Choose a text file" ),
832- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString (),
833831 tr (" Text files(*.csv *.txt);;All files(*)" ));
834832
835833 if (QFile::exists (wFile) )
@@ -898,10 +896,9 @@ void MainWindow::exportDatabaseToSQL()
898896void MainWindow::importDatabaseFromSQL ()
899897{
900898 // Get file name to import
901- QString fileName = QFileDialog ::getOpenFileName (
899+ QString fileName = FileDialog ::getOpenFileName (
902900 this ,
903901 tr (" Choose a file to import" ),
904- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString (),
905902 tr (" Text files(*.sql *.txt);;All files(*)" ));
906903
907904 // Cancel when file doesn't exist
@@ -916,10 +913,9 @@ void MainWindow::importDatabaseFromSQL()
916913 " If you answer no we will attempt to import the data in the SQL file to the current database." ),
917914 QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) || !db.isOpen ())
918915 {
919- newDbFile = QFileDialog ::getSaveFileName (
916+ newDbFile = FileDialog ::getSaveFileName (
920917 this ,
921- tr (" Choose a filename to save under" ),
922- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString ());
918+ tr (" Choose a filename to save under" ));
923919 if (QFile::exists (newDbFile))
924920 {
925921 QMessageBox::information (this , QApplication::applicationName (), tr (" File %1 already exists. Please choose a different name." ).arg (newDbFile));
@@ -1250,10 +1246,9 @@ unsigned int MainWindow::openSqlTab(bool resetCounter)
12501246
12511247void MainWindow::openSqlFile ()
12521248{
1253- QString file = QFileDialog ::getOpenFileName (
1249+ QString file = FileDialog ::getOpenFileName (
12541250 this ,
12551251 tr (" Select SQL file to open" ),
1256- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString (),
12571252 tr (" Text files(*.sql *.txt);;All files(*)" ));
12581253
12591254 if (QFile::exists (file))
@@ -1297,10 +1292,9 @@ void MainWindow::saveSqlFile()
12971292
12981293void MainWindow::saveSqlFileAs ()
12991294{
1300- QString file = QFileDialog ::getSaveFileName (
1295+ QString file = FileDialog ::getSaveFileName (
13011296 this ,
13021297 tr (" Select file name" ),
1303- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString (),
13041298 tr (" Text files(*.sql *.txt);;All files(*)" ));
13051299
13061300 if (!file.isEmpty ())
@@ -1313,10 +1307,9 @@ void MainWindow::saveSqlFileAs()
13131307
13141308void MainWindow::loadExtension ()
13151309{
1316- QString file = QFileDialog ::getOpenFileName (
1310+ QString file = FileDialog ::getOpenFileName (
13171311 this ,
13181312 tr (" Select extension file" ),
1319- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString (),
13201313 tr (" Extensions(*.so *.dll);;All files(*)" ));
13211314
13221315 if (file.isEmpty ())
@@ -1719,9 +1712,8 @@ void MainWindow::on_treePlotColumns_itemDoubleClicked(QTreeWidgetItem *item, int
17191712
17201713void MainWindow::on_butSavePlot_clicked ()
17211714{
1722- QString fileName = QFileDialog ::getSaveFileName (this ,
1715+ QString fileName = FileDialog ::getSaveFileName (this ,
17231716 tr (" Choose a filename to save under" ),
1724- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString (),
17251717 tr (" PNG(*.png);;JPG(*.jpg);;PDF(*.pdf);;BMP(*.bmp);;All Files(*)" )
17261718 );
17271719 if (!fileName.isEmpty ())
@@ -1790,9 +1782,8 @@ bool MainWindow::loadProject(QString filename)
17901782 // Show the open file dialog when no filename was passed as parameter
17911783 if (filename.isEmpty ())
17921784 {
1793- filename = QFileDialog ::getOpenFileName (this ,
1785+ filename = FileDialog ::getOpenFileName (this ,
17941786 tr (" Choose a file to open" ),
1795- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString (),
17961787 tr (" DB Browser for SQLite project file (*.sqbpro)" ));
17971788 }
17981789
@@ -1930,9 +1921,8 @@ static void saveDbTreeState(const QTreeView* tree, QXmlStreamWriter& xml, QModel
19301921
19311922void MainWindow::saveProject ()
19321923{
1933- QString filename = QFileDialog ::getSaveFileName (this ,
1924+ QString filename = FileDialog ::getSaveFileName (this ,
19341925 tr (" Choose a filename to save under" ),
1935- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString (),
19361926 tr (" DB Browser for SQLite project file (*.sqbpro)" )
19371927 );
19381928 if (!filename.isEmpty ())
@@ -2014,10 +2004,9 @@ void MainWindow::saveProject()
20142004void MainWindow::fileAttach ()
20152005{
20162006 // Get file name of database to attach
2017- QString file = QFileDialog ::getOpenFileName (
2007+ QString file = FileDialog ::getOpenFileName (
20182008 this ,
2019- tr (" Choose a database file" ),
2020- PreferencesDialog::getSettingsValue (" db" , " defaultlocation" ).toString ());
2009+ tr (" Choose a database file" ));
20212010 if (!QFile::exists (file))
20222011 return ;
20232012
0 commit comments