in >> list;
void artur :: openButton(){ QString fileName = QFileDialog::getOpenFileName(this, tr("Open list"), "", tr("Kitap (*.ktp);;All Files (*)")); if (fileName.isEmpty()) return; else { QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { QMessageBox::information(this, tr("Unable to open file"), file.errorString()); return; } QDataStream in(&file); in.setVersion(QDataStream::Qt_4_5); list.empty(); // очистка существующих контактов //list.clear(); /*QLinkedList<Kitap>::iterator listIterator = list.begin(); QLinkedList<Kitap>::iterator end = list.end(); for( ; listIterator != end; listIterator++) { Kitap currentData = *listIterator; in >> currentData.authorName; in >> currentData.bookName; in >> currentData.year; in >> currentData.publishingHouse; in >> currentData.requestCount; }*/ in >> list; if (list.isEmpty()) { QMessageBox::information(this, tr("No elements in file"), tr("The file you are attempting to open contains no kitap.")); } else { //very very strong QLinkedList<Kitap>::iterator listIterator = list.begin(); QLinkedList<Kitap>::iterator end = list.end(); int j = 0; for( ; listIterator != end; listIterator++) { Kitap currentData = *listIterator; QTableWidgetItem * newda1 = new QTableWidgetItem(currentData.authorName); ui.tableWidget->setItem(j,0,newda1); QTableWidgetItem * newda2 = new QTableWidgetItem(currentData.bookName); ui.tableWidget->setItem(j,1,newda2); QTableWidgetItem * newda3 = new QTableWidgetItem(currentData.year); newda3->setData(Qt::DisplayRole,currentData.year); ui.tableWidget->setItem(j,2,newda3); QTableWidgetItem * newda4 = new QTableWidgetItem(currentData.publishingHouse); ui.tableWidget->setItem(j,3,newda4); QTableWidgetItem * newda5 = new QTableWidgetItem(currentData.requestCount); newda5->setData(Qt::DisplayRole,currentData.requestCount); ui.tableWidget->setItem(j,4,newda5); j++; } // da da } } }
QDataStream & operator<< ( QDataStream & out, const QLinkedList<T> & list )QDataStream & operator>> ( QDataStream & in, QLinkedList<T> & list )