void Pane::load_state(QSettings *s) { QString uri = s->value("path", "").toString(); if (uri.isEmpty()) { uri = Special_uri(Special_uri::places).uri(); } set_uri(uri); }
void Directory::refresh() { need_update = false; refresh_timer.restart(); if (uri.isEmpty()) { emit error(tr("Address is empty")); return; } if (Special_uri(uri).name() == Special_uri::mounts) { //mounting of unmounted volume was requested //uri is something like "places/mounts/42" int id = uri.split("/").last().toInt(); QList<Gio_volume*> volumes = core->get_mount_manager()->get_volumes(); if (id < 0 || id >= volumes.count()) { emit error(tr("Invalid volume id")); return; } GVolume* volume = volumes.at(id)->get_gvolume(); interrupt_gio_operation(); gcancellable = g_cancellable_new(); async_result_type = async_result_mount_volume; g_volume_mount(volume, GMountMountFlags(), 0, gcancellable, async_result, this); return; } create_task(uri); }
void Path_button::contextMenuEvent(QContextMenuEvent *e) { if (Special_uri(uri).name() == Special_uri::places) { QMenu* menu = new QMenu(this); menu->addAction(Special_uri(Special_uri::places).caption())->setEnabled(false); menu->exec(e->globalPos()); return; } if (parent_directory == 0) { Directory d(core, uri); parent_directory = new Directory(core, d.get_parent_uri()); connect(parent_directory, SIGNAL(ready(File_info_list)), this, SLOT(directory_ready(File_info_list))); } menu_point = e->globalPos(); menu_pending = true; parent_directory->refresh(); }
QString Directory::get_parent_uri(QString target_uri) { QRegExp network_root("^[^\\:]*\\://[^/]*/$"); if (network_root.indexIn(target_uri) == 0) { //we are in network root such as "ftp://user@host/" return Special_uri(Special_uri::places).uri(); } if (target_uri == "/" || Special_uri(target_uri).name() == Special_uri::places) { return Special_uri(Special_uri::places).uri(); } QStringList m = target_uri.split("/"); //uri separator must always be "/" if (!m.isEmpty()) m.removeLast(); if (m.count() == 1 && m.first().isEmpty()) return "/"; QString s = m.join("/"); if (network_root.indexIn(s + "/") == 0) { //we are near network root, e.g. "ftp://user@host/one_folder" //we must get "ftp://user@host/" instead of "ftp://user@host" s += "/"; } return s; }
void Directory::create_task(QString uri) { Directory_list_task* task = new Directory_list_task(uri, core); task->setAutoDelete(true); connect(task, SIGNAL(ready(File_info_list)), this, SLOT(task_ready(File_info_list))); connect(task, SIGNAL(error(QString)), this, SIGNAL(error(QString))); connect(task, SIGNAL(location_not_found()), this, SLOT(location_not_found())); QThreadPool::globalInstance()->start(task); if (Special_uri(uri).name() != Special_uri::places) { if (!watcher_created) { emit watch(uri); watcher_created = true; } } }