1 #include "mainwindow.h"
5 * Constructs a MainWindow which is a child of 'parent', with the
6 * name 'name' and widget flags set to 'f'
8 MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl )
9 : CMainWindowBase( parent, name, fl )
14 * Destroys the object and frees any allocated resources
16 MainWindow::~MainWindow()
18 // no need to delete child widgets, Qt does it all for us
24 void MainWindow::slotSave()
26 if (filename.isNull())
28 filename = QFileDialog::getSaveFileName( 0, "Adresslista (*.adr)");
29 if (filename.isNull())
37 if ( !f.open( IO_WriteOnly ) )
42 CContact* contact = CContact::getFirst();
44 while ( contact != '\0')
46 t << contact->firstname() << "\n";
47 t << contact->lastname() << "\n";
48 t << contact->adress() << "\n";
49 t << contact->phoneNumber() << "\n";
50 contact=contact->getNext();
57 void MainWindow::slotAdd()
59 qWarning( "MainWindow::slotAdd() not yet implemented!" );
64 void MainWindow::slotDel()
66 qWarning( "MainWindow::slotDel() not yet implemented!" );
71 void MainWindow::slotLoad()
73 filename = QFileDialog::getOpenFileName(0, "Adressfiler (*.adr)", this);
76 if ( !f.open( IO_ReadOnly ) )
79 while (CContact::getNum() != 0)
81 delete CContact::getFirst();
88 QString fname = t.readLine();
89 QString lname = t.readLine();
90 QString adr = t.readLine();
91 QString pn = t.readLine();
92 if (fname == "" && lname == "" && lname == "" && pn == "")
94 (void) new CContact(fname, lname, adr, pn);
101 void MainWindow::slotSearch()
103 qWarning( "MainWindow::slotSearch() not yet implemented!" );
106 void MainWindow::slotModify(QListViewItem* lvi)
108 qWarning( "MainWindow::slotModif(QListViewItem*) not yet implemented!" );
111 * This funtion puts all contacts in the listview
113 void MainWindow::updateView()
116 ContactView->clear();
118 CContact* contact = CContact::getFirst();
123 while (contact != '\0')
125 sprintf(s,"%i",i);//.arg(i);
126 (void) new QListViewItem(ContactView, s, contact->lastname(), contact->firstname(), contact->adress(), contact->phoneNumber());
127 contact = contact->getNext();