示例#1
0
void docItem::viewItems(){
    for (int a = ui.tableWidget_docs->rowCount(); a >=0; a--){
        ui.tableWidget_docs->removeRow(a);
    }
    QSqlQuery query(QString("select book_item.book, books.isbn, books.title, publish.name, books.year, book_item.identifier "
                    "from book_item, doc_item, books, publish "
                    "where books.id = book_item.book and book_item.id = doc_item.book_item "
                            "and publish.id = books.pub and doc_item.doc = \'%1\' ").arg(doc));
    int row = 0;
    while (query.next()){
        ui.tableWidget_docs->insertRow(row);
        for (int col = 0; col < 2; col++){
            QTableWidgetItem *item = new QTableWidgetItem(query.value(col+1).toString());
            ui.tableWidget_docs->setItem(row, col, item);
        }
        for (int col =3; col < 6; col++){
            QTableWidgetItem *item = new QTableWidgetItem(query.value(col).toString());
            ui.tableWidget_docs->setItem(row, col, item);
        }
        //******
        QSqlQuery queryAuth(QString("select authors.name_k from authors, book_auth "
                                    "where book_auth.auth = authors.id and book_auth.book = \'%1\' ").arg(query.value(0).toString()));
        QString authBook;
        while (queryAuth.next()){
            authBook.append(QString("%1 ").arg(queryAuth.value(0).toString()));
        }
        QTableWidgetItem *itemAuth = new QTableWidgetItem(authBook);
        ui.tableWidget_docs->setItem(row, 2, itemAuth);
        //******
        row++;
    }
}
示例#2
0
    void simpleTest()
    {
        KPasswdServer server(this);
        server.setWalletDisabled(true);

        // Check that processRequest doesn't crash when it has nothing to do
        server.processRequest();

        KIO::AuthInfo info;
        info.url = QUrl(QStringLiteral("http://www.example.com"));

        // Make a check for that host, should say "not found"
        QVERIFY(noCheckAuth(server, info));

        // Now add auth to the cache
        const qlonglong windowId = 42;
        KIO::AuthInfo realInfo = info;
        realInfo.username = QStringLiteral("toto"); // you can see I'm french
        realInfo.password = QStringLiteral("foobar");
        server.addAuthInfo(realInfo, windowId); // seqnr=2

        // queryAuth without the ability to prompt, will just return info unmodified
        KIO::AuthInfo resultInfo;
        queryAuth(server, info, resultInfo);
        QCOMPARE(resultInfo.url, info.url);
        QCOMPARE(resultInfo.username, QString());
        QCOMPARE(resultInfo.password, QString());
        QCOMPARE(resultInfo.isModified(), false);

        // Check that checkAuth finds it
        QVERIFY(successCheckAuth(server, info, realInfo));

        // Now remove auth
        server.removeAuthInfo(info.url.host(), info.url.scheme(), info.username);
        // Check we can't find that auth anymore
        QVERIFY(noCheckAuth(server, info));
    }