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 )
15 * Destroys the object and frees any allocated resources
17 MainWindow::~MainWindow()
19 // no need to delete child widgets, Qt does it all for us
25 void MainWindow::slotSave()
27 if (filename.isNull())
29 filename = QFileDialog::getSaveFileName( 0, "Adresslista (*.adr)");
30 if (filename.isNull())
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()
74 filename = QFileDialog::getOpenFileName(0, "Adressfiler (*.adr)", this);
77 if ( !f.open( IO_ReadOnly ) )
80 while (CContact::getNum() != 0)
82 delete CContact::getFirst();
89 QString fname = t.readLine();
90 QString lname = t.readLine();
91 QString adr = t.readLine();
92 QString pn = t.readLine();
93 if (fname == "" && lname == "" && lname == "" && pn == "")
95 (void) new CContact(fname, lname, adr, pn);
102 void MainWindow::slotSearch()
104 qWarning( "MainWindow::slotSearch() not yet implemented!" );
107 void slotModify(QListViewItem* lvi)
109 qWarning( "MainWindow::slotModif(QListViewItem*) not yet implemented!" );
112 * This funtion puts all contacts in the listview
114 void MainWindow::updateView()
117 ContactView->clear();
119 CContact* contact = CContact::getFirst();
124 while (contact != '\0')
126 sprintf(s,"%i",i);//.arg(i);
127 (void) new QListViewItem(ContactView, s, contact->lastname(), contact->firstname(), contact->adress(), contact->phoneNumber());
128 contact = contact->getNext();