void FolderView::onFileClicked(int type, FmFileInfo* fileInfo) { if(type == ActivatedClick) { if(fileLauncher_) { GList* files = g_list_append(NULL, fileInfo); fileLauncher_->launchFiles(NULL, files); g_list_free(files); } } else if(type == ContextMenuClick) { FmPath* folderPath = path(); QMenu* menu = NULL; if(fileInfo) { // show context menu if (FmFileInfoList* files = selectedFiles()) { Fm::FileMenu* fileMenu = new Fm::FileMenu(files, fileInfo, folderPath); fileMenu->setFileLauncher(fileLauncher_); prepareFileMenu(fileMenu); fm_file_info_list_unref(files); menu = fileMenu; } } else { FmFolder* _folder = folder(); FmFileInfo* info = fm_folder_get_info(_folder); Fm::FolderMenu* folderMenu = new Fm::FolderMenu(this); prepareFolderMenu(folderMenu); menu = folderMenu; } if (menu) { menu->popup(QCursor::pos()); connect(menu, SIGNAL(aboutToHide()), menu, SLOT(deleteLater())); } } }
/*static*/ void TabPage::onFolderFinishLoading(FmFolder* _folder, TabPage* pThis) { // FIXME: is this needed? FmFileInfo* fi = fm_folder_get_info(_folder); if(fi) { // if loading of the folder fails, it's possible that we don't have FmFileInfo. pThis->title_ = QString::fromUtf8(fm_file_info_get_disp_name(fi)); Q_EMIT pThis->titleChanged(pThis->title_); } fm_folder_query_filesystem_info(_folder); // FIXME: is this needed? #if 0 FmFolderView* fv = folder_view; const FmNavHistoryItem* item; GtkScrolledWindow* scroll = GTK_SCROLLED_WINDOW(fv); /* Note: most of the time, we delay the creation of the * folder model and do it after the whole folder is loaded. * That is because adding rows into model is much faster when no handlers * are connected to its signals. So we detach the model from folder view * and create the model again when it's fully loaded. * This optimization, however, is not used for FmFolder objects * with incremental loading (search://) */ if(fm_folder_view_get_model(fv) == NULL) { /* create a model for the folder and set it to the view */ FmFolderModel* model = fm_folder_model_new(folder, app_config->show_hidden); fm_folder_view_set_model(fv, model); #if FM_CHECK_VERSION(1, 0, 2) /* since 1.0.2 sorting should be applied on model instead of view */ fm_folder_model_set_sort(model, app_config->sort_by, (app_config->sort_type == GTK_SORT_ASCENDING) ? FM_SORT_ASCENDING : FM_SORT_DESCENDING); #endif g_object_unref(model); } #endif // update status text QString& text = pThis->statusText_[StatusTextNormal]; text = pThis->formatStatusText(); Q_EMIT pThis->statusChanged(StatusTextNormal, text); if(pThis->overrideCursor_) { QApplication::restoreOverrideCursor(); // remove busy cursor pThis->overrideCursor_ = false; } // After finishing loading the folder, the model is updated, but Qt delays the UI update // for performance reasons. Therefore at this point the UI is not up to date. // Of course, the scrollbar ranges are not updated yet. We solve this by installing an Qt timeout handler. QTimer::singleShot(10, pThis, SLOT(restoreScrollPos())); }