Пример #1
0
bool TrashImpl::checkTrashSubdirs( const TQCString& trashDir_c ) const
{
    // testDir currently works with a TQString - ## optimize
    TQString trashDir = TQFile::decodeName( trashDir_c );
    const TQString info = trashDir + "/info";
    if ( testDir( info ) != 0 )
        return false;
    const TQString files = trashDir + "/files";
    if ( testDir( files ) != 0 )
        return false;
    return true;
}
Пример #2
0
PWS::PWS(QWidget *parent, const char *name)
	: KTopLevelWidget(name)
{
    createdUI = FALSE;
    menuBar = 0x0;
    statusBar = 0x0;
    toolBar = 0x0;
    view = 0x0;

    testDir ("/share");
    testDir ("/share/config");
    testDir ("/share/apps");
    testDir ("/share/apps/pws");
}
Пример #3
0
int main( int argc, char** argv )
{
	int status = EXIT_SUCCESS;

	if(argc >= 2)
	{
		if( parseConfig(argv[1]) )
		{
			getEntities(_entityPath);
			testDir(_testPath);
		}
		else status = EXIT_FAILURE;
	}
	else
	{
		status = EXIT_FAILURE;
		std::cout << "Problem lauching program." << std::endl
				<< "USAGE: contextIdentifier <path to config file>" << std::endl;
	}

	return status;
	/**setMovie( "The Grey", "./data/movies/grey.jpg" );
	setMovie( "The Silence of the Lambs", "./data/movies/lambs.jpg" );
	setMovie( "The Dark Knight", "./data/movies/batman.jpg" );

	testDir( "./data/movies/tests" );


	setMovie( "Bom Jesus", "./data/monuments/bom_jesus.jpg" );
	setMovie( "Sameiro", "./data/monuments/sameiro.jpg" );

	testDir( "./data/monuments/tests" );*/
}
Пример #4
0
void testagrguments(int argc,char*argv[])
{
 int counter; 
    printf("Program Name Is: %s\n",argv[0]); 
	    if(argc == 1) 
		printf("No Extra Command Line Argument Passed Other Than Program Name\n"); 
	    else if(argc<4) 
	    { 
	        printf("less Number Of Arguments Passed: %d\n", argc); 
	    }
		else
		{
		     printf("Number Of Arguments Passed: %d\n", argc); 
		     printf("----Following Are The Command Line Arguments Passed----\n"); 
			for(counter=0; counter<argc; counter++) 
			    printf("argv[%d]: %s\n",counter, argv[counter]);
		}

   if((validateurl(argv[1]))==1)
   {
   printf("valid match with seed url\n");
   }
   else
   {
   printf("url do not match with seed url\n");
   exit(1);
   }
	validatedepth(argv[2]);
	testDir(argv[3]);
}
Пример #5
0
bool Manager::copyAppData(const QUrl &src, const QString& subdir, const QString& fileName)
{
	//let saveLocation find and create the appropriate place to
	//store the templates (usually $HOME/.kde/share/apps/kile/templates)
	QString dir = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + '/' + subdir;

	QUrl targetURL = QUrl::fromUserInput(dir);
	targetURL = targetURL.adjusted(QUrl::StripTrailingSlash);
	targetURL.setPath(targetURL.path() + '/' + fileName);

	//if a directory is found
	if (!dir.isNull()) {
		// create dir if not existing, needed for copyjob
		QDir testDir(dir);
		if (!testDir.exists()){
			testDir.mkpath(dir);
		}
		// copy file
		KIO::FileCopyJob* copyJob = KIO::file_copy(src, targetURL);
		KJobWidgets::setWindow(copyJob, m_kileInfo->mainWindow());
		return copyJob->exec();
	}
	else {
		KMessageBox::error(Q_NULLPTR, i18n("Could not find a folder to save %1 to.\nCheck whether you have a .kde folder with write permissions in your home folder.", fileName));
		return false;
	}
}
Пример #6
0
// Launch the given app/project file. Put here so that Shortcuts and
// BartLauncher can share this code!
status_t
LaunchCommand(char** argv, int32 argc)
{
	BEntry entry(argv[0], true);
	if (entry.Exists()) {
		// See if it's a directory. If it is, ask Tracker to open it, rather
		// than launch.
		BDirectory testDir(&entry);
		if (testDir.InitCheck() == B_NO_ERROR) {
			// Hack way to do this--really I should be able to do this by 
			// sending a BMessage. But how? When I finally get my copy of the
			// BeOS Bible, maybe then I'll find out.
			BPath trackerPath;
			if (find_directory(B_SYSTEM_DIRECTORY, &trackerPath) != B_OK
				|| trackerPath.Append("Tracker") != B_OK) {
				return B_ENTRY_NOT_FOUND;
			}
			BString cmd(trackerPath.Path());
			cmd << " '" << argv[0] << "'";
			system(cmd.String());
			return B_NO_ERROR;
		} else {
			// It's not a directory. Must be a file.
			entry_ref ref;
			if (entry.GetRef(&ref) == B_NO_ERROR) {
				if (argc > 1) 
					be_roster->Launch(&ref, argc-1, &argv[1]);
				else
					be_roster->Launch(&ref);
				return B_NO_ERROR;
			}
		}
	}
	return B_ERROR;
}
Пример #7
0
// Launch the given app/project file. Put here so that Shortcuts and
// BartLauncher can share this code!
status_t
LaunchCommand(char** argv, int32 argc)
{
	BEntry entry(argv[0], true);
	if (entry.Exists()) {
		// See if it's a directory. If it is, ask Tracker to open it, rather
		// than launch.
		BDirectory testDir(&entry);
		if (testDir.InitCheck() == B_NO_ERROR) {
			entry_ref ref;
			status_t status = entry.GetRef(&ref);
			if (status < B_OK)
				return status;

			BMessenger target(kTrackerSignature);
			BMessage message(B_REFS_RECEIVED);
			message.AddRef("refs", &ref);

			return target.SendMessage(&message);
		} else {
			// It's not a directory. Must be a file.
			entry_ref ref;
			if (entry.GetRef(&ref) == B_NO_ERROR) {
				if (argc > 1) 
					be_roster->Launch(&ref, argc - 1, &argv[1]);
				else
					be_roster->Launch(&ref);
				return B_NO_ERROR;
			}
		}
	}
	return B_ERROR;
}
Пример #8
0
// Launch the given app/project file. Put here so that Shortcuts and
// BartLauncher can share this code!
status_t
LaunchCommand(char** argv, int32 argc)
{
	BEntry entry(argv[0], true);
	if (entry.Exists()) {
		// See if it's a directory. If it is, ask Tracker to open it, rather
		// than launch.
		BDirectory testDir(&entry);
		if (testDir.InitCheck() == B_NO_ERROR) {
			// Hack way to do this--really I should be able to do this by 
			// sending a BMessage. But how? When I finally get my copy of the
			// BeOS Bible, maybe then I'll find out.
			const char* trackerFile = PATHTOTRACKER;
			char* temp = new char[strlen(trackerFile) + strlen(argv[0]) + 10];
			sprintf(temp, "%s '%s'", trackerFile, argv[0]);
			system(temp);
			delete [] temp;
			return B_NO_ERROR;
		} else {
			// It's not a directory. Must be a file.
			entry_ref ref;
			if (entry.GetRef(&ref) == B_NO_ERROR) {
				if (argc > 1) 
					be_roster->Launch(&ref, argc-1, &argv[1]);
				else
					be_roster->Launch(&ref);
				return B_NO_ERROR;
			}
		}
	}
	return B_ERROR;
}
Пример #9
0
void StorageGroup::CheckAllStorageGroupDirs(void)
{
    QString m_groupname;
    QString dirname;
    MSqlQuery query(MSqlQuery::InitCon());

    query.prepare("SELECT groupname, dirname "
                  "FROM storagegroup "
                  "WHERE hostname = :HOSTNAME;");
    query.bindValue(":HOSTNAME", gCoreContext->GetHostName());
    if (!query.exec() || !query.isActive())
    {
        MythDB::DBError("StorageGroup::CheckAllStorageGroupDirs()", query);
        return;
    }

    LOG(VB_FILE, LOG_DEBUG, LOC + 
        "CheckAllStorageGroupDirs(): Checking All Storage Group directories");

    QFile testFile("");
    QDir testDir("");
    while (query.next())
    {
        m_groupname = query.value(0).toString();
        /* The storagegroup.dirname column uses utf8_bin collation, so Qt
         * uses QString::fromAscii() for toString(). Explicitly convert the
         * value using QString::fromUtf8() to prevent corruption. */
        dirname = QString::fromUtf8(query.value(1)
                                    .toByteArray().constData());

        dirname.replace(QRegExp("^\\s*"), "");
        dirname.replace(QRegExp("\\s*$"), "");

        LOG(VB_FILE, LOG_DEBUG, LOC +
            QString("Checking directory '%1' in group '%2'.")
                .arg(dirname).arg(m_groupname));

        testDir.setPath(dirname);
        if (!testDir.exists())
        {
            LOG(VB_FILE, LOG_WARNING, LOC +
                QString("Group '%1' references directory '%2' but this "
                        "directory does not exist.  This directory "
                        "will not be used on this server.")
                    .arg(m_groupname).arg(dirname));
        }
        else
        {
            testFile.setFileName(dirname + "/.test");
            if (testFile.open(QIODevice::WriteOnly))
                testFile.remove();
            else
                LOG(VB_GENERAL, LOG_ERR, LOC +
                    QString("Group '%1' wants to use directory '%2', but "
                            "this directory is not writeable.")
                        .arg(m_groupname).arg(dirname));
        }
    }
}
Пример #10
0
Manager::Manager(KileInfo* kileInfo, QObject *parent) : QObject(parent), m_kileInfo(kileInfo), m_abbreviationsDirty(false)
{
    setObjectName("KileAbbreviation::Manager");
    m_localAbbreviationFile = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + '/' + "complete/abbreviation/" + "kile-abbrevs.cwl";
    QDir testDir(m_localAbbreviationFile);
    if (!testDir.exists()) {
        testDir.mkpath(m_localAbbreviationFile);
    }
}
Пример #11
0
int main(int argc, char *argv[])
{
	KApplication app(argc, argv, "pws");
        conf=app.getConfig();

        testDir ("/share");
        testDir ("/share/config");
        testDir ("/share/apps");
        testDir ("/share/apps/pws");
        
        PWS widget;

	app.setMainWidget(&widget);
	app.setTopWidget(&widget);

	widget.show();

	return app.exec();
}
Пример #12
0
void tst_QVersit::addFiles()
{
    QTest::addColumn<QString>("filename");

    QDir testDir(TESTDATA_DIR "testdata_vcf/");
    QStringList files(testDir.entryList());
    foreach (QString filename, files) {
        if (filename != "." && filename != "..") {
            QTest::newRow(filename.toAscii()) << testDir.filePath(filename);
        }
    }
}
Пример #13
0
void KDMThemeWidget::checkThemesDir()
{
    QDir testDir(themeDir);
    if (!testDir.exists()) {
        QVariantMap helperargs;
        helperargs["subaction"] = Helper::CreateThemesDir;

        if (executeThemeAction(parentWidget(), helperargs))
            KMessageBox::sorry(this,
                               i18n("Unable to create folder %1", testDir.absolutePath()));
    }
}
QString QStandardPaths::writableLocation(StandardLocation type)
{
    switch (type) {
    case QStandardPaths::MusicLocation:
        return getExternalStoragePublicDirectory("DIRECTORY_MUSIC");
    case QStandardPaths::MoviesLocation:
        return getExternalStoragePublicDirectory("DIRECTORY_MOVIES");
    case QStandardPaths::PicturesLocation:
        return getExternalStoragePublicDirectory("DIRECTORY_PICTURES");
    case QStandardPaths::DocumentsLocation:
        if (QtAndroidPrivate::androidSdkVersion() > 18)
            return getExternalStoragePublicDirectory("DIRECTORY_DOCUMENTS");
        else
            return getExternalStorageDirectory() + QLatin1String("/Documents");
    case QStandardPaths::DownloadLocation:
        return getExternalStoragePublicDirectory("DIRECTORY_DOWNLOADS");
    case QStandardPaths::GenericConfigLocation:
    case QStandardPaths::ConfigLocation:
        return getFilesDir() + testDir() + QLatin1String("/settings");
    case QStandardPaths::GenericDataLocation:
        return getExternalStorageDirectory() + testDir();
    case QStandardPaths::AppDataLocation:
    case QStandardPaths::AppLocalDataLocation:
        return getFilesDir() + testDir();
    case QStandardPaths::GenericCacheLocation:
    case QStandardPaths::RuntimeLocation:
    case QStandardPaths::TempLocation:
    case QStandardPaths::CacheLocation:
        return getCacheDir() + testDir();
    case QStandardPaths::DesktopLocation:
    case QStandardPaths::HomeLocation:
        return getFilesDir();
    case QStandardPaths::ApplicationsLocation:
    case QStandardPaths::FontsLocation:
    default:
        break;
    }

    return QString();
}
Пример #15
0
bool TrashImpl::init()
{
    if ( m_initStatus == InitOK )
        return true;
    if ( m_initStatus == InitError )
        return false;

    // Check the trash directory and its info and files subdirs
    // see also kdesktop/init.cc for first time initialization
    m_initStatus = InitError;
    // $XDG_DATA_HOME/Trash, i.e. ~/.local/share/Trash by default.
    const TQString xdgDataDir = TDEGlobal::dirs()->localxdgdatadir();
    if ( !TDEStandardDirs::makeDir( xdgDataDir, 0700 ) ) {
        kdWarning() << "failed to create " << xdgDataDir << endl;
        return false;
    }

    const TQString trashDir = xdgDataDir + "Trash";
    int err;
    if ( ( err = testDir( trashDir ) ) ) {
        error( err, trashDir );
        return false;
    }
    if ( ( err = testDir( trashDir + "/info" ) ) ) {
        error( err, trashDir + "/info" );
        return false;
    }
    if ( ( err = testDir( trashDir + "/files" ) ) ) {
        error( err, trashDir + "/files" );
        return false;
    }
    m_trashDirectories.insert( 0, trashDir );
    m_initStatus = InitOK;
    kdDebug() << k_funcinfo << "initialization OK, home trash dir: " << trashDir << endl;
    return true;
}
Пример #16
0
std::string FileFinder::getPath(std::string const& filename) const
{
    if (_directories.empty())
        ERR("FileFinder::getPath(): No directories set.");

    for (auto const& dir : _directories)
    {
        std::string testDir(dir);
        std::ifstream is(testDir.append(filename).c_str());
        if (is.good())
        {
            is.close();
            return testDir;
        }
    }
    ERR("FileFinder::getPath(): File not found.");
    return filename;
}
bool MainWindow::setExportPath(QUrl path) {
    QDir testDir(path.toLocalFile());
    if(testDir.exists() && !path.toLocalFile().isEmpty()) {
        std::cout << "set export path to " + path.toLocalFile().toStdString() << std::endl;
        this->exportPath = path;
        //stop highlighting
        ui->lineEdit_outputPath->setStyleSheet("");
        ui->lineEdit_outputPath->setText(path.toLocalFile());
        return true;
    }
    else if(path.toLocalFile().isEmpty()) {
        //keep previous highlighting
        return false;
    }
    else {
        //hightlight wrong path in red
        ui->lineEdit_outputPath->setStyleSheet("color: red;");
        return false;
    }
}
Пример #18
0
int main( int argc, char **argv )
{

    KApplication a( argc, argv, "krn" );

    app=&a;
    conf=a.getConfig();

    nls=a.getLocale();

    // Create our directory. If it exists, no problem
    // Should do some checking, though

    testDir( "/share" );
    testDir( "/share/config" );
    testDir( "/share/apps" );
    testDir( "/share/apps/krn" );
    testDir( "/share/apps/krn/folders" );
    testDir( "/share/apps/krn/cache" );
    testDir( "/share/apps/krn/groupinfo" );
    testDir( "/share/apps/krn/outgoing" );

    Groupdlg *k=new Groupdlg();
    main_widget = k;

    //insert this: (said Matthias)
    if (a.isRestored())
        k->restore(1);

    a.setMainWidget( k );

    k->setMinimumSize( 250, 250 );
    k->show();

    a.exec();

    k->close();
}
bool EventFileRefFilter::Filter( const entry_ref* ref,
											BNode* node,
											struct stat_beos* st,
											const char* filetype )
{
	BString 		fileType( filetype );
	BDirectory 	testDir( ref );
	BEntry		tempEntry;
	BNode			tempNode;
	char			buffer[ B_MIME_TYPE_LENGTH ];

	// All directories are allowed - else the user won't be able to travel
	if ( testDir.InitCheck() == B_OK ) {
		return true;
	}
	
	// All Event files are allowed
	if ( fileType.IFindFirst( kEventFileMIMEType ) == 0 ) {
		return true;
	}
	
	// Symlinks are traversed and allowed only if they point to audio file
	while ( fileType.IFindFirst( "application/x-vnd.Be-symlink" ) == 0 )
	{
		if ( ( B_OK == tempEntry.SetTo( ref, true ) ) &&	// Find the entry referenced by symlink
		     ( B_OK == tempNode.SetTo( &tempEntry ) ) &&	// Access the attributes (needed to read file type)
		     ( 0 != tempNode.ReadAttr( "BEOS:TYPE", B_STRING_TYPE, 0, buffer, 255 ) ) &&
		     ( NULL != fileType.SetTo( buffer ) ) &&		// This check is really unnecessary
		     ( fileType.IFindFirst( kEventFileMIMEType ) == 0 ) )
	   {
			return true;
	   }
	}
	
	return false;	
}	// <-- end of function EventFileRefFilter::Filter
SortServiceModel::SortServiceModel(QObject *parent)
    : QSortFilterProxyModel(parent)
{
    /* testing purpose */
    QString testPath(getenv("SERVICES_PRIORITY"));
    if (!testPath.isEmpty()) {
        QDir testDir(testPath);
        QStringList testPriorityList = testDir.entryList(QDir::Files);
        foreach(QString filename, testPriorityList)
            createPriorities(testDir.filePath(filename));
    }
    else {
        QDir etc(QDir::rootPath() + QLatin1String("/etc/accounts-ui/service-sorting.d"));
        QDir home(QDir::homePath() + QLatin1String("/.config/accounts-ui/service-sorting.d"));

        QStringList etcPriorityList = etc.entryList(QDir::Files);
        foreach(QString filename, etcPriorityList)
            createPriorities(etc.filePath(filename));

        QStringList homePriorityList = home.entryList(QDir::Files);
        foreach(QString filename, homePriorityList)
            createPriorities(home.filePath(filename));
    }
}
Пример #21
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    if (a.arguments().size() < 3) {
        qCritical() << "this application requires more arguments!";
        return -1;
    }

    const QString trainDirName = a.arguments().at(1);
    const QString testDirName = a.arguments().at(2);
    const QString outputName = a.arguments().at(3);
    const QString extractorName = a.arguments().at(4);
    const QStringList extractorArgs = a.arguments().mid(5);
    ExtractorInterface *extractor =
            ExtractorFactory::getExtractor(extractorName, extractorArgs);
    if (extractor == NULL) {
        qCritical() << "failed to initialise extractor" << extractorName;
        return -2;
    }

    QDir trainDir(trainDirName);
    QStringList subdirs = QStringList() << "wood" << "straw" << "salt" << "linen";
    QList<quint8> labels = QList<quint8>() << 32 << 96 << 160 << 224;
    QVector<LabelledData> trainData;
