Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. void diaOpenFileByListView::BindLV(){
  2. int curRow=-1;
  3. if(model!=0 && ui->lvwFile->currentIndex().row()>0){
  4. curRow= ui->lvwFile->currentIndex().row();
  5. }
  6. init_styleditemdelegate_cell listdelegate;
  7. model = new QStandardItemModel(this);
  8. ui->lvwFile->setModel(model);
  9. listdelegate = new init_styleditemdelegate_cell();
  10. ui->lvwFile->setItemDelegate(listdelegate);
  11. QDir dir=QDir::rootPath();
  12. QString myPath;
  13. myPath=gData->strFileFolder;
  14. dir.cd(myPath);
  15. ui->lblPath->setText(dir.absolutePath());
  16. dir.setNameFilters(QStringList()<<".qqq");
  17. QStringList fileList = dir.entryList();
  18. QStandardItem *item ;//= new QStandardItem();
  19. for (int i=0; i<fileList.count(); i++)
  20. {
  21. item = new QStandardItem();
  22. QString tmpFilePaht=dir.absolutePath()+"/"+fileList[i];
  23. QIcon icon=GetListIcon(tmpFilePaht);
  24. item->setData(icon,init_styleditemdelegate_cell::IconRole);
  25. item->setData(tmpFilePaht,init_styleditemdelegate_cell::headerTextRole);
  26. item->setData(fileList[i],init_styleditemdelegate_cell::subHeaderTextrole);
  27. item->setEditable(false);
  28. model->appendRow(item);
  29. }
  30. if(model->rowCount()>0){
  31. if(curRow>-1){
  32. ui->lvwFile->setCurrentIndex(model->indexFromItem(model->item(curRow,0)));
  33. }else{
  34. ui->lvwFile->setCurrentIndex(model->indexFromItem(model->item(0,0)));
  35. }
  36. }
  37. ShowIni();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement