bool FileSearchResult::execute() { #ifdef Q_OS_WIN const QString exe = this->filename; const QString params = this->args.join(' '); qDebug() << "Executing" << (exe + params); int rv = (int) ::ShellExecuteW( 0, L"open", exe.toStdWString().c_str(), params.toStdWString().c_str(), QDir::homePath().toStdWString().c_str(), SW_SHOW ); if (rv <= 32) qDebug() << "Unable to execute; rv is" << rv; #else if (this->filename.endsWith(".desktop")) { QString execname = getXdgExec(this->filename); if (execname.length()) { if (getDe() == DeKde) execname = "kstart --activate " + execname; qDebug() << "Executing: " << execname; // Change current working directory; startDetached doesn't seem to // have an overload that accepts the `program` string having // arguments AND a parameter for the process pwd. const QDir savedPwd = QDir::current(); QDir::setCurrent(QDir::homePath()); QProcess::startDetached(execname); QDir::setCurrent(savedPwd.absolutePath()); } else { QMessageBox::critical(0, QObject::tr("Unable to Launch"), QObject::tr("Unable to find command to launch.") ); return false; } } else { QMessageBox::critical(0, QObject::tr("Unable to Launch"), QObject::tr("I don't know how to launch this file.") ); return false; } #endif return true; }
/* generate a (hopefully not too bogus) set of bond stretch parameters for a bond type that we haven't entered real data for */ static struct bondStretch * generateGenericBondStretch(char *bondName, int element1, int element2, char bondOrder) { double ks, r0, de, beta; int quality = QUALITY_GUESSED; switch (bondOrder) { default: // XXX Falls through to single bond case. WRONG!!!! quality = QUALITY_INACCURATE; case '1': ks = 0.0; de = getDe(bondName); beta = 0.0; r0 = getAtomTypeByIndex(element1)->covalentRadius + getAtomTypeByIndex(element2)->covalentRadius ; if (r0 <= 0.0) { // XXX warn about this // maybe better to just fill out the periodic table... r0 = 1.0; } beta = 0.4 + 125.0 / (r0 * de); ks = 200.0 * de * beta * beta ; if (ks > 1000.0) { ks = 1000.0; } break; case 'a': return interpolateGenericBondStretch(bondName, element1, element2, 1.5); case 'g': return interpolateGenericBondStretch(bondName, element1, element2, 1.3333333333333); case '2': quality = QUALITY_INACCURATE; ks = 0.0; de = getDe(bondName); beta = 0.0; r0 = getAtomTypeByIndex(element1)->covalentRadius + getAtomTypeByIndex(element2)->covalentRadius ; if (r0 <= 0.0) { // XXX warn about this // maybe better to just fill out the periodic table... r0 = 1.0; } r0 *= 0.8; // XXX this is just completly wrong, assuming double bonds are 80% shorter than single beta = 0.4 + 125.0 / (r0 * de); ks = 200.0 * de * beta * beta ; if (ks > 1000.0) { ks = 1000.0; } break; case '3': quality = QUALITY_INACCURATE; ks = 0.0; de = getDe(bondName); beta = 0.0; r0 = getAtomTypeByIndex(element1)->covalentRadius + getAtomTypeByIndex(element2)->covalentRadius ; if (r0 <= 0.0) { // XXX warn about this // maybe better to just fill out the periodic table... r0 = 1.0; } r0 *= 0.7; // XXX this is just completly wrong, assuming triple bonds are 70% shorter than single beta = 0.4 + 125.0 / (r0 * de); ks = 200.0 * de * beta * beta ; if (ks > 1000.0) { ks = 1000.0; } } return addBondStretch(bondName, ks, r0, de, beta*1e-2, findInflectionR(r0, ks, de), quality, 0); }