#include <QtGui/QApplication>#include <QDir>#include <QFile>#include <QWidget>#include <QLabel>#include <QList>#include <QBoxLayout>#include <QListWidget>#include <QObject>#include <QListWidgetItem>#include <iostream>#include <QTextStream>#include <QFileInfo>#include <QPushButton>#include "ListWidgetItem.h"QString *path = new QString("C:/Users/Q6HKi/Desktop/Download/Infected Mushroom - Discography");QString *m3uFile = new QString("C:/Users/Q6HKi/Desktop/file.m3u");QStringList *files = new QStringList();static QStringList filesToListF( QString* inPath, QString inFilter){ QDir *dir = new QDir(*inPath); QStringList *filter = new QStringList(inFilter); QStringList files( dir->entryList( *filter, QDir::Files, QDir::Name) ); return files;}static QStringList filesList( QString* inPath, QString inFilter){ QDir *dir = new QDir(*inPath); QStringList *filter = new QStringList(inFilter); QFileInfoList *infoList = new QFileInfoList(); infoList->append( dir->entryInfoList( *filter, QDir::Files, QDir::Name) ); QStringList files; for( int i = 0; i < infoList->count(); i++ ){ files.append( (*infoList)[i].absoluteFilePath() ); } return files;}static QStringList folderList(QString* inPath){ QDir *dir = new QDir(*inPath); QList<QString> files( dir->entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) ); for( int i = 0; i < (files.count()); i++){ (files[i]).prepend(*inPath + "/"); } return files;}int main(int argc, char *argv[]){ QApplication a(argc, argv); QVBoxLayout *vlay = new QVBoxLayout(); QStringList *folders = new QStringList( *path ); for( int i = 0; i < folders->count(); i++ ){ folders->append( folderList( &(*folders)[i] ) ); } for( int i = 0; i < folders->count(); i++ ){ files->append( filesList( &(*folders)[i], "*.mp3") ); } QStringList *filesToList = new QStringList(); for( int i = 0; i < folders->count(); i++ ){ filesToList->append( filesToListF( &(*folders)[i], "*.mp3") ); } QLabel *currPath = new QLabel(); currPath->setText( *path ); vlay->addWidget(currPath); QLabel *foldersNum = new QLabel(); QString *foldersNumStr = new QString(); foldersNumStr->setNum(folders->count()); foldersNum->setText( *foldersNumStr + " folders" ); vlay->addWidget(foldersNum); QLabel *filesNum = new QLabel(); QString *filesNumStr = new QString(); filesNumStr->setNum(files->count()); filesNum->setText( *filesNumStr + " files" ); vlay->addWidget(filesNum); QListWidget *listW = new QListWidget(); //Нужно сделать внешней listW->setSelectionMode(QAbstractItemView::ExtendedSelection); QList<QListWidgetItem *> listItem; for( int i = 0; i < (filesToList->count()); i++){ listItem << new QListWidgetItem( (*filesToList)[i], listW); } for( int i = 0; i < (files->count()); i++){ listItem[i]->setToolTip( (*files)[i] ); ; } vlay->addWidget(listW); QPushButton *makeListB = new QPushButton("Make playlist"); vlay->addWidget(makeListB); ListWidgetItem *tt = new ListWidgetItem(); //Наследный класс QListWidgetItem, где объявляются слоты, в которых и нужно иметь доступ к QListWidget *listW QObject::connect( listW, SIGNAL( currentItemChanged(QListWidgetItem*,QListWidgetItem*) ), tt, SLOT( itemReceive(QListWidgetItem*,QListWidgetItem*) ) ); QObject::connect( makeListB, SIGNAL(clicked()), tt, SLOT(makeList()) ); QWidget *window = new QWidget(); window->setLayout(vlay); window->resize(500,500); window->show(); return a.exec();}