File: mainwindow.cpp

package info (click to toggle)
libqxt 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,000 kB
  • ctags: 6,583
  • sloc: cpp: 57,582; xml: 296; sh: 256; makefile: 60; php: 14
file content (36 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "mainwindow.h"
#include <QTreeWidgetItem>
#include <QDebug>
MainWindow::MainWindow()
{
    ui.setupUi(this);
    hash.open("contacts.db");
    initTree();
}
void MainWindow::initTree()
{
    ui.treeWidget->clear();
    QxtBdbHashIterator<QString,Contact> it=hash.begin();
    do
    {
        Contact c=it.value();
        QTreeWidgetItem *item=new QTreeWidgetItem(ui.treeWidget);
        item->setText(0,c.name);
        item->setText(1,c.phone);
        item->setText(2,c.address);

    }
    while((++it).isValid());
}


void MainWindow::on_addButton_clicked()
{
    Contact c;
    c.name=ui.inputName->text();
    c.phone=ui.inputPhone->text();
    c.address=ui.inputAddress->text();
    qDebug()<<hash.insert(c.name,c);
    initTree();
}