void USBLinkTreeWidget::reloadFilebrowser()
{
    bool is_false = false;
    if(!doing_dirlist.compare_exchange_strong(is_false, true))
        usblink_queue_reset(); // The treeWidget is cleared, so references to items get invalid -> Get rid of them!

    this->clear();
    usblink_queue_dirlist("/", usblink_dirlist_callback, this);
}
Example #2
0
void MainWindow::reload_filebrowser()
{
    if(!refresh_filebrowser)
        return;

    if(!usblink_connected)
        usblink_connect();

    ui->treeWidget->clear();
    usblink_queue_dirlist("/", usblink_dirlist_callback, ui->treeWidget);
}
Example #3
0
static bool usblink_dirlist_nested(QTreeWidgetItem *w)
{
    if(w->data(0, Qt::UserRole).value<bool>() == false) //Not a directory
        return false;

    if(w->data(1, Qt::UserRole).value<bool>() == false) //Not filled yet
    {
        QByteArray path_utf8 = usblink_path_item(w).toUtf8();
        usblink_queue_dirlist(path_utf8.data(), MainWindow::usblink_dirlist_callback_nested, w);
        return true;
    }
    else
    {
        for(int i = 0; i < w->childCount(); ++i)
            if(usblink_dirlist_nested(w->child(i)))
                return true;
    }

    return false;
}
bool USBLinkTreeWidget::usblink_dirlist_nested(QTreeWidgetItem *w)
{
    // Find a directory (w or its children) to fill

    if(w->data(0, Qt::UserRole).value<bool>() == false) //Not a directory
        return false;

    if(w->data(1, Qt::UserRole).value<bool>() == false) //Not filled yet
    {
        std::string path_utf8 = usblink_path_item(w).toStdString();
        usblink_queue_dirlist(path_utf8, USBLinkTreeWidget::usblink_dirlist_callback_nested, w);
        return true;
    }
    else
    {
        for(int i = 0; i < w->childCount(); ++i)
            if(usblink_dirlist_nested(w->child(i)))
                return true;
    }

    return false;
}