Example #1
0
SimpleListModelBase::SimpleListModelBase(int columns, QObject *parent)
    : QAbstractListModel(parent), d(new Data)
{
    d->columns = columns;
    connect(this, &QAbstractItemModel::dataChanged,
            this, [this] (const QModelIndex &tl, const QModelIndex &br)
    {
        emit rowChanged(tl.row());
        if (tl.row() != br.row())
            emit rowChanged(br.row());
    });

    connect(this, &SimpleListModelBase::dataChanged, this,
            [=] (int row, const QVector<int> &roles)
    {
        if (!isValidRow(row))
            return;
        const auto tl = index(row, 0), br = index(row, d->columns - 1);
        emit QAbstractListModel::dataChanged(tl, br, roles);
    });

    auto signal = &SimpleListModelBase::contentsChanged;
    using M = QAbstractItemModel;
    connect(this, &M::modelReset, this, signal);
    connect(this, &M::dataChanged, this, signal);
    connect(this, &M::rowsInserted, this, signal);
    connect(this, &M::rowsRemoved, this, signal);
    connect(this, &M::rowsMoved, this, signal);
    connect(this, &M::layoutChanged, this, signal);
}
Example #2
0
//--------------------------------------------------------------------------------------
// Update table
//--------------------------------------------------------------------------------------
void tNDP2kDevicePage::UpdateDeviceList()
{
    if(tGlobal<tNDP2k>::Instance()->IsBusOff())
    {
        if(m_IsBusOff == false)
        {
            // If we just realized about the Bus Off, restart the list so that only the internal devices are shown
            m_IsBusOff = true;
            RefreshDeviceList();
            return;
        }
    }
    else
    {
        m_IsBusOff = false;
    }

    tNDP2kDevice* pDevice;
    for (int row=0; row < m_pTableWidget->rowCount(); ++row)
    {
        if (tGlobal<tNDP2k>::Instance()->DeviceManager().NameToDevice(m_pTableWidget->item(row, m_NameColumn)->text(), &pDevice))
        {
            rowChanged(row, pDevice);
        }
    }

    if (m_SortOption >= 0)
    {
        Sort();
    }   
}
Example #3
0
void Sbrowse::mousePressEvent(QMouseEvent * event)
{
	if (event->type() == QEvent::MouseButtonPress)
	{
		event->accept();

		int row = this->rowAt(event->y());
		if (row != -1)
		{
			selectRow(row);
		}

		emit rowChanged(this);

		int id = this->getQuery().record().field("id").value().toInt();
#ifdef DEBUG
        qDebug("SIGNAL rowChanged emitted Click (QEvent::MouseButtonPress) row [%d] id [%d] %s %d",
               row, id, __FILE__, __LINE__);
#endif

	}
	else
	{
		event->ignore();
	}
}
Example #4
0
void WebSocketClient::onMessageReceived(const QByteArray &data)
{
	QDataStream ds(data);
	quint8 cmd;
	ds >> cmd;

	switch (cmd) {
	case GET_TRACK:
	{
		quint32 length;
		ds >> length;
		Q_ASSERT(1 + sizeof(length) + length == size_t(data.length()));
		QByteArray nameData(data.constData() + 1 + sizeof(length), length);
		requestTrack(QString::fromUtf8(nameData));
	}
	break;

	case SET_ROW:
	{
		quint32 row;
		ds >> row;
		emit rowChanged(row);
	}
	break;
	}
}
Example #5
0
void DColorPicker::setRow(int row)
{
    if (m_row == row)
        return;

    m_row = row;
    resize();
    emit rowChanged(row);
}
bool StatsTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    if (role == Qt::EditRole && static_cast<size_t>(index.row()) < m_statsModel.size())
    {
        m_isSaved = false;
        switch (index.column())
        {
        case COLUMN_ID_NAME:
            emit rowChanged(index.row(), value.toString(), m_statsModel.value(index.row()));
            return true;
        case COLUMN_ID_VALUE:
            emit rowChanged(index.row(), m_statsModel.key(index.row()), value.toInt());
            return true;
        default:
            break;
        }
    }
    return QAbstractTableModel::setData(index, value, role);
}
Example #7
0
//--------------------------------------------------------------------------------------
//! Insert device into the table
//--------------------------------------------------------------------------------------
void tNDP2kDevicePage::insertDevice(tNDP2kDevice* pDevice, int row)
{
    m_pTableWidget->insertRow(row);

    for(int i = 0; i < m_DisplayColumns.count(); i++)
    {
        m_pTableWidget->setItem(row, i, new QTableWidgetItem());
    }
    rowChanged(row, pDevice);
}
Example #8
0
void EffectSelectDialog::updateSelection()
{
    // no valid selection anymore due to changed filter?
    if( ui->pluginList->selectionModel()->selection().size() <= 0 )
    {
        // then select our first item
        ui->pluginList->selectionModel()->select( m_model.index( 0, 0 ),
                QItemSelectionModel::ClearAndSelect );
        rowChanged( m_model.index( 0, 0 ), QModelIndex() );
    }
}
Example #9
0
void ItemDelegate::onItemChanged(ItemWidget *item)
{
    for( int i = 0; i < m_cache.length(); ++i ) {
        ItemWidget *w = m_cache[i];
        if ( w != NULL && w == item ) {
            QSize oldSize = w->widget()->size();
            emit rowChanged(i, oldSize);
            return;
        }
    }
}
Example #10
0
void GroupWidget::resetButtons()
{
    int row = currentRow();
    int cnt = groupListWidget->count();

    upButton->setEnabled(row > 0 );
    downButton->setEnabled((( cnt - row) > 1 ) && ( row >= 0 ));
    editButton->setEnabled(row >= 0);
    if (delButton) delButton->setEnabled(row >= 0);
    emit rowChanged(row);
}
Example #11
0
serversDialog::serversDialog(QWidget *parent) : QDialog(parent) {

	setupUi(this) ;

	connect(buttonBox,SIGNAL(rejected()),this,SLOT(deleteLater())) ;
	connect(buttonBox,SIGNAL(accepted()),this,SLOT(acceptList())) ;
	connect(addButton,SIGNAL(clicked()),this,SLOT(addServer())) ;
	connect(editButton,SIGNAL(clicked()),this,SLOT(editServer())) ;
	connect(removeButton,SIGNAL(clicked()),this,SLOT(removeServer())) ;
	connect(serverList,SIGNAL(itemSelectionChanged()),this,SLOT(rowChanged())) ;

	updateServerList() ;

}
Example #12
0
void GroupWidget::initGroup()
{
    int cnt = groupListWidget->count();
    for (int i = 0; i < cnt; i++) {
        groupListWidget->takeItem(0);
    }
    for (int i = 0; i < groupList->count(); i++) {
        groupListWidget->addItem((*groupList)[i]);
    }
    if ( groupListWidget->count() > 0 ) {
        groupListWidget->setCurrentRow(0);
        emit rowChanged(0);
        //qDebug() << "emit changeRow";
    }
}
Example #13
0
void Sbrowse::keyPressEvent(QKeyEvent *event)
{
	QTableView::keyPressEvent(event);

	if (
			event->key() == Qt::Key_Up ||
			event->key() == Qt::Key_Down ||
			event->key() == Qt::Key_PageUp ||
			event->key() == Qt::Key_PageDown
		 )
	{
        emit rowChanged(this);
#ifdef DEBUG
        qDebug("SIGNAL rowChanged emitted %s %d", __FILE__, __LINE__);
#endif
	}

	if ( event->key() == Qt::Key_Return ||
			 event->key() == Qt::Key_Enter )
	{
        emit rowEdit(this);
#ifdef DEBUG
        qDebug("SIGNAL rowEdit emitted %s %d", __FILE__, __LINE__);
#endif
	}

	if ( event->key() == Qt::Key_Insert)
	{
		emit rowInsert(this);
#ifdef DEBUG
        qDebug("SIGNAL rowInsert emitted %s %d", __FILE__, __LINE__);
#endif
	}


	if ( event->key() == Qt::Key_Delete)
	{
		emit rowDelete(this);
#ifdef DEBUG
        qDebug("SIGNAL rowDelete emitted %s %d", __FILE__, __LINE__);
#endif
	}

}
Example #14
0
void ItemDelegate::setItemMaximumSize(const QSize &size)
{
    int w = size.width() - 8;
    if (m_showNumber) {
        w -= QFontMetrics(m_numberFont).boundingRect( QString("0123") ).width();
    }

    if (m_maxSize.width() == w)
        return;

    m_maxSize.setWidth(w);

    for( int i = 0; i < m_cache.length(); ++i ) {
        ItemWidget *w = m_cache[i];
        if (w != NULL) {
            QSize oldSize = w->widget()->size();
            w->widget()->setMaximumSize(m_maxSize);
            w->updateSize();
            emit rowChanged(i, oldSize);
        }
    }
}
Example #15
0
//--------------------------------------------------------------------------------------
//! Update the list of devices when a device changes
//--------------------------------------------------------------------------------------
void tNDP2kDevicePage::OnDeviceChanged(const tN2kName &N2kName)
{
    tNDP2kDevice *pDevice;
    if(tGlobal<tNDP2k>::Instance()->DeviceManager().NameToDevice(N2kName, &pDevice))
    {
        if(pDevice->IsAlive())
        {
            if (m_DeviceList.contains(pDevice))
            {   
                // Search for device in table
                for (int row=0; row < m_pTableWidget->rowCount(); ++row)
                {
                    if (m_pTableWidget->item(row, m_NameColumn)->text() == pDevice->HexName())
                    {
                        rowChanged(row, pDevice);
                        if (m_SortOption >= 0)
                        {
                            if ( m_pTableWidget->IsScrolling() == false )
                            {
                                Sort();
                            }
                        }
                        break;
                    }
                }
            }
            else 
            {
                // Add the device if missing from the list
                m_DeviceList.prepend(pDevice);

                // Insert device at the beginning of the table (they are sorted anyhow)
                insertDevice(pDevice, 0);
                if( pDevice->ProductCode() == N2K_PRESSURE_ID )
                {
                    tPressureSensorProxy proxy( pDevice->N2kName() );
                    proxy.RequestPressureConfiguration(  );
                }
                if ( m_pTableWidget->IsScrolling() == false )
                {
                    Sort(); //always update the selection, even if the sortOption is < 0
                }
            }
        }
        else // Device IsALive == false
        {
            if (m_DeviceList.contains(pDevice)) // Device Lost
            {   
                // Search for device in table
                for (int row=0; row < m_pTableWidget->rowCount(); ++row)
                {
                    if (m_pTableWidget->item(row, m_NameColumn)->text() == pDevice->HexName())
                    {
                        m_pTableWidget->removeRow(row);
                        m_DeviceList.removeOne(pDevice);
                        break;
                    }
                }
            }
        }
    }
}
Example #16
0
void AbstractSocketClient::processSetRow()
{
	quint32 newRow;
	if (recv((char *)&newRow, sizeof(newRow)))
		emit rowChanged(qFromBigEndian(newRow));
}
Example #17
0
void QmlView::setCurrentRow(int row)
{
    emit rowChanged(row);
}
Example #18
0
QmlView::QmlView(QUrl source, QWidget *parent, MafwRegistryAdapter *mafwRegistry ) :
    QMainWindow(parent),
    ui(new Ui::QmlView),
    mafwRegistry(mafwRegistry),
    mafwRenderer(mafwRegistry->renderer())
{
    ui->setupUi(this);
    ui->declarativeView->setSource(source);
    ui->declarativeView->setResizeMode(QDeclarativeView::SizeRootObjectToView);

    setAttribute(Qt::WA_DeleteOnClose);
    setAttribute(Qt::WA_Maemo5StackedWindow);
    setAttribute(Qt::WA_Maemo5NonComposited);

    QGLWidget *glWidget = new QGLWidget(this);
    ui->declarativeView->setViewport(glWidget);

    positionTimer = new QTimer(this);
    positionTimer->setInterval(1000);

    fmtx = new FMTXInterface(this);

    Rotator *rotator = Rotator::acquire();
    savedPolicy = rotator->policy();
    rotator->setPolicy(Rotator::Landscape);

    rootObject = dynamic_cast<QObject*>(ui->declarativeView->rootObject());
    rootObject->setParent(this);

    connect(rootObject, SIGNAL(quitButtonClicked()), this, SLOT(close()));
    connect(rootObject, SIGNAL(prevButtonClicked()), mafwRenderer, SLOT(previous()));
    connect(rootObject, SIGNAL(playButtonClicked()), this, SLOT(onPlayClicked()));
    connect(rootObject, SIGNAL(nextButtonClicked()), mafwRenderer, SLOT(next()));
    connect(rootObject, SIGNAL(fmtxButtonClicked()), this, SLOT(onFmtxClicked()));
    connect(rootObject, SIGNAL(sliderValueChanged(int)), this, SLOT(onSliderValueChanged(int)));
    connect(rootObject, SIGNAL(playlistItemSelected(int)), this, SLOT(onPlaylistItemChanged(int)));

    connect(this, SIGNAL(titleChanged(QVariant)), rootObject, SLOT(setSongTitle(QVariant)));
    connect(this, SIGNAL(albumChanged(QVariant)), rootObject, SLOT(setSongAlbum(QVariant)));
    connect(this, SIGNAL(artistChanged(QVariant)), rootObject, SLOT(setSongArtist(QVariant)));
    connect(this, SIGNAL(albumArtChanged(QVariant)), rootObject, SLOT(setAlbumArt(QVariant)));
    connect(this, SIGNAL(durationTextChanged(QVariant)), rootObject, SLOT(setPosition(QVariant)));
    connect(this, SIGNAL(positionChanged(QVariant)), rootObject, SLOT(setSliderValue(QVariant)));
    connect(this, SIGNAL(durationChanged(QVariant)), rootObject, SLOT(setSliderMaximum(QVariant)));
    connect(this, SIGNAL(stateIconChanged(QVariant)), rootObject, SLOT(setPlayButtonIcon(QVariant)));
    connect(this, SIGNAL(rowChanged(QVariant)), rootObject, SLOT(onRowChanged(QVariant)));
    connect(this, SIGNAL(fmtxStateChanged(QVariant)), rootObject, SLOT(onFmtxStateChanged(QVariant)));

    connect(this, SIGNAL(playlistItemAppended(QVariant,QVariant,QVariant)),
            rootObject, SLOT(appendPlaylistItem(QVariant,QVariant,QVariant)));
    connect(this, SIGNAL(playlistItemInserted(QVariant,QVariant,QVariant,QVariant)),
            rootObject, SLOT(insertPlaylistItem(QVariant,QVariant,QVariant,QVariant)));
    connect(this, SIGNAL(playlistItemSet(QVariant,QVariant,QVariant,QVariant)),
            rootObject, SLOT(setPlaylistItem(QVariant,QVariant,QVariant,QVariant)));
    connect(this, SIGNAL(playlistItemRemoved(QVariant)),
            rootObject, SLOT(removePlaylistItem(QVariant)));
    connect(this, SIGNAL(playlistCleared()),
            rootObject, SLOT(clearPlaylist()));

    connect(mafwRenderer, SIGNAL(stateChanged(MafwPlayState)), this, SLOT(onStateChanged(MafwPlayState)));
    connect(mafwRenderer, SIGNAL(positionReceived(int,QString)), this, SLOT(onPositionChanged(int)));
    connect(mafwRenderer, SIGNAL(statusReceived(MafwPlaylist*,uint,MafwPlayState,QString,QString)),
            this, SLOT(onStatusReceived(MafwPlaylist*,uint,MafwPlayState)));
    connect(positionTimer, SIGNAL(timeout()), mafwRenderer, SLOT(getPosition()));

    connect(fmtx, SIGNAL(propertyChanged()), this, SLOT(onFmtxChanged()));
    onFmtxChanged();

    positionTimer->start();

    quint32 disable = {0};
    Atom winPortraitModeSupportAtom = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_SUPPORT", false);
    XChangeProperty(QX11Info::display(), winId(), winPortraitModeSupportAtom, XA_CARDINAL, 32, PropModeReplace, (uchar*) &disable, 1);

    this->setDNDAtom(true);

    mafwRenderer->getStatus();
    mafwRenderer->getPosition();
}
Example #19
0
void TableView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
{
    emit rowChanged(this->currentIndex().row());
}