#ifdef HAS_ELAPSED_TIMER
    QElapsedTimer extractionTimer;
#else
    QTime extractionTimer;
#endif

    int threadCount = 1;
#ifdef _OPENMP
#pragma omp parallel
    {
#pragma omp single
        {
            threadCount = omp_get_num_threads();
        }
    }
#endif
    qDebug() << "using" << threadCount << "threads.";

    extractionTimer.start();
    unsigned int imagesCount = 0;
    for (int j = 0; j < subdirs.size(); j++) {
        trainDir.cd(subdirs.at(j));
        const QFileInfoList fileList = trainDir.entryInfoList(QStringList() << "*.png");
#ifdef HAS_ELAPSED_TIMER
        QElapsedTimer extractorTimer;
#else
        QTime extractorTimer;
#endif
        extractorTimer.start();
        for (int i = 0; i < fileList.size(); i++) {
            imagesCount++;
            const QString filename = fileList.at(i).filePath();
            const QImage image(filename);
            if (image.format() != QImage::Format_Indexed8) {
                qCritical("Image is not greyscale!");
                return -1;
            }
            extractor->preprocess(image);
            if (extractor->extracts()) {
                unsigned int count = trainData.size();
                trainData.resize(trainData.size() + image.width() * image.height());
                LabelledData *trainDataPtr = trainData.data();
#pragma omp parallel for
                for (int x = 0; x < image.width(); x++) {
                    for (int y = 0; y < image.height(); y++) {
                        const QVector<nnreal> res = extractor->extract(image, x, y);
                        Q_ASSERT(res.size() == extractor->size());
                        LabelledData li(res, labels.at(j));
                        const unsigned int idx = count + x * image.height() + y;
                        trainDataPtr[idx] = li;
                    }
                }
            }
            const QVector<QVector<nnreal> > ppFeatures = extractor->postprocess(image);
            const int ppCount = ppFeatures.size();
            if (ppCount > 0) {
                const int count = trainData.size();
                trainData.resize(trainData.size() + ppFeatures.size());
                LabelledData *trainDataPtr = trainData.data();
#pragma omp parallel for
                for (int k = 0; k < ppCount; k++) {
                    Q_ASSERT(ppFeatures.at(k).size() == extractor->size());
                    LabelledData ld(ppFeatures.at(k), labels.at(j));
                    trainDataPtr[count + k] = ld;
                }
            }
            qDebug() << fileList.at(i).filePath() << extractorTimer.restart();
        }
        trainDir.cdUp();
    }

    const int msecs = extractionTimer.elapsed();
    qDebug() << "trainSize:" << trainData.size() << "extraction of "
             << imagesCount << "images took" << msecs << "msecs, average"
             << float(msecs) / imagesCount << "msecs per image";
    const QString trainOutFilename(outputName + "_" + extractorName + "_train.out");
    QFile trainOutput(trainOutFilename);
    if (!trainOutput.open(QIODevice::WriteOnly)) {
        qCritical() << "failed to open output file" << trainOutFilename;
        return -3;
    }
    {
#ifdef HAS_ELAPSED_TIMER
        QElapsedTimer saveTimer;
#else
        QTime saveTimer;
#endif
        saveTimer.start();
        QDataStream outstream(&trainOutput);
        saveFeatures(outstream, extractorName, extractorArgs, extractor->size(), trainData);
        int msecs = saveTimer.elapsed();
        qDebug() << "saving took" << msecs << "msecs";
    }
    trainOutput.close();
    trainData.clear();

    {
        QDir testDir(testDirName);
        const QFileInfoList dataFileList  = testDir.entryInfoList(QStringList() << "test*.png");
        const QFileInfoList labelFileList = testDir.entryInfoList(QStringList() << "label*.png");
        Q_ASSERT(dataFileList.size() == labelFileList.size());
#ifdef HAS_ELAPSED_TIMER
        QElapsedTimer extractorTimer;
#else
        QTime extractorTimer;
#endif
        extractorTimer.start();
        QTextStream out(stdout);
        for (int i = 0; i < dataFileList.size(); i++) {
            const QImage dataImage(dataFileList.at(i).filePath());
            const QImage labelImage(labelFileList.at(i).filePath());
            QVector<LabelledData> testData;
            extractor->preprocessTest(dataImage, labelImage);
            int cnt = 0;
            if (extractor->extracts()) {
                unsigned int count = testData.size();
                testData.resize(dataImage.width() * dataImage.height());
                LabelledData *testDataPtr = testData.data();
#pragma omp parallel for
                for (int x = 0; x < dataImage.width(); x++) {
#pragma omp critical
                    {
                        cnt++;
                        out << cnt * 100 / dataImage.width() << "%" << '\r';
                        out.flush();
                    }
                    for (int y = 0; y < dataImage.height(); y++) {
                        const QVector<nnreal> res = extractor->extract(dataImage, x, y);
                        const quint8 c = labelImage.pixelIndex(x, y);
                        LabelledData li(res, c);
                        li.squeeze();
                        const unsigned int idx = count + x * dataImage.height() + y;
                        testDataPtr[idx] = li;
                    }
                }
                out << endl;
            }
            const QVector<LabelledData> ppFeatures = extractor->postprocessTest(dataImage, labelImage);
            testData << ppFeatures;
            qDebug() << dataFileList.at(i).filePath() << extractorTimer.restart();
            const QString testOutFilename(outputName + "_" + extractorName + "_test" + QString::number(i) + ".out");
            QFile testOutput(testOutFilename);
            if (!testOutput.open(QIODevice::WriteOnly)) {
                qCritical() << "failed to open output file" << testOutFilename;
                return -3;
            }
            {
#ifdef HAS_ELAPSED_TIMER
                QElapsedTimer saveTimer;
#else
                QTime saveTimer;
#endif
                saveTimer.start();
                QDataStream outstream(&testOutput);
                saveFeatures(outstream, extractorName, extractorArgs, extractor->size(), testData);
                int msecs = saveTimer.elapsed();
                qDebug() << "saving took" << msecs << "msecs";
            }
            testOutput.close();
        }
    }

    delete extractor;

    return 0;
}
Пример #22
0
void computePerformance(double threshold = 0.8)
{
	QVector<Record> records;

    QString datasetPath = "C:/Users/XXX/Dropbox/DDTT-dataset/evaluation/userstudy/group matching";

    QString endText = ".gmatch";
    QString extension = "*.gmatch";

	QDir datasetDir(datasetPath);
	QStringList subdirs = datasetDir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);

	QStringList users;

	for (QString subdir : subdirs)
	{
		QDir d(datasetPath + "/" + subdir);

        auto matchFiles = d.entryList(QStringList() << extension, QDir::Files);
		if (matchFiles.isEmpty()) continue;

		users << subdir;

		for (QString matchFile : matchFiles)
		{
			// Get matches from file
			QFile ff(d.absolutePath() + "/" + matchFile);
			ff.open(QFile::ReadOnly | QFile::Text);
			QTextStream in(&ff);
			auto matches = in.readAll().split("\n", QString::SkipEmptyParts);

			// Shape names
            QStringList shapes = matchFile.replace(endText, "").split("-", QString::SkipEmptyParts);
            if(shapes.back() == "g") shapes.removeLast();

			bool isSwap = shapes.front() > shapes.back();

			// Add to vector
			QVector< QPair<QString, QString> > pairMatches;
			for (QString matchLine : matches)
			{
				QStringList match = matchLine.split(" ", QString::SkipEmptyParts);

				QString p = match.front();
				QString q = match.back();

				if (isSwap) std::swap(p, q);

				pairMatches << qMakePair(p, q);
			}

			//qDebug() << pairMatches;

			// Add record
			if (isSwap) std::reverse(shapes.begin(), shapes.end());
			for (auto a : pairMatches) records << Record(shapes.front(), shapes.back(), a.first, a.second, subdir);
		}
	}

	// Debug records:
	qSort(records);
	for (Record & record : records)
	{
		//qDebug() << record.p << " " << record.q << " " << record.shapeA << " " << record.shapeB << " " << record.user;
	}

	//qDebug() << "Num records =" << records.size();

	// ShapePairs/part_p/part_q/users
	QMap<QString, QMap<QString, QMap<QString, QStringList> > > part_matches;

	// Extract set of good pair-wise part correspondences
	for (Record r : records)
	{
		part_matches[r.shapeA + "|" + r.shapeB][r.p][r.q] << r.user;
	}

	// Passed threshold
	int num_users = users.size();
	
    QVector<Record> C, badC;

	for (QString shapePair : part_matches.keys())
	{
		auto cur_shape_pairs = shapePair.split("|");

		for (auto p : part_matches[shapePair].keys())
		{
			auto part_matching = part_matches[shapePair][p];

			for (auto q : part_matching.keys())
			{
				auto match = part_matching[q];

				int num_assigned = match.size();

				double v = double(num_assigned) / num_users;

				if (v >= threshold)
				{
					C << Record(cur_shape_pairs.front(), cur_shape_pairs.back(), p, q, "from_users");
				}
                else
                {
                    badC << Record(cur_shape_pairs.front(), cur_shape_pairs.back(), p, q, "from_users");
                }
			}
		}
	}

	int totalNumPairTypes = C.size() + badC.size();

	//qDebug() << "Num records passed =" << C.size();

	// Ground truth
	// ShapePair/part_p/part_q
	QMap <QString, QMap<QString, QStringList> > ground_truth;
	for (Record r : C)
	{
		QStringList tstr = ground_truth[r.shapeA + "|" + r.shapeB][r.p];
		tstr.push_back(r.q);
		ground_truth[r.shapeA + "|" + r.shapeB][r.p] = tstr;
	}

	// Test set:
	QString testPath = "C:/Users/XXX/Dropbox/DDTT-dataset/evaluation/userstudy/geotopo";
	QDir testDir(testPath);

	int wins = 0;
	int loss = 0;
	int testPairs = 0;

