Esempio n. 1
0
int rockbox_browse(struct browse_context *browse)
{
    static char current[MAX_PATH];
    int ret_val = 0;
    int dirfilter = browse->dirfilter;

    if (backup_count >= NUM_TC_BACKUP)
        return GO_TO_PREVIOUS;
    if (backup_count >= 0)
        backups[backup_count] = tc;
    backup_count++;

    tc.dirfilter = &dirfilter;
    tc.sort_dir = global_settings.sort_dir;

    reload_dir = true;
    if (*tc.dirfilter >= NUM_FILTER_MODES)
    {
        int last_context;

        tc.browse = browse;
        tc.selected_item = 0;
        tc.dirlevel = 0;
        strlcpy(tc.currdir, browse->root, sizeof(tc.currdir));
        start_wps = false;
        last_context = curr_context;

        if (browse->selected)
        {
            snprintf(current, sizeof(current), "%s/%s",
                browse->root, browse->selected);
            set_current_file(current);
            /* set_current_file changes dirlevel, change it back */
            tc.dirlevel = 0; 
        }

        ret_val = dirbrowse();
        curr_context = last_context;
    }
    else
    {
        if (dirfilter != SHOW_ID3DB)
            tc.dirfilter = &global_settings.dirfilter;
        tc.browse = browse;
        strcpy(current, browse->root);
        set_current_file(current);
        ret_val = dirbrowse();
    }
    backup_count--;
    if (backup_count >= 0)
        tc = backups[backup_count];
    return ret_val;
}
Esempio n. 2
0
void FileDialog::set_current_path(const String& p_path) {
	
	if (!p_path.size())
		return;
	int pos=MAX( p_path.find_last("/"), p_path.find_last("\\") );
	if (pos==-1) {
		
		set_current_file(p_path);
	} else {
		
		String dir=p_path.substr(0,pos);
		String file=p_path.substr(pos+1,p_path.length());
		set_current_dir(dir);
		set_current_file(file);
	}
}
Esempio n. 3
0
void MainWindow::load_file(const QString &filename)
{
    QFile  file(filename);

    if (!file.open(QFile::ReadOnly | QFile::Text))				// open the file
    {
        QMessageBox::warning(this, tr("parameterGUI"),
                             tr("Cannot read file %1:\n%2.")
                             .arg(filename)
                             .arg(file.errorString()));
        return;
    };

    tree_widget->clear();							// clear the tree

    XMLParameterReader  xml_reader(tree_widget);				// and read the xml file

    if (!xml_reader.read_xml_file(&file))
    {
        QMessageBox::warning(this, tr("parameterGUI"),
                             tr("Parse error in file %1:\n\n%2")
                             .arg(filename)
                             .arg(xml_reader.error_string()));
    }
    else
    {
        statusBar()->showMessage(tr("File loaded - Start editing by double-clicking or hitting F2"), 25000);
        set_current_file(filename);						// show a message and set current file

        show_message ();							// show some informations how values can be edited
    };
}
Esempio n. 4
0
bool MainWindow::save_file(const QString &filename)
{
    QFile  file(filename);

    if (!file.open(QFile::WriteOnly | QFile::Text))				// open a file dialog
    {
        QMessageBox::warning(this, tr("parameterGUI"),
                             tr("Cannot write file %1:\n%2.")
                             .arg(filename)
                             .arg(file.errorString()));
        return false;
    };

    XMLParameterWriter  xml_writer(tree_widget);				// create a xml_writer

    if (!xml_writer.write_xml_file(&file))					// and read the xml file
        return false;

    statusBar()->showMessage(tr("File saved"), 2000);				// if we succeed, show a message
    set_current_file(filename);						// and reset the window

    return true;
}