void Qt5Files::buttonClicked() { QString filter; if (!m_extensions.size()) { filter = tr("All Files (*.*)"); } else { filter = tr("Valid Files ("); for (unsigned int i=0; i<m_extensions.size(); ++i) { if (i) filter += " "; filter += "*."+QString::fromStdString(m_extensions[i]); } filter += tr(")"); } QStringList files = QFileDialog::getOpenFileNames(nullptr, "Open Files...", filter, tr("All Files (*.*)"), nullptr, 0); QStringList::Iterator it = files.begin(); m_value.clear(); QString text; while (it != files.end()) { m_value.push_back(fs::path(it->toStdString())); if (it != files.begin()) text += ", "; text += *it; ++it; } m_lineEdit->setText(text); notify(m_value); }
void MainWindow::LoadImages() { images_.clear(); QStringList files = QFileDialog::getOpenFileNames( this, tr("Load Images"), "~/Pictures", tr("Images (*.png, *.jpeg, *.jpg, *.tiff, *.bmp, *")); QStringList files_copy = files; for (QStringList::Iterator i = files_copy.begin(); i != files_copy.end(); ++i) { // Load files and add to ThumbnailView. QImage* img = new QImage(*i); std::cout << i->toStdString() << " " << img->width() << " " << img->height() << "\n"; images_.push_back(shared_ptr<QImage>(img)); thumb_->addImage(img, *i); } }
/** * Funtion returns image pointer to Image located * in cache folder where shoul be downloaded cover * with name from parameter. * @param name * @return */ QImage* CoverDownloader::getImage(QString name) { QDir d = QDir::current(); std::cout << "Current dir cover.. " << d.absolutePath().toStdString() << std::endl; if (d.cd("cache")) { QImage * img = new QImage(); QStringList filters; filters << name + ".*"; QStringList files = d.entryList(filters, QDir::Readable | QDir::Files | QDir::NoSymLinks); for (QStringList::Iterator it = files.begin(); it != files.end(); ++it) { std::cout << it->toStdString() << std::endl; if (img->load("cache/" + *it)) { break; } } if (!img->isNull()) { return img; } SAFE_DELETE(img); } return NULL; }
void ReduxWidget::open() { QStringList files = QFileDialog::getOpenFileNames( this, tr( "Open File" ), "", tr( "Log Files (*_lg*)" ) ); int sz = PATH_MAX + 1; // N.B. It is possible to construct a path longer than PATH_MAX on most systems, // so this is really not fool-proof... char* buf = new char[sz]; QStringList::Iterator it = files.begin(); while( it != files.end() ) { memset( buf, 0, sz * sizeof( char ) ); if( ( ! it->isEmpty() ) && realpath( it->toStdString().c_str(), buf ) ) { dumpMsg( QString( "Opening LogFile : " ) + *it ); /*LogFile* tmpLog = new LogFile ( buf ); bool skip = false; for ( unsigned int i=0; i<myLogs.size(); ++i) if ( !(*(myLogs[i]) != *tmpLog) ) skip = true; cout << *tmpLog << endl; if ( ! skip ) myLogs.push_back( tmpLog ); else delete tmpLog; //myLog.load(); */ } ++it; } delete[] buf; //emit setsChanged(); //logTree->reset(); //emit jobsChanged(); //jobTree->reset(); //for (int i=0; i<myJobs.size(); ++i) cout << *myJobs[i]; //cout << myNet; //cout << dumpXML(true) << endl; }
void QmitkCommonExtPlugin::handleIPCMessage(const QByteArray& msg) { QDataStream ds(msg); QString msgType; ds >> msgType; // we only handle messages containing command line arguments if (msgType != "$cmdLineArgs") return; // activate the current workbench window berry::IWorkbenchWindow::Pointer window = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(); QMainWindow* mainWindow = static_cast<QMainWindow*> (window->GetShell()->GetControl()); mainWindow->setWindowState(mainWindow->windowState() & ~Qt::WindowMinimized); mainWindow->raise(); mainWindow->activateWindow(); // Get the preferences for the instantiation behavior berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); berry::IPreferences::Pointer prefs = prefService->GetSystemPreferences()->Node("/General"); bool newInstanceAlways = prefs->GetBool("newInstance.always", false); bool newInstanceScene = prefs->GetBool("newInstance.scene", true); QStringList args; ds >> args; QStringList fileArgs; QStringList sceneArgs; Poco::Util::OptionSet os; berry::Platform::GetOptionSet(os); Poco::Util::OptionProcessor processor(os); #if !defined(POCO_OS_FAMILY_UNIX) processor.setUnixStyle(false); #endif args.pop_front(); QStringList::Iterator it = args.begin(); while (it != args.end()) { std::string name; std::string value; if (processor.process(it->toStdString(), name, value)) { ++it; } else { if (it->endsWith(".mitk")) { sceneArgs << *it; } else { fileArgs << *it; } it = args.erase(it); } } if (newInstanceAlways) { if (newInstanceScene) { startNewInstance(args, fileArgs); foreach(QString sceneFile, sceneArgs) { startNewInstance(args, QStringList(sceneFile)); } } else {