Exemplo n.º 1
0
JobManager::JobManager(QQmlContext* context, QObject *parent) :
    QObject(parent)
{
    qsrand(QDateTime::currentMSecsSinceEpoch());
    context_ = context;
    connect(this, SIGNAL(listUpdated()), this, SLOT(updateContext()));
}
Exemplo n.º 2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    network_ = new Network(this);
    connect(network_,SIGNAL(listUpdated()),
            this,SLOT(onRedraw()));
    this->setFixedSize(this->size());
    //QTextCodec::setCodecForLocale(QTextCodec::codecForName("CP-866"));
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);

    QAction *act;
    modeMenu_ = new QMenu(this);

    act = new QAction(tr("Telnet mode"),this);
    connect(act,SIGNAL(triggered()),this,SLOT(runTelnet()));
    modeMenu_->addAction(act);

    act = new QAction(tr("File mode"),this);
    connect(act,SIGNAL(triggered()),this,SLOT(runFile()));
    modeMenu_->addAction(act);

    act = new QAction(tr("Graphics mode"),this);
    connect(act,SIGNAL(triggered()),this,SLOT(runGraph()));
    modeMenu_->addAction(act);

    modeMenu_->addSeparator();

    act = new QAction(tr("Options"),this);
    connect(act,SIGNAL(triggered()),this,SLOT(runOptions()));
    modeMenu_->addAction(act);
}
/// @brief Constructor
CollectionTreeWidget::CollectionTreeWidget()
{
    setColumnCount(1);
    header()->hide(); // hide headers
    setDragEnabled(true);
    setAcceptDrops(true);
    setSelectionMode(QAbstractItemView::ExtendedSelection);

    service = new CollectionService();

    // Add songs that currently exist on database
    QSqlTableModel *artistModel = service->artistModel();
    artistModel->select();

    // TODO: verify if we can put fetchmore() inside the for loop.
    // TODO: put this task in background... URGENT
    while (artistModel->canFetchMore()) artistModel->fetchMore();
    int total = artistModel->rowCount();

    for (int i = 0; i < total; i++) {
        QString artist = artistModel->record(i).value(artistModel->fieldIndex("name")).toString();
        unsigned int id = artistModel->record(i).value(artistModel->fieldIndex("id")).toInt();
        addArtist(artist, id);
    }
    delete artistModel;

    /*
     * TODO: modify the slots in order to add only the artist, not the music.
     *       The album and song must be shown only if the node is already expanded.
     */
    connect(service, SIGNAL(songAdded(Music*)), this, SLOT(addMusic(Music*)));
    connect(service, SIGNAL(songRemoved(unsigned int)), this, SLOT(removeMusic(uint)));
    connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(doubleClickAt(QModelIndex)));
    connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(showChildrenOf(QModelIndex)));

    /*
     * We shall emit those signals to show or hide the widget that will
     * give the feedback that the collection is being scanned.
     */
    connect(service, SIGNAL(scanning()), this, SIGNAL(scanning()));
    connect(service, SIGNAL(listUpdated()), this, SIGNAL(listUpdated()));

    // Start service to find new songs and remove the inexistent ones
    service->start(QThread::LowestPriority);
}
Exemplo n.º 4
0
void SessionsBox::Inner::terminateDone(uint64 hash, const MTPBool &result) {
	for (int32 i = 0, l = _list->size(); i < l; ++i) {
		if (_list->at(i).hash == hash) {
			_list->removeAt(i);
			break;
		}
	}
	listUpdated();
	emit oneTerminated();
}
Exemplo n.º 5
0
void JobManager::startNextJob()
{
    disconnect(this, SIGNAL(listUpdated()), this, SLOT(startNextJob()));
    int i = 0;
    currentJob = 0;
    while( i < list_.size() && !currentJob) {
        Job* job = qobject_cast<Job*>(list_.at(i));
        if (!job->isPrinted())
        {
            currentJob = job;
        }
        i++;
    }

    if (currentJob)
    {
        currentJob->setPrinting(true);
        qDebug() << "Start job " << currentJob->getId() << " time: " << currentJob->getPrintTime();
        QTimer::singleShot(currentJob->getPrintTime()*1000, this, SLOT(endCurrentJob()));
    }
    else {
        connect(this, SIGNAL(listUpdated()), this, SLOT(startNextJob()), Qt::UniqueConnection);
    }
}
Exemplo n.º 6
0
void JobManager::addJob(Job *job)
{
    job->setId(list_.size());
    list_.append(job);
    emit listUpdated();
}
Exemplo n.º 7
0
//update the choices of the variable, called on variable thread from the var_AddListCallback callback
//calling vlcValToVariant is safe here as m_type will only be modified when no callbacks is registred
int VLCVarChoiceModel::updateList(const vlc_object_t* object, int action, const vlc_value_t* p_value)
{
    QVariant valueVariant = p_value ? vlcValToVariant(*p_value) : QVariant();
    emit listUpdated(object, action, valueVariant, QPrivateSignal{});
    return VLC_SUCCESS;
}