X-Git-Url: https://ruin.nu/git/?p=adress.git;a=blobdiff_plain;f=mainwindow.cpp;h=4552b94bf9ea299409901b76f8a61cdce61e8346;hp=68afb4353941166251e07141d5a7e1ec3d0c1127;hb=7d9ac6d07bdb73b8ebce6b56cafd6e473b7086b1;hpb=d4423804880ac9c8e20b7772e165f1a936927aa9 diff --git a/mainwindow.cpp b/mainwindow.cpp index 68afb43..4552b94 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,10 +1,4 @@ #include "mainwindow.h" -#include -#include -#include -#include -#include -#include "contact.h" #include /* BRÖÖL @@ -30,13 +24,19 @@ MainWindow::~MainWindow() */ void MainWindow::slotSave() { - if (filename == "") - return; + if (filename.isNull()) + { + filename = QFileDialog::getSaveFileName( 0, "Adresslista (*.adr)"); + if (filename.isNull()) + { + return; + } + } QFile f(filename); if ( !f.open( IO_WriteOnly ) ) - return false; + return; QTextStream t(&f); QString s; @@ -71,14 +71,17 @@ void MainWindow::slotDel() */ void MainWindow::slotLoad() { - slotSave(); + filename = QFileDialog::getOpenFileName(0, "Adressfiler (*.adr)", this); + QFile f(filename); - do + if ( !f.open( IO_ReadOnly ) ) + return; + + while (CContact::getNum() != 0) { - filename(QFileDialog::getOpenFileName(0, "Adressfiler (*.adr)", this)); + delete CContact::getFirst(); } - while ( !f.open( IO_ReadOnly ) ); - + QTextStream t(&f); while (!t.eof())