Example #1
0
 ExecStatus
 LqView<VX,VY,VZ,shr>::post(Home home, ViewArray<VX>& x,
                            VY y, VZ z, int c) {
   GECODE_ME_CHECK(z.gq(home,-c));
   if (z.assigned())
     return LqInt<VX,VY>::post(home,x,y,z.val()+c);
   if (sharing(x,y,z))
     (void) new (home) LqView<VX,VY,VZ,true>(home,x,y,z,c);
   else
     (void) new (home) LqView<VX,VY,VZ,false>(home,x,y,z,c);
   return ES_OK;
 }
Example #2
0
 ExecStatus
 EqView<VX,VY,VZ,shr,dom>::post(Home home,
                            ViewArray<VX>& x, VY y, VZ z, int c) {
   GECODE_ME_CHECK(z.gq(home,-c));
   GECODE_ME_CHECK(z.lq(home,x.size()-c));
   if ((vtd(y) != VTD_VARVIEW) && z.assigned())
     return EqInt<VX,VY>::post(home,x,y,z.val()+c);
   if (sharing(x,y,z))
     (void) new (home) EqView<VX,VY,VZ,true,dom>(home,x,y,z,c);
   else
     (void) new (home) EqView<VX,VY,VZ,false,dom>(home,x,y,z,c);
   return ES_OK;
 }
Example #3
0
void QMplayer::okClicked()
{
    if(screen == QMplayer::ScreenInit || screen == QMplayer::ScreenEncoding)
    {
        QString dir = "";
        bool hit = false;
        QStringList list;
        QStringList downList;
        QStringList nameList;
        QMessageBox::StandardButton answer = QMessageBox::NoButton;
        QMessageBox::StandardButton moreAnswer = QMessageBox::NoButton;

        list << mpargs;
        list << mplist;

        if (mpgui)
        {
            QListWidgetItem *sel = lw->currentItem();
            if(sel == NULL)
            {
                return;
            }
            if(sel == scanItem)
            {
                scan();
                return;
            }
            if(sel == sharingItem)
            {
                sharing();
                return;
            }
            if(sel == encodingItem)
            {
                if(screen != ScreenEncoding)
                {
                    showScreen(ScreenEncoding);
                    if(lw->count() > NUM_MENU_ITEMS)
                    {
                        QListWidgetItem *item = lw->item(NUM_MENU_ITEMS);
                        item->setSelected(true);
                    }
                }
                else
                {
                    showScreen(ScreenInit);
                }
                return;
            }

            for(int i = NUM_MENU_ITEMS; i < lw->count(); i++)
            {
                QListWidgetItem *item = lw->item(i);
                QString path = item->text();
                bool isDir = isDirectory(path);
                if(isDir)
                {
                    if(hit)
                    {
                        break;
                    }
                    dir = path;
                }
                hit |= (item == sel);
                if(!hit || isDir)
                {
                    continue;
                }
                if(!dir.startsWith("http://"))
                {
                    list.append(dir + "/" + path);      // add local files to playlist
                    continue;
                }
                if(moreAnswer == QMessageBox::NoButton)
                {
                    answer = QMessageBox::question(this, "qmplayer", path, QMessageBox::Save | QMessageBox::Open | QMessageBox::Cancel);
                }
                if(answer == QMessageBox::Cancel)
                {
                    break;
                }
                if(answer == QMessageBox::Open)
                {
                    list.append(dir + pathToUrl(path));      // append to playlist if we just play (no download)
                }
                downList.append(dir + pathToUrl(path));
                nameList.append(path);
                if(moreAnswer != QMessageBox::YesToAll)
                {
                    moreAnswer = QMessageBox::question(this, "qmplayer", tr("Next file?"),
                                                       QMessageBox::Yes | QMessageBox::No | QMessageBox::YesToAll);

                    if(moreAnswer == QMessageBox::No)
                    {
                        break;
                    }
                }
            }
            for(int i = 0; i < downList.count(); i++)
            {
                QString url = downList[i];
                int slashIndex = url.lastIndexOf('/');
                if(slashIndex < 0)
                {
                    continue;
                }
                QString filename = nameList[i];
                QString destPath = QDir::homePath() + "/" + filename;
                if(QDir("/media/card").exists())
                {
                    destPath = "/media/card/" + filename;
                }
                bool justCheck = list.contains(url);
                if(!download(url, destPath, filename, justCheck))
                {
                    return;
                }
                if(justCheck)
                {
                    continue;
                }
                // Add downloaded file to list
                list.append(destPath);
            }
        }

        if(list.count() > mpargs.count())
        {
            if(screen == ScreenEncoding)
            {
                encode(list.at(0));
            }
            else
            {
                if (isPlaylist(list[mpargs.count()]))
                    list.insert(mpargs.count(),"-playlist");
                play(list);
            }
        }
    }
    else if(screen == QMplayer::ScreenPlay)
    {
        if(processRunning(process))
        {
            process->write(" ");
        }
        showScreen(QMplayer::ScreenStopped);
    }
    else if(screen == QMplayer::ScreenStopped)
    {
        if(processRunning(process))
        {
            process->write(" ");
#ifdef QTOPIA
            // Workaround unpause not working for alsa out in mplayer glamo.
            // We send left key to make mplayer start playing.
            process->write("\x1b""[D");
#endif
        }
        showScreen(QMplayer::ScreenPlay);
    }
    else if(screen == QMplayer::ScreenConnect)
    {
        runClient();
    }
    else if(screen == QMplayer::ScreenTube)
    {
        this->screen = QMplayer::ScreenInit;
        okClicked();
    }
}