Example #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    model = new QSqlRelationalTableModel(this);
    qmodel = new QSqlQueryModel(this);
    delegate = new QSqlRelationalDelegate(ui->tableView);
    faculties = new QStringList();
    student = new Student();
    visit = new Visit();
    fillFaculties();
    ui->facultyComboBox->setEditable(true);
    ui->groupComboBox->setEditable(true);

    //ui->tableView->setItemDelegateForColumn(QAbstractItemDelegate);
    //initializeModel(model);
    ui->tableView->setModel(model);
    ui->tableView->setItemDelegate(delegate);

    connect(ui->tablesComboBox, SIGNAL(currentIndexChanged(int)),
            this, SLOT(changeDisplayedTable(int)));
    connect(ui->tablesComboBox, SIGNAL(currentIndexChanged(int)),
            this, SLOT(updateTableView()));
    connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteRowFromTable()));
    connect(ui->tableView, SIGNAL(clicked(QModelIndex)),this, SLOT(setEnabledDeleteButton(QModelIndex)));
    connect(ui->tablesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setDisabledDeleteButton(int)));
    connect(ui->facultyComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fillGroups(QString)));
    displayStudentTable(model);



}
GroupSelectionBox::GroupSelectionBox(QWidget *parent)
	: QListWidget(parent)
{
	setSelectionMode(QAbstractItemView::SingleSelection);

	connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(fillGroups()));

	// Fill with available groups
	fillGroups();
}
Example #3
0
void MainWindow::fillFaculties()
{
    faculties->clear();
    ui->facultyComboBox->clear();
    QSqlQuery query("SELECT name FROM faculty");
    while (query.next())
    {
        QString facultyName = query.value(0).toString();
        faculties->push_back(facultyName);
    }
    ui->facultyComboBox->addItems(*faculties);
    fillGroups(ui->facultyComboBox->itemText(0));
}
GaduAddContactPage::GaduAddContactPage( GaduAccount* owner, QWidget* parent, const char* name )
: AddContactPage( parent, name )
{
	account_	= owner;
	( new QVBoxLayout( this ) )->setAutoAdd( true );
	addUI_	= new GaduAddUI( this );
	connect( addUI_->addEdit_, SIGNAL( textChanged( const QString & ) ), SLOT( slotUinChanged( const QString & ) ) );
	addUI_->addEdit_->setValidChars( "1234567890" );
	addUI_->addEdit_->setText( "" );
	addUI_->groups->setDisabled( TRUE );

	kdDebug(14100) << "filling gropus" << endl;

	fillGroups();
}
GaduAddContactPage::GaduAddContactPage( GaduAccount* owner, QWidget* parent )
    : AddContactPage( parent )
{
    account_	= owner;

    QVBoxLayout* l = new QVBoxLayout( this );
    QWidget* w = new QWidget;
    addUI_	= new Ui::GaduAddUI;
    addUI_->setupUi( w );
    l->addWidget( w );

    connect( addUI_->addEdit_, SIGNAL(textChanged(QString)), SLOT(slotUinChanged(QString)) );
    addUI_->addEdit_->setValidChars( "1234567890" );
    addUI_->addEdit_->setText( "" );
    addUI_->groups->setDisabled( true );
    addUI_->addEdit_->setFocus();

    kDebug(14100) << "filling gropus";

    fillGroups();
}
void ConnectFriendWizard::initializePage(int id)
{
    switch ((Page) id) {
    case Page_Intro:
        ui->textRadioButton->setChecked(true);
        break;
    case Page_Text:
        connect(ui->userCertHelpButton, SIGNAL( clicked()), this, SLOT(showHelpUserCert()));
        connect(ui->userCertIncludeSignaturesButton, SIGNAL(clicked()), this, SLOT(toggleSignatureState()));
        connect(ui->userCertOldFormatButton, SIGNAL(clicked()), this, SLOT(toggleFormatState()));
        connect(ui->userCertCopyButton, SIGNAL(clicked()), this, SLOT(copyCert()));
        connect(ui->userCertSaveButton, SIGNAL(clicked()), this, SLOT(saveCert()));
        connect(ui->userCertMailButton, SIGNAL(clicked()), this, SLOT(runEmailClient()));
        connect(ui->friendCertEdit, SIGNAL(textChanged()), this, SLOT(friendCertChanged()));

        cleanfriendCertTimer = new QTimer(this);
        cleanfriendCertTimer->setSingleShot(true);
        cleanfriendCertTimer->setInterval(1000); // 1 second
        connect(cleanfriendCertTimer, SIGNAL(timeout()), this, SLOT(cleanFriendCert()));

        ui->userCertOldFormatButton->setChecked(true);

        toggleFormatState(false);
        toggleSignatureState(false);
        updateOwnCert();

        cleanFriendCert();

        break;
    case Page_Cert:
        connect(ui->userFileCreateButton, SIGNAL(clicked()), this, SLOT(generateCertificateCalled()));
        connect(ui->friendFileNameOpenButton, SIGNAL(clicked()), this, SLOT(loadFriendCert()));

        ui->friendFileNameEdit->setAcceptFile(true);

        ui->CertificatePage->registerField("friendCertificateFile*", ui->friendFileNameEdit);
        break;
    case Page_Foff:
        ui->userSelectionCB->addItem(tr("Any peer I've not signed"));
        ui->userSelectionCB->addItem(tr("Friends of my friends who already trust me"));
        ui->userSelectionCB->addItem(tr("Signed peers showing as denied"));

        ui->selectedPeersTW->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("")));
        ui->selectedPeersTW->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Peer name")));
        ui->selectedPeersTW->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Also signed by")));
        ui->selectedPeersTW->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("Peer id")));

        connect(ui->makeFriendButton, SIGNAL(clicked()), this, SLOT(signAllSelectedUsers()));
        connect(ui->userSelectionCB, SIGNAL(activated(int)), this, SLOT(updatePeersList(int)));

        updatePeersList(ui->userSelectionCB->currentIndex());

        ui->FofPage->setComplete(false);
        break;
    case Page_Rsid:
        ui->RsidPage->registerField("friendRSID*", ui->friendRsidEdit);
        break;
    case Page_Email:
        ui->EmailPage->registerField("addressEdit*", ui->addressEdit);
        ui->EmailPage->registerField("subjectEdit*", ui->subjectEdit);

        ui->subjectEdit->setText(tr("RetroShare Invitation"));
        ui->inviteTextEdit->setPlainText(GetStartedDialog::GetInviteText());

        break;
    case Page_ErrorMessage:
        break;
    case Page_Conclusion:
    {
        std::cerr << "Conclusion page id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;

        ui->_anonymous_routing_CB_2->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_TURTLE) ;
        ui->_discovery_CB_2        ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DISCOVERY) ;
        ui->_forums_channels_CB_2  ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DISTRIB) ;
        ui->_direct_transfer_CB_2  ->setChecked(peerDetails.service_perm_flags & RS_SERVICE_PERM_DIRECT_DL) ;

        RsPeerDetails tmp_det ;
        bool already_in_keyring = rsPeers->getPeerDetails(peerDetails.gpg_id, tmp_det) ;

        ui->addKeyToKeyring_CB->setChecked(true) ;
        ui->addKeyToKeyring_CB->setEnabled(!already_in_keyring) ;

        if(already_in_keyring)
            ui->addKeyToKeyring_CB->setToolTip(tr("This key is already in your keyring")) ;
        else
            ui->addKeyToKeyring_CB->setToolTip(tr("Check this to add the key to your keyring\nThis might be useful for sending\ndistant messages to this peer\neven if you don't make friends.")) ;

        //set the radio button to sign the GPG key
        if (peerDetails.accept_connection && !peerDetails.ownsign) {
            //gpg key connection is already accepted, don't propose to accept it again
            ui->signGPGCheckBox->setChecked(false);
            ui->acceptNoSignGPGCheckBox->hide();
            ui->acceptNoSignGPGCheckBox->setChecked(false);
        }
        if (!peerDetails.accept_connection && peerDetails.ownsign) {
            //gpg key is already signed, don't propose to sign it again
            ui->acceptNoSignGPGCheckBox->setChecked(true);
            ui->signGPGCheckBox->hide();
            ui->signGPGCheckBox->setChecked(false);
        }
        if (!peerDetails.accept_connection && !peerDetails.ownsign) {
            ui->acceptNoSignGPGCheckBox->setChecked(true);
            ui->signGPGCheckBox->show();
            ui->signGPGCheckBox->setChecked(false);
            ui->acceptNoSignGPGCheckBox->show();
        }
        if (peerDetails.accept_connection && peerDetails.ownsign) {
            ui->acceptNoSignGPGCheckBox->setChecked(false);
            ui->acceptNoSignGPGCheckBox->hide();
            ui->signGPGCheckBox->setChecked(false);
            ui->signGPGCheckBox->hide();
            ui->alreadyRegisteredLabel->show();
        } else {
            ui->alreadyRegisteredLabel->hide();
        }

        QString trustString;
        switch (peerDetails.validLvl) {
        case RS_TRUST_LVL_ULTIMATE:
            trustString = tr("Ultimate");
            break;
        case RS_TRUST_LVL_FULL:
            trustString = tr("Full");
            break;
        case RS_TRUST_LVL_MARGINAL:
            trustString = tr("Marginal");
            break;
        case RS_TRUST_LVL_NEVER:
            trustString = tr("None");
            break;
        default:
            trustString = tr("No Trust");
            break;
        }

        QString ts;
        std::list<std::string>::iterator it;
        for (it = peerDetails.gpgSigners.begin(); it != peerDetails.gpgSigners.end(); ++it) {
            {
                std::string peer_name = rsPeers->getPeerName(*it) ;

                // This is baaaad code. We should handle this kind of errors with proper exceptions.
                // This happens because signers from a unknown key cannt be found in the keyring, including
                // self-signatures.
                //
                if(peer_name == "[Unknown PGP Cert name]" && *it == peerDetails.gpg_id)
                    peer_name = peerDetails.name ;

                ts += QString("%1<%2>\n").arg(QString::fromUtf8(peer_name.c_str()), QString::fromStdString(*it));
            }
        }

        ui->nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str()));
        ui->trustEdit->setText(trustString);
        ui->emailEdit->setText(QString::fromUtf8(peerDetails.email.c_str()));
        QString loc = QString::fromUtf8(peerDetails.location.c_str());
        if (!loc.isEmpty())
        {
            loc += " (";
            loc += QString::fromStdString(peerDetails.id);
            loc += ")";
        }
        else
        {
            if (!peerDetails.id.empty())
            {
                loc += QString::fromStdString(peerDetails.id);
            }
        }

        ui->locationEdit->setText(loc);
        ui->signersEdit->setPlainText(ts);

        fillGroups(this, ui->groupComboBox, groupId);
    }
    break;
    case Page_FriendRequest:
    {
        std::cerr << "Friend request page id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;

        ui->fr_avatar->setFrameType(AvatarWidget::NORMAL_FRAME);
        setPixmap(QWizard::LogoPixmap, QPixmap(":/images/user/user_request48.png"));

        //set the radio button to sign the GPG key
        if (peerDetails.accept_connection && !peerDetails.ownsign) {
            //gpg key connection is already accepted, don't propose to accept it again
            ui->fr_signGPGCheckBox->setChecked(false);
            ui->fr_acceptNoSignGPGCheckBox->hide();
            ui->fr_acceptNoSignGPGCheckBox->setChecked(false);
        }
        if (!peerDetails.accept_connection && peerDetails.ownsign) {
            //gpg key is already signed, don't propose to sign it again
            ui->fr_acceptNoSignGPGCheckBox->setChecked(true);
            ui->fr_signGPGCheckBox->hide();
            ui->fr_signGPGCheckBox->setChecked(false);
        }
        if (!peerDetails.accept_connection && !peerDetails.ownsign) {
            ui->fr_acceptNoSignGPGCheckBox->setChecked(true);
            ui->fr_signGPGCheckBox->show();
            ui->fr_signGPGCheckBox->setChecked(false);
            ui->fr_acceptNoSignGPGCheckBox->show();
        }
        if (peerDetails.accept_connection && peerDetails.ownsign) {
            ui->fr_acceptNoSignGPGCheckBox->setChecked(false);
            ui->fr_acceptNoSignGPGCheckBox->hide();
            ui->fr_signGPGCheckBox->setChecked(false);
            ui->fr_signGPGCheckBox->hide();
        }

        ui->fr_nameEdit->setText(QString::fromUtf8(peerDetails.name.c_str()));
        ui->fr_emailEdit->setText(QString::fromUtf8(peerDetails.email.c_str()));

        QString loc = QString::fromUtf8(peerDetails.location.c_str());
        if (!loc.isEmpty())
        {
            loc += " (";
            loc += QString::fromStdString(peerDetails.id);
            loc += ")";
        }
        else
        {
            if (!peerDetails.id.empty())
            {
                loc += QString::fromStdString(peerDetails.id);
            }
        }

        ui->fr_locationEdit->setText(loc);

        ui->fr_label->setText(tr("You have a friend request from") + " " + QString::fromUtf8(peerDetails.name.c_str()));

        fillGroups(this, ui->fr_groupComboBox, groupId);
    }
    break;
    case Page_FriendRecommendations:
        ui->frec_recommendList->setHeaderText(tr("Recommend friends"));
        ui->frec_recommendList->setModus(FriendSelectionWidget::MODUS_CHECK);
        ui->frec_recommendList->setShowType(FriendSelectionWidget::SHOW_GROUP | FriendSelectionWidget::SHOW_SSL);
        ui->frec_recommendList->start();

        ui->frec_toList->setHeaderText(tr("To"));
        ui->frec_toList->setModus(FriendSelectionWidget::MODUS_CHECK);
        ui->frec_toList->start();

        ui->frec_messageEdit->setText(MessageComposer::recommendMessage());
        break;
    }
}