QValidator::State ListValidator::validate(QString &text, int &pos) const { Q_ASSERT(inner); QStringList strings = text.split(QLatin1Char(',')); int unusedPos; QValidator::State state = Acceptable; for (QStringList::iterator i = strings.begin(); i != strings.end(); ++i) { QString string = i->trimmed(); const int position = i->indexOf(string); const int size = string.size(); const QValidator::State current = inner->validate(string, unusedPos); i->replace(position, size, string); if (current == Invalid) { state = Invalid; break; } if (current == Intermediate) { if (state == Intermediate) { state = Invalid; break; } state = Intermediate; } } text = strings.join(QLatin1Char(',')); return state; }
bool PathManager::CheckSysEnvironment() { QString javaHome = QString(""); QStringList environment = QProcess::systemEnvironment(); for (QStringList::iterator ite = environment.begin(); ite != environment.end(); ite++) { if (ite->toLower().startsWith("path=")){ QStringList pathValueList = ite->mid(QString("path=").length()).split(";"); for (QStringList::iterator ite = pathValueList.begin(); ite != pathValueList.end(); ite++) { QString path = ite->toLower(); if (path.contains("java") && path.contains("bin")){ SetJdkPath(ite->replace("\\", "/")); break; } } continue; } else if (ite->toLower().startsWith("java_home")){ javaHome = *ite; } } if (JDKPATH.isEmpty()){ BjMessageBox::warning(NULL, QStringLiteral("jdk环境变量错误"), QStringLiteral("在系统环境变量中未发现jdk路径,请先设置jdk环境变量,如果已经设置jdk环境变量,请在设置中指定其位置!"), QMessageBox::Ok, QMessageBox::NoButton); return false; } else if (javaHome.isEmpty()){ BjMessageBox::warning(NULL, QStringLiteral("java_home环境变量错误"), QStringLiteral("在系统环境变量中未发现java_home环境变量,请先设置java_home环境变量!"), QMessageBox::Ok, QMessageBox::NoButton); return false; } return true; }
bool FGame::execute() { syncData(); qDebug() << "Game type: " << gameType; if(gameType == FGameType::Steam) { #ifdef _WIN32 QString cmd("start steam://rungameid/" + gameExe); system(cmd.toStdString().c_str()); #else QStringList args; args << "-applaunch" << gameExe; QProcess::startDetached("steam", args); #endif } else if (gameType == FGameType::Origin) { QString cmd("start origin://launchgame/" + gameExe); system(cmd.toStdString().c_str()); } else if (gameType == FGameType::Executable || gameType == FGameType::Galaxy || gameType == FGameType::ROM ) { if(gameExe.isEmpty() || gamePath.isEmpty() || !QFile(gamePath+'/'+gameExe).exists()) { qDebug() << "gameExe.isEmpty() || gamePath.isEmpty() || !QFile(gamePath+'/'+gameExe).exists()"; return false; } if(launcherEnabled) { qDebug() << "Launcher:" << launcher.getName() << ", path:" << launcher.getPath() << ", args:" << launcher.getArgs() << ", id:" << launcher.getDbId(); QProcess *process = new QProcess(); process->setWorkingDirectory(gamePath); if(!launcher.getArgs().isEmpty()) { qDebug() << "Found some arguments!"; QStringList argList = createStringListFromArguments(launcher.getArgs()); qDebug() << "Launcher ArgList: " << argList; QStringList::iterator i; for(i = argList.begin(); i != argList.end(); i++) { i->replace("$GAMENAME", gameName); i->replace("$GAMECOMMAND", gameCommand); i->replace("$GAMEPATH", gamePath); i->replace("$GAMEEXE", gameExe); } process->start(launcher.getPath(), argList); } else { qDebug() << "Didn't find arguments."; process->start(launcher.getPath(), QStringList(gameExe)); } } else { QProcess *process = new QProcess(); process->setWorkingDirectory(gamePath); qDebug() << "Command: " << gameCommand; if(!gameCommand.isEmpty()) { QStringList newGameArgs = createStringListFromArguments(gameArgs.at(0)); qDebug() << "Found a command!"; QStringList::iterator i; for(i = newGameArgs.begin(); i != newGameArgs.end(); i++) { i->replace("$GAMENAME", gameName); i->replace("$GAMECOMMAND", gameCommand); i->replace("$GAMEPATH", gamePath); i->replace("$GAMEEXE", gameExe); } process->start(gameCommand, newGameArgs); } else { qDebug() << "Didn't find command, running executable"; process->start(gamePath+'/'+gameExe, gameArgs); } } } return true; }
MixxxLibraryFeature::MixxxLibraryFeature(QObject* parent, TrackCollection* pTrackCollection, ConfigObject<ConfigValue>* pConfig) : LibraryFeature(parent), kMissingTitle(tr("Missing Tracks")), kHiddenTitle(tr("Hidden Tracks")), m_pMissingView(NULL), m_pHiddenView(NULL), m_trackDao(pTrackCollection->getTrackDAO()), m_pConfig(pConfig), m_pTrackCollection(pTrackCollection) { QStringList columns; columns << "library." + LIBRARYTABLE_ID << "library." + LIBRARYTABLE_PLAYED << "library." + LIBRARYTABLE_TIMESPLAYED //has to be up here otherwise Played and TimesPlayed are not show << "library." + LIBRARYTABLE_ARTIST << "library." + LIBRARYTABLE_TITLE << "library." + LIBRARYTABLE_ALBUM << "library." + LIBRARYTABLE_ALBUMARTIST << "library." + LIBRARYTABLE_YEAR << "library." + LIBRARYTABLE_DURATION << "library." + LIBRARYTABLE_RATING << "library." + LIBRARYTABLE_GENRE << "library." + LIBRARYTABLE_COMPOSER << "library." + LIBRARYTABLE_GROUPING << "library." + LIBRARYTABLE_FILETYPE << "library." + LIBRARYTABLE_TRACKNUMBER << "library." + LIBRARYTABLE_KEY << "library." + LIBRARYTABLE_KEY_ID << "library." + LIBRARYTABLE_DATETIMEADDED << "library." + LIBRARYTABLE_BPM << "library." + LIBRARYTABLE_BPM_LOCK << "library." + LIBRARYTABLE_BITRATE << "track_locations.location" << "track_locations.fs_deleted" << "library." + LIBRARYTABLE_COMMENT << "library." + LIBRARYTABLE_MIXXXDELETED; QSqlQuery query(pTrackCollection->getDatabase()); QString tableName = "library_cache_view"; QString queryString = QString( "CREATE TEMPORARY VIEW IF NOT EXISTS %1 AS " "SELECT %2 FROM library " "INNER JOIN track_locations ON library.location = track_locations.id") .arg(tableName, columns.join(",")); query.prepare(queryString); if (!query.exec()) { LOG_FAILED_QUERY(query); } // Strip out library. and track_locations. for (QStringList::iterator it = columns.begin(); it != columns.end(); ++it) { if (it->startsWith("library.")) { *it = it->replace("library.", ""); } else if (it->startsWith("track_locations.")) { *it = it->replace("track_locations.", ""); } } BaseTrackCache* pBaseTrackCache = new BaseTrackCache( pTrackCollection, tableName, LIBRARYTABLE_ID, columns, true); connect(&m_trackDao, SIGNAL(trackDirty(int)), pBaseTrackCache, SLOT(slotTrackDirty(int))); connect(&m_trackDao, SIGNAL(trackClean(int)), pBaseTrackCache, SLOT(slotTrackClean(int))); connect(&m_trackDao, SIGNAL(trackChanged(int)), pBaseTrackCache, SLOT(slotTrackChanged(int))); connect(&m_trackDao, SIGNAL(tracksAdded(QSet<int>)), pBaseTrackCache, SLOT(slotTracksAdded(QSet<int>))); connect(&m_trackDao, SIGNAL(tracksRemoved(QSet<int>)), pBaseTrackCache, SLOT(slotTracksRemoved(QSet<int>))); connect(&m_trackDao, SIGNAL(dbTrackAdded(TrackPointer)), pBaseTrackCache, SLOT(slotDbTrackAdded(TrackPointer))); m_pBaseTrackCache = QSharedPointer<BaseTrackCache>(pBaseTrackCache); pTrackCollection->addTrackSource(QString("default"), m_pBaseTrackCache); // These rely on the 'default' track source being present. m_pLibraryTableModel = new LibraryTableModel(this, pTrackCollection); TreeItem* pRootItem = new TreeItem(); TreeItem* pmissingChildItem = new TreeItem(kMissingTitle, kMissingTitle, this, pRootItem); TreeItem* phiddenChildItem = new TreeItem(kHiddenTitle, kHiddenTitle, this, pRootItem); pRootItem->appendChild(pmissingChildItem); pRootItem->appendChild(phiddenChildItem); m_childModel.setRootItem(pRootItem); }