예제 #1
0
//virtual 
S32 LLFlatListView::notify(const LLSD& info)
{
	if(info.has("action"))
	{
		std::string str_action = info["action"];
		if(str_action == "select_first")
		{
			setFocus(true);
			selectFirstItem();
			return 1;
		}
		else if(str_action == "select_last")
		{
			setFocus(true);
			selectLastItem();
			return 1;
		}
	}
	else if (info.has("rearrange"))
	{
		rearrangeItems();
		notifyParentItemsRectChanged();
		return 1;
	}
	return 0;
}
예제 #2
0
void LLComboBox::initFromParams(const LLComboBox::Params& p)
{
	LLUICtrl::initFromParams(p);

	if (!acceptsTextInput() && mLabel.empty())
	{
		selectFirstItem();
	}
}
예제 #3
0
// add item "name" with attached generic data
LLScrollListItem* LLComboBox::add(const std::string& name, LLSD value, EAddPosition pos, BOOL enabled )
{
	LLScrollListItem* item = mList->addSimpleElement(name, pos, value);
	item->setEnabled(enabled);
	if (!mAllowTextEntry && mLabel.empty())
	{
		selectFirstItem();
	}
	return item;
}
예제 #4
0
void PupilArchiveListTreeWidget::delCurrentArchive()
{
    QList<QTreeWidgetItem *> selectedItemList = this->selectedItems();
    QString selectedItemIdString;
    if(!selectedItemList.empty()) {
        selectedItemIdString = selectedItemList.first()->data(0,Qt::UserRole).toString();
    }

    int ret = QMessageBox::warning(this, QString::fromUtf8(tr("Qupil - Archiveintrag löschen").toStdString().c_str()),
                                   QString::fromUtf8(tr("Möchten Sie den Archiveintrag \"%1\" wirklich löschen?").arg(selectedItemList.first()->data(0,Qt::DisplayRole).toString().toUtf8().constData()).toStdString().c_str()),
                                   QMessageBox::Ok | QMessageBox::Cancel);
    if(ret == QMessageBox::Ok) {
        QSqlQuery delArchiveQuery("DELETE FROM pupilarchive WHERE pupilid = "+selectedItemIdString, *myW->getMyDb()->getMyPupilDb());
        if (delArchiveQuery.lastError().isValid()) qDebug() << "DB Error: 89 - " << delArchiveQuery.lastError();

        refreshPupilArchiveList();
        selectFirstItem();

        //refresh menu
        myW->rightTabsChanged(2);
    }
}
예제 #5
0
void RecitalTabs::refreshPieces()
{
    QList<QTreeWidgetItem *> selectedItemList = ui->treeWidget->selectedItems();
    QString selectedItemIdString;
    if(!selectedItemList.empty()) {
        selectedItemIdString = selectedItemList.first()->data(0,Qt::UserRole).toString();
    }

    ui->treeWidget->clear();
    QStringList groupAlreadyDone;
    QSqlQuery query("SELECT l.lessonid, l.lessonname, pc.composer, p.title, p.genre, p.duration, pu.instrumenttype, CASE WHEN date(pu.birthday, '+' || (strftime('%Y', 'now') - strftime('%Y', pu.birthday)) || ' years') <= date('now') THEN strftime('%Y', 'now') - strftime('%Y', pu.birthday) ELSE strftime('%Y', 'now') - strftime('%Y', pu.birthday) -1 END AS age, pu.forename, pu.surname, par.parid, par.sorting FROM pupil pu, piece p, lesson l, pupilatlesson pal, piececomposer pc, pieceatrecital par WHERE pal.palid = p.palid AND p.piececomposerid=pc.piececomposerid AND pal.lessonid = l.lessonid AND pal.pupilid= pu.pupilid AND pal.stopdate > date('now') AND par.pieceid=p.pieceid AND par.ifexternalpiece=0 AND par.recitalid="+QString::number(recitalId)+" ORDER by par.sorting ASC, age ASC");
    if (query.lastError().isValid()) {
        qDebug() << "DB Error: 196 - " << query.lastError();
    }
    while(query.next()) {
        //Prüfen ob der Eintrag ein gemeinsamer Gruppeneintrag ist.
        QSqlQuery query1("SELECT count(*) FROM piece p, lesson l, pupilatlesson pal WHERE pal.palid = p.palid AND pal.lessonid = l.lessonid AND pal.stopdate > date('now') AND l.lessonid="+query.value(0).toString()+" AND p.title='"+query.value(3).toString()+"'");
        if (query1.lastError().isValid()) {
            qDebug() << "DB Error: 197 - " << query1.lastError();
        }
        query1.next();
        if(query1.value(0).toInt() > 1) {

            QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
            item->setData(1, Qt::DisplayRole, query.value(2).toString());
            item->setData(0, Qt::DisplayRole, query.value(11).toString());
            item->setData(0, Qt::UserRole, query.value(10).toString()); //set hidden parid for database actions
            item->setData(2, Qt::DisplayRole, query.value(3).toString());
            item->setData(3, Qt::DisplayRole, query.value(4).toString());
            item->setData(4, Qt::DisplayRole, query.value(5).toString()+" Min.");
//                                item->setData(4, Qt::DisplayRole, query.value(5).toString());

            QSqlQuery query2("SELECT pu.forename, pu.surname, pu.instrumenttype, CASE WHEN date(pu.birthday, '+' || (strftime('%Y', 'now') - strftime('%Y', pu.birthday)) || ' years') <= date('now') THEN strftime('%Y', 'now') - strftime('%Y', pu.birthday) ELSE strftime('%Y', 'now') - strftime('%Y', pu.birthday) -1 END AS age FROM pupil pu, pupilatlesson pal WHERE pal.pupilid= pu.pupilid AND pal.lessonid = "+query.value(0).toString()+" AND pal.stopdate > date('now') ORDER by age ASC");
            if (query2.lastError().isValid()) {
                qDebug() << "DB Error: 198 - " << query2.lastError();
            }
            QString pupilsString;
            while(query2.next()) {
                pupilsString += query2.value(1).toString()+", "+query2.value(0).toString()+" ("+query2.value(3).toString()+") - "+query2.value(2).toString()+"\n";
            }
            pupilsString = pupilsString.remove(pupilsString.length()-1,1); //remove last <br>
            item->setData(5, Qt::DisplayRole, pupilsString);

            ui->treeWidget->resizeColumnToContents(1);
            ui->treeWidget->resizeColumnToContents(2);
            ui->treeWidget->resizeColumnToContents(3);
            ui->treeWidget->resizeColumnToContents(4);
            ui->treeWidget->resizeColumnToContents(5);

        } else {
//          Einzeleintrag
            QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
            item->setData(0, Qt::DisplayRole, query.value(11).toString());
            item->setData(0, Qt::UserRole, query.value(10).toString()); //set hidden parid for database actions
            item->setData(1, Qt::DisplayRole, query.value(2).toString());
            item->setData(2, Qt::DisplayRole, query.value(3).toString());
            item->setData(3, Qt::DisplayRole, query.value(4).toString());
            item->setData(4, Qt::DisplayRole, query.value(5).toString()+" Min.");
            item->setData(5, Qt::DisplayRole, query.value(9).toString()+", "+query.value(8).toString()+" ("+query.value(7).toString()+") - "+query.value(6).toString());

            ui->treeWidget->resizeColumnToContents(1);
            ui->treeWidget->resizeColumnToContents(2);
            ui->treeWidget->resizeColumnToContents(3);
            ui->treeWidget->resizeColumnToContents(4);
            ui->treeWidget->resizeColumnToContents(5);
        }
    }

    QSqlQuery query3("SELECT par.parid, par.sorting, erp.composer, erp.title, erp.genre, erp.duration, erp.musician FROM externalrecitalpiece erp, pieceatrecital par WHERE par.pieceid=erp.erpid AND par.ifexternalpiece=1 AND par.recitalid="+QString::number(recitalId)+" ORDER by par.sorting ASC");
    if (query3.lastError().isValid()) {
        qDebug() << "DB Error: 196 - " << query3.lastError();
    }
    while(query3.next()) {

        QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
        item->setData(0, Qt::DisplayRole, query3.value(1).toString());
        item->setData(0, Qt::UserRole, query3.value(0).toString()); //set hidden parid for database actions
        item->setData(1, Qt::DisplayRole, query3.value(2).toString());
        item->setData(2, Qt::DisplayRole, query3.value(3).toString());
        item->setData(3, Qt::DisplayRole, query3.value(4).toString());
        item->setData(4, Qt::DisplayRole, query3.value(5).toString()+" Min.");
        item->setData(5, Qt::DisplayRole, query3.value(6).toString());

        ui->treeWidget->resizeColumnToContents(1);
        ui->treeWidget->resizeColumnToContents(2);
        ui->treeWidget->resizeColumnToContents(3);
        ui->treeWidget->resizeColumnToContents(4);
        ui->treeWidget->resizeColumnToContents(5);
    }

    ui->treeWidget->sortByColumn(0, Qt::AscendingOrder);

    //calculate completeDuration
    completePiecesDuration = 0;
    int piecesCounter = 0;
    QTreeWidgetItemIterator it(ui->treeWidget);
    while (*it) {
        completePiecesDuration += (*it)->data(4, Qt::DisplayRole).toString().remove(QRegExp("[^0-9]")).toInt();
        piecesCounter++;
        ++it;
    }

    if(piecesCounter) {
        completeAllInAllDuration = myConfig->readConfigInt("RecitalModerationDuration")+completePiecesDuration+(piecesCounter*myConfig->readConfigInt("RecitalBetweenPiecesDuration"));
    } else {
        completeAllInAllDuration = 0;
    }


    ui->label_completeDuration->setText("Reine Spielzeit: "+QString("<span style='color: blue;'>%1 Min.</span>").arg(completePiecesDuration)+ " - Gesch&auml;tzte Gesamtdauer: "+QString("<span style='color: blue;'>%1 Min.</span>").arg(completeAllInAllDuration));

    myCM->refreshPieceActions(ui->treeWidget->topLevelItemCount());

    //set selection
    if(ui->treeWidget->topLevelItemCount()) {
        int i;
        bool found = false;
        for (i=0; i<ui->treeWidget->topLevelItemCount(); i++) {

            QTreeWidgetItem *item = ui->treeWidget->topLevelItem(i);
            if(item->data(0, Qt::UserRole).toString() == selectedItemIdString) {
                ui->treeWidget->setCurrentItem(item);
                found = true;
                break;
            }
        }
        if(!found) {
            selectFirstItem();
        }
    }

}
예제 #6
0
// virtual
bool LLFlatListView::selectNextItemPair(bool is_up_direction, bool reset_selection)
{
	// No items - no actions!
	if ( 0 == size() )
		return false;

	if (!mIsConsecutiveSelection)
	{
		// Leave only one item selected if list has not consecutive selection
		if (mSelectedItemPairs.size() && !reset_selection)
		{
			item_pair_t* cur_sel_pair = mSelectedItemPairs.back();
			resetSelection();
			selectItemPair (cur_sel_pair, true);
		}
	}

	if ( mSelectedItemPairs.size() )
	{
		item_pair_t* to_sel_pair = NULL;
		item_pair_t* cur_sel_pair = NULL;

		// Take the last selected pair
		cur_sel_pair = mSelectedItemPairs.back();
		// Bases on given direction choose next item to select
		if ( is_up_direction )
		{
			// Find current selected item position in mItemPairs list
			pairs_list_t::reverse_iterator sel_it = std::find(mItemPairs.rbegin(), mItemPairs.rend(), cur_sel_pair);

			for (;++sel_it != mItemPairs.rend();)
			{
				// skip invisible items
				if ( (*sel_it)->first->getVisible() )
				{
					to_sel_pair = *sel_it;
					break;
				}
			}
		}
		else
		{
			// Find current selected item position in mItemPairs list
			pairs_list_t::iterator sel_it = std::find(mItemPairs.begin(), mItemPairs.end(), cur_sel_pair);

			for (;++sel_it != mItemPairs.end();)
			{
				// skip invisible items
				if ( (*sel_it)->first->getVisible() )
				{
					to_sel_pair = *sel_it;
					break;
				}
			}
		}

		if ( to_sel_pair )
		{
			bool select = true;
			if ( reset_selection )
			{
				// Reset current selection if we were asked about it
				resetSelection();
			}
			else
			{
				// If item already selected and no reset request than we should deselect last selected item.
				select = (mSelectedItemPairs.end() == std::find(mSelectedItemPairs.begin(), mSelectedItemPairs.end(), to_sel_pair));
			}
			// Select/Deselect next item
			selectItemPair(select ? to_sel_pair : cur_sel_pair, select);
			// Mark it as consecutive selection
			mIsConsecutiveSelection = true;
			return true;
		}
	}
	else
	{
		// If there weren't selected items then choose the first one bases on given direction
		// Force selection to first item
		if (is_up_direction)
			selectLastItem();
		else
			selectFirstItem();
		// Mark it as consecutive selection
		mIsConsecutiveSelection = true;
		return true;
	}

	return false;
}