Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 22420 → Rev 22422

/trunk/Scribus/scribus/gtgettext.cpp
67,8 → 67,7
// If the map is found, assign ida to the corresponding struct in the map.
ida = *m_importerMap[fend];
// Otherwise, test for the lowercase version
else
if (m_importerMap.find(fendL) != m_importerMap.end())
else if (m_importerMap.find(fendL) != m_importerMap.end())
// If the map is found, assign ida to the corresponding struct in the map.
ida = *m_importerMap[fendL];
// Otherwise, try and ask the user.
78,7 → 77,7
m_dias = new gtDialogs();
// Pop up the dialog asking the user to select the type from our list (ilist) of
// importable file types. If one is not selected, set callImporter to false.
callImporter = m_dias->runImporterDialog(m_ilist);
callImporter = m_dias->runImporterDialog(filename, m_ilist);
// If we're gonna call an importer, we need to copy it's struct to ida.
if (callImporter)
ida = m_importers[m_dias->getImporter()];
223,9 → 222,7
impsetup.importer = m_dias->getImporter();
impsetup.textOnly = m_dias->importTextOnly();
impsetup.prefixNames = m_dias->prefixStyles();
// launchImporter(dias->getImporter(), dias->getFileName(),
// dias->importTextOnly(), dias->getEncoding(), append);
} // if (dias->runFileDialog(filters, ilist))
}
// Destroy the dialog.
delete m_dias;
// Return the ImportSetup struct.
/trunk/Scribus/scribus/ui/gtdialogs.cpp
32,6 → 32,8
#include "prefsmanager.h"
#include "sccombobox.h"
#include "ui/gtfiledialog.h"
 
#include <QFileInfo>
#include <QHBoxLayout>
#include <QLabel>
#include <QPixmap>
43,8 → 45,13
 
/********* Class gtImporterDialog*******************************************************************/
 
gtImporterDialog::gtImporterDialog(const QStringList& importers, int currentSelection)
gtImporterDialog::gtImporterDialog(const QString& fileName, const QStringList& importers, int currentSelection)
{
QFileInfo fInfo(fileName);
QString ext = fInfo.suffix();
if ((ext.length() > 0) && !ext.startsWith("."))
ext.prepend(".");
 
setWindowTitle( tr("Choose the importer to use"));
setWindowIcon(IconManager::instance()->loadIcon("AppIcon.png"));
 
53,7 → 60,13
QBoxLayout* llayout = new QHBoxLayout;
llayout->setMargin(5);
llayout->setSpacing(5);
QLabel* label = new QLabel( tr("Choose the importer to use"), this);
 
QString labelText;
if (ext.length() > 0)
labelText = tr("Choose the importer to use for %1 file:").arg(ext);
else
labelText = tr("Choose the importer to use:");
QLabel* label = new QLabel(labelText, this);
llayout->addWidget(label);
layout->addLayout(llayout);
 
111,12 → 124,11
 
gtDialogs::gtDialogs()
{
fdia = NULL;
fileName = "";
encoding = "";
importer = -1;
prefs = PrefsManager::instance()->prefsFile->getContext("gtDialogs");
pwd = QDir::currentPath();
m_fdia = NULL;
m_fileName = "";
m_encoding = "";
m_importer = -1;
m_prefs = PrefsManager::instance()->prefsFile->getContext("gtDialogs");
}
 
bool gtDialogs::runFileDialog(const QString& filters, const QStringList& importers)
124,56 → 136,56
bool accepted = false;
PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
QString dir = dirs->get("get_text", ".");
fdia = new gtFileDialog(filters, importers, dir);
if (fdia->exec() == QDialog::Accepted)
m_fdia = new gtFileDialog(filters, importers, dir);
if (m_fdia->exec() == QDialog::Accepted)
{
fileName = fdia->selectedFile();
if (!fileName.isEmpty())
m_fileName = m_fdia->selectedFile();
if (!m_fileName.isEmpty())
accepted = true;
encoding = fdia->encodingCombo->currentText();
m_encoding = m_fdia->encodingCombo->currentText();
// if (encoding == "UTF-16")
// encoding = "ISO-10646-UCS-2";
importer = fdia->importerCombo->currentIndex() - 1;
dirs->set("get_text", fileName.left(fileName.lastIndexOf("/")));
m_importer = m_fdia->importerCombo->currentIndex() - 1;
dirs->set("get_text", m_fileName.left(m_fileName.lastIndexOf("/")));
}
QDir::setCurrent(pwd);
return accepted;
}
 
