コード例 #1
0
ファイル: kardview.cpp プロジェクト: KDE/kard
void KardView::slotMatch()
{
    kDebug() << "in slot match" << endl;
    tries++;
    
    emit signalChangeStatusbar(i18n("Tries: %1", tries), IDS_TRY);
    
    co=0;

    if (((theme == "colors") && (color[0]==color[1])) || ((theme == "syllables") && (mText[0]==mText[1])) )  {//if same color or same picture
	kardW[0]->slotDisappear(); //hide the 2 same cards
	kardW[1]->slotDisappear();
	count=count+2; //count the cards that are matched by pairs
	if (count==noc)  {
	    slotAll();
	    return;
	}
    }
    else if ((theme == "house" || theme == "opposites" ||  theme == "animals" ||  theme == "food") && (getRef[0]==getRef[1]))  {
	kardW[0]->slotDisappear(); //hide the 2 same cards
	kardW[1]->slotDisappear();
	count=count+2; //count the cards that are matched by pairs
	if (count==noc)  {
	    slotAll();
	    return;
	}
    }
    else {
	kardW[0]->slotShow();
	kardW[1]->slotShow();
    }

    slotConnect();
}
コード例 #2
0
ファイル: bank_deposit.cpp プロジェクト: cwarden/quasar
BankDeposit::BankDeposit(MainWindow* main)
    : QuasarWindow(main, "BankDeposit")
{
    _helpSource = "bank_deposit.html";

    _quasar->db()->lookup(_company);

    QFrame* frame = new QFrame(this);

    QLabel* safeStoreLabel = new QLabel(tr("Safe Store:"), frame);
    _safeStore = new LookupEdit(new StoreLookup(main, this), frame);
    _safeStore->setLength(30);
    safeStoreLabel->setBuddy(_safeStore);

    QLabel* safeIdLabel;
    if (_company.shiftMethod() == Company::BY_STATION) {
	safeIdLabel = new QLabel(tr("Safe Station:"), frame);
	_safeId = new LookupEdit(new StationLookup(main, this), frame);
    } else {
	safeIdLabel = new QLabel(tr("Safe Employee:"), frame);
	_safeId = new LookupEdit(new EmployeeLookup(main, this), frame);
    }
    _safeId->setLength(30);
    safeIdLabel->setBuddy(_safeId);

    _tenders = new Table(frame);
    _tenders->setVScrollBarMode(QScrollView::AlwaysOn);
    _tenders->setLeftMargin(fontMetrics().width("99999"));
    _tenders->setDisplayRows(10);
    connect(_tenders, SIGNAL(cellChanged(int,int,Variant)),
	    SLOT(cellChanged(int,int,Variant)));
    connect(_tenders, SIGNAL(focusNext(bool&,int&,int&,int)),
	    SLOT(focusNext(bool&,int&,int&,int)));
    connect(_tenders, SIGNAL(rowDeleted(int)), SLOT(recalculate()));

    // Add columns
    new TextColumn(_tenders, tr("Tender"), 30);
    new MoneyColumn(_tenders, tr("In Safe"), 10);
    new MoneyColumn(_tenders, tr("Amount"), 10);

    // Add editors
    new NumberEditor(_tenders, 2, new MoneyEdit(_tenders));

    QLabel* totalLabel = new QLabel(tr("Tender Total:"), frame);
    _total = new MoneyEdit(frame);
    _total->setFocusPolicy(NoFocus);

    QFrame* buttons = new QFrame(frame);

    QPushButton* refresh = new QPushButton(tr("&Refresh"), buttons);
    connect(refresh, SIGNAL(clicked()), SLOT(slotRefresh()));

    QPushButton* all = new QPushButton(tr("Deposit All"), buttons);
    connect(all, SIGNAL(clicked()), SLOT(slotAll()));

    QPushButton* ok = new QPushButton(tr("&OK"), buttons);
    connect(ok, SIGNAL(clicked()), SLOT(slotOk()));

    QPushButton* cancel = new QPushButton(tr("&Cancel"), buttons);
    connect(cancel, SIGNAL(clicked()), SLOT(close()));

    ok->setMinimumSize(cancel->sizeHint());
    cancel->setMinimumSize(cancel->sizeHint());

    QGridLayout* buttonsGrid = new QGridLayout(buttons);
    buttonsGrid->setSpacing(6);
    buttonsGrid->setMargin(6);
    buttonsGrid->setColStretch(2, 1);
    buttonsGrid->addWidget(refresh, 0, 0, AlignLeft | AlignVCenter);
    buttonsGrid->addWidget(all, 0, 1, AlignLeft | AlignVCenter);
    buttonsGrid->addWidget(cancel, 0, 2, AlignRight | AlignVCenter);
    buttonsGrid->addWidget(ok, 0, 3, AlignRight | AlignVCenter);

    QGridLayout* grid = new QGridLayout(frame);
    grid->setSpacing(6);
    grid->setMargin(6);
    grid->setRowStretch(2, 1);
    grid->setColStretch(1, 1);
    grid->addWidget(safeStoreLabel, 0, 0);
    grid->addWidget(_safeStore, 0, 1, AlignLeft | AlignVCenter);
    grid->addWidget(safeIdLabel, 1, 0);
    grid->addWidget(_safeId, 1, 1, AlignLeft | AlignVCenter);
    grid->addMultiCellWidget(_tenders, 2, 2, 0, 2);
    grid->addMultiCellWidget(totalLabel, 3, 3, 0, 1, AlignRight|AlignVCenter);
    grid->addWidget(_total, 3, 2, AlignLeft | AlignVCenter);
    grid->addMultiCellWidget(buttons, 4, 4, 0, 2);

    _safeStore->setId(_company.safeStore());
    if (_company.shiftMethod() == Company::BY_STATION)
	_safeId->setId(_company.safeStation());
    else
	_safeId->setId(_company.safeEmployee());

    TenderSelect conditions;
    conditions.activeOnly = true;
    conditions.bankOnly = true;
    _quasar->db()->select(_tenderList, conditions);
    std::sort(_tenderList.begin(), _tenderList.end());

    unsigned int i;
    for (i = 0; i < _tenderList.size(); ++i) {
	VectorRow* row = new VectorRow(_tenders->columns());
	row->setValue(0, _tenderList[i].name());
	row->setValue(1, "");
	row->setValue(2, "");
	_tenders->appendRow(row);
    }
    _tenders->setCurrentCell(0, 2);
    qApp->processEvents();
    _tenders->verticalScrollBar()->setValue(0);
    _date = QDate::currentDate();
    _tenders->setFocus();

    slotRefresh();

    setCentralWidget(frame);
    setCaption(tr("Bank Deposit"));
    finalize();
}