void FileFinder::performScan( const boost::filesystem::path& dir_path, const std::set<string_t>& exts ) { if ( !fs::exists( dir_path ) ) return; fs::directory_iterator end_itr; // default construction yields past-the-end for ( fs::directory_iterator itr( dir_path ); itr != end_itr; ++itr ) { string_t::size_type pos = rootPath_.size(); string_t fullPath = toUtf8(itr->path().wstring()); string_t relPath = fullPath.substr(pos); if ( fs::is_directory(itr->status()) ) { ++numDirs_; dirs_.insert(relPath); if (recursiveScan_) performScan( itr->path(), exts ); } else if ( fs::is_regular_file(itr->status()) ) { // see below if ( isExtensionMatches(itr, exts) ) { /// if this is not a file in the ignore list if ( ignore_.find(relPath) == ignore_.end() ) files_.insert(relPath); } } } }
FileFinder::FileFinder( bool recursiveScan, const string_t& rootPath, const string_t& extensions /*= ""*/, const string_t& ignoredFiles /*= ""*/ ) : rootPath_(rootPath) , recursiveScan_(recursiveScan) , numDirs_(0) { /// have normalized string Poco::Path tmp(rootPath); rootPath_ = tmp.toString(); Poco::StringTokenizer tokenizer(extensions, ";", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); std::set<string_t> exts(tokenizer.begin(), tokenizer.end()); Poco::StringTokenizer ignoreToks( ignoredFiles, ";", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); for (auto it = ignoreToks.begin(); it != ignoreToks.end(); ++it) { /// the reason we are inserting paths through Poco::Path is /// that it will let us have paths similar path in each platform /// in windows with '\', in linux '/' ignore_.insert(Poco::Path(*it).toString()); } performScan(rootPath_, exts); }
BearerMonitor::BearerMonitor(QWidget *parent) : QWidget(parent) { setupUi(this); #ifdef MAEMO_UI newSessionButton->hide(); deleteSessionButton->hide(); #else delete tabWidget->currentWidget(); sessionGroup->hide(); #endif updateConfigurations(); onlineStateChanged(!manager.allConfigurations(QNetworkConfiguration::Active).isEmpty()); QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration(); for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem *item = treeWidget->topLevelItem(i); if (item->data(0, Qt::UserRole).toString() == defaultConfiguration.identifier()) { treeWidget->setCurrentItem(item); showConfigurationFor(item); break; } } connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool))); connect(&manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), this, SLOT(configurationAdded(const QNetworkConfiguration&))); connect(&manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), this, SLOT(configurationRemoved(const QNetworkConfiguration&))); connect(&manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), this, SLOT(configurationChanged(const QNetworkConfiguration))); connect(&manager, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations())); #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) connect(registerButton, SIGNAL(clicked()), this, SLOT(registerNetwork())); connect(unregisterButton, SIGNAL(clicked()), this, SLOT(unregisterNetwork())); #else // Q_OS_WIN && !Q_OS_WINRT nlaGroup->hide(); #endif connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(createSessionFor(QTreeWidgetItem*))); connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(showConfigurationFor(QTreeWidgetItem*))); connect(newSessionButton, SIGNAL(clicked()), this, SLOT(createNewSession())); #ifndef MAEMO_UI connect(deleteSessionButton, SIGNAL(clicked()), this, SLOT(deleteSession())); #endif connect(scanButton, SIGNAL(clicked()), this, SLOT(performScan())); // Just in case update all configurations so that all // configurations are up to date. manager.updateConfigurations(); }