// 	endText = ".match";
// 	extension = "*.match";
	auto matchFiles = testDir.entryList(QStringList() << extension, QDir::Files);
	for (auto matches_filename : matchFiles)
	{
		// Get matches from file
		QFile ff(testDir.absolutePath() + "/" + matches_filename);
		ff.open(QFile::ReadOnly | QFile::Text);
		QTextStream in(&ff);
		auto matches = in.readAll().split("\n", QString::SkipEmptyParts);

        QStringList shapes = matches_filename.replace(endText, "").split("-", QString::SkipEmptyParts);
        if(shapes.back() == "g") shapes.removeLast();

		bool isSwap = shapes.front() > shapes.back();

		// Shape names sorted
		if (isSwap) std::reverse(shapes.begin(), shapes.end());
		QString shapeA = shapes.front();
		QString shapeB = shapes.back();

		// Get pair matches
		for (QString matchLine : matches)
		{
			QStringList match = matchLine.split(" ", QString::SkipEmptyParts);

			QString p = match.front();
			QString q = match.back();

			if (isSwap) std::swap(p, q);

			if (ground_truth[shapeA + "|" + shapeB].contains(p))
			{
				QStringList truth = ground_truth[shapeA + "|" + shapeB][p];

				if (truth.contains(q))
					wins++;
				else
					loss++;
			}
			testPairs++;
		}
	}

	double performance = (double(wins) / (wins + loss));

	QString result = QString("Performance = %1, agreement %6%, selected = %4, wins = %2, loss = %3, all pairs = %5, test = %7")
		.arg(performance).arg(wins).arg(loss).arg(C.size()).arg(records.size()).arg(threshold * 100).arg(testPairs);

	QMessageBox::information(0, "Performance", result);

	qDebug() << result;
}
Пример #23
0
KDMUsersWidget::KDMUsersWidget( QWidget *parent )
	: QWidget( parent )
{
#ifdef __linux__
	struct stat st;
	if (!stat( "/etc/debian_version", &st )) { /* debian */
		defminuid = "1000";
		defmaxuid = "29999";
	} else if (!stat( "/usr/portage", &st )) { /* gentoo */
		defminuid = "1000";
		defmaxuid = "65000";
	} else if (!stat( "/etc/mandrake-release", &st )) { /* mandrake - check before redhat! */
		defminuid = "500";
		defmaxuid = "65000";
	} else if (!stat( "/etc/redhat-release", &st )) { /* redhat */
		defminuid = "100";
		defmaxuid = "65000";
	} else /* if (!stat( "/etc/SuSE-release", &st )) */ { /* suse */
		defminuid = "500";
		defmaxuid = "65000";
	}
#else
	defminuid = "1000";
	defmaxuid = "65000";
#endif

	// We assume that $kde_datadir/kdm exists, but better check for pics/ and pics/users,
	// and create them if necessary.
	m_userPixDir = config->group("X-*-Greeter").readEntry( "FaceDir", KGlobal::dirs()->resourceDirs( "data" ).last() + "kdm/faces" ) + '/';
	QDir testDir( m_userPixDir );
	if (!testDir.exists() && !testDir.mkdir( testDir.absolutePath() ) && !geteuid())
		KMessageBox::sorry( this, i18n("Unable to create folder %1", testDir.absolutePath() ) );
	if (!getpwnam( "nobody" ) && !geteuid())
		KMessageBox::sorry( this,
			i18n("User 'nobody' does not exist. "
			     "Displaying user images will not work in KDM.") );

	m_defaultText = i18n("<placeholder>default</placeholder>");

	QString wtstr;

	minGroup = new QGroupBox( i18n("System U&IDs"), this );
	minGroup->setWhatsThis( i18n("Users with a UID (numerical user identification) outside this range will not be listed by KDM and this setup dialog."
	                             " Note that users with the UID 0 (typically root) are not affected by this and must be"
	                             " explicitly hidden in \"Not hidden\" mode.") );
	QSizePolicy sp_ign_fix( QSizePolicy::Ignored, QSizePolicy::Fixed );
	QValidator *valid = new QIntValidator( 0, 999999, minGroup );
	QLabel *minlab = new QLabel( i18n("Below:"), minGroup );
	leminuid = new KLineEdit( minGroup );
	minlab->setBuddy( leminuid );
	leminuid->setSizePolicy( sp_ign_fix );
	leminuid->setValidator( valid );
	connect( leminuid, SIGNAL(textChanged( const QString & )), SIGNAL(changed()) );
	connect( leminuid, SIGNAL(textChanged( const QString & )), SLOT(slotMinMaxChanged()) );
	QLabel *maxlab = new QLabel( i18n("Above:"), minGroup );
	lemaxuid = new KLineEdit( minGroup );
	maxlab->setBuddy( lemaxuid );
	lemaxuid->setSizePolicy( sp_ign_fix );
	lemaxuid->setValidator( valid );
	connect( lemaxuid, SIGNAL(textChanged( const QString & )), SIGNAL(changed()) );
	connect( lemaxuid, SIGNAL(textChanged( const QString & )), SLOT(slotMinMaxChanged()) );
	QGridLayout *grid = new QGridLayout( minGroup );
	grid->addWidget( minlab, 0, 0 );
	grid->addWidget( leminuid, 0, 1 );
	grid->addWidget( maxlab, 1, 0 );
	grid->addWidget( lemaxuid, 1, 1 );

	usrGroup = new QGroupBox( i18n("Users"), this );
	cbshowlist = new QCheckBox( i18n("Show list"), usrGroup );
	cbshowlist->setWhatsThis( i18n("If this option is checked, KDM will show a list of users,"
	                               " so users can click on their name or image rather than typing in their login.") );
	cbcomplete = new QCheckBox( i18n("Autocompletion"), usrGroup );
	cbcomplete->setWhatsThis( i18n("If this option is checked, KDM will automatically complete"
	                               " user names while they are typed in the line edit.") );
	cbinverted = new QCheckBox( i18n("Inverse selection"), usrGroup );
	cbinverted->setWhatsThis( i18n("This option specifies how the users for \"Show list\" and \"Autocompletion\""
	                               " are selected in the \"Select users and groups\" list: "
	                               "If not checked, select only the checked users. "
	                               "If checked, select all non-system users, except the checked ones.") );
	cbusrsrt = new QCheckBox( i18n("Sor&t users"), usrGroup );
	cbusrsrt->setWhatsThis( i18n("If this is checked, KDM will alphabetically sort the user list."
	                             " Otherwise users are listed in the order they appear in the password file.") );
	QButtonGroup *buttonGroup = new QButtonGroup( usrGroup );
	buttonGroup->setExclusive( false );
	connect( buttonGroup, SIGNAL(buttonClicked( int )), SLOT(slotShowOpts()) );
	connect( buttonGroup, SIGNAL(buttonClicked( int )), SIGNAL(changed()) );
	buttonGroup->addButton( cbshowlist );
	buttonGroup->addButton( cbcomplete );
	buttonGroup->addButton( cbinverted );
	buttonGroup->addButton( cbusrsrt );
	QBoxLayout *box = new QVBoxLayout( usrGroup );
	box->addWidget( cbshowlist );
	box->addWidget( cbcomplete );
	box->addWidget( cbinverted );
	box->addWidget( cbusrsrt );

	wstack = new QStackedWidget( this );
	s_label = new QLabel( i18n("S&elect users and groups:"), this );
	s_label->setBuddy( wstack );
	optinlv = new K3ListView( this );
	optinlv->addColumn( i18n("Selected Users") );
	optinlv->setResizeMode( Q3ListView::LastColumn );
	optinlv->setWhatsThis( i18n("KDM will show all checked users. Entries denoted with '@' are user groups. Checking a group is like checking all users in that group.") );
	wstack->addWidget( optinlv );
	connect( optinlv, SIGNAL(clicked( Q3ListViewItem * )),
	         SLOT(slotUpdateOptIn( Q3ListViewItem * )) );
	connect( optinlv, SIGNAL(clicked( Q3ListViewItem * )),
	         SIGNAL(changed()) );
	optoutlv = new K3ListView( this );
	optoutlv->addColumn( i18n("Hidden Users") );
	optoutlv->setResizeMode( Q3ListView::LastColumn );
	optoutlv->setWhatsThis( i18n("KDM will show all non-checked non-system users. Entries denoted with '@' are user groups. Checking a group is like checking all users in that group.") );
	wstack->addWidget( optoutlv );
	connect( optoutlv, SIGNAL(clicked( Q3ListViewItem * )),
	         SLOT(slotUpdateOptOut( Q3ListViewItem * )) );
	connect( optoutlv, SIGNAL(clicked( Q3ListViewItem * )),
	         SIGNAL(changed()) );

	faceGroup = new QGroupBox( i18n("User Image Source"), this );
	faceGroup->setWhatsThis( i18n("Here you can specify where KDM will obtain the images that represent users."
	                              " \"Admin\" represents the global folder; these are the pictures you can set below."
	                              " \"User\" means that KDM should read the user's $HOME/.face.icon file."
	                              " The two selections in the middle define the order of preference if both sources are available.") );
	rbadmonly = new QRadioButton( i18n("Admin"), faceGroup );
	rbprefadm = new QRadioButton( i18n("Admin, user"), faceGroup );
	rbprefusr = new QRadioButton( i18n("User, admin"), faceGroup );
	rbusronly = new QRadioButton( i18n("User"), faceGroup );
	buttonGroup = new QButtonGroup( faceGroup );
	connect( buttonGroup, SIGNAL(buttonClicked( int )), SLOT(slotFaceOpts()) );
	connect( buttonGroup, SIGNAL(buttonClicked( int )), SIGNAL(changed()) );
	buttonGroup->addButton( rbadmonly );
	buttonGroup->addButton( rbprefadm );
	buttonGroup->addButton( rbprefusr );
	buttonGroup->addButton( rbusronly );
	box = new QVBoxLayout( faceGroup );
	box->addWidget( rbadmonly );
	box->addWidget( rbprefadm );
	box->addWidget( rbprefusr );
	box->addWidget( rbusronly );

	QGroupBox *picGroup = new QGroupBox( i18n("User Images"), this );
	usercombo = new KComboBox( picGroup );
	usercombo->setWhatsThis( i18n("The user the image below belongs to.") );
	connect( usercombo, SIGNAL(activated( int )),
	         SLOT(slotUserSelected()) );
	QLabel *userlabel = new QLabel( i18n("User:"******"Click or drop an image here") );
	userbutton->setWhatsThis( i18n("Here you can see the image assigned to the user selected in the combo box above. Click on the image button to select from a list"
	                               " of images or drag and drop your own image on to the button (e.g. from Konqueror).") );
	rstuserbutton = new QPushButton( i18n("Unset"), picGroup );
	rstuserbutton->setWhatsThis( i18n("Click this button to make KDM use the default image for the selected user.") );
	connect( rstuserbutton, SIGNAL(clicked()),
	         SLOT(slotUnsetUserPix()) );
	QGridLayout *hlpl = new QGridLayout( picGroup );
	hlpl->setSpacing( KDialog::spacingHint() );
	hlpl->addWidget( userlabel, 0, 0 );
	hlpl->addWidget( usercombo, 0, 1 ); // XXX this makes the layout too wide
	hlpl->addWidget( userbutton, 1, 0, 1, 2, Qt::AlignHCenter );
	hlpl->addWidget( rstuserbutton, 2, 0, 1, 2, Qt::AlignHCenter );

	QHBoxLayout *main = new QHBoxLayout( this );
	main->setSpacing( 10 );

	QVBoxLayout *lLayout = new QVBoxLayout();
	main->addItem( lLayout );
	lLayout->setSpacing( 10 );
	lLayout->addWidget( minGroup );
	lLayout->addWidget( usrGroup );
	lLayout->addStretch( 1 );

	QVBoxLayout *mLayout = new QVBoxLayout();
	main->addItem( mLayout );
	mLayout->setSpacing( 10 );
	mLayout->addWidget( s_label );
	mLayout->addWidget( wstack );
	mLayout->setStretchFactor( wstack, 1 );
	main->setStretchFactor( mLayout, 1 );

	QVBoxLayout *rLayout = new QVBoxLayout();
	main->addItem( rLayout );
	rLayout->setSpacing( 10 );
	rLayout->addWidget( faceGroup );
	rLayout->addWidget( picGroup );
	rLayout->addStretch( 1 );

}
Пример #24
0
static void DoTestFileWrite(TInt aBlockSize, TInt aFileSize = KMaxFileSize, TBool aUpdate = EFalse)
//
// Do Write benchmark
//
{
    DataBuf.SetLength(aBlockSize);
    const TInt maxWriteCount = aFileSize / aBlockSize;

    TFileName testDir(_L("?:\\F32-TST\\"));
    testDir[0] = (TText) gDriveToTest;
    TInt r = TheFs.MkDir(testDir);
    test_Value(r, r == KErrNone || r == KErrAlreadyExists);

    TFileName fileName;
    r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gFileSequentialModeOn ? EFileSequential : 0)
                  | (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
    test_KErrNone(r);

    if (aUpdate)
    {
        TInt r = File.SetSize(aFileSize);
        test_KErrNone(r);
    }

    TUint functionCalls = 0;

    TTime startTime;
    TTime endTime;
    TUint initTicks = 0;
    TUint finalTicks = 0;


    // we stop after the entire file has been written or after 10 seconds, whichever happens sooner
    RTimer timer;
    timer.CreateLocal();
    TRequestStatus reqStat;

    TInt pos = 0;
    File.Seek(ESeekStart, pos);

    timer.After(reqStat, 10000000); // After 10 secs

    startTime.HomeTime();
    initTicks = User::FastCounter();

    for (TInt i = 0 ; i<maxWriteCount && reqStat==KRequestPending; i++)
    {
        File.Write(pos, DataBuf, aBlockSize);

        pos += aBlockSize;
        if (pos > KMaxFileSize-aBlockSize)
            pos = 0;

        functionCalls++;
    }

    if (gFlushAfterWrite)
    {
        r = File.Flush();
        test_KErrNone(r)
    }

    // write file once only
    finalTicks = User::FastCounter();
    endTime.HomeTime();
//	TTimeIntervalMicroSeconds duration = endTime.MicroSecondsFrom(startTime);
    TTimeIntervalMicroSeconds duration = TInt64(finalTicks - initTicks) * TInt64(1000000) / TInt64(gFastCounterFreq) ;

    TInt dataTransferred = functionCalls * aBlockSize;
    TReal transferRate =
        TReal32(dataTransferred) /
        TReal(duration.Int64()) * TReal(1000000) / TReal(K1K); // KB/s
    test.Printf(_L("Write %7d bytes in %7d byte blocks:\t%11.3f KBytes/s (%d microsecs)\n"),
                dataTransferred, aBlockSize, transferRate, endTime.MicroSecondsFrom(startTime).Int64());

    timer.Close();

    File.Close();
    r = TheFs.Delete(fileName);
    test_KErrNone(r)

    return;
}
Пример #25
0
static void DoTestFileWriteCPU(TInt aBlockSize)
//
// Benchmark CPU utilisation for Write method
//
// Write operations are performed for 10 seconds whilst a second thread executes floating point calculations
// The higher the number of calculations the less amount of CPU time has been used by the Write method.
//
{
    DataBuf.SetLength(aBlockSize);

    TFileName testDir(_L("?:\\F32-TST\\"));
    testDir[0] = (TText) gDriveToTest;
    TInt r = TheFs.MkDir(testDir);
    test_Value(r, r == KErrNone || r == KErrAlreadyExists);

    TFileName fileName;
    r = File.Temp(TheFs, testDir, fileName, EFileWrite | (gFileSequentialModeOn ? EFileSequential : 0)
                  | (gWriteCachingOn ? EFileWriteBuffered : EFileWriteDirectIO));
    test_KErrNone(r);

    TUint functionCalls = 0;
    TUint fltPntCalls = 0;
    RThread fltPntThrd;

    TBuf<6> buf = _L("Floaty");
    fltPntThrd.Create(buf, FloatingPointLoop, KDefaultStackSize, KHeapSize, KHeapSize, (TAny*) &fltPntCalls);

    TUint initTicks = 0;
    TUint finalTicks = 0;

    // up the priority of this thread so that we only run the floating point thread when this thread is idle
    RThread				thisThread;
    thisThread.SetPriority(EPriorityMuchMore);

    TRequestStatus req;
    fltPntThrd.Logon(req);

    RTimer timer;
    timer.CreateLocal();
    TRequestStatus reqStat;

    TInt pos = 0;
    File.Seek(ESeekStart, pos);

    timer.After(reqStat, KFloatingPointTestTime);
    initTicks = User::FastCounter();

    fltPntThrd.Resume();

    for (TInt i = 0 ; reqStat==KRequestPending; i++)
    {
        File.Write(DataBuf, aBlockSize);
        functionCalls++;
    }
    TUint fltPntCallsFinal = fltPntCalls;

    fltPntThrd.Kill(KErrNone);

    finalTicks = User::FastCounter();

    fltPntThrd.Close();
    User::WaitForRequest(req);

    TTimeIntervalMicroSeconds duration = TInt64(finalTicks - initTicks) * TInt64(1000000) / TInt64(gFastCounterFreq) ;

    TInt dataTransferred = functionCalls * aBlockSize;
    TReal transferRate =  TReal32(dataTransferred) /
                          TReal(duration.Int64()) * TReal(1000000) / TReal(K1K); // KB/s

    test.Printf(_L("Write %7d bytes in %7d byte blocks:\t%11.3f KBytes/s; %d Flt Calcs\n"),
                dataTransferred, aBlockSize, transferRate, fltPntCallsFinal);

    timer.Close();

    File.Close();
    r = TheFs.Delete(fileName);
    test_KErrNone(r)

    return;
}
Пример #26
0
int main( int argc, char **argv )
{
    msgSender=0;
    // Initialize the mime++ library
    DwInitialize();

    KApplication *a=new KApplication ( argc, argv, "krn" );
    //a.enableSessionManagement();

    app=a;
    conf=a->getConfig();

    checkConf();
    nls=a->getLocale();
    keys = new KStdAccel(conf);
    kbp=new KBusyPtr();
    msgSender=new KRNSender();
    msgSender->readConfig();
    msgSender->setMethod(KMSender::smSMTP);
    KMMessage::readConfig();

    addrBook=new KMAddrBook();
    addrBook->readConfig();
    addrBook->load();


    // Create our directory. If it exists, no problem
    // Should do some checking, though

    testDir( "/share" );
    testDir( "/share/config" );
    testDir( "/share/apps" );
    testDir( "/share/apps/krn" );
    testDir( "/share/apps/krn/cache" );
    testDir( "/share/apps/krn/groupinfo" );
    testDir( "/share/apps/krn/outgoing" );

    krnpath = KApplication::localkdedir() + "/share/apps/krn/";

    mkdir (krnpath.data(),S_IREAD|S_IWRITE|S_IEXEC);
    cachepath=krnpath+"/cache/";
    mkdir (cachepath.data(),S_IREAD|S_IWRITE|S_IEXEC);
    groupinfopath=krnpath+"/groupinfo/";
    mkdir (groupinfopath.data(),S_IREAD|S_IWRITE|S_IEXEC);
    outpath=krnpath+"outgoing/";
    mkdir (outpath.data(),S_IREAD|S_IWRITE|S_IEXEC);

    // Create the articles database


    artinfopath=krnpath+"/artinfo.db";
    artdb=gdbm_open(artinfopath.data(),0,GDBM_WRCREAT | GDBM_FAST,448,0);
    artinfopath=krnpath+"/refs.db";
    refsdb=gdbm_open(artinfopath.data(),0,GDBM_WRCREAT | GDBM_FAST,448,0);
    artinfopath=krnpath+"/scores.db";
    scoredb=gdbm_open(artinfopath.data(),0,GDBM_WRCREAT | GDBM_FAST,448,0);

    if ((!artdb) || (!refsdb) || (!scoredb)) //the gdbm open failed!
    {
        int i=KMsgBox::yesNo(0,"KRN - Error",
                             "I have detected another Krn running\n"
                             "Do you REALLY want to continue?\n"
                             "If you are sure there isn't one, press \"Yes\"\n"
                             "But if there *is* another one, it's going to be UGLY\n");
    }
    // Fill the unreadDict
    datum key=gdbm_firstkey ( artdb );
    datum nextkey;


    while ( key.dptr )
    {
        unreadDict.insert(key.dptr,key.dptr);
        nextkey = gdbm_nextkey ( artdb, key );
        free (key.dptr);
        key = nextkey;
    };

    // Load the rules
    ruleFile=new KSimpleConfig(krnpath+"/rules");
    Rule::updateGlobals();


    Groupdlg *k=new Groupdlg();
    main_widget = k;

    //insert this:
    if (a->isRestored())
        k->restore(1);

    a->setMainWidget( k );
    a->setTopWidget( k );

    k->setMinimumSize( 250, 250 );
    k->show();

    a->exec();

    expireCache();

//    k->close();
    gdbm_reorganize(artdb);
    gdbm_reorganize(refsdb);
    gdbm_reorganize(scoredb);

    gdbm_close(artdb);
    gdbm_close(refsdb);
    gdbm_close(scoredb);
//    delete k;
}