X-Git-Url: https://ruin.nu/git/?p=adress.git;a=blobdiff_plain;f=mainwindow.cpp;h=68afb4353941166251e07141d5a7e1ec3d0c1127;hp=97c8a71dc1c2ef56f02dbd2b96236056d7065318;hb=47556496969ef4c98f36d54c0dd1eac44d2d6caf;hpb=e23c6cb03fe262ee52e7b34803ce0dc0233e42a3 diff --git a/mainwindow.cpp b/mainwindow.cpp index 97c8a71..68afb43 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -14,7 +14,7 @@ MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl ) : CMainWindowBase( parent, name, fl ) { - //connect(LoadButton, SIGNAL(clicked()), SLOT(slotLoad())); + slotLoad(); } /* @@ -30,7 +30,27 @@ MainWindow::~MainWindow() */ void MainWindow::slotSave() { - qWarning( "MainWindow::slotSave() not yet implemented!" ); + if (filename == "") + return; + + QFile f(filename); + + if ( !f.open( IO_WriteOnly ) ) + return false; + + QTextStream t(&f); + QString s; + CContact* contact = CContact::getFirst(); + + while ( contact != '\0') + { + t << contact->firstname() << "\n"; + t << contact->lastname() << "\n"; + t << contact->adress() << "\n"; + t << contact->phoneNumber() << "\n"; + contact=contact->getNext(); + } + f.close(); } /* * public slot @@ -51,12 +71,14 @@ void MainWindow::slotDel() */ void MainWindow::slotLoad() { - QString filename(QFileDialog::getOpenFileName(0, "Adressfiler (*.adr)", this)); - cout << "Funkar"; + slotSave(); QFile f(filename); - if ( !f.open( IO_ReadOnly ) ) - return; - + do + { + filename(QFileDialog::getOpenFileName(0, "Adressfiler (*.adr)", this)); + } + while ( !f.open( IO_ReadOnly ) ); + QTextStream t(&f); while (!t.eof()) @@ -79,7 +101,10 @@ void MainWindow::slotSearch() qWarning( "MainWindow::slotSearch() not yet implemented!" ); } - +void slotModify(QListViewItem* lvi) +{ + qWarning( "MainWindow::slotModif(QListViewItem*) not yet implemented!" ); +} /* * This funtion puts all contacts in the listview */