void ListLog::setOpMode(RDAirPlayConf::OpMode mode)
{
    if(mode==list_op_mode) {
        return;
    }
    list_op_mode=mode;
    UpdateTimes();
}
void ListLog::setTimeMode(RDAirPlayConf::TimeMode mode)
{
    if(mode==list_time_mode) {
        return;
    }
    list_hour_selector->setTimeMode(mode);
    list_time_mode=mode;
    UpdateTimes();
    RefreshList();
}
void ListLog::logRemovedData(int line,int num,bool moving)
{
    int count;
    RDListViewItem *item=GetItem(line+num);
    while(item!=NULL) {
        if((count=item->text(15).toInt())>=0) {
            item->setText(15,QString().sprintf("%d",count-num));
        }
        item=(RDListViewItem *)item->nextSibling();
    }
    for(int i=line; i<(line+num); i++) {
        delete GetItem(i);
    }
    if(!moving) {
        UpdateTimes(line,num);
    }
}
void ListLog::logStoppedData(int line)
{
    setStatus(line,RDLogLine::Finished);
    UpdateTimes();
}
void ListLog::logPausedData(int line)
{
    setStatus(line,RDLogLine::Paused);
    UpdateTimes();
}
void ListLog::logPlayedData(int line)
{
    setStatus(line,RDLogLine::Playing);
    UpdateTimes();
}
void ListLog::logReloadedData()
{
    RefreshList();
    UpdateTimes();
    selectionChangedData();
}
ListLog::ListLog(LogPlay *log,RDCae *cae,int id,bool allow_pause,
                 QWidget *parent)
    : QWidget(parent)
{
    list_id=id;
    list_log=log;
    list_cae=cae;
    list_op_mode=RDAirPlayConf::LiveAssist;
    list_action_mode=RDAirPlayConf::Normal;
    list_time_mode=RDAirPlayConf::TwentyFourHour;
    list_scroll=true;
    list_pause_allowed=allow_pause;
    list_playbutton_mode=ListLog::ButtonDisabled;
    list_audition_head_playing=false;
    list_audition_tail_playing=false;

    //
    // Create Fonts
    //
    QFont list_font=QFont("Helvetica",12,QFont::Normal);
    list_font.setPixelSize(12);
    setFont(list_font);
    QFont label_font=QFont("Helvetica",12,QFont::Bold);
    label_font.setPixelSize(12);
    QFont font=QFont("Helvetica",14,QFont::Bold);
    font.setPixelSize(14);
    QFont name_font=QFont("Helvetica",18,QFont::Bold);
    name_font.setPixelSize(18);

    //
    // Create Icons
    //
    list_playout_map=new QPixmap(play_xpm);
    list_macro_map=new QPixmap(rml5_xpm);
    list_chain_map=new QPixmap(chain_xpm);
    list_track_cart_map=new QPixmap(track_cart_xpm);
    list_mic16_map=new QPixmap(mic16_xpm);
    list_notemarker_map=new QPixmap(notemarker_xpm);
    list_traffic_map=new QPixmap(traffic_xpm);
    list_music_map=new QPixmap(music_xpm);

    //
    // Create Palettes
    //
    QColor system_button_text_color = palette().active().buttonText();
    QColor system_button_color = palette().active().button();
    QColor system_mid_color = colorGroup().mid();
    list_from_color=
        QPalette(QColor(BUTTON_FROM_BACKGROUND_COLOR),QColor(system_mid_color));
    list_from_color.
    setColor(QColorGroup::ButtonText,QColor(BUTTON_FROM_TEXT_COLOR));

    list_to_color=
        QPalette(QColor(BUTTON_TO_BACKGROUND_COLOR),QColor(system_mid_color));
    list_to_color.
    setColor(QColorGroup::ButtonText,QColor(BUTTON_TO_TEXT_COLOR));
    list_list_to_color=palette();
    list_list_to_color.setColor(QPalette::Active,QColorGroup::Highlight,
                                BUTTON_TO_BACKGROUND_COLOR);
    list_list_to_color.setColor(QPalette::Active,QColorGroup::HighlightedText,
                                BUTTON_TO_TEXT_COLOR);
    list_list_to_color.setColor(QPalette::Inactive,QColorGroup::Highlight,
                                BUTTON_TO_BACKGROUND_COLOR);
    list_list_to_color.setColor(QPalette::Inactive,QColorGroup::HighlightedText,
                                BUTTON_TO_TEXT_COLOR);
    list_list_from_color=palette();
    list_list_from_color.setColor(QPalette::Active,QColorGroup::Highlight,
                                  BUTTON_FROM_BACKGROUND_COLOR);
    list_list_from_color.setColor(QPalette::Active,QColorGroup::HighlightedText,
                                  BUTTON_FROM_TEXT_COLOR);
    list_list_from_color.setColor(QPalette::Inactive,QColorGroup::Highlight,
                                  BUTTON_FROM_BACKGROUND_COLOR);
    list_list_from_color.
    setColor(QPalette::Inactive,QColorGroup::HighlightedText,
             BUTTON_FROM_TEXT_COLOR);
    list_scroll_color[0]=palette();
    list_scroll_color[0].setColor(QPalette::Active,QColorGroup::ButtonText,
                                  BUTTON_LOG_ACTIVE_TEXT_COLOR);
    list_scroll_color[0].setColor(QPalette::Active,QColorGroup::Button,
                                  BUTTON_LOG_ACTIVE_BACKGROUND_COLOR);
    list_scroll_color[0].setColor(QPalette::Active,QColorGroup::Background,
                                  system_mid_color);
    list_scroll_color[0].setColor(QPalette::Inactive,QColorGroup::ButtonText,
                                  BUTTON_LOG_ACTIVE_TEXT_COLOR);
    list_scroll_color[0].setColor(QPalette::Inactive,QColorGroup::Button,
                                  BUTTON_LOG_ACTIVE_BACKGROUND_COLOR);
    list_scroll_color[0].setColor(QPalette::Inactive,QColorGroup::Background,
                                  system_mid_color);
    list_scroll_color[1]=palette();
    list_scroll_color[1].setColor(QPalette::Active,QColorGroup::ButtonText,
                                  system_button_text_color);
    list_scroll_color[1].setColor(QPalette::Active,QColorGroup::Button,
                                  system_button_color);
    list_scroll_color[1].setColor(QPalette::Active,QColorGroup::Background,
                                  system_mid_color);
    list_scroll_color[1].setColor(QPalette::Inactive,QColorGroup::ButtonText,
                                  system_button_text_color);
    list_scroll_color[1].setColor(QPalette::Inactive,QColorGroup::Button,
                                  system_button_color);
    list_scroll_color[1].setColor(QPalette::Inactive,QColorGroup::Background,
                                  system_mid_color);

    //
    // Hour Selector
    //
    list_hour_selector=new HourSelector(this);
    list_hour_selector->setTimeMode(list_time_mode);
    connect(list_hour_selector,SIGNAL(hourSelected(int)),
            this,SLOT(selectHour(int)));
    list_hour_selector->hide();

    //
    // Log List
    //
    list_log_list=new LibListView(this);
    list_log_list->setFont(list_font);
    int y=0;
    int h=sizeHint().height()-60;
    if(rda->airplayConf()->showCounters()) {
        h-=60;
    }
    if(rda->airplayConf()->hourSelectorEnabled()) {
        y+=80;
        h-=80;
        list_hour_selector->setGeometry(0,0,sizeHint().width(),80);
        list_hour_selector->show();
    }
    list_log_list->setGeometry(0,y,sizeHint().width(),h);
    list_log_list->setAllColumnsShowFocus(true);
    list_log_list->setSelectionMode(QListView::Extended);
    list_log_list->setItemMargin(5);
    list_log_list->addColumn("");
    list_log_list->setColumnAlignment(0,Qt::AlignHCenter);
    list_log_list->addColumn(tr("EST TIME"));
    list_log_list->setColumnAlignment(1,Qt::AlignRight);
    list_log_list->addColumn(tr("LEN"));
    list_log_list->setColumnAlignment(2,Qt::AlignRight);
    list_log_list->addColumn(tr("TRANS"));
    list_log_list->setColumnAlignment(3,Qt::AlignHCenter);
    list_log_list->addColumn(tr("CART"));
    list_log_list->setColumnAlignment(4,Qt::AlignHCenter);
    list_log_list->addColumn(tr("TITLE"));
    list_log_list->setColumnAlignment(5,Qt::AlignLeft);
    list_log_list->addColumn(tr("ARTIST"));
    list_log_list->setColumnAlignment(6,Qt::AlignLeft);
    list_log_list->addColumn(tr("GROUP"));
    list_log_list->setColumnAlignment(7,Qt::AlignHCenter);
    list_log_list->addColumn(tr("TIME"));
    list_log_list->setColumnAlignment(8,Qt::AlignHCenter);
    list_log_list->addColumn(tr("ALBUM"));
    list_log_list->setColumnAlignment(9,Qt::AlignLeft);
    list_log_list->addColumn(tr("LABEL"));
    list_log_list->setColumnAlignment(10,Qt::AlignLeft);
    list_log_list->addColumn(tr("CLIENT"));
    list_log_list->setColumnAlignment(11,Qt::AlignLeft);
    list_log_list->addColumn(tr("AGENCY"));
    list_log_list->setColumnAlignment(12,Qt::AlignLeft);
    list_log_list->addColumn(tr("MARKER"));
    list_log_list->setColumnAlignment(13,Qt::AlignHCenter);
    list_log_list->addColumn(tr("LINE ID"));
    list_log_list->setColumnAlignment(14,Qt::AlignHCenter);
    list_log_list->addColumn(tr("COUNT"));
    list_log_list->setColumnAlignment(15,Qt::AlignHCenter);
    list_log_list->addColumn(tr("STATUS"));
    list_log_list->setColumnAlignment(16,Qt::AlignHCenter);
    list_log_list->setHardSortColumn(15);
    list_log_list->setFocusPolicy(QWidget::NoFocus);
    connect(list_log_list,SIGNAL(selectionChanged()),
            this,SLOT(selectionChangedData()));
    connect(list_log_list,
            SIGNAL(doubleClicked(QListViewItem *,const QPoint &,int)),
            this,
            SLOT(doubleclickedData(QListViewItem *,const QPoint &,int)));
    connect(list_log_list,SIGNAL(cartDropped(int,RDLogLine *)),
            this,SLOT(cartDroppedData(int,RDLogLine *)));

    //
    // List Logs Dialog
    //
    list_logs_dialog=new ListLogs(list_log,this);

    //
    // Time Counter Section
    //
    QLabel *label=new QLabel(tr("Run Length"),this);
    label->setGeometry(372,sizeHint().height()-120,75,20);
    label->setFont(label_font);
    label->setAlignment(AlignCenter);
    label->setBackgroundColor(QColor(system_mid_color));
    if(!rda->airplayConf()->showCounters()) {
        label->hide();
    }

    //
    // Stop Time Counter
    //
    list_stoptime_edit=new QLineEdit(this);
    list_stoptime_edit->setGeometry(407,sizeHint().height()-100,70,18);
    list_stoptime_label=new QLabel(list_stoptime_edit,tr("Next Stop:"),this);
    list_stoptime_label->setGeometry(337,sizeHint().height()-100,65,18);
    list_stoptime_label->setFont(label_font);
    list_stoptime_label->setAlignment(AlignRight|AlignVCenter);
    list_stoptime_label->setBackgroundColor(QColor(system_mid_color));
    if(!rda->airplayConf()->showCounters()) {
        list_stoptime_edit->hide();
        list_stoptime_label->hide();
    }

    //
    // End Time Counter
    //
    list_endtime_edit=new QLineEdit(this);
    list_endtime_edit->setGeometry(407,sizeHint().height()-80,70,18);
    list_endtime_label=new QLabel(list_endtime_edit,tr("Log End:"),this);
    list_endtime_label->setGeometry(337,sizeHint().height()-80,65,18);
    list_endtime_label->setFont(label_font);
    list_endtime_label->setAlignment(AlignRight|AlignVCenter);
    list_endtime_label->setBackgroundColor(QColor(system_mid_color));
    if(!rda->airplayConf()->showCounters()) {
        list_endtime_edit->hide();
        list_endtime_label->hide();
    }

    //
    // Select Button
    //
    list_take_button=new QPushButton(this);
    list_take_button->setGeometry(10,sizeHint().height()-55,80,50);
    list_take_button->setFont(font);
    list_take_button->setPalette(QPalette(QColor(system_button_color),QColor(system_mid_color)));
    list_take_button->setText(tr("Select"));
    list_take_button->setFocusPolicy(QWidget::NoFocus);
    connect(list_take_button,SIGNAL(clicked()),this,SLOT(takeButtonData()));
    list_take_button->hide();

    //
    // Audition Head Button
    //
    list_head_button=new QPushButton(this);
    list_head_button->setGeometry(10,sizeHint().height()-113,80,50);
    list_head_button->setFont(font);
    list_head_button->setPalette(QPalette(QColor(system_button_color),QColor(system_mid_color)));
    list_head_button->setText(tr("Audition\nHead"));
    list_head_button->setFocusPolicy(QWidget::NoFocus);
    connect(list_head_button,SIGNAL(clicked()),this,SLOT(headButtonData()));
    if(!rda->airplayConf()->showCounters()) {
        list_head_button->hide();
    }

    //
    // Audition Tail Button
    //
    list_tail_button=new QPushButton(this);
    list_tail_button->setGeometry(90,sizeHint().height()-113,80,50);
    list_tail_button->setFont(font);
    list_tail_button->setPalette(QPalette(QColor(system_button_color),QColor(system_mid_color)));
    list_tail_button->setText(tr("Audition\nTail"));
    list_tail_button->setFocusPolicy(QWidget::NoFocus);
    connect(list_tail_button,SIGNAL(clicked()),this,SLOT(tailButtonData()));
    if(!rda->airplayConf()->showCounters()) {
        list_tail_button->hide();
    }

    //
    // Play Button
    //
    list_play_button=new QPushButton(this);
    list_play_button->setGeometry(10,sizeHint().height()-55,80,50);
    list_play_button->setFont(font);
    list_play_button->setPalette(QPalette(QColor(system_button_color),QColor(system_mid_color)));
    list_play_button->setText(tr("Start"));
    list_play_button->setDisabled(true);
    list_play_button->setFocusPolicy(QWidget::NoFocus);
    connect(list_play_button,SIGNAL(clicked()),this,SLOT(playButtonData()));

    //
    // Next Button
    //
    list_next_button=new QPushButton(this);
    list_next_button->setGeometry(90,sizeHint().height()-55,80,50);
    list_next_button->setFont(font);
    list_next_button->setPalette(QPalette(QColor(system_button_color),QColor(system_mid_color)));
    list_next_button->setText(tr("Make\nNext"));
    list_next_button->setDisabled(true);
    list_next_button->setFocusPolicy(QWidget::NoFocus);
    connect(list_next_button,SIGNAL(clicked()),this,SLOT(nextButtonData()));

    //
    // Modify Button
    //
    list_modify_button=new QPushButton(this);
    list_modify_button->setGeometry(170,sizeHint().height()-55,80,50);
    list_modify_button->setFont(font);
    list_modify_button->setPalette(QPalette(QColor(system_button_color),QColor(system_mid_color)));
    list_modify_button->setText(tr("Modify"));
    list_modify_button->setDisabled(true);
    list_modify_button->setFocusPolicy(QWidget::NoFocus);
    connect(list_modify_button,SIGNAL(clicked()),this,SLOT(modifyButtonData()));

    //
    // Scroll Button
    //
    list_scroll_button=new QPushButton(this);
    list_scroll_button->setGeometry(250,sizeHint().height()-55,80,50);
    list_scroll_button->setFont(font);
    list_scroll_button->setPalette(QPalette(QColor(system_button_color),QColor(system_mid_color)));
    list_scroll_button->setText(tr("Scroll"));
    list_scroll_button->setFocusPolicy(QWidget::NoFocus);
    connect(list_scroll_button,SIGNAL(clicked()),this,SLOT(scrollButtonData()));
    list_scroll_button->setPalette(list_scroll_color[0]);

    //
    // Refresh Button
    //
    list_refresh_button=new QPushButton(this);
    list_refresh_button->setGeometry(330,sizeHint().height()-55,80,50);
    list_refresh_button->setFont(font);
    list_refresh_button->setPalette(QPalette(QColor(system_button_color),QColor(system_mid_color)));
    list_refresh_button->setText(tr("Refresh\nLog"));
    list_refresh_button->setDisabled(true);
    list_refresh_button->setFocusPolicy(QWidget::NoFocus);
    connect(list_refresh_button,SIGNAL(clicked()),
            this,SLOT(refreshButtonData()));

    //
    // Log Load
    //
    list_load_button=new QPushButton(this);
    list_load_button->setGeometry(sizeHint().width()-90,sizeHint().height()-55,
                                  80,50);
    list_load_button->setFont(font);
    list_load_button->setPalette(QPalette(QColor(system_button_color),QColor(system_mid_color)));
    list_load_button->setText(tr("Select\nLog"));
    list_load_button->setFocusPolicy(QWidget::NoFocus);
    connect(list_load_button,SIGNAL(clicked()),this,SLOT(loadButtonData()));

    //
    // Edit Event Dialog
    //
    list_event_edit=new EditEvent(list_log,list_cae,this);

    //
    // Map Slots
    //
    connect(list_log,SIGNAL(reloaded()),this,SLOT(logReloadedData()));
    connect(list_log,SIGNAL(played(int)),this,SLOT(logPlayedData(int)));
    connect(list_log,SIGNAL(paused(int)),this,SLOT(logPausedData(int)));
    connect(list_log,SIGNAL(stopped(int)),this,SLOT(logStoppedData(int)));
    connect(list_log,SIGNAL(inserted(int)),this,SLOT(logInsertedData(int)));
    connect(list_log,SIGNAL(removed(int,int,bool)),
            this,SLOT(logRemovedData(int,int,bool)));
    connect(list_log,SIGNAL(transportChanged()),
            this,SLOT(transportChangedData()));
    connect(list_log,SIGNAL(modified(int)),this,SLOT(modifiedData(int)));
    connect(list_log,SIGNAL(refreshabilityChanged(bool)),
            this,SLOT(refreshabilityChangedData(bool)));
    connect(list_log,SIGNAL(auditionHeadPlayed(int)),
            this,SLOT(auditionHeadData(int)));
    connect(list_log,SIGNAL(auditionTailPlayed(int)),
            this,SLOT(auditionTailData(int)));
    connect(list_log,SIGNAL(auditionStopped(int)),
            this,SLOT(auditionStoppedData(int)));

    setBackgroundColor(QColor(system_mid_color));

    RefreshList();
    UpdateTimes();
}
void ListLog::refresh(int line)
{
    RefreshList(line);
    UpdateTimes();
}
void ListLog::refresh()
{
    RefreshList();
    UpdateTimes();
}
void ListLog::modifiedData(int line)
{
    RefreshList(line);
    UpdateTimes();
}
Beispiel #12
0
BOOL FAdWindow::UpdatePosition(IAdPosition& pPos)
{
	//TODO: Find ads matching this position.
	//Hide ad if m_EndPos > pPos.curPos

	DWORD dwPlayState = pPos.m_dwFlags & FLAG_PLAYBACK_MASK; 

	if (m_bAdLoaded)
	{
		if (m_CurrentItem.m_TimeEndMS < pPos.m_PlaybackPosMS)
		{
			//Hide ad if no timeout exists.
			if (m_CurrentItem.m_TimeoutMS == 0 && !(m_CurrentItem.m_dwFlags & AD_FLAG_PERSISTENT))
				OnAdFinished();
		}
	}
	//Still loaded ?
	if (m_bAdLoaded)
	{
		if (dwPlayState == FLAG_PLAYBACK_PAUSED)
		{
			if (m_LastState != FLAG_PLAYBACK_PAUSED)
			{
				//User paused the playback. Compute remaining timeout. 
				KillTimer(1); 
				m_CurrentItem.m_TimeoutMS -= (GetTickCount() - m_TimerStarted);
			}
		}
		else if (dwPlayState == FLAG_PLAYBACK_RUNNING)
		{
				if (m_LastState == FLAG_PLAYBACK_PAUSED)
				{
					if (m_CurrentItem.m_TimeoutMS > 0)
						SetTimer(1, (UINT)m_CurrentItem.m_TimeoutMS); 
				}
		}
	}
	
	m_LastState = dwPlayState;

	//Total duration is 0, this is invalid and we shouldn't 
	//try to locate ads for it; until it becomes > 0
	if (pPos.m_TotalDurationMS == 0)
		return FALSE; 

	for (size_t k = 0; k < m_Ads.size(); k++)
	{
		FAdItem& pItem = m_Ads[k];
		UpdateTimes(pItem, pPos);	//recompute position (if specified in percent)

		//START / END ads can only be shown ONCE
		if (pItem.m_dwFlags & AD_FLAG_AT_START)
		{	
			if ((dwPlayState == FLAG_PLAYBACK_START || 
			   (dwPlayState == FLAG_PLAYBACK_RUNNING && pPos.m_MSPlayed < 5000)) && 
				pItem.m_LastDisplay == 0)
			{
				if (LoadAd(pItem))
					return TRUE; 
			}
			continue; 
		}

		if (pItem.m_dwFlags & AD_FLAG_AT_END)
		{
			if (dwPlayState == FLAG_PLAYBACK_ENDED && pItem.m_LastDisplay == 0)
				if (LoadAd(pItem))
					return TRUE; 

			continue; 
		}

		if (pItem.m_MSPlayed > 0 && pPos.m_MSPlayed > pItem.m_MSPlayed && pItem.m_LastDisplay == 0)
		{
			if (LoadAd(pItem))
				return TRUE; 
		}
		else if (pItem.m_MSPlayed == 0)
		{
			duration_type TimeEndMS = pItem.m_TimeEndMS;

			if (TimeEndMS == 0)
				TimeEndMS = pItem.m_TimeMS + pItem.m_TimeoutMS;

			if (pItem.m_TimeMS <= pPos.m_PlaybackPosMS)
			{
				if (TimeEndMS >= pPos.m_PlaybackPosMS)
				{
					//Good candidate
					if (LoadAd(pItem))
						return TRUE; 
				}
			}
		}
	}
	return FALSE; 
}