Exemple #1
0
PanoseValueModel::PanoseValueModel( QObject * parent)
		:QAbstractListModel(parent)
{
	const QMap< FontStrings::PanoseKey, QMap<int, QString> >& p(FontStrings::Panose());
	QSettings settings;
	QString defaultDir(FMPaths::ResourcesDir() + "Panose/Icons");
	QString pDir(settings.value("Panose/IconDir", defaultDir).toString() + QDir::separator());

	foreach(const FontStrings::PanoseKey& k, p.keys())
	{
		foreach(const int& v, p[k].keys())
		{
			if(v > 1) // We do not want "Any" and "No Fit"
			{
				QString fn(pDir + QString::number(k) + QDir::separator() + QString::number(v) +".png");
				if(QFile::exists(fn))
					m_icons[k] << QIcon(fn);
				else
					m_icons[k] << QIcon();
				m_names[k] << p[k][v];
			}
		}
	}
	m_cat = FontStrings::firstPanoseKey();
}
void LineHelpersTest::testExtrapolate()
{
	Line2d l;
	Point2d defaultPoint(0,0);
	Point2d defaultDir(1,0);
	Point2d res = extrapolateLine(l, 0, 1, defaultPoint, defaultDir);
	QVERIFY2(res == defaultPoint, "Empty test failed");
	l.push_back(defaultPoint);
	res = extrapolateLine(l, 1, 1, defaultPoint, defaultDir);
	QVERIFY2(res == defaultPoint + defaultDir, "Single point failed");
	l.push_back(defaultDir);
	res = extrapolateLine(l, 2, 1, defaultPoint, defaultDir);
	QVERIFY2(res == defaultPoint + Point2d(2, 0), "Two points failed");
	l.push_back(Point2d(2, 0));
	res = extrapolateLine(l, 3, 1, defaultPoint, defaultDir);
	QVERIFY2(res == Point2d(3, 0), "Three points failed");
	res = extrapolateLine(l, 0, 1, defaultPoint, defaultDir);
	QVERIFY2(res == defaultPoint, "Empty test 2 failed");
	res = extrapolateLine(l, 1, 1, defaultPoint, defaultDir);
	QVERIFY2(res == defaultPoint + defaultDir, "Single point 2 failed");
	res = extrapolateLine(l, 2, 1, defaultPoint, defaultDir);
	QVERIFY2(res == defaultPoint + Point2d(2, 0), "Two points 2 failed");
	l.push_back(Point2d(4, 0));
	res = extrapolateLine(l, 3, 1, defaultPoint, defaultDir);
	QVERIFY2(res == Point2d(3, 0), "Three points 2 failed");
}
QString BbMediaStorageLocation::generateFileName(const QString &requestedName, QCamera::CaptureMode mode, const QString &prefix, const QString &extension) const
{
    if (requestedName.isEmpty())
        return generateFileName(prefix, defaultDir(mode), extension);

    if (QFileInfo(requestedName).isDir())
        return generateFileName(prefix, QDir(requestedName), extension);

    return requestedName;
}
QString QAndroidMediaStorageLocation::generateFileName(const QString &requestedName,
                                                       CaptureSource source,
                                                       const QString &prefix,
                                                       const QString &extension) const
{
    if (requestedName.isEmpty())
        return generateFileName(prefix, defaultDir(source), extension);

    QString path = requestedName;

    if (QFileInfo(path).isRelative())
        path = defaultDir(source).absoluteFilePath(path);

    if (QFileInfo(path).isDir())
        return generateFileName(prefix, QDir(path), extension);

    if (!path.endsWith(extension))
        path.append(QString(".%1").arg(extension));

    return path;
}
Exemple #5
0
OsPath SipXecsService::Path(DirectoryType pathType, const char* fileName)
{
    OsPath path;

    const char* dirPath;
    if ( (dirPath = getenv(pathType)) )
    {
        OsSysLog::add(FAC_KERNEL, PRI_NOTICE,
                      "SipXecsService::Path type '%s' overridden by environment to '%s'",
                      pathType, dirPath);
    }
    else
    {
        dirPath = defaultDir(pathType);
    }
    path.append(dirPath);

    const char slash = OsPath::separator(0);
    const char lastPathChar = path(path.length()-1);
    if (fileName && *fileName != '\000')
    {
        // Add the file name
        //   make sure there is exactly one separator between the directory and the file
        if (   slash != lastPathChar
                && slash != fileName[0]
           )
        {
            // neither has separator - add one
            path.append(OsPath::separator);
        }
        else if (   slash == lastPathChar
                    && slash == fileName[0]
                )
        {
            // both have the separator - take one off so there's only one
            path.remove(path.length()-1);
        }

        path.append(fileName);
    }
    // There is no file name, so make sure the returned directory name does not
    // end in a separator
    else if ( slash == lastPathChar )
    {
        path.remove(path.length()-1);
    }

    OsSysLog::add(FAC_KERNEL, PRI_DEBUG,
                  "SipXecsService::Path('%s', '%s') returning '%s'",
                  pathType, fileName ? fileName : "", path.data() );
    return path;
}
Exemple #6
0
PanoseAttributeModel::PanoseAttributeModel(QObject * parent)
		:QAbstractListModel(parent)
{
	const QMap< FontStrings::PanoseKey, QMap<int, QString> >& p(FontStrings::Panose());
	QSettings settings;
	QString defaultDir(FMPaths::ResourcesDir() + "Panose/Icons");
	QString pDir(settings.value("Panose/IconDir", defaultDir).toString() + QDir::separator());
	foreach(const FontStrings::PanoseKey& k, p.keys())
	{
		QString fn(pDir + QString::number(k) + QDir::separator() + "attribute.png");
		if(QFile::exists(fn))
			m_icons << QIcon(fn);
		else
			m_icons << QIcon();
		m_names << FontStrings::PanoseKeyName(k);
	}
}
void SourceImageLoader::changeSource() {
    string defaultPath = sourceDirectories[activeDirIndex];
    ofDirectory defaultDir(defaultPath);
    defaultDir.listDir(); // Make this specific to images

    int prob = 100 / defaultDir.size();

    // Empty the vectors and repopulate
    sourceImages.clear();
    imageProbabilities.clear();

    for (int i = 0; i < defaultDir.size(); i++) {
        ofImage ofi;
        ofi.load(defaultDir.getPath(i));
        sourceImages.push_back(ofi);
        imageProbabilities.push_back(prob);
    }
};
Exemple #8
0
void MainWindow::openFile()
{
    QString currentFile(viewer->filePath());
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    const QString systemPicturesPath = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation);
#else
    const QStringList systemPaths = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
    const QString systemPicturesPath = systemPaths.empty() ? QString::null : systemPaths.first();
