mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Export dialog in Edit Database Cell uses data type for extension filter
The extension filter is adjusted to the type of data loaded in the editor. Previously, only image extensions were adjusted, remaining were treated as text. Now the following are used: *.bin, *.txt, *.json and *.svg. For coherence, the *.bin filter is added to the import dialog.
This commit is contained in:
@@ -290,7 +290,7 @@ void EditDialog::importData()
|
||||
this,
|
||||
tr("Choose a file to import")
|
||||
#ifndef Q_OS_MAC // Filters on OS X are buggy
|
||||
, tr("Text files (*.txt);;Image files (%1);;JSON files (*.json);;XML files (*.xml);;All files (*)").arg(image_formats)
|
||||
, tr("Text files (*.txt);;Image files (%1);;JSON files (*.json);;XML files (*.xml);;Binary files (*.bin);;All files (*)").arg(image_formats)
|
||||
#endif
|
||||
);
|
||||
if(QFile::exists(fileName))
|
||||
@@ -312,15 +312,29 @@ void EditDialog::exportData()
|
||||
{
|
||||
// Images get special treatment
|
||||
QString fileExt;
|
||||
if (dataType == Image) {
|
||||
switch (dataType) {
|
||||
case Image: {
|
||||
// Determine the likely filename extension
|
||||
QByteArray cellData = hexEdit->data();
|
||||
QBuffer imageBuffer(&cellData);
|
||||
QImageReader imageReader(&imageBuffer);
|
||||
QString imageFormat = imageReader.format();
|
||||
fileExt = imageFormat.toUpper() % " " % tr("Image") % "(*." % imageFormat.toLower() % ");;All files(*)";
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
case Binary:
|
||||
case Null:
|
||||
fileExt = tr("Binary files(*.bin);;All files(*)");
|
||||
break;
|
||||
case Text:
|
||||
fileExt = tr("Text files(*.txt);;All files(*)");
|
||||
break;
|
||||
case JSON:
|
||||
fileExt = tr("JSON files(*.json);;All files(*)");
|
||||
break;
|
||||
case SVG:
|
||||
fileExt = tr("SVG files(*.svg);;All files(*)");
|
||||
break;
|
||||
}
|
||||
|
||||
QString fileName = FileDialog::getSaveFileName(
|
||||
@@ -342,7 +356,7 @@ void EditDialog::exportData()
|
||||
file.write(ui->editorText->toPlainText().toUtf8());
|
||||
break;
|
||||
case SciBuffer:
|
||||
// Data source is the JSON buffer
|
||||
// Data source is the Scintilla buffer
|
||||
file.write(sciEdit->text().toUtf8());
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user