Changeset 201757f


Ignore:
Timestamp:
08/22/14 10:12:31 (4 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.3, releng/10.1
Children:
14220b49
Parents:
8102fda
Message:

Redo the lumina-fm backend browser widgets so that they switch between directories about 100x faster.

Location:
lumina/lumina-fm
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • lumina/lumina-fm/MainUI.cpp

    r0ec6f71 r201757f  
    2525  fsmod = new QFileSystemModel(this); 
    2626    fsmod->setRootPath("/"); 
     27    ui->tree_dir_view->setModel(fsmod); 
     28    ui->tree_dir_view->sortByColumn(0, Qt::AscendingOrder); 
     29    ui->tree_dir_view->setColumnWidth(0,200); 
     30    ui->tree_dir_view->setColumnWidth(1,80); //size column should be small 
     31    ui->tree_dir_view->setColumnWidth(2,80); //type column should be small 
     32    ui->list_dir_view->setModel(fsmod); 
    2733  dirCompleter = new QCompleter(fsmod, this); 
    2834    dirCompleter->setModelSorting( QCompleter::CaseInsensitivelySortedModel ); 
    2935    currentDir->setCompleter(dirCompleter); 
    30   dirWatcher = new QFileSystemWatcher(this); 
    31     dirWatcher->addPath(QDir::homePath()); 
    32      
    3336  snapmod = new QFileSystemModel(this); 
    3437    ui->tree_zfs_dir->setModel(snapmod); 
    3538    ui->tree_zfs_dir->sortByColumn(0, Qt::AscendingOrder); 
     39  iconProv = new MimeIconProvider(); 
     40    fsmod->setIconProvider(iconProv); 
     41    snapmod->setIconProvider(iconProv); 
     42  fswatcher = new QFileSystemWatcher(this); 
     43    connect(fswatcher, SIGNAL(directoryChanged(QString)), this, SLOT(reloadDirectory()) ); 
    3644  contextMenu = new QMenu(this); 
    3745  radio_view_details = new QRadioButton(tr("Detailed List"), this); 
     
    6068    playerSlider->setMediaObject(mediaObj); 
    6169    ui->videoControlLayout->insertWidget(4, playerSlider); 
    62   //playerFile = new QFile(); 
    6370    ui->tool_player_stop->setEnabled(false); //nothing to stop yet 
    6471    ui->tool_player_pause->setVisible(false); //nothing to pause yet 
     
    120127  ui->tool_goToPlayer->setIcon( LXDG::findIcon("applications-multimedia","") ); 
    121128  ui->tool_goToRestore->setIcon( LXDG::findIcon("document-revert","") ); 
    122   picIcon = LXDG::findIcon("image-loading",""); //default picture thumbnail icon 
    123129         
    124130  //Multimedia Player page 
     
    153159         
    154160  //Tree Widget interaction 
    155   connect(ui->tree_dir_widget, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(ItemRun(QTreeWidgetItem*)) ); 
    156   connect(ui->list_dir_widget, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(ItemRun(QListWidgetItem*)) ); 
    157   connect(ui->tree_dir_widget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OpenContextMenu(const QPoint&)) ); 
    158   connect(ui->list_dir_widget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OpenContextMenu(const QPoint&)) ); 
    159   connect(ui->tree_dir_widget->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(loadItemIcons()) ); 
    160   connect(ui->tree_dir_widget->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(loadItemIcons()) ); 
    161   connect(ui->list_dir_widget->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(loadItemIcons()) ); 
    162   connect(ui->list_dir_widget->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(loadItemIcons()) ); 
    163   connect(dirWatcher, SIGNAL(directoryChanged(QString)), this, SLOT( loadDirectory() ) ); 
    164          
     161  connect(ui->tree_dir_view, SIGNAL(activated(const QModelIndex&)), this, SLOT(ItemRun(const QModelIndex&)) );   
     162  connect(ui->list_dir_view, SIGNAL(activated(const QModelIndex&)), this, SLOT(ItemRun(const QModelIndex&)) ); 
     163  connect(ui->tree_dir_view, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OpenContextMenu(const QPoint&)) ); 
     164  connect(ui->list_dir_view, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OpenContextMenu(const QPoint&)) ); 
     165   
    165166  //Page Switching 
    166167  connect(ui->tool_goToPlayer, SIGNAL(clicked()), this, SLOT(goToMultimediaPage()) ); 
     
    177178         
    178179  //ZFS Restore page 
    179   connect(snapmod, SIGNAL(directoryLoaded(QString)), this, SLOT(snapshotLoaded()) ); 
    180180  connect(ui->slider_zfs_snapshot, SIGNAL(valueChanged(int)), this, SLOT(showSnapshot()) ); 
    181181  connect(ui->tool_zfs_nextSnap, SIGNAL(clicked()), this, SLOT(nextSnapshot()) ); 
     
    275275} 
    276276 
    277 QString MainUI::bytesToText(qint64 bytes){ 
    278   QString lab; //label 
    279   double disp; //display number 
    280   if(bytes > 1125899906842580){ lab="PB"; disp = bytes/1125899906842580.0; } 
    281   else if(bytes>1099511627776){ lab="TB"; disp = bytes/1099511627776.0; } 
    282   else if(bytes>1073741824){ lab="GB"; disp = bytes/1073741824.0; } 
    283   else if(bytes>1048576){ lab="MB"; disp = bytes/1048576.0; } 
    284   else if(bytes>1024){ lab="KB"; disp = bytes/1024.0; } 
    285   else{ lab="B"; disp = bytes; } 
    286   //Round to number of decimel places 
    287   if(disp<10){ disp = qRound(disp*100)/(100.0); } //2 decimel places 
    288   else if(disp<100){ disp = qRound(disp*10)/(10.0); } //1 decimel place 
    289   else{ disp = qRound(disp); } // no decimel places 
    290   //Return text 
    291   return QString::number(disp)+" "+lab; 
    292 } 
    293  
    294277QString MainUI::msToText(qint64 ms){ 
    295278  QString disp; 
     
    339322  currentDir->setText(dir);   
    340323  //Update the directory viewer and update the line edit 
    341   if(dir!=currentDir->whatsThis()){ 
    342324    keepFocus = !currentDir->hasFocus(); 
    343325    currentDir->setWhatsThis(dir); //save the full path internally 
    344     //fsmod->setRootPath(dir); 
    345     QTimer::singleShot(0,this, SLOT(loadDirectory()) ); 
    346   } 
    347   dirWatcher->removePaths( dirWatcher->directories() ); 
    348   dirWatcher->addPath(rawdir); //make sure we are watching this directory 
     326    if(radio_view_details->isChecked()){ 
     327      ui->tree_dir_view->setRootIndex(fsmod->index(dir)); 
     328    }else{ 
     329      ui->list_dir_view->setRootIndex(fsmod->index(dir)); 
     330    } 
     331  //Setup the directory watcher here 
     332  if( !fswatcher->directories().isEmpty() ){ fswatcher->removePaths(fswatcher->directories()); } 
     333  fswatcher->addPath(dir); 
    349334  //Adjust the tab data 
    350335  tabBar->setTabWhatsThis( tabBar->currentIndex(), rawdir ); 
     
    359344  QTimer::singleShot(0, this, SLOT(checkForBackups())); 
    360345  QTimer::singleShot(0, this, SLOT(checkForPictures())); 
     346  if(isUserWritable){ ui->label_dir_stats->setText(""); } 
     347  else{ ui->label_dir_stats->setText(tr("Limited Access Directory")); } 
    361348  ui->tool_addToDir->setVisible(isUserWritable); 
    362349  ui->actionUpDir->setEnabled(dir!="/"); 
     
    366353} 
    367354 
    368 QStringList MainUI::getSelectedItems(){ 
    369   QStringList out; 
     355QFileInfoList MainUI::getSelectedItems(){ 
     356  QFileInfoList out; 
    370357  if(radio_view_details->isChecked()){ 
    371     QList<QTreeWidgetItem*> items = ui->tree_dir_widget->selectedItems(); 
     358    QModelIndexList items = ui->tree_dir_view->selectionModel()->selectedIndexes(); 
    372359    for(int i=0; i<items.length(); i++){ 
    373        out << items[i]->text(0); 
     360      if(!out.contains(fsmod->fileInfo(items[i]))){ 
     361        out << fsmod->fileInfo(items[i]); 
     362      } 
    374363    } 
    375364  }else{ 
    376     QList<QListWidgetItem*> items = ui->list_dir_widget->selectedItems(); 
     365    QModelIndexList items = ui->list_dir_view->selectionModel()->selectedIndexes(); 
    377366    for(int i=0; i<items.length(); i++){ 
    378        out << items[i]->text(); 
     367      if(!out.contains(fsmod->fileInfo(items[i]))){ 
     368        out <<  fsmod->fileInfo(items[i]); 
     369      } 
    379370    } 
    380371  }      
    381   out.removeDuplicates(); 
    382372  return out; 
    383373} 
     
    423413    if(dir.exists(".zfs/snapshot")){ found = true;} 
    424414    else{ dir.cdUp(); } 
     415    QApplication::processEvents(); //keep the UI snappy 
    425416  } 
    426417  //Now find the snapshots that contain this directory and save them 
     
    429420          reldir.remove(dir.absolutePath()); 
    430421    dir.cd(".zfs/snapshot"); 
     422    snapmod->setRootPath(dir.canonicalPath()); //set the base snapshot dir as the new root 
    431423    snapDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time); 
    432424    //Check that the current directory exists in each snapshot 
     
    438430        snapDirs[i] = QFileInfo(dir, snapDirs[i]+"/"+reldir).created().toString("yyyyMMddhhmmsszzz")+"::::"+snapDirs[i]; 
    439431      } 
     432      QApplication::processEvents(); //keep the UI snappy 
    440433    } 
    441434    snapDirs.sort(); 
     
    443436    for(int i=0; i<snapDirs.length(); i++){ 
    444437      snapDirs[i] = dir.absolutePath()+"/"+snapDirs[i].section("::::",1,50)+"/"+reldir; 
     438      QApplication::processEvents(); //keep the UI snappy 
    445439    } 
    446440    //qDebug() << "Found snapshots:" << snapDirs; 
     
    461455  if(!pics.isEmpty()){ 
    462456    ui->combo_image_name->clear(); 
    463     /*for(int i=0; i<pics.length(); i++){ 
    464       ui->combo_image_name->addItem(QIcon(dir.absoluteFilePath(pics[i])), pics[i]); 
    465     }*/ 
    466457    ui->combo_image_name->addItems(pics); 
    467458    ui->tool_goToImages->setVisible(true);         
     
    483474  //Disable all the UI elements specifically for the Browser side of things 
    484475  ui->actionNew_Tab->setEnabled(false); 
    485   //ui->menuEdit->setEnabled(false); 
    486476  ui->menuView->setEnabled(false); 
    487477  ui->menuBookmarks->setEnabled(false); 
    488478  ui->menuExternal_Devices->setEnabled(false); 
    489479  //Start the player on the first selected item 
    490   QStringList sel = getSelectedItems(); 
     480  QFileInfoList sel = getSelectedItems(); 
    491481  if(!sel.isEmpty()){ 
     482    QStringList names; 
     483    for(int i=0; i<sel.length(); i++){ names << sel[i].fileName(); } 
    492484    //start the slideshow on the first selected picture 
    493485    for(int i=0; i<ui->combo_player_list->count(); i++){ 
    494       if(sel.contains( ui->combo_player_list->itemText(i) )){ ui->combo_player_list->setCurrentIndex(i); break; } 
     486      if(names.contains( ui->combo_player_list->itemText(i) )){ ui->combo_player_list->setCurrentIndex(i); break; } 
    495487    } 
    496488  } 
     
    510502  //Disable all the UI elements specifically for the Browser side of things 
    511503  ui->actionNew_Tab->setEnabled(false); 
    512   //ui->menuEdit->setEnabled(false); 
    513504  ui->menuView->setEnabled(false); 
    514505  ui->menuBookmarks->setEnabled(false); 
     
    532523  //Disable all the UI elements specifically for the Browser side of things 
    533524  ui->actionNew_Tab->setEnabled(false); 
    534   //ui->menuEdit->setEnabled(false); 
    535525  ui->menuView->setEnabled(false); 
    536526  ui->menuBookmarks->setEnabled(false); 
    537527  ui->menuExternal_Devices->setEnabled(false); 
    538   QStringList sel = getSelectedItems(); 
     528  QFileInfoList sel = getSelectedItems(); 
    539529  if(!sel.isEmpty()){ 
     530    QStringList names; 
     531    for(int i=0; i<sel.length(); i++){ names << sel[i].fileName(); } 
    540532    //start the slideshow on the first selected picture 
    541533    for(int i=0; i<ui->combo_image_name->count(); i++){ 
    542       if(sel.contains( ui->combo_image_name->itemText(i) )){ ui->combo_image_name->setCurrentIndex(i); break; } 
     534      if(names.contains( ui->combo_image_name->itemText(i) )){ ui->combo_image_name->setCurrentIndex(i); break; } 
    543535    } 
    544536  } 
     
    558550  //Disable all the UI elements specifically for the Browser side of things 
    559551  ui->actionNew_Tab->setEnabled(true); 
    560   //ui->menuEdit->setEnabled(true); 
    561552  ui->menuView->setEnabled(true); 
    562553  ui->menuBookmarks->setEnabled(true); 
     
    596587  //Now save this setting for later 
    597588  settings->setValue("showhidden", ui->actionView_Hidden_Files->isChecked()); 
    598   loadDirectory(); //Reload 
     589  //Re-load the view widget 
     590  setCurrentDir(getCurrentDir()); 
    599591} 
    600592 
     
    621613  if(!active){ return; } //on every view change, all 3 radio buttons will call this function - only run this once though 
    622614  if(radio_view_details->isChecked()){ 
    623     ui->tree_dir_widget->setVisible(true); 
    624     ui->list_dir_widget->setVisible(false); 
     615    ui->tree_dir_view->setVisible(true); 
     616    ui->list_dir_view->setVisible(false); 
    625617        settings->setValue("viewmode","details"); 
    626618  }else if(radio_view_list->isChecked()){ 
    627     ui->tree_dir_widget->setVisible(false); 
    628     ui->list_dir_widget->setVisible(true); 
    629     ui->list_dir_widget->setViewMode( QListView::ListMode ); 
    630         ui->list_dir_widget->setGridSize(QSize()); 
     619    ui->tree_dir_view->setVisible(false); 
     620    ui->list_dir_view->setVisible(true); 
     621    ui->list_dir_view->setViewMode( QListView::ListMode ); 
     622        ui->list_dir_view->setUniformItemSizes(false); 
    631623        settings->setValue("viewmode","list"); 
    632624  }else{  //icons 
    633     ui->tree_dir_widget->setVisible(false); 
    634     ui->list_dir_widget->setVisible(true); 
    635     ui->list_dir_widget->setViewMode( QListView::IconMode ); 
    636         ui->list_dir_widget->setGridSize(QSize( ui->list_dir_widget->viewport()->width()/5,ui->list_dir_widget->viewport()->width()/4)); 
     625    ui->tree_dir_view->setVisible(false); 
     626    ui->list_dir_view->setVisible(true); 
     627    ui->list_dir_view->setViewMode( QListView::IconMode ); 
     628        ui->list_dir_view->setUniformItemSizes(true); 
    637629        settings->setValue("viewmode","icons"); 
    638630  } 
    639   loadDirectory(); //reload current directory 
     631  //Re-load the view widget 
     632  setCurrentDir(getCurrentDir()); 
    640633         
    641634} 
     
    705698} 
    706699 
    707 void MainUI::loadDirectory(){ 
    708   //Disable the widgets 
    709   ui->tree_dir_widget->setEnabled(false); 
    710   ui->list_dir_widget->setEnabled(false); 
    711   ui->label_dir_stats->setText(tr("Loading...")); 
    712   //Load the directory contents and fill the widgets 
    713   QDir dir(getCurrentDir()); 
    714   QFileInfoList list; 
    715   if(ui->actionView_Hidden_Files->isChecked()){ list = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Hidden | QDir::AllEntries, QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::LocaleAware); } 
    716   else{ list = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries, QDir::Name | QDir::DirsFirst | QDir::IgnoreCase | QDir::LocaleAware); } 
    717   //Clear the widgets 
    718   ui->tree_dir_widget->clear(); 
    719   ui->list_dir_widget->clear(); 
    720   //reset the list widget icons sizes before adding items 
    721   if(!radio_view_details->isChecked()){ ui->list_dir_widget->setGridSize(QSize()); } //reset the grid 
    722   if(radio_view_list->isChecked()){ ui->list_dir_widget->setIconSize( QSize(22,22) ); } 
    723   else{ ui->list_dir_widget->setIconSize( QSize(32,32) ); } 
    724   //Now fill the widgets 
    725   int longname=0; 
    726   for(int i=0; i<list.length(); i++){ 
    727     if(list[i].fileName().length() > longname){ longname=list[i].fileName().length(); } 
    728     //Get the appropriate icon 
    729     QIcon ico; 
    730     if(list[i].isDir()){ ico = LXDG::findIcon("folder",""); } 
    731     else if( imgFilter.contains("*."+list[i].suffix().toLower()) ){ico = picIcon; } 
    732     else if(list[i].isExecutable()){ ico = LXDG::findIcon("application-x-executable",""); } 
    733     else{ ico = LXDG::findMimeIcon(list[i].suffix()); } 
    734     //Add it to the widgets 
    735     if(radio_view_details->isChecked()){ 
    736       QString sz; 
    737       if(!list[i].isDir()){ sz = bytesToText(list[i].size()); } 
    738       QTreeWidgetItem *it = new QTreeWidgetItem(QStringList() << list[i].fileName() << sz << list[i].lastModified().toString(Qt::DefaultLocaleShortDate) ); //add other info columns here later 
    739       it->setIcon(0,ico); 
    740       ui->tree_dir_widget->addTopLevelItem(it); 
    741       if(i==0){ ui->tree_dir_widget->setCurrentItem(it); } 
    742     }else{ 
    743       ui->list_dir_widget->addItem( new QListWidgetItem( ico, list[i].fileName() ) ); 
    744       if(i==0){ ui->list_dir_widget->setCurrentRow(0); } 
    745     } 
    746     QApplication::processEvents(); 
    747   } 
    748   //Make sure the items are the proper size 
    749   if( list.length() > 0 ){ 
    750     if( radio_view_details->isChecked() ){ for(int i=0; i<3; i++){ ui->tree_dir_widget->resizeColumnToContents(i); } } 
    751   } 
    752   if(!radio_view_details->isChecked()){ ui->list_dir_widget->setGridSize(QSize()); } 
    753   loadItemIcons(); //load the initially visible icons 
    754   //Re-enable the widgets 
    755   ui->tree_dir_widget->setEnabled(true); 
    756   ui->list_dir_widget->setEnabled(true); 
    757   //Reset the keyboard focus back to the widget if necessary 
    758   if(keepFocus){ 
    759     if(radio_view_details->isChecked()){ ui->tree_dir_widget->setFocus(); } 
    760     else{ ui->list_dir_widget->setFocus(); } 
    761   } 
    762   if(isUserWritable){ ui->label_dir_stats->setText(""); } 
    763   else{ ui->label_dir_stats->setText(tr("Limited Access Directory")); } 
    764 } 
    765  
    766 void MainUI::loadItemIcons(){ 
    767   QString dir = getCurrentDir(); 
    768   //define the static variables in case this gets called in quick succession 
    769   static bool running = true; 
    770   static int st = 0; 
    771   static int end = 0; 
    772   running = true; //set internal flag to stop any running loops 
    773   if(radio_view_details->isChecked()){ 
    774     st = 0; 
    775     end = ui->tree_dir_widget->topLevelItemCount()-1; //start/end of visible items 
    776     QTreeWidgetItem *first, *last; 
    777           first = last =0; //make sure this is pre-set 
    778     first = ui->tree_dir_widget->itemAt(5,5); 
    779     last = ui->tree_dir_widget->itemAt(5, ui->tree_dir_widget->height()-5); 
    780     if(first!=0){ st = ui->tree_dir_widget->indexOfTopLevelItem(first); } 
    781     if(last!=0){ end = ui->tree_dir_widget->indexOfTopLevelItem(last); } 
    782     if( (end-st) > 50){ end = st+50; } //never load more than 20 
    783     //qDebug() << "Visible Items:" << st << "->" << end; 
    784     running = false; 
    785     for(int i=0; i<ui->tree_dir_widget->topLevelItemCount(); i++){ 
    786       if( imgFilter.contains("*."+ ui->tree_dir_widget->topLevelItem(i)->text(0).section(".",-1).toLower() ) ){ 
    787         if((i<st) || (i>end)){ 
    788           ui->tree_dir_widget->topLevelItem(i)->setIcon(0, picIcon); 
    789         }else{ 
    790           ui->tree_dir_widget->topLevelItem(i)->setIcon( 0, QIcon( dir+"/"+ui->tree_dir_widget->topLevelItem(i)->text(0)) );     
    791         } 
    792       } 
    793       QCoreApplication::processEvents(); //make sure the UI is still snappy 
    794       if(running){ qDebug() << "Stopping Loop"; return; }//another loop starting - stop this one immediately 
    795     } 
    796      
    797   }else{ 
    798     st = 0; 
    799     end = ui->list_dir_widget->count()-1; //start/end of visible items 
    800     QListWidgetItem *first, *last; 
    801           first = last =0; //make sure this is pre-set 
    802     first = ui->list_dir_widget->itemAt(5,5); 
    803     QPoint endpoint(ui->list_dir_widget->viewport()->width(), ui->list_dir_widget->viewport()->height()); 
    804     //qDebug() << "Viewport:" << endpoint.x() << endpoint.y(); 
    805     //qDebug() << "Widget:" << ui->list_dir_widget->size().width() << ui->list_dir_widget->size().height(); 
    806     if(radio_view_icons->isChecked()){ 
    807         int diff = 10; 
    808         while(last==0 && diff < endpoint.x()/20){ 
    809           last = ui->list_dir_widget->itemAt(endpoint.x()-diff, endpoint.y()); 
    810           diff+=10; 
    811         } 
    812     }else{ 
    813         int diff = 10; 
    814         while(last==0 && diff < endpoint.y()/20){ 
    815           last = ui->list_dir_widget->itemAt(endpoint.x(), endpoint.y()-diff); 
    816           diff+=10; 
    817         } 
    818     } 
    819     if(first!=0){ st = ui->list_dir_widget->row(first); } 
    820     if(last!=0){ end = ui->list_dir_widget->row(last); } 
    821     if( (end-st) > 50){ end = st+50; } //never load more than 50 
    822     //qDebug() << "Visible Items:" << st << "->" << end; 
    823     running = false; 
    824     for(int i=0; i<ui->list_dir_widget->count(); i++){ 
    825       if( imgFilter.contains("*."+ ui->list_dir_widget->item(i)->text().section(".",-1).toLower() ) ){ 
    826         if((i<st) || (i>end)){ 
    827           ui->list_dir_widget->item(i)->setIcon(picIcon); //hidden item 
    828         }else{ 
    829           ui->list_dir_widget->item(i)->setIcon( QIcon( dir+"/"+ui->list_dir_widget->item(i)->text()) );         
    830         } 
    831       } 
    832       QCoreApplication::processEvents(); //make sure the UI is still snappy 
    833       if(running){ qDebug() << "Stopping Loop"; return; }//another loop starting - stop this one immediately       
    834     } 
    835   } //end basic list and icon view 
     700void MainUI::reloadDirectory(){ 
     701  setCurrentDir( getCurrentDir() ); 
    836702} 
    837703 
     
    927793 
    928794void MainUI::OpenContextMenu(const QPoint &pt){ 
     795  QFileInfo info;  
    929796  if(radio_view_details->isChecked()){  
    930     QTreeWidgetItem *it = ui->tree_dir_widget->itemAt(pt); 
    931     if(it==0){ CItem.clear();} 
    932     else{ CItem = it->text(0); } 
     797    QModelIndex it = ui->tree_dir_view->indexAt(pt); 
     798    if(!it.isValid()){ CItem.clear();} 
     799    else{  
     800      info = fsmod->fileInfo(it);  
     801      CItem = info.absoluteFilePath();  
     802    } 
    933803  }else{  
    934     QListWidgetItem *it = ui->list_dir_widget->itemAt(pt); 
    935     if(it==0){ CItem.clear(); } 
    936     else{ CItem = it->text(); } 
    937   } 
    938   QString cdir = getCurrentDir(); 
    939   if(!cdir.endsWith("/")){ cdir.append("/"); } 
    940   if(!CItem.isEmpty()){ CItem.prepend(cdir); } 
     804    QModelIndex it = ui->list_dir_view->indexAt(pt); 
     805    if(!it.isValid()){ CItem.clear();} 
     806    else{  
     807      info = fsmod->fileInfo(it);  
     808      CItem = info.absoluteFilePath();  
     809    } 
     810  } 
    941811  //Create the context menu 
    942812  contextMenu->clear(); 
    943   QFileInfo info(CItem);   
    944813  if(!CItem.isEmpty()){   
    945814    if(info.isDir()){ 
     
    961830  //Now show the menu 
    962831  if(radio_view_details->isChecked()){ 
    963     contextMenu->popup(ui->tree_dir_widget->mapToGlobal(pt)); 
     832    contextMenu->popup(ui->tree_dir_view->mapToGlobal(pt)); 
    964833  }else{ 
    965     contextMenu->popup(ui->list_dir_widget->mapToGlobal(pt)); 
     834    contextMenu->popup(ui->list_dir_view->mapToGlobal(pt)); 
    966835  } 
    967836} 
     
    1017886  ui->label_zfs_snap->setText( snapDirs[ui->slider_zfs_snapshot->value()-1].section("/.zfs/snapshot/",1,1).section("/",0,0) ); 
    1018887  //Load the dir contents 
    1019   ui->tree_zfs_dir->setRootIndex(snapmod->setRootPath(snapDirs[ui->slider_zfs_snapshot->value()-1])); 
     888  ui->tree_zfs_dir->setRootIndex(snapmod->index(snapDirs[ui->slider_zfs_snapshot->value()-1])); 
    1020889} 
    1021890 
     
    1030899void MainUI::restoreItems(){ 
    1031900   //Get the selected items 
    1032    QStringList sel = getSelectedItems(); 
     901   QStringList sel; //= getSelectedItems(); 
    1033902   QModelIndexList items = ui->tree_zfs_dir->selectionModel()->selectedIndexes(); 
    1034903   for(int i=0; i<items.length(); i++){ 
     
    11951064   if(!checkUserPerms()){ return; } 
    11961065   //Get the selected items 
    1197    QStringList sel, names; 
    1198    names = getSelectedItems(); 
    1199    //QModelIndexList items = ui->tree_dir_view->selectionModel()->selectedIndexes(); 
    1200    QString baseDir = getCurrentDir(); 
    1201    if(!baseDir.endsWith("/")){ baseDir.append("/"); } 
    1202    for(int i=0; i<names.length(); i++){ 
    1203      sel << baseDir+names[i]; 
     1066   QStringList paths, names; 
     1067   QFileInfoList sel = getSelectedItems(); 
     1068   for(int i=0; i<sel.length(); i++){ 
     1069     paths << sel[i].absoluteFilePath(); 
     1070     names << sel[i].fileName(); 
    12041071   } 
    12051072   if(sel.isEmpty()){ return; } //nothing selected 
     
    12091076  } 
    12101077  //Now remove the file/dir 
    1211   qDebug() << "Delete: "<<sel; 
     1078  qDebug() << "Delete: "<<paths; 
    12121079  FODialog dlg(this); 
    1213     dlg.RemoveFiles(sel); 
     1080    dlg.RemoveFiles(paths); 
    12141081    dlg.exec(); 
    12151082} 
     
    12561123  if(!checkUserPerms()){ return; } 
    12571124  //Get all the selected Items  
    1258   QStringList sel = getSelectedItems(); 
     1125  QFileInfoList sel = getSelectedItems(); 
     1126  QStringList items; 
    12591127  if(sel.isEmpty()){ return; } //nothing selected 
    1260   QString base = getCurrentDir(); 
    1261   if(!base.endsWith("/")){ base.append("/"); } 
    1262   for(int i=0; i<sel.length(); i++){ 
     1128  /*for(int i=0; i<sel.length(); i++){ 
    12631129    sel[i].prepend(base); 
    12641130  } 
    1265   qDebug() << "Cut Items:" << sel; 
     1131  qDebug() << "Cut Items:" << sel;*/ 
    12661132  //Format the data string 
    12671133  for(int i=0; i<sel.length(); i++){ 
    1268     sel[i] = sel[i].prepend("cut::::"); 
     1134    items << "cut::::"+sel[i].absoluteFilePath(); 
     1135    //sel[i] = sel[i].prepend("cut::::"); 
    12691136  } 
    12701137   
     
    12721139  QMimeData *dat = new QMimeData; 
    12731140        dat->clear(); 
    1274         dat->setData("x-special/lumina-copied-files", sel.join("\n").toLocal8Bit()); 
     1141        dat->setData("x-special/lumina-copied-files", items.join("\n").toLocal8Bit()); 
    12751142  QApplication::clipboard()->clear(); 
    12761143  QApplication::clipboard()->setMimeData(dat); 
     
    12811148  if(ui->stackedWidget->currentWidget()!=ui->page_browser){ return; } 
    12821149  //Get all the selected Items  
    1283   QStringList sel = getSelectedItems(); 
     1150  QFileInfoList sel = getSelectedItems(); 
     1151  QStringList items; 
    12841152  if(sel.isEmpty()){ return; } //nothing selected 
    1285   QString base = getCurrentDir(); 
     1153  /*QString base = getCurrentDir(); 
    12861154  if(!base.endsWith("/")){ base.append("/"); } 
    12871155  for(int i=0; i<sel.length(); i++){ 
    12881156    sel[i].prepend(base); 
    12891157  } 
    1290   qDebug() << "Copy Items:" << sel; 
     1158  qDebug() << "Copy Items:" << sel;*/ 
    12911159  //Format the data string 
    12921160  for(int i=0; i<sel.length(); i++){ 
    1293     sel[i] = sel[i].prepend("copy::::"); 
     1161    items << "copy::::"+sel[i].absoluteFilePath(); 
     1162    //sel[i] = sel[i].prepend("copy::::"); 
    12941163  } 
    12951164  //Now save that data to the global clipboard 
    12961165  QMimeData *dat = new QMimeData; 
    12971166        dat->clear(); 
    1298         dat->setData("x-special/lumina-copied-files", sel.join("\n").toLocal8Bit()); 
     1167        dat->setData("x-special/lumina-copied-files", items.join("\n").toLocal8Bit()); 
    12991168  QApplication::clipboard()->clear(); 
    13001169  QApplication::clipboard()->setMimeData(dat);   
  • lumina/lumina-fm/MainUI.h

    r0ec6f71 r201757f  
    3535#include <QImageReader> 
    3636#include <QScrollBar> 
     37#include <QFileDialog> 
    3738 
    3839//Phonon widgets 
     
    5152#include "FODialog.h" //file operation dialog 
    5253#include "BMMDialog.h" //bookmark manager dialog 
     54#include "MimeIconProvider.h" //icon provider for the view widgets 
    5355 
    5456namespace Ui{ 
     
    7072        QLineEdit *currentDir; 
    7173        QFileSystemModel *fsmod, *snapmod; 
     74        QFileSystemWatcher *fswatcher; 
     75        MimeIconProvider *iconProv; 
    7276        QMenu *contextMenu; 
    7377        QRadioButton *radio_view_details, *radio_view_list, *radio_view_icons; 
     
    7983        Phonon::AudioOutput *audioOut; 
    8084        Phonon::SeekSlider *playerSlider; 
    81         //QFile *playerFile; 
    8285        QString playerTTime; //total time - to prevent recalculation every tick 
    8386 
     
    8992        QShortcut *nextTabLShort, *nextTabRShort, *closeTabShort, *copyFilesShort, *pasteFilesShort, *deleteFilesShort; 
    9093        QCompleter *dirCompleter; 
    91         QFileSystemWatcher *dirWatcher; 
    9294        bool isUserWritable, keepFocus; 
    93         QIcon picIcon; 
    9495 
    9596        //Simplification Functions 
     
    102103         
    103104        bool checkUserPerms(); 
    104         QString bytesToText(qint64 bytes); 
    105105        QString msToText(qint64 ms); 
    106106         
     
    108108        QString getCurrentDir(); 
    109109        void setCurrentDir(QString); 
    110         QStringList getSelectedItems(); 
     110        QFileInfoList getSelectedItems(); 
    111111 
    112112private slots: 
     
    145145        void startEditDir(QWidget *old, QWidget *now); 
    146146        void goToDirectory(); //go to a manually typed in directory 
    147         void loadDirectory(); //Update the widget with the dir contents 
    148         void loadItemIcons(); //Update the icons for the list 
     147        void reloadDirectory(); //Update the widget with the dir contents 
    149148        void on_tool_addToDir_clicked(); 
    150149        void tabChanged(int tab); 
  • lumina/lumina-fm/MainUI.ui

    rfc776ce r201757f  
    2929         <layout class="QVBoxLayout" name="verticalLayout_browser"> 
    3030          <item> 
    31            <widget class="QListWidget" name="list_dir_widget"> 
     31           <widget class="QListView" name="list_dir_view"> 
    3232            <property name="contextMenuPolicy"> 
    3333             <enum>Qt::CustomContextMenu</enum> 
     
    4545             <enum>QListView::Adjust</enum> 
    4646            </property> 
     47            <property name="layoutMode"> 
     48             <enum>QListView::Batched</enum> 
     49            </property> 
    4750            <property name="spacing"> 
    4851             <number>1</number> 
     
    5255            </property> 
    5356            <property name="batchSize"> 
    54              <number>20</number> 
     57             <number>100</number> 
    5558            </property> 
    5659            <property name="wordWrap"> 
     
    6366          </item> 
    6467          <item> 
    65            <widget class="QTreeWidget" name="tree_dir_widget"> 
     68           <widget class="QTreeView" name="tree_dir_view"> 
    6669            <property name="contextMenuPolicy"> 
    6770             <enum>Qt::CustomContextMenu</enum> 
     
    7073             <enum>QAbstractItemView::ExtendedSelection</enum> 
    7174            </property> 
    72             <property name="iconSize"> 
    73              <size> 
    74               <width>22</width> 
    75               <height>22</height> 
    76              </size> 
    77             </property> 
    7875            <property name="indentation"> 
    7976             <number>0</number> 
    8077            </property> 
     78            <property name="rootIsDecorated"> 
     79             <bool>false</bool> 
     80            </property> 
    8181            <property name="uniformRowHeights"> 
    82              <bool>true</bool> 
     82             <bool>false</bool> 
    8383            </property> 
    8484            <property name="itemsExpandable"> 
     
    8686            </property> 
    8787            <property name="sortingEnabled"> 
    88              <bool>false</bool> 
     88             <bool>true</bool> 
    8989            </property> 
    9090            <property name="expandsOnDoubleClick"> 
    9191             <bool>false</bool> 
    9292            </property> 
    93             <attribute name="headerDefaultSectionSize"> 
    94              <number>100</number> 
     93            <attribute name="headerCascadingSectionResizes"> 
     94             <bool>true</bool> 
    9595            </attribute> 
    9696            <attribute name="headerMinimumSectionSize"> 
    97              <number>70</number> 
     97             <number>30</number> 
    9898            </attribute> 
    99             <attribute name="headerShowSortIndicator" stdset="0"> 
    100              <bool>false</bool> 
     99            <attribute name="headerStretchLastSection"> 
     100             <bool>true</bool> 
    101101            </attribute> 
    102             <column> 
    103              <property name="text"> 
    104               <string notr="true">Name</string> 
    105              </property> 
    106             </column> 
    107             <column> 
    108              <property name="text"> 
    109               <string>Size</string> 
    110              </property> 
    111             </column> 
    112             <column> 
    113              <property name="text"> 
    114               <string>Last Modified</string> 
    115              </property> 
    116             </column> 
    117102           </widget> 
    118103          </item> 
  • lumina/lumina-fm/lumina-fm.pro

    r4333764 r201757f  
    1414HEADERS  += MainUI.h \ 
    1515                FODialog.h \ 
    16                 BMMDialog.h 
     16                BMMDialog.h \ 
     17                MimeIconProvider.h 
    1718 
    1819FORMS    += MainUI.ui \ 
Note: See TracChangeset for help on using the changeset viewer.