#endif // QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    QString defaultDir(currentFile.isEmpty() ? systemPicturesPath
                       : QFileInfo(currentFile).absolutePath());
    QString fileName =
            QFileDialog::getOpenFileName(
                this, tr("Open File"), defaultDir,
                tr("Images (%1);;All Files (*)").arg(Config::supportFormats()));
    if (!fileName.isEmpty())
        viewer->openFile(fileName);
}
Exemple #9
0
void MyFrame::OnOpenDatabase(wxCommandEvent& WXUNUSED(event))
{


    wxString defaultDir("");
    wxString defaultFile("");

    if (lastDatabasePath.size() > 0) defaultDir = lastDatabasePath;
    if (lastDatabaseFile.size() > 0) defaultFile = lastDatabaseFile;


    wxFileDialog dialog(this, "Choose database file", defaultDir, defaultFile, "*.db", wxFD_OPEN | wxFD_FILE_MUST_EXIST, wxDefaultPosition, wxDefaultSize, "filedlg");

    if (dialog.ShowModal() == wxID_OK)
    {    
        if (tcDatabaseManager::Get()->IsOpen())
        {
            tcDatabaseManager::Get()->Close();
            SetStatusText("Closed database");
        }

        std::string databaseFileName;
        databaseFileName = dialog.GetPath().c_str();

        if (tcDatabaseManager::Get()->Open(databaseFileName))
        {
            UpdatePages();

            wxString fullPath = dialog.GetPath();

            lastDatabasePath = fullPath.BeforeLast('\\');
            lastDatabaseFile = fullPath.AfterLast('\\');


            wxString msg = wxString("Editing ") + fullPath;
            SetStatusText(msg);
        }
        else
        {
            wxMessageBox("Open failed");
        }
    }

}