示例#1
0
void MarkerView::deleteMarker()
{
	MarkerItem* item = (MarkerItem*) table->currentItem();
	if (item)
	{
		table->blockSignals(true);
		song->removeMarker(item->marker());
		table->blockSignals(false);
		// Removed p3.3.43 Let Song::removeMarker emit markerChanged(MARKER_REMOVE)
		//  and handle it in MarkerView::markerChanged(int)
		//delete item;
	}
}
示例#2
0
void MarkerView::markerChanged(int val)
{
	//if (val != Song::MARKER_CUR)
	//      return;
	// p3.3.43
	switch (val)
	{
			// MARKER_CUR, MARKER_ADD, MARKER_REMOVE, MARKER_NAME,
			// MARKER_TICK, MARKER_LOCK
		case Song::MARKER_ADD:
		case Song::MARKER_REMOVE:
			updateList();
			break; // Try falling through and let it try to select something. No, let updateList() do it...

		case Song::MARKER_CUR:
		{

			MarkerList* marker = song->marker();
			for (iMarker i = marker->begin(); i != marker->end(); ++i)
			{
				if (i->second.current())
				{
					MarkerItem* item = (MarkerItem*) table->topLevelItem(0);
					while (item)
					{
						if (item->marker() == &i->second)
						{
							table->setCurrentItem(item);
							return;
						}
						item = (MarkerItem*) table->itemBelow(item);
					}
				}
			}
		}
			break;

		default:
			break;
	}
}
示例#3
0
void MarkerView::updateList()
{
	// Added p3.3.43 Manage selected item, due to clearing of table...
	MarkerList* marker = song->marker();
	MarkerItem* selitem = (MarkerItem*) table->currentItem();
	Marker* selm = selitem ? selitem->marker() : 0;
	// p3.3.44 Look for removed markers before added markers...
	if (selitem)
	{
		MarkerItem* mitem = (MarkerItem*) table->topLevelItem(0);
		while (mitem)
		{
			bool found = false;
			for (iMarker i = marker->begin(); i != marker->end(); ++i)
			{
				Marker* m = &i->second;
				if (m == mitem->marker())
				{
					found = true;
					break;
				}
			}
			// Anything removed from the marker list?
			if (!found)
			{
				// If it is the current selected item, it no longer exists. Make the next item be selected.
				if (mitem == selitem)
				{
					MarkerItem* mi = (MarkerItem*) table->itemBelow(selitem);
					if (mi)
					{
						selitem = mi;
						selm = selitem->marker();
					}
				}
			}
			mitem = (MarkerItem*) table->itemBelow(mitem);
		}
	}
	// Look for added markers...
	for (iMarker i = marker->begin(); i != marker->end(); ++i)
	{
		Marker* m = &i->second;
		bool found = false;
		MarkerItem* item = (MarkerItem*) table->topLevelItem(0);
		while (item)
		{
			if (item->marker() == m)
			{
				found = true;
				break;
			}
			item = (MarkerItem*) table->itemBelow(item);
		}
		// Anything new found in the marker list?
		if (!found)
			selm = m;
	}

	// Block signals added. Triggers itemSelectionChanged() causing crash. Tim.
	table->blockSignals(true);
	table->clear();
	table->blockSignals(false);

	//MarkerList* marker = song->marker();
	for (iMarker i = marker->begin(); i != marker->end(); ++i)
	{
		Marker* m = &i->second;

		// Changed p3.3.43
		//QString tick;
		//tick.setNum(i->first);
		//new MarkerItem(table, m);
		MarkerItem* item = new MarkerItem(table, m);
		if (m == selm)
		{
			m->setCurrent(true);
			table->setCurrentItem(item);
		}
		else
		{
			m->setCurrent(false);
		}
	}
}