1 #include "mainwindow.h"
3 #include <qfiledialog.h>
4 #include <qtextstream.h>
11 * Constructs a MainWindow which is a child of 'parent', with the
12 * name 'name' and widget flags set to 'f'
14 MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl )
15 : CMainWindowBase( parent, name, fl )
21 * Destroys the object and frees any allocated resources
23 MainWindow::~MainWindow()
25 // no need to delete child widgets, Qt does it all for us
31 void MainWindow::slotSave()
38 if ( !f.open( IO_WriteOnly ) )
43 CContact* contact = CContact::getFirst();
45 while ( contact != '\0')
47 t << contact->firstname() << "\n";
48 t << contact->lastname() << "\n";
49 t << contact->adress() << "\n";
50 t << contact->phoneNumber() << "\n";
51 contact=contact->getNext();
58 void MainWindow::slotAdd()
60 qWarning( "MainWindow::slotAdd() not yet implemented!" );
65 void MainWindow::slotDel()
67 qWarning( "MainWindow::slotDel() not yet implemented!" );
72 void MainWindow::slotLoad()
78 filename(QFileDialog::getOpenFileName(0, "Adressfiler (*.adr)", this));
80 while ( !f.open( IO_ReadOnly ) );
86 QString fname = t.readLine();
87 QString lname = t.readLine();
88 QString adr = t.readLine();
89 QString pn = t.readLine();
90 if (fname == "" && lname == "" && lname == "" && pn == "")
92 (void) new CContact(fname, lname, adr, pn);
99 void MainWindow::slotSearch()
101 qWarning( "MainWindow::slotSearch() not yet implemented!" );
104 void slotModify(QListViewItem* lvi)
106 qWarning( "MainWindow::slotModif(QListViewItem*) not yet implemented!" );
109 * This funtion puts all contacts in the listview
111 void MainWindow::updateView()
114 ContactView->clear();
116 CContact* contact = CContact::getFirst();
121 while (contact != '\0')
123 sprintf(s,"%i",i);//.arg(i);
124 (void) new QListViewItem(ContactView, s, contact->lastname(), contact->firstname(), contact->adress(), contact->phoneNumber());
125 contact = contact->getNext();