#include "my.h"
#include <QFile>
#include <QTextStream>
#include <QMessageBox>
#include "all.h"
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
}
void MyWidget::showItem(){
setFixedSize(700, 500);
QPixmap pixmap("/home/elaheh/file_joda/1.bmp");
QVBoxLayout *layout = new QVBoxLayout;
int size = items.size();
count =1;
for (int i =0 ; i < size ; i++ )
{
if (items[i]->checkFormat()==2)
{
cout << "1" << items[i]->checkName() << endl;
QPushButton *tempP = new QPushButton(pixmap,"pic", this);
tempP->setFont(QFont("Times", 8, QFont::Bold));
cout << "address:" << items[i]->checkAddress() << endl;
connect(tempP, SIGNAL(clicked()),this, SLOT(text(items[i].checkAddress())));
layout->addWidget(tempP);
pic.push_back(tempP);
}
if (items[i]->checkFormat() == 1)
{
cout << "2" <<items[i]->checkName() << endl;
QPushButton *tempT = new QPushButton(pixmap,"txt", this);
tempT->setFont(QFont("Times", 8, QFont::Bold));
connect(tempT, SIGNAL(clicked()),this, SLOT(run(items[i].checkAddress())));
layout->addWidget(tempT);
pic.push_back(tempT);
}
if (items[i]->checkFormat() == 0)
{
cout << "3" << items[i]->checkName() << endl;
QPushButton *tempF = new QPushButton(pixmap,"folder", this);
tempF->setFont(QFont("Times", 8, QFont::Bold));
layout->addWidget(tempF);
fold.push_back(tempF);
cout << "salam" << endl;
connect(fold[i], SIGNAL(clicked()),this, SLOT(showFolder(fold[i])));
cout << "sare kar" <<endl;
count++;
}
setLayout(layout);
}
}
void MyWidget::run(string strE){
QString strQE;
strQE = QString::fromStdString(strE);
QPixmap pixmap(strQE);
l.setPixmap(pixmap);
l.show();
}
void MyWidget::text(string strE){
QString strQE;
strQE = QString::fromStdString(strE);
QFile file(strQE);
file.open(QFile::ReadWrite);
QTextStream st(&file);
QString str = st.readAll();
l.setText(str);
l.show();
}
void MyWidget::showFolder(item*){
MyWidget* newItem=new MyWidget;
cout << "chandomin:" << count << endl;
newItem->items =items[count-1]->checkItems();
cout << "chandomin:" << count-1 << endl;
newItem->showItem();
newItem->show();
}
در واقع مي خوام وقتي از connect استفاده مي كنم و ميره تو showFolder بدونه كه چه وكتوري از ايتم ها رو نمايش بده !