void CWindowMain::on_open() { QStringList lstFiles = QFileDialog::getOpenFileNames(this,tr("Открыть функцию"),"", tr("Булева функция(*.%1)").arg(BFSuffix)); foreach (QString fileName, lstFiles) { QFile file(fileName); if (file.open(QIODevice::ReadOnly)) { QByteArray text(file.readAll()); file.close(); QList<QList<int> > cnf(CBoolFormula::fromDimacs(text)); if (!cnf.isEmpty()) { emit m_widgetBFList->append(QFileInfo(file).baseName(), new CBoolFormula(cnf)); } else { emit messageAppend(tr("ОШИБКА!Неизвестный формат файла функции.")); } } else { emit messageAppend(QString("%1 : %2") .arg(tr("Невозможно открыть файл")) .arg(fileName)); } }
void SplashInstaller::load() { KConfig _cnf( "ksplashrc" ); KConfigGroup cnf(&_cnf, "KSplash"); QString curTheme = cnf.readEntry("Theme","Default"); mThemesList->setCurrentRow(findTheme(curTheme)); emit changed( false ); }
//----------------------------------------------------------------------------- void SplashInstaller::save() { KConfig _cnf( "ksplashrc" ); KConfigGroup cnf(&_cnf, "KSplash"); int cur = mThemesList->currentRow(); if (cur < 0) return; QString path = mThemesList->item(cur)->text(); if ( mThemesList->text2path.contains( path ) ) path = mThemesList->text2path[path]; cur = path.lastIndexOf('/'); cnf.writeEntry("Theme", path.mid(cur+1) ); // save also the engine, so that it's known at KDE startup which splash implementation to use cnf.writeEntry("Engine", mEngineOfSelected ); cnf.sync(); emit changed( false ); }
void main(int argc, char **argv) { int **sudoku; char *cells; if (argc != 2) { printf("Erro de entrada!\n"); exit(-1); } cells = sdk_iconfig(argv[1]); sudoku = gen_matrix(); sudoku = sdk_init(cells, sudoku); cnf(sudoku); free_matrix(sudoku); }
FileDownloader::FileDownloader(const QUrl &url, const char *userAgent, const QString &eTag, QObject *p) : QObject(p), m_WebCtrl(), m_DownloadedData(), m_url(url), m_rawHeaderPairs(), m_reply(0L), m_request(url), m_userAgent(userAgent), m_generic(false) { moveToThread(m_WebCtrl.thread()); QObject::connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)), SLOT(fileDownloaded(QNetworkReply*))); QSslConfiguration cnf(m_request.sslConfiguration()); cnf.setPeerVerifyMode(QSslSocket::VerifyNone); cnf.setProtocol(QSsl::AnyProtocol); m_request.setSslConfiguration(cnf); m_request.setRawHeader("User-Agent", QByteArray(userAgent)); if(!eTag.isEmpty()) m_request.setRawHeader("If-None-Match", eTag.toLatin1()); m_request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); }
//----------------------------------------------------------------------------- void SplashInstaller::slotSetTheme(int id) { bool enabled; QString path = QString(); QString infoTxt; if (id < 0) { mPreview->setText(QString()); mText->setText(QString()); enabled = false; } else { QString error = i18n("(Could not load theme)"); path = mThemesList->item(id)->text(); if ( mThemesList->text2path.contains( path ) ) path = mThemesList->text2path[path]; enabled = false; KUrl url; QString themeName; if (!path.isEmpty()) { // Make sure the correct plugin is installed. int i = path.lastIndexOf('/'); if (i >= 0) themeName = path.mid(i+1); url.setPath( path + "/Theme.rc" ); if (!KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) { url.setPath( path + "/Theme.RC" ); if (!KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) { url.setPath( path + "/theme.rc" ); if (!KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) url.setPath( path + '/' + themeName + ".rc" ); } } if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) { KConfig _cnf(url.path()); KConfigGroup cnf(&_cnf, QString("KSplash Theme: %1").arg(themeName) ); // Get theme information. infoTxt = "<qt>"; if ( cnf.hasKey( "Name" ) ) infoTxt += i18n( "<b>Name:</b> %1", cnf.readEntry( "Name", i18nc( "Unknown name", "Unknown" ) ) ) + "<br />"; if ( cnf.hasKey( "Description" ) ) infoTxt += i18n( "<b>Description:</b> %1", cnf.readEntry( "Description", i18nc( "Unknown description", "Unknown" ) ) ) + "<br />"; if ( cnf.hasKey( "Version" ) ) infoTxt += i18n( "<b>Version:</b> %1", cnf.readEntry( "Version", i18nc( "Unknown version", "Unknown" ) ) ) + "<br />"; if ( cnf.hasKey( "Author" ) ) infoTxt += i18n( "<b>Author:</b> %1", cnf.readEntry( "Author", i18nc( "Unknown author", "Unknown" ) ) ) + "<br />"; if ( cnf.hasKey( "Homepage" ) ) infoTxt += i18n( "<b>Homepage:</b> %1", cnf.readEntry( "Homepage", i18nc( "Unknown homepage", "Unknown" ) ) ) + "<br />"; infoTxt += "</qt>"; QString pluginName( cnf.readEntry( "Engine", "KSplashX" ).trimmed() ); if( pluginName == "Simple" || pluginName == "None" || pluginName == "KSplashX" || pluginName == "KSplashQML" ) enabled = true; // these are not plugins else if ((KServiceTypeTrader::self()->query("KSplash/Plugin", QString("[X-KSplash-PluginName] == '%1'").arg(pluginName))).isEmpty()) { enabled = false; error = i18n("This theme requires the plugin %1 which is not installed.", pluginName); } else enabled = true; // Hooray, there is at least one plugin which can handle this theme. mEngineOfSelected = pluginName; } else { error = i18n("Could not load theme configuration file."); } } mBtnTest->setEnabled(enabled && themeName != "None" ); mText->setHtml(infoTxt); if (!enabled) { url.setPath( path + '/' + "Preview.png" ); if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) mPreview->setPixmap(QPixmap(url.path())); else mPreview->setText(i18n("(Could not load theme)")); KMessageBox::sorry(this, error); } else { url.setPath( path + '/' + "Preview.png" ); if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, 0)) mPreview->setPixmap(QPixmap(url.path())); else mPreview->setText(i18n("No preview available.")); emit changed(true); } } mBtnRemove->setEnabled( !path.isEmpty() && QFileInfo(path).isWritable()); }
// Copy theme package into themes directory void SplashInstaller::addNewTheme(const KUrl &srcURL) { const QString dir = KGlobal::dirs()->saveLocation("ksplashthemes"); KUrl url; QStringList themeNames; QString filename = srcURL.fileName(); int i = filename.lastIndexOf('.'); // Convert extension to lower case. if (i >= 0) filename = filename.left(i)+filename.mid(i).toLower(); url.setPath(KStandardDirs::locateLocal("tmp",filename)); // Remove file from temporary directory if it aleady exists - usually the result of a failed install. if ( KIO::NetAccess::exists( url, KIO::NetAccess::SourceSide, 0 ) ) KIO::NetAccess::del( url, 0 ); if (srcURL.fileName().toLower() == "theme.rc" ) // uncompressed theme selected { QString themeName; // Get the name of the Theme from the theme.rc file KConfig _cnf(srcURL.path()); KConfigGroup cnf(&_cnf, QString("KSplash Theme: %1").arg(themeName) ); // copy directory of theme.rc to ThemesDir KIO::NetAccess::dircopy(KUrl(srcURL.directory()), KUrl(dir + themeName)); themeNames << themeName; } else { bool rc = KIO::NetAccess::file_copy(srcURL, url, 0); if (!rc) { kWarning() << "Failed to copy theme " << srcURL.fileName() << " into temporary directory " << url.path() << endl; return; } // Extract into theme directory: we may have multiple themes in one tarball! KTar tarFile(url.path()); if (!tarFile.open(QIODevice::ReadOnly)) { kWarning() << "Unable to open archive: " << url.path(); KIO::NetAccess::del( url, 0 ); return; } KArchiveDirectory const *ad = tarFile.directory(); // Find first directory entry. const QStringList entries = ad->entries(); foreach(const QString& s, entries) { if( ad->entry(s)->isDirectory() ) { // each directory may contain one theme themeNames << s; } } if (themeNames.count() < 1) { kWarning() << "No directory in archive: " << url.path(); tarFile.close(); KIO::NetAccess::del( url, 0 ); return; } // copy the theme into the "ksplashthemes" directory ad->copyTo(dir); tarFile.close(); KIO::NetAccess::del( url, 0 ); } readThemesList(); mThemesList->setCurrentRow(findTheme(themeNames.first())); if (mThemesList->currentItem()) { mThemesList->currentItem()->setSelected(true); } }
std::vector<Expr> Tptp::getFreeVar() { assert(cnf()); std::vector<Expr> r; r.swap(d_freeVar); return r; }
void Tptp::addFreeVar(Expr var) { assert(cnf()); d_freeVar.push_back(var); }