Няма описание

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "dialog.h"
  2. #include "ui_dialog.h"
  3. #include <QMessageBox>
  4. #include <QFileDialog>
  5. Dialog::Dialog(QWidget *parent) :
  6. QDialog(parent),
  7. ui(new Ui::Dialog)
  8. {
  9. ui->setupUi(this);
  10. QDir myPath(QDir::homePath());
  11. myPath.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
  12. myList = myPath.entryList();
  13. ui->listWidget->addItems(myList);
  14. ui->total_amount->setText(QString("%1").arg(ui->listWidget->count()));
  15. }
  16. Dialog::~Dialog()
  17. {
  18. delete ui;
  19. }
  20. // Filter for folders
  21. void Dialog::on_filter_textChanged(const QString &arg1)
  22. {
  23. QRegExp regExp(arg1, Qt::CaseInsensitive, QRegExp::Wildcard);
  24. ui->listWidget->clear();
  25. ui->listWidget->addItems(myList.filter(regExp));
  26. ui->total_amount->setText(QString("%1").arg(ui->listWidget->count()));
  27. }
  28. // Open folder
  29. void Dialog::on_pushButton_clicked()
  30. {
  31. // QFileDialog::
  32. QMessageBox mbox;
  33. mbox.setWindowTitle("How to use the Simple Image Editor");
  34. QString test = ui->listWidget->currentItem()->text();
  35. if (ui->listWidget->currentItem() != NULL)
  36. mbox.setText(ui->listWidget->currentItem()->text());
  37. mbox.exec();
  38. }
  39. //this function is in charge of loading the
  40. //parts of a creature in the given directory
  41. void Dialog::loadItems(QString path, int N)
  42. {
  43. QDir dir(path); //create a QDir with the given path
  44. dir.setFilter(QDir::Files); //Set a filter so only files are looked for
  45. dir.setSorting(QDir::Name); //Set sorting by name
  46. QFileInfoList list = dir.entryInfoList(); //get the list of files in the directory
  47. QFileInfo fileInfo; //holds the info of the next file to be checked
  48. QString filePath; //string to store the path of the current file being checked
  49. QString fileName; //string to store the name of the current file being checked
  50. for(int i = 0; i < list.size(); i++)
  51. {
  52. fileInfo = list.at(i); //get the file info at possition i
  53. filePath = fileInfo.filePath(); //get the file path
  54. fileName = fileInfo.fileName(); //get the file name
  55. //QImage image(filePath); //load the file as an image
  56. //if the file cant be loaded continue
  57. //if(image.isNull()) continue;
  58. }
  59. }