bool gtDialogs::runImporterDialog(const QStringList& importers)
bool gtDialogs::runImporterDialog(const QString& fileName, const QStringList& importers)
{
int curSel = prefs->getInt("curSel", 0);
QString extension = "";
QString shortName = fileName.right(fileName.length() - fileName.lastIndexOf("/") - 1);
if (shortName.indexOf(".") == -1)
extension = ".no_extension";
else
extension = fileName.right(fileName.length() - fileName.lastIndexOf("."));
int extensionSel = prefs->getInt(extension, -1);
QString imp = prefs->get("remember"+extension, QString("false"));
bool ok = false;
bool shouldRemember = false;
 
QFileInfo fileInfo(fileName);
QString fileExtension = fileInfo.suffix();
if (fileExtension.length() > 0 && !fileExtension.startsWith("."))
fileExtension.prepend(".");
if (fileExtension.isEmpty())
fileExtension = ".no_extension";
QString imp = m_prefs->get("remember"+ fileExtension, QString("false"));
QString res = "";
bool shouldRemember = false;
bool ok = false;
if (imp != "false")
{
res = imp;
if (importers.contains(res) > 0)
if (importers.contains(res))
ok = true;
}
if (!ok)
{
int curSel = m_prefs->getInt("curSel", 0);
int extensionSel = m_prefs->getInt(fileExtension, -1);
if ((extensionSel > -1) && (extensionSel < static_cast<int>(importers.count())))
curSel = extensionSel;
else
curSel = 0;
gtImporterDialog* idia = new gtImporterDialog(importers, curSel);
gtImporterDialog* idia = new gtImporterDialog(fileName, importers, curSel);
if (idia->exec())
{
res = idia->getImporter();
shouldRemember = idia->shouldRemember();
ok = true;
}
delete idia;
181,27 → 193,17
 
if (ok)
{
QString fileExtension = "";
for (int i = 0; i < importers.count(); ++i)
QString fileExtension;
int importerIndex = importers.indexOf(res);
if (importerIndex >= 0)
{
if (importers[i] == res)
m_importer = importerIndex;
m_prefs->set("curSel", static_cast<int>(importerIndex));
if (!fileExtension.isEmpty())
{
importer = i;
prefs->set("curSel", static_cast<int>(i));
if (fileName.indexOf(".") != -1)
{
if (shortName.indexOf(".") == -1)
fileExtension = ".no_extension";
else
fileExtension = fileName.right(fileName.length() - fileName.lastIndexOf("."));
if (!fileExtension.isEmpty())
{
prefs->set(fileExtension, static_cast<int>(i));
if (shouldRemember)
prefs->set("remember"+fileExtension, res);
}
}
break;
m_prefs->set(fileExtension, static_cast<int>(importerIndex));
if (shouldRemember)
m_prefs->set("remember" + fileExtension, res);
}
}
}
210,24 → 212,24
 
const QString& gtDialogs::getFileName()
{
return fileName;
return m_fileName;
}
 
const QString& gtDialogs::getEncoding()
{
return encoding;
return m_encoding;
}
 
int gtDialogs::getImporter()
{
return importer;
return m_importer;
}
 
bool gtDialogs::importTextOnly()
{
bool ret = false;
if (fdia)
ret = fdia->textOnlyCheckBox->isChecked();
if (m_fdia)
ret = m_fdia->textOnlyCheckBox->isChecked();
return ret;
}
 
234,12 → 236,12
bool gtDialogs::prefixStyles()
{
bool ret = false;
if (fdia)
ret = fdia->prefixStylesCheckBox->isChecked();
if (m_fdia)
ret = m_fdia->prefixStylesCheckBox->isChecked();
return ret;
}
 
gtDialogs::~gtDialogs()
{
delete fdia;
delete m_fdia;
}
/trunk/Scribus/scribus/ui/gtdialogs.h
45,7 → 45,7
QCheckBox* rememberCheck;
QPushButton* okButton;
public:
gtImporterDialog(const QStringList& importers, int currentSelection);
gtImporterDialog(const QString& fileName, const QStringList& importers, int currentSelection);
~gtImporterDialog();
bool shouldRemember();
QString getImporter();
53,16 → 53,10
 
class SCRIBUS_API gtDialogs
{
private:
gtFileDialog* fdia;
QString fileName;
QString encoding;
int importer;
PrefsContext* prefs;
QString pwd;
public:
gtDialogs();
~gtDialogs();
 
const QString& getFileName();
const QString& getEncoding();
int getImporter();
69,7 → 63,14
bool importTextOnly();
bool prefixStyles();
bool runFileDialog(const QString& filters, const QStringList& importers);
bool runImporterDialog(const QStringList& importers);
bool runImporterDialog(const QString& file, const QStringList& importers);
 
private:
gtFileDialog* m_fdia;
QString m_fileName;
QString m_encoding;
int m_importer;
PrefsContext* m_prefs;
};
 
#endif // GTDIALOGS_H