fix #90811: allow dots in filenames

rather than truncating and cutting off anything after the 1st dot of a
filename.
This commit is contained in:
Joachim Schmitz 2015-12-16 10:24:34 +01:00
parent 600306e1ec
commit a862889de5
16 changed files with 29 additions and 29 deletions

View file

@ -145,7 +145,7 @@ static void dumpHash(const QByteArray& _hash)
ImageStoreItem* ImageStore::getImage(const QString& path) const
{
QString s = QFileInfo(path).baseName();
QString s = QFileInfo(path).completeBaseName();
if (s.size() != 32) {
//
// some limited support for backward compatibility

View file

@ -3926,7 +3926,7 @@ QString Score::title()
fn = metaTag("workTitle");
if (fn.isEmpty())
fn = fileInfo()->baseName();
fn = fileInfo()->completeBaseName();
if (fn.isEmpty())
fn = "Untitled";

View file

@ -65,7 +65,7 @@ bool MP3Exporter::findLibrary()
if (!mLibPath.isEmpty()) {
QFileInfo fi(mLibPath);
path = fi.absolutePath();
name = fi.baseName();
name = fi.completeBaseName();
}
else {
path = getLibraryPath();
@ -531,7 +531,7 @@ void MP3Exporter::cancelEncoding()
else if (beWriteInfoTag) {
f.flush();
QFileInfo fi(f);
beWriteInfoTag(mGF, qPrintable(fi.baseName()));
beWriteInfoTag(mGF, qPrintable(fi.completeBaseName()));
mGF = NULL;
}
#endif

View file

@ -1690,7 +1690,7 @@ bool MuseScore::exportParts()
QString skipMessage = tr("Skip");
foreach (Excerpt* e, thisScore->excerpts()) {
Score* pScore = e->partScore();
QString partfn = fi.absolutePath() + QDir::separator() + fi.baseName() + "-" + createDefaultFileName(pScore->name()) + "." + ext;
QString partfn = fi.absolutePath() + QDir::separator() + fi.completeBaseName() + "-" + createDefaultFileName(pScore->name()) + "." + ext;
QFileInfo fip(partfn);
if(fip.exists() && !overwrite) {
if(noToAll)
@ -1724,7 +1724,7 @@ bool MuseScore::exportParts()
foreach(Excerpt* e, thisScore->excerpts()) {
scores.append(e->partScore());
}
QString partfn(fi.absolutePath() + QDir::separator() + fi.baseName() + "-" + createDefaultFileName(tr("Score_and_Parts")) + ".pdf");
QString partfn(fi.absolutePath() + QDir::separator() + fi.completeBaseName() + "-" + createDefaultFileName(tr("Score_and_Parts")) + ".pdf");
QFileInfo fip(partfn);
if(fip.exists() && !overwrite) {
if (!noToAll) {

View file

@ -151,7 +151,7 @@ void MediaDialog::addAudioPressed()
#endif
QFileInfo fi(path);
QFile syncFile(fi.absolutePath() + "/" + fi.baseName() + ".txt");
QFile syncFile(fi.absolutePath() + "/" + fi.completeBaseName() + ".txt");
TempoMap* tmo = score->tempomap();

View file

@ -64,11 +64,11 @@ void MuseScore::registerPlugin(PluginDescription* plugin)
QFileInfo np(pluginPath);
if (np.suffix() != "qml")
return;
QString baseName = np.baseName();
QString baseName = np.completeBaseName();
foreach(QString s, plugins) {
QFileInfo fi(s);
if (fi.baseName() == baseName) {
if (fi.completeBaseName() == baseName) {
if (MScore::debugMode)
qDebug(" Plugin <%s> already registered", qPrintable(pluginPath));
return;
@ -130,12 +130,12 @@ void MuseScore::unregisterPlugin(PluginDescription* plugin)
QFileInfo np(pluginPath);
if (np.suffix() != "qml")
return;
QString baseName = np.baseName();
QString baseName = np.completeBaseName();
bool found = false;
foreach(QString s, plugins) {
QFileInfo fi(s);
if (fi.baseName() == baseName) {
if (fi.completeBaseName() == baseName) {
found = true;
break;
}
@ -324,11 +324,11 @@ void MuseScore::removeMenuEntry(PluginDescription* plugin)
int MuseScore::pluginIdxFromPath(QString pluginPath) {
QFileInfo np(pluginPath);
QString baseName = np.baseName();
QString baseName = np.completeBaseName();
int idx = 0;
foreach(QString s, plugins) {
QFileInfo fi(s);
if (fi.baseName() == baseName)
if (fi.completeBaseName() == baseName)
return idx;
idx++;
}

View file

@ -462,7 +462,7 @@ bool NewWizard::emptyScore() const
{
QString p = p4->templatePath();
QFileInfo fi(p);
return fi.baseName() == "00-Blank";
return fi.completeBaseName() == "00-Blank";
}
}

View file

@ -1015,7 +1015,7 @@ void Palette::dropEvent(QDropEvent* event)
s->load(filePath);
e = s;
QFileInfo f(filePath);
name = f.baseName();
name = f.completeBaseName();
}
}
else if (data->hasFormat(mimeSymbolFormat)) {

View file

@ -216,7 +216,7 @@ void PaletteBox::paletteCmd(PaletteCommand cmd, int slot)
QString path = mscore->getPaletteFilename(true);
if (!path.isEmpty()) {
QFileInfo fi(path);
Palette* palette = newPalette(fi.baseName(), slot);
Palette* palette = newPalette(fi.completeBaseName(), slot);
palette->read(path);
}
}

View file

@ -415,7 +415,7 @@ void PluginCreator::load()
}
created = false;
setState(PCState::CLEAN);
setTitle( fi.baseName() );
setTitle( fi.completeBaseName() );
setToolTip(path);
raise();
}
@ -444,7 +444,7 @@ void PluginCreator::savePlugin()
textEdit->document()->setModified(false);
created = false;
setState(PCState::CLEAN);
setTitle( fi.baseName() );
setTitle( fi.completeBaseName() );
setToolTip(path);
}
else {

View file

@ -58,7 +58,7 @@ void PluginManager::init()
Shortcut* s = &d.shortcut;
localShortcuts[s->key()] = new Shortcut(*s);
QListWidgetItem* item = new QListWidgetItem(QFileInfo(d.path).baseName(), pluginList);
QListWidgetItem* item = new QListWidgetItem(QFileInfo(d.path).completeBaseName(), pluginList);
item->setFlags(item->flags() | Qt::ItemIsEnabled);
item->setCheckState(d.load ? Qt::Checked : Qt::Unchecked);
item->setData(Qt::UserRole, i);
@ -126,7 +126,7 @@ void PluginManager::pluginListItemChanged(QListWidgetItem* item, QListWidgetItem
int idx = item->data(Qt::UserRole).toInt();
const PluginDescription& d = prefs.pluginList[idx];
QFileInfo fi(d.path);
pluginName->setText(fi.baseName());
pluginName->setText(fi.completeBaseName());
pluginPath->setText(fi.absolutePath());
pluginVersion->setText(d.version);
pluginShortcut->setText(d.shortcut.keysToString());

View file

@ -118,13 +118,13 @@ ScoreItem* ScoreBrowser::genScoreItem(const QFileInfo& fi, ScoreListWidget* l)
painter.drawPixmap(0, 0, pixmap);
painter.setPen(QPen(QColor(0, 0, 0, 128), 1));
painter.setBrush(Qt::white);
if (fi.baseName() == "00-Blank" || fi.baseName() == "Create_New_Score") {
if (fi.completeBaseName() == "00-Blank" || fi.completeBaseName() == "Create_New_Score") {
qreal round = 8.0 * qApp->devicePixelRatio();
painter.drawRoundedRect(QRectF(0, 0, pm.width() - 1 , pm.height() - 1), round, round);
}
else
painter.drawRect(0, 0, pm.width() - 1, pm.height() - 1);
if (fi.baseName() != "00-Blank")
if (fi.completeBaseName() != "00-Blank")
painter.drawPixmap(1, 1, pixmap);
painter.end();
QPixmapCache::insert(fi.filePath(), pm);
@ -137,15 +137,15 @@ ScoreItem* ScoreBrowser::genScoreItem(const QFileInfo& fi, ScoreListWidget* l)
QFont f = item->font();
f.setPointSize(f.pointSize() - 2.0);
f.setBold(_boldTitle);
if (fi.baseName() == "00-Blank") {
if (fi.completeBaseName() == "00-Blank") {
item->setText(tr("Choose Instruments"));
f.setBold(true);
}
else if (fi.baseName() == "Create_New_Score") {
else if (fi.completeBaseName() == "Create_New_Score") {
item->setText(tr("Create New Score"));
f.setBold(true);
}
else if (fi.baseName() == "Getting_Started") {
else if (fi.completeBaseName() == "Getting_Started") {
item->setText(tr("Getting Started"));
f.setBold(true);
}

View file

@ -424,7 +424,7 @@ QList<Workspace*>& Workspace::workspaces()
foreach (const QString& entry, pl) {
Workspace* p = 0;
QFileInfo fi(s + "/" + entry);
QString name(fi.baseName());
QString name(fi.completeBaseName());
foreach (Workspace* w, _workspaces) {
if (w->name() == name) {
p = w;

View file

@ -198,7 +198,7 @@ void TestMidiMapping::testReadWriteOther(const char* f1, const char* ref)
score->doLayout();
QVERIFY(score);
score->rebuildMidiMapping();
QVERIFY(saveCompareScore(score, qf.baseName()+QString(".mscx"), DIR + ref));
QVERIFY(saveCompareScore(score, qf.completeBaseName()+QString(".mscx"), DIR + ref));
delete score;
}

View file

@ -43,7 +43,7 @@ static void scanDir(QDir d)
}
else if (fi.isExecutable()) {
QString s(fi.filePath());
if (fi.baseName().startsWith("tst_"))
if (fi.completeBaseName().startsWith("tst_"))
process(s);
}
}

View file

@ -116,7 +116,7 @@ bool ZInstrument::load(const QString& path)
{
instrumentPath = path;
QFileInfo fi(path);
_name = fi.baseName();
_name = fi.completeBaseName();
if (fi.isFile())
return loadFromFile(path);
if (fi.isDir())