Attached Files | MultipleFileOpen.patch [^] (8,522 bytes) 2009-02-20 13:39 [Show Content] [Hide Content]--- a/Qt/Core/pqMainWindowCore.h
+++ b/Qt/Core/pqMainWindowCore.h
@@ -282,6 +283,7 @@
void makeDefaultConnectionIfNoneExists();
virtual void onFileOpen();
+ virtual void onFilesOpen();
virtual void onFileOpen(pqServer* Server);
virtual void onFileOpen(const QStringList& Files);
@@ -481,7 +483,6 @@
class pqImplementation;
pqImplementation* const Implementation;
-
};
#endif // !_pqMainWindowCore_h
--- a/Qt/Core/pqMainWindowCore.cxx
+++ b/Qt/Core/pqMainWindowCore.cxx
@@ -1488,7 +1488,22 @@
this->makeServerConnectionIfNoneExists();
pqServer *server = this->getActiveServer();
if(server)
+ {
+ this->onFileOpen(server);
+ }
+ else
{
+ qDebug() << "No active server selected.";
+ }
+}
+
+//-----------------------------------------------------------------------------
+void pqMainWindowCore::onFilesOpen()
+{
+ this->makeServerConnectionIfNoneExists();
+ pqServer *server = this->getActiveServer();
+ if(server)
+ {
this->onFileOpen(server);
}
else
@@ -1511,19 +1526,21 @@
file_dialog->setAttribute(Qt::WA_DeleteOnClose);
file_dialog->setObjectName("FileOpenDialog");
- file_dialog->setFileMode(pqFileDialog::ExistingFiles);
+ file_dialog->setFileMode(pqFileDialog::ExistingFiles);
QObject::connect(file_dialog, SIGNAL(filesSelected(const QStringList&)),
this, SLOT(onFileOpen(const QStringList&)));
file_dialog->setModal(true);
file_dialog->show();
}
+
//-----------------------------------------------------------------------------
void pqMainWindowCore::onFileOpen(const QStringList& files)
{
this->createReaderOnActiveServer(files);
}
+
//-----------------------------------------------------------------------------
void pqMainWindowCore::onFileLoadServerState()
{
--- a/Qt/Core/pqFileDialog.h
+++ b/Qt/Core/pqFileDialog.h
@@ -93,7 +93,7 @@
/// Typically used by "Open..."
/// ExistingFiles: The names of zero or more existing files.
/// Directory: The name of a directory.
- enum FileMode { AnyFile, ExistingFile, ExistingFiles, Directory };
+ enum FileMode { AnyFile, ExistingFile, ExistingFiles, Directory};
/// Creates a file dialog with the specified server
/// if the server is NULL, files are browsed locally
@@ -164,6 +164,7 @@
class pqImplementation;
pqImplementation* const Implementation;
+ void acceptInternal(QList<QStringList> selected_files);
void acceptInternal(QStringList& selected_files);
QString fixFileExtension(const QString& filename, const QString& filter);
};
--- a/Qt/Core/pqFileDialog.cxx
+++ b/Qt/Core/pqFileDialog.cxx
@@ -458,16 +458,18 @@
// so SingleSelection mode is used here, and when a *group*
// file is selected, we internally get all series files in
// this group, and pass them along.
+
this->Implementation->Ui.Files->setSelectionMode(
- QAbstractItemView::SingleSelection);
+ QAbstractItemView::ExtendedSelection);
+
this->Implementation->Ui.Favorites->setSelectionMode(
QAbstractItemView::ExtendedSelection);
- }
+ }
}
}
//-----------------------------------------------------------------------------
-void pqFileDialog::emitFilesSelected(const QStringList& files)
+void pqFileDialog::emitFilesSelected( const QStringList& files)
{
// Ensure that we are hidden before broadcasting the selection,
// so we don't get caught by screen-captures
@@ -476,6 +478,7 @@
emit filesSelected(this->Implementation->SelectedFiles);
this->done(QDialog::Accepted);
}
+
//-----------------------------------------------------------------------------
QStringList pqFileDialog::getSelectedFiles()
@@ -486,16 +489,68 @@
//-----------------------------------------------------------------------------
void pqFileDialog::accept()
{
- /* TODO: handle pqFileDialog::ExistingFiles mode */
- QString filename = this->Implementation->Ui.FileName->text();
- filename = filename.trimmed();
+
+
+ //need to detect if we are saving or opening before we loop
+ const QModelIndexList indices =
+ this->Implementation->Ui.Files->selectionModel()->selectedIndexes();
+ if(this->Implementation->Mode != pqFileDialog::AnyFile && indices.size() != 0)
+ {
+ //storage for all the files to load
+ QList<QStringList> allFiles;
+ for(int i = 0; i < indices.size(); ++i)
+ {
+ QStringList files;
+ QModelIndex index = indices[i];
+ QString filename = this->Implementation->FileFilter.data(index).toString();
+ filename = filename.trimmed();
- QString fullFilePath = this->Implementation->Model->absoluteFilePath(filename);
- emit this->fileAccepted(fullFilePath);
+ QString fullFilePath = this->Implementation->Model->absoluteFilePath(filename);
+ emit this->fileAccepted(fullFilePath);
+
+ // if we got a group, let's expand it.
+ QAbstractProxyModel* m = &this->Implementation->FileFilter;
+ int numrows = m->rowCount(QModelIndex());
+ for(int i=0; i<numrows; i++)
+ {
+ QModelIndex idx = m->index(i, 0, QModelIndex());
+ QString cmp = m->data(idx, Qt::DisplayRole).toString();
+ if(filename == cmp)
+ {
+ QModelIndex sidx = m->mapToSource(idx);
+ QStringList sel_files = this->Implementation->Model->getFilePaths(sidx);
+ for(int j=0; j<sel_files.count();j++)
+ {
+ files.push_back(sel_files.at(j));
+ if(this->Implementation->Mode == pqFileDialog::ExistingFile)
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ if(files.empty())
+ {
+ files.append(fullFilePath);
+ }
+
+ allFiles.append( files );
+ }
+ //send the data
+ this->acceptInternal( allFiles );
+ }
+ else
+ {
+ //instead of selecting the path based on selected files, we need to use
+ //what the user has typed in
+ QString filename = this->Implementation->Ui.FileName->text();
+ filename = filename.trimmed();
+
+ QString fullFilePath = this->Implementation->Model->absoluteFilePath(filename);
+ emit this->fileAccepted(fullFilePath);
- QStringList files;
- if(this->Implementation->Mode != pqFileDialog::AnyFile)
- {
+ QStringList files;
// if we got a group, let's expand it.
QAbstractProxyModel* m = &this->Implementation->FileFilter;
int numrows = m->rowCount(QModelIndex());
@@ -516,20 +571,17 @@
}
}
}
- }
+ }
+
+ if(files.empty())
+ {
+ files.append(fullFilePath);
+ }
+ //send the data
+ this->acceptInternal( files );
}
- else
- {
- files.push_back(fullFilePath);
- }
- if(files.empty())
- {
- filename = this->Implementation->Model->absoluteFilePath(filename);
- files.append(filename);
- }
-
- this->acceptInternal(files);
+
}
//-----------------------------------------------------------------------------
@@ -694,6 +746,19 @@
}
return fixedFilename;
}
+//-----------------------------------------------------------------------------
+void pqFileDialog::acceptInternal(QList<QStringList> selected_files)
+{
+ if(selected_files.empty())
+ {
+ return;
+ }
+
+ for (int i=0; i < selected_files.size(); i++)
+ {
+ this->acceptInternal( selected_files[i] );
+ }
+ }
//-----------------------------------------------------------------------------
void pqFileDialog::acceptInternal(QStringList& selected_files)
@@ -714,7 +779,7 @@
break;
case ExistingFile:
- case ExistingFiles:
+ case ExistingFiles:
case AnyFile:
this->onNavigate(file);
this->Implementation->Ui.FileName->clear();
@@ -750,7 +815,7 @@
// User chose a file in directory mode, do nothing
this->Implementation->Ui.FileName->clear();
return;
- case ExistingFile:
+ case ExistingFile:
case ExistingFiles:
{
// TODO: we need to verify that all selected files are indeed
|