From e1a219bcfad438f0d772d13822cc52665fa92c9f Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 2 Jul 2017 19:03:36 +0200 Subject: [PATCH] dropEvent: Check for suffix, not complete suffix Often file base names without the suffix contain dots. For this application it is sufficient and necessary to check only the suffix and not the complete suffix. --- src/mainwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fb47603..a107346 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -68,13 +68,13 @@ void MainWindow::dropEvent(QDropEvent *event) foreach (const QUrl &url, mimeData->urls()) { QString fileName = url.toLocalFile(); qDebug() << "[MainWindow] Dropped file:" << fileName; - if(QFileInfo(fileName).completeSuffix()=="txt"){ + if(QFileInfo(fileName).suffix()=="txt"){ scr.accumulatePointsFromTxtPointCloud(fileName.toUtf8().constData()); qDebug() << "[MainWindow] Accumulating a txt point cloud."; qApp->processEvents(); ui->statusBar->showMessage("Loading " + QFileInfo(fileName).baseName()); } - if(QFileInfo(fileName).completeSuffix()=="pcd"){ + if(QFileInfo(fileName).suffix()=="pcd"){ if (pcl::io::loadPCDFile(fileName.toUtf8().constData(), *tmp_cloud) == -1) //* load the file { qWarning() << "Couldn't read file " << fileName; @@ -83,7 +83,7 @@ void MainWindow::dropEvent(QDropEvent *event) pcl::fromPCLPointCloud2(*tmp_cloud, *cloud_); } - if(QFileInfo(fileName).completeSuffix()=="ply"){ + if(QFileInfo(fileName).suffix()=="ply"){ if (pcl::io::loadPLYFile(fileName.toUtf8().constData(), *tmp_cloud) == -1) //* load the file { qWarning() << "Couldn't read file " << fileName; @@ -92,7 +92,7 @@ void MainWindow::dropEvent(QDropEvent *event) pcl::fromPCLPointCloud2(*tmp_cloud, *cloud_); } - if(QFileInfo(fileName).completeSuffix()=="labels"){ + if(QFileInfo(fileName).suffix()=="labels"){ //scr.loadLabels(fileName.toUtf8().constData()); } }