Exemplo n.º 1
0
AddressBook::~AddressBook()
{
    QFile file(QDir::homePath() + "/addressbook.txt");
    if (file.open(QIODevice::WriteOnly)) {
        QTextStream output(&file);
        output.setCodec("UTF-8");

        for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) {
            ABItem *entry =
                    static_cast<ABItem *>(treeWidget->topLevelItem(i));
            output << entry->contact() << endl;
            output << entry->address() << endl;
            output << entry->phoneNumber() << endl;
            output << endl;
        }
    }
}
Exemplo n.º 2
0
AddressBook::~AddressBook()
{
    QFile file(QDir::homeDirPath() + "/addressbook.txt");
    if (file.open(IO_WriteOnly | IO_Translate)) {
        QTextStream output(&file);
        output.setEncoding(QTextStream::UnicodeUTF8);
        QListViewItemIterator it(listView);
        while (it.current()) {
            ABItem *entry = (ABItem*)it.current();
            output << entry->contact() << endl;
            output << entry->address() << endl;
            output << entry->phoneNumber() << endl;
            output << endl;
            ++it;
        }
    }
}