ServiceMessagesPage::ServiceMessagesPage(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ServiceMessagesPage),
    clientModel(0),
    walletModel(0)
{
    ui->setupUi(this);

    connect(ui->tableServiceMessagesView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(handleClicked(QModelIndex)));

    QColor foreground(qRgb(48,134,196));
    QStandardItemModel* model = new QStandardItemModel(2, 2, this);

    for (int i = 0; i < 0; ++i)
    {
        QStandardItem* item = new QStandardItem(trUtf8("17:56, 01.03.2012"));
        item->setForeground(foreground);
        model->setItem(i, 0, item);

        item = new QStandardItem(QString::fromUtf8(
                                     i == 0 ?
                                         "":
                                         ""));
        item->setForeground(foreground);
        model->setItem(i, 1, item);
    }

    ui->tableServiceMessagesView->setModel(model);
    ui->tableServiceMessagesView->setColumnWidth(0, 120);
    ui->tableServiceMessagesView->horizontalHeader()->setStretchLastSection(true);
    ui->tableServiceMessagesView->resizeRowsToContents();
}
예제 #2
0
// -------- QTestFunction
void QTestFunction::addIncident(IncidentType type,
                                const QString &file,
                                const QString &line,
                                const QString &details)
{
    QStandardItem *status = new QStandardItem(incidentString(type));
    status->setData(QVariant::fromValue(type));

    switch (type) {
        case QTestFunction::Pass: status->setForeground(Qt::green); break;
        case QTestFunction::Fail: status->setForeground(Qt::red); break;
        case QTestFunction::XFail: status->setForeground(Qt::darkMagenta); break;
        case QTestFunction::XPass: status->setForeground(Qt::darkGreen); break;
    }

    QStandardItem *location = new QStandardItem;
    if (!file.isEmpty()) {
        location->setText(file + QLatin1Char(':') + line);
        location->setForeground(Qt::red);

        QTestLocation loc;
        loc.file = file;
        loc.line = line;
        location->setData(QVariant::fromValue(loc));
    }

    appendRow(QList<QStandardItem *>() << status << location);

    if (!details.isEmpty()) {
        status->setColumnCount(2);
        status->appendRow(QList<QStandardItem *>() << new QStandardItem() << new QStandardItem(details));
    }
}
예제 #3
0
static void addOneRecordToModel(const data::AccountReceivableRecord & record
                                , QStandardItemModel * model
                                , bool isChecked)
{
    QList<QStandardItem *> row;
    row.append(new QStandardItem);
    row.append(new QStandardItem(record.date.toString("yyyy-MM-dd")));
    row.append(new QStandardItem(record.product.category.name));
    row.append(new QStandardItem(record.product.name));
    row.append(new QStandardItem(QString("%1").arg(record.quantity)));

    if (0 == record.price) {
        QBrush redBrush(Qt::red);

        QStandardItem * item = new QStandardItem(QObject::tr("Please assign unzero price"));
        item->setForeground(redBrush);

        row.append(item);
    } else {
        row.append(new QStandardItem(QString("%1").arg(record.quantity * record.price)));
    }

    row.first()->setCheckable(true);
    row.first()->setCheckState(isChecked ? Qt::Checked : Qt::Unchecked);

    for (int i = 0; i < row.size(); ++i)
        row[i]->setEditable(false);

    model->appendRow(row);
}
예제 #4
0
void ChannelConfigModel::updateChannelConfig(const SongFormat *currentFormat)
{
    this->removeRows(0, this->rowCount());

    this->currentFormat = currentFormat;
    if(currentFormat == nullptr)
    {
        return;
    }

    this->setRowCount(currentFormat->Voices);
    for (int i = 0; i < currentFormat->Voices; i++)
    {
        const std::string &voiceName = currentFormat->VoiceName[i];
        QStandardItem *item = new QStandardItem(QString::fromStdString(voiceName));

        QBrush b(currentFormat->VoiceIsMuted[i] ? Qt::red : Qt::green);
        item->setBackground(b);

        QBrush f(currentFormat->VoiceIsMuted[i] ? Qt::white : Qt::black);
        item->setForeground(f);

        item->setTextAlignment(Qt::AlignCenter);
        item->setCheckable(false);
        item->setCheckState(currentFormat->VoiceIsMuted[i] ? Qt::Unchecked : Qt::Checked);
        this->setItem(i, 0, item);
    }
}
예제 #5
0
void tst_QStandardItem::clone()
{
    QStandardItem item;
    item.setText(QLatin1String("text"));
    item.setToolTip(QLatin1String("toolTip"));
    item.setStatusTip(QLatin1String("statusTip"));
    item.setWhatsThis(QLatin1String("whatsThis"));
    item.setSizeHint(QSize(64, 48));
    item.setFont(QFont());
    item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    item.setBackground(QColor(Qt::blue));
    item.setForeground(QColor(Qt::green));
    item.setCheckState(Qt::PartiallyChecked);
    item.setAccessibleText(QLatin1String("accessibleText"));
    item.setAccessibleDescription(QLatin1String("accessibleDescription"));
    item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);

    QStandardItem *clone = item.clone();
    QCOMPARE(clone->text(), item.text());
    QCOMPARE(clone->toolTip(), item.toolTip());
    QCOMPARE(clone->statusTip(), item.statusTip());
    QCOMPARE(clone->whatsThis(), item.whatsThis());
    QCOMPARE(clone->sizeHint(), item.sizeHint());
    QCOMPARE(clone->font(), item.font());
    QCOMPARE(clone->textAlignment(), item.textAlignment());
    QCOMPARE(clone->background(), item.background());
    QCOMPARE(clone->foreground(), item.foreground());
    QCOMPARE(clone->checkState(), item.checkState());
    QCOMPARE(clone->accessibleText(), item.accessibleText());
    QCOMPARE(clone->accessibleDescription(), item.accessibleDescription());
    QCOMPARE(clone->flags(), item.flags());
    QVERIFY(!(*clone < item));
    delete clone;
}
QList<QStandardItem*> QDatabaseTableViewController::makeStandardItemListFromStringList(const QList<QString>& szStringList)
{
	QList<QStandardItem*> listStandardItemList;
	QStandardItem* pStandardItem;
	QFont font;

	QPalette palette = QApplication::palette(m_pDatabaseTableView);
	QBrush nullbrush = palette.brush(QPalette::Disabled, QPalette::Text);

	QList<QString>::const_iterator iter = szStringList.begin();
	while(iter != szStringList.end())
	{
		//Getting an item from QList<QString> to add it to a QList<QStandardItem>
		if((*iter).isNull()){
			pStandardItem = new QStandardItem(QString("NULL"));
			font = pStandardItem->font();
			font.setItalic(true);
			pStandardItem->setFont(font);
			pStandardItem->setForeground(nullbrush);
		} else {
			pStandardItem = new QStandardItem(*iter);
		}
		pStandardItem->setEditable(true);
		listStandardItemList.append(pStandardItem);
		iter++;
	}
	return listStandardItemList;
}
예제 #7
0
void RegistersModel::addItems(int startAddress, int noOfItems, bool valueIsEditable)
{
    int row;
    int col;
    m_startAddress = startAddress;
    m_noOfItems = noOfItems;
    m_offset = (startAddress % 10);
    m_firstRow = startAddress / 10;
    m_lastRow = (startAddress + noOfItems - 1) / 10;

    qDebug()<<  "RegistersModel : address " << startAddress << " ,noOfItems " << noOfItems
                << " ,offset " << m_offset << " ,first row " << m_firstRow << " ,last row " << m_lastRow;

    //Format Vertical - Horizontal Header
    clear();
    if (noOfItems > 1) {
        model->setHorizontalHeaderLabels(QStringList()<<RegModelHeaderLabels[0]<<RegModelHeaderLabels[1]
                                                    <<RegModelHeaderLabels[2]<<RegModelHeaderLabels[3]
                                                    <<RegModelHeaderLabels[4]<<RegModelHeaderLabels[5]
                                                    <<RegModelHeaderLabels[6]<<RegModelHeaderLabels[7]
                                                    <<RegModelHeaderLabels[8]<<RegModelHeaderLabels[9]);

        QStringList vertHeader;
        for (int i = m_firstRow; i <= m_lastRow ; i++) {
            vertHeader<<QString("%1").arg(i * 10, 2, 10, QLatin1Char('0'));
        }
        model->setVerticalHeaderLabels(vertHeader);
    }
    else {
        model->setHorizontalHeaderLabels(QStringList()<<RegModelHeaderLabels[0]);
        model->setVerticalHeaderLabels(QStringList()<<QString("%1").arg(startAddress, 2, 10, QLatin1Char('0')));
    }

    //Add data to model
    if (noOfItems == 1){
        QStandardItem *valueItem = new QStandardItem("-");model->setItem(0, 0, valueItem);
        valueItem->setEditable(valueIsEditable);
    }
    else {
        for (int i = 0; i < ((m_offset + noOfItems - 1) / 10 + 1) * 10 ; i++) {
            row = i / 10;
            col = i % 10;
            //Address
            if (i >= m_offset + noOfItems || i < m_offset){//not used cells
                QStandardItem *valueItem = new QStandardItem("x");model->setItem(row, col, valueItem);
                valueItem->setEditable(false);
                valueItem->setForeground(QBrush(Qt::red));
                valueItem->setBackground(QBrush(Qt::lightGray));
            }
            else {
                QStandardItem *valueItem = new QStandardItem("-");model->setItem(row, col, valueItem);
                valueItem->setEditable(valueIsEditable);
            }
        }
    }

    emit(refreshView());

}
예제 #8
0
void TrackListView::updatePartSelection(Part* part)/*{{{*/
{
    if(part)
    {
        MidiTrack* track = part->track();
        Part* curPart = m_editor->curCanvasPart();
        if (curPart)
        {
            song->setRecordFlag(curPart->track(), false);
        }
        m_editor->setCurCanvasPart(part);
        Song::movePlaybackToPart(part);
        // and turn it on for the new parts track
        song->setRecordFlag(track, true);
        song->deselectTracks();
        song->deselectAllParts();
        track->setSelected(true);
        part->setSelected(true);
        song->update(SC_SELECTION);

        int psn = part->sn();
        for(int i = 0; i < m_model->rowCount(); ++i)
        {
            QStandardItem* item = m_model->item(i, 0);
            if(item)
            {
                int type = item->data(TrackRole).toInt();
                if(type == 1)
                {//TrackMode
                    continue;
                }
                else
                {//PartMode
                    int sn = item->data(PartRole).toInt();
                    if(psn == sn)
                    {
                        m_selectedIndex = item->row();

                        m_tempColor = item->foreground();

                        m_model->blockSignals(true);
                        item->setForeground(QColor(99, 36, 36));
                        m_model->blockSignals(false);
                        update();
                        m_table->selectRow(m_selectedIndex);
                        m_table->scrollTo(m_model->index(m_selectedIndex, 0));

                        m_colorRows.append(m_selectedIndex);

                        QTimer::singleShot(350, this, SLOT(updateColor()));
                        break;
                    }
                }
            }
        }
    }
}/*}}}*/
예제 #9
0
//*** class PathEnum ***
PathEnum::PathEnum(const CppReader &reader, CppObjList &objs):
    ok(false), reader(reader)
{
    //recognization?
    if( !reader.header().startsWith("enum"))
        return;
    ok = true;
    //yes!

    //whether exists the enum name?
    QString name;
    QRegExp rn("^enum\\s+([a-zA-Z_]\\w*)\\s*$");
    if(reader.header().contains(rn) &&
            ! objs.indexOf( name = rn.cap(1)) )        //query for the existance of the name.
    {
        QStandardItem *item = new Item::CppItem(Item::Enum);
        item->setForeground(Qt::darkMagenta);
        item->setData(rn.cap(1),Item::NameRole);
        item->setData(reader.header(),Qt::ToolTipRole);
        item->setEditable(false);
        objs.append( item);
    }

    //the content of the enum.
    QStringList list = reader.body().split(',',QString::SkipEmptyParts);
    QRegExp rx("^\\s*([a-zA-Z_]\\w*)\\s*(?:=[^,;]+)?$");
    foreach (const QString &it, list)
    {
        if(! it.contains(rx) )
            continue;
        if( ! objs.indexOf( rx.cap(1)))
        {
            QStandardItem *item = new Item::CppItem(Item::Enumerator);
            item->setForeground(Qt::darkMagenta);
            item->setData(rx.cap(1),Item::NameRole);
            item->setData("enum: " + it,Qt::ToolTipRole);
            item->setData( name.isEmpty() ? "int" : name, Item::PurifiedTypeRole);
            item->setEditable(false);
            objs.append( item);
        }
    }
}
예제 #10
0
InterceptWidget::InterceptWidget(IntercepSource * source, QWidget *parent) :
    QWidget(parent),
    source(source)
{
    currentBlockSource = NULL;
    currentGui = NULL;
    ui = new(std::nothrow) Ui::InterceptWidget;
    if (ui == NULL) {
        qFatal("Cannot allocate memory for Ui::InterceptWidget X{");
    }
    ui->setupUi(this);

    packetsTable = new(std::nothrow) QTableView(this);
    if (packetsTable == NULL) {
        qFatal("Cannot allocate memory for QTableView X{");
    }
    QAbstractItemModel *old = packetsTable->model();
    model = source->getModel();
    packetsTable->setModel(model);
    delete old;

    packetsTable->setSelectionMode(QAbstractItemView::ContiguousSelection);
    packetsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    packetsTable->verticalHeader()->setFont(RegularFont);
    packetsTable->horizontalHeader()->setFont(RegularFont);
    packetsTable->setColumnWidth(PayloadModel::TIMESPTAMP_COLUMN,TIMESTAMP_COLUMN_WIDTH);
    packetsTable->setColumnWidth(PayloadModel::DIRECTION_COLUMN,25);
    packetsTable->verticalHeader()->setDefaultSectionSize(20);
#if QT_VERSION >= 0x050000
    packetsTable->horizontalHeader()->setSectionsMovable( false );
#else
    packetsTable->horizontalHeader()->setMovable(true);
#endif
    connect(packetsTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), SLOT(onCurrentSelectedChanged(QModelIndex,QModelIndex)));
    ui->listLayout->addWidget(packetsTable);

    updateColumns();

    sourceChoices << CHOOSE_TEXT << UDP_EXTERNAL_SOURCE_TEXT << TCP_EXTERNAL_SOURCE_TEXT << RAW_TCP_SOURCE_TEXT;
    ui->blockSourceComboBox->addItems(sourceChoices);
    ui->blockSourceComboBox->setCurrentIndex(0);
    QStandardItem * item = qobject_cast<QStandardItemModel *>(ui->blockSourceComboBox->model())->item(0);
    item->setEnabled( false );
    item->setTextAlignment(Qt::AlignCenter);
    item->setBackground(Qt::darkGray);
    item->setForeground(Qt::white);

    connect(ui->blockSourceComboBox, SIGNAL(currentIndexChanged(QString)), SLOT(onSourceChanged(QString)));
}
예제 #11
0
void RxDev::fillItemModel_availableComponents(const QString compFile)
{
    int begin = compFile.lastIndexOf("/")+1;
    int end = compFile.lastIndexOf(".launch");
    QString subString = compFile.mid(begin,end-begin);

    QStandardItem *group = new QStandardItem(QString("%1").arg(subString));
    QStandardItem *path = new QStandardItem(QString("%1").arg(compFile));
    QBrush b;
    b.setColor(Qt::darkBlue);
    group->setForeground(b);
    group->appendRow(path);

    // append group as new row to the model. model takes the ownership of the item
            model_availableComponents->appendRow(group);
}
예제 #12
0
void TrackListView::updateColor()
{
    while(!m_colorRows.isEmpty())
    {
        int row = m_colorRows.takeFirst();
        QStandardItem *item = m_model->item(row);
        if(item)
        {
            //qDebug("TrackListView::updateColor: row: %d", row);
            m_model->blockSignals(true);
            item->setForeground(QColor(187, 191, 187));
            m_model->blockSignals(false);
        }
    }
    update();
}
예제 #13
0
/*!
    Log a message.

    If the module should determinated automaticly use the function
    log(const Level level, const QString &message, const QObject *sender) instead.

    \param level One of the message level identifiers, e.g., Warning
    \param message The message
    \param module The calling module
*/
void QLoggerModel::log(const Level level, const QString &message, const QString &module)
{
    if (message.isEmpty())
        return;

    const quint32 iLevel = static_cast<quint32>(level);
    const QBrush textColor(FOREGROUNDCOLORS[iLevel]);

    const QString strTime = QTime::currentTime().toString(*QLOGGERVIEW_STR_TIMEFORMAT);
    const QString strModule = module.isEmpty() ? tr(*QLOGGERVIEW_STR_UNKNOWN) : module;
    const QString strMsg = QString("%0 [%1] %2").arg(strTime).arg(strModule).arg(message);

    QStandardItem *item = new QStandardItem(_iconList.at(iLevel), strMsg);
    item->setForeground(textColor);

    appendRow(item);
}
예제 #14
0
void tst_QStandardItem::streamItem()
{
    QStandardItem item;
    
    item.setText(QLatin1String("text"));
    item.setToolTip(QLatin1String("toolTip"));
    item.setStatusTip(QLatin1String("statusTip"));
    item.setWhatsThis(QLatin1String("whatsThis"));
    item.setSizeHint(QSize(64, 48));
    item.setFont(QFont());
    item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    item.setBackground(QColor(Qt::blue));
    item.setForeground(QColor(Qt::green));
    item.setCheckState(Qt::PartiallyChecked);
    item.setAccessibleText(QLatin1String("accessibleText"));
    item.setAccessibleDescription(QLatin1String("accessibleDescription"));

    QByteArray ba;
    {
        QDataStream ds(&ba, QIODevice::WriteOnly);
        ds << item;
    }
    {
        QStandardItem streamedItem;
        QDataStream ds(&ba, QIODevice::ReadOnly);
        ds >> streamedItem;
        QCOMPARE(streamedItem.text(), item.text());
        QCOMPARE(streamedItem.toolTip(), item.toolTip());
        QCOMPARE(streamedItem.statusTip(), item.statusTip());
        QCOMPARE(streamedItem.whatsThis(), item.whatsThis());
        QCOMPARE(streamedItem.sizeHint(), item.sizeHint());
        QCOMPARE(streamedItem.font(), item.font());
        QCOMPARE(streamedItem.textAlignment(), item.textAlignment());
        QCOMPARE(streamedItem.background(), item.background());
        QCOMPARE(streamedItem.foreground(), item.foreground());
        QCOMPARE(streamedItem.checkState(), item.checkState());
        QCOMPARE(streamedItem.accessibleText(), item.accessibleText());
        QCOMPARE(streamedItem.accessibleDescription(), item.accessibleDescription());
        QCOMPARE(streamedItem.flags(), item.flags());
    }
}
예제 #15
0
void CodeEditor::select(QStandardItem *parent,const QStandardItem *sourceParent)
{
    for (int i=0; i<sourceParent->rowCount(); ++i)
    {
       QStandardItem *child = sourceParent->child(i);

       QStandardItem *item = child->QStandardItem::clone();
       item->setToolTip(child->toolTip());
       assert(item);

       QString text = child->data(Item::DescriptionRole).toStringList().join('\n');
       QStandardItem *desitem = new QStandardItem(text);
       desitem->setForeground(Qt::darkGreen);
       desitem->setEditable(false);

       parent->appendRow(QList<QStandardItem *>() << item << desitem);

       if(child->hasChildren())
           select(item,child);
    }
}
void QgsFieldConditionalFormatWidget::setPresets( QList<QgsConditionalStyle> styles )
{
  mPresets.clear();
  mPresetsModel->clear();
  Q_FOREACH ( const QgsConditionalStyle& style, styles )
  {
    if ( style.isValid() )
    {
      QStandardItem* item = new QStandardItem( "abc - 123" );
      if ( style.backgroundColor().isValid() )
        item->setBackground( style.backgroundColor() );
      if ( style.textColor().isValid() )
        item->setForeground( style.textColor() );
      if ( style.symbol() )
        item->setIcon( style.icon() );
      item->setFont( style.font() );
      mPresetsModel->appendRow( item );
      mPresets.append( style );
    }
  }
  mPresetsList->setCurrentIndex( 0 );
}
예제 #17
0
void SelectSiteDialog::initializeTable()
{
    model = new QStandardItemModel(importedSites.size(), 1, this);
    QStandardItem *item;

    QStringList verticalHeader;

    int row = 0;
    foreach(QSharedPointer<Site> site, importedSites)
    {
        verticalHeader.append(QString::number(row + 1));

        item = new QStandardItem(site.data()->siteDetails.Csc);
        item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
        item->setData(QVariant(QString::number(site.data()->siteDetails.SwpId)), DataType::SWP_ID);
        item->setCheckable(true);
        item->setTextAlignment(Qt::AlignJustify);
        item->setCheckState(Qt::Unchecked);
        item->setBackground(QColor(Qt::white));
        item->setForeground(QColor(Qt::black));
        model->setItem(row, 0, item);

        row++;
    }
예제 #18
0
void TransformsGui::buildSavedCombo()
{
    ui->savedComboBox->blockSignals(true);
    ui->savedComboBox->clear();
    int row = 0;
    // first inactive element
    ui->savedComboBox->addItem(QString("User's chains"));
    QStandardItem * item = qobject_cast<QStandardItemModel *>(ui->savedComboBox->model())->item( row );
    item->setEnabled( false );
    item->setTextAlignment(Qt::AlignCenter);
    item->setBackground(Qt::darkGray);
    item->setForeground(Qt::white);
    // then the rest
    QHash<QString, QString> hash = transformFactory->getSavedConfs();
    QStringList list = hash.keys();
    if (list.isEmpty()) {
        ui->savedComboBox->setEnabled(false);
    } else {
        ui->savedComboBox->addItems(list);
        ui->savedComboBox->setEnabled(true);
    }

    ui->savedComboBox->blockSignals(false);
}
void LandmarkRegistrationObjectWidget::UpdateUI()
{
    Q_ASSERT(m_registrationObject);
    vtkSmartPointer<LandmarkTransform> landmarkTransform = m_registrationObject->GetLandmarkTransform();
    double rms = landmarkTransform->GetFinalRMS();

    disconnect(m_model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(PointDataChanged(QStandardItem*)));
    int numberOfRows;
    while ((numberOfRows = m_model->rowCount()) > 0)
        m_model->takeRow(numberOfRows-1);
    QStringList names = m_registrationObject->GetPointNames();
    ui->rmsDisplayLabel->setText(QString::number(rms));
    QColor disabled("gray");
    QBrush brush(disabled);
    QString sourceCoords;
    QString targetCoords;
    vtkSmartPointer<PointsObject> source = m_registrationObject->GetSourcePoints();
    vtkSmartPointer<PointsObject> target = m_registrationObject->GetTargetPoints();
    double coords[3];
    int activePointsCount = 0;
    for (int idx = 0; idx < m_registrationObject->GetNumberOfPoints(); idx++)
    {
        m_model->insertRow(idx);
        m_model->setData(m_model->index(idx, 0), names.at(idx));
        source->GetPointCoordinates( idx, coords );
        sourceCoords = QString( "%1,%2,%3" ).arg(coords[0]).arg(coords[1]).arg(coords[2]);
        m_model->setData(m_model->index(idx, 1), sourceCoords);
        target->GetPointCoordinates( idx, coords );
        targetCoords = QString( "%1,%2,%3" ).arg(coords[0]).arg(coords[1]).arg(coords[2]);
        m_model->setData(m_model->index(idx, 2), targetCoords);
        double fre = 0, rms = 0;
        bool ok = landmarkTransform->GetFRE(activePointsCount, fre);
        bool ok1 = landmarkTransform->GetRMS(activePointsCount, rms);
        if ( m_registrationObject->GetPointEnabledStatus(idx) == 1 && ok && ok1 )
        {
            m_model->setData(m_model->index(idx, 3), QString::number((fre)));
            m_model->setData(m_model->index(idx, 4), QString::number((rms)));
            activePointsCount++;
        }
        else
        {
            m_model->setData(m_model->index(idx, 3), "n/a");
            m_model->setData(m_model->index(idx, 4), "n/a");
        }
        m_model->item(idx, 0)->setEditable(true);
        m_model->item(idx, 1)->setEditable(false);
        m_model->item(idx, 2)->setEditable(false);
        m_model->item(idx, 3)->setEditable(false);
        m_model->item(idx, 4)->setEditable(false);
        for (int j = 0; j < 2; j++)
            ui->tagTreeView->resizeColumnToContents(j);
        if (m_registrationObject->GetPointEnabledStatus(idx) != 1)
        {
            for (int j = 0; j < m_model->columnCount(); j++)
            {
                QStandardItem* item = m_model->item(idx,j);
                if (item)
                    item->setForeground(brush);
            }
        }
    }
    ui->tagSizeSpinBox->blockSignals(true);
    ui->tagSizeSpinBox->setValue((int)(m_registrationObject->GetSourcePoints()->Get3DRadius()));
    ui->tagSizeSpinBox->blockSignals(false);
    connect(m_model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(PointDataChanged(QStandardItem*)));
    if( m_registrationObject->GetNumberOfPoints() > 0 )
    {
        int selectedPointIndex = m_registrationObject->GetSourcePoints()->GetSelectedPointIndex();
        if( selectedPointIndex == PointsObject::InvalidPointIndex  || selectedPointIndex >= m_registrationObject->GetNumberOfPoints() )
            selectedPointIndex = 0;
        ui->tagTreeView->setCurrentIndex( m_model->index( selectedPointIndex, 0 ) );
    }
}
예제 #20
0
void tst_QStandardItem::getSetData()
{
    QStandardItem item;
    for (int x = 0; x < 2; ++x) {
        for (int i = 1; i <= 2; ++i) {
            QString text = QString("text %0").arg(i);
            item.setText(text);
            QCOMPARE(item.text(), text);
            
            QPixmap pixmap(32, 32);
            pixmap.fill((i == 1) ? Qt::red : Qt::green);
            QIcon icon(pixmap);
            item.setIcon(icon);
            QCOMPARE(item.icon(), icon);
            
            QString toolTip = QString("toolTip %0").arg(i);
            item.setToolTip(toolTip);
            QCOMPARE(item.toolTip(), toolTip);
            
            QString statusTip = QString("statusTip %0").arg(i);
            item.setStatusTip(statusTip);
            QCOMPARE(item.statusTip(), statusTip);
        
            QString whatsThis = QString("whatsThis %0").arg(i);
            item.setWhatsThis(whatsThis);
            QCOMPARE(item.whatsThis(), whatsThis);
            
            QSize sizeHint(64*i, 48*i);
            item.setSizeHint(sizeHint);
            QCOMPARE(item.sizeHint(), sizeHint);
            
            QFont font;
            item.setFont(font);
            QCOMPARE(item.font(), font);
        
            Qt::Alignment textAlignment((i == 1)
                                        ? Qt::AlignLeft|Qt::AlignVCenter
                                        : Qt::AlignRight);
            item.setTextAlignment(textAlignment);
            QCOMPARE(item.textAlignment(), textAlignment);
            
            QColor backgroundColor((i == 1) ? Qt::blue : Qt::yellow);
            item.setBackground(backgroundColor);
            QCOMPARE(item.background().color(), backgroundColor);
            
            QColor textColor((i == i) ? Qt::green : Qt::cyan);
            item.setForeground(textColor);
            QCOMPARE(item.foreground().color(), textColor);
            
            Qt::CheckState checkState((i == 1) ? Qt::PartiallyChecked : Qt::Checked);
            item.setCheckState(checkState);
            QCOMPARE(item.checkState(), checkState);
            
            QString accessibleText = QString("accessibleText %0").arg(i);
            item.setAccessibleText(accessibleText);
            QCOMPARE(item.accessibleText(), accessibleText);
            
            QString accessibleDescription = QString("accessibleDescription %0").arg(i);
            item.setAccessibleDescription(accessibleDescription);
            QCOMPARE(item.accessibleDescription(), accessibleDescription);
            
            QCOMPARE(item.text(), text);
            QCOMPARE(item.icon(), icon);
            QCOMPARE(item.toolTip(), toolTip);
            QCOMPARE(item.statusTip(), statusTip);
            QCOMPARE(item.whatsThis(), whatsThis);
            QCOMPARE(item.sizeHint(), sizeHint);
            QCOMPARE(item.font(), font);
            QCOMPARE(item.textAlignment(), textAlignment);
            QCOMPARE(item.background().color(), backgroundColor);
            QCOMPARE(item.foreground().color(), textColor);
            QCOMPARE(item.checkState(), checkState);
            QCOMPARE(item.accessibleText(), accessibleText);
            QCOMPARE(item.accessibleDescription(), accessibleDescription);
            
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::DisplayRole)), text);
            QCOMPARE(qvariant_cast<QIcon>(item.data(Qt::DecorationRole)), icon);
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::ToolTipRole)), toolTip);
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::StatusTipRole)), statusTip);
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::WhatsThisRole)), whatsThis);
            QCOMPARE(qvariant_cast<QSize>(item.data(Qt::SizeHintRole)), sizeHint);
            QCOMPARE(qvariant_cast<QFont>(item.data(Qt::FontRole)), font);
            QCOMPARE(qvariant_cast<int>(item.data(Qt::TextAlignmentRole)), int(textAlignment));
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundColorRole)), QBrush(backgroundColor));
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundRole)), QBrush(backgroundColor));
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::TextColorRole)), QBrush(textColor));
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::ForegroundRole)), QBrush(textColor));
            QCOMPARE(qvariant_cast<int>(item.data(Qt::CheckStateRole)), int(checkState));
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::AccessibleTextRole)), accessibleText);
            QCOMPARE(qvariant_cast<QString>(item.data(Qt::AccessibleDescriptionRole)), accessibleDescription);

            item.setBackground(pixmap);
            QCOMPARE(item.background().texture(), pixmap);
            QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundRole)).texture(), pixmap);
        }
        item.setData(QVariant(), Qt::DisplayRole);
        item.setData(QVariant(), Qt::DecorationRole);
        item.setData(QVariant(), Qt::ToolTipRole);
        item.setData(QVariant(), Qt::StatusTipRole);
        item.setData(QVariant(), Qt::WhatsThisRole);
        item.setData(QVariant(), Qt::SizeHintRole);
        item.setData(QVariant(), Qt::FontRole);
        item.setData(QVariant(), Qt::TextAlignmentRole);
        item.setData(QVariant(), Qt::BackgroundRole);
        item.setData(QVariant(), Qt::ForegroundRole);
        item.setData(QVariant(), Qt::CheckStateRole);
        item.setData(QVariant(), Qt::AccessibleTextRole);
        item.setData(QVariant(), Qt::AccessibleDescriptionRole);
        
        QCOMPARE(item.data(Qt::DisplayRole), QVariant());
        QCOMPARE(item.data(Qt::DecorationRole), QVariant());
        QCOMPARE(item.data(Qt::ToolTipRole), QVariant());
        QCOMPARE(item.data(Qt::StatusTipRole), QVariant());
        QCOMPARE(item.data(Qt::WhatsThisRole), QVariant());
        QCOMPARE(item.data(Qt::SizeHintRole), QVariant());
        QCOMPARE(item.data(Qt::FontRole), QVariant());
        QCOMPARE(item.data(Qt::TextAlignmentRole), QVariant());
        QCOMPARE(item.data(Qt::BackgroundColorRole), QVariant());
        QCOMPARE(item.data(Qt::BackgroundRole), QVariant());
        QCOMPARE(item.data(Qt::TextColorRole), QVariant());
        QCOMPARE(item.data(Qt::ForegroundRole), QVariant());
        QCOMPARE(item.data(Qt::CheckStateRole), QVariant());
        QCOMPARE(item.data(Qt::AccessibleTextRole), QVariant());
        QCOMPARE(item.data(Qt::AccessibleDescriptionRole), QVariant());
    }
}
예제 #21
0
void RxDev::fillItemModel_availableNodes(QString nodeFile, Specfile &node){

    QBrush b;

    QStandardItem *group = new QStandardItem(QString("%1").arg(QString::fromStdString(node.type)));

    QStandardItem *child;
    QStandardItem *item;
        QStandardItem *item2;
    child = new QStandardItem(QString("path"));
    item = new QStandardItem(QString("%1").arg(nodeFile));
    b.setColor(Qt::blue);
    child->setForeground(b);
    b.setColor(Qt::black);
    item->setForeground(b);
    child->appendRow(item);
    // the appendRow function appends the child as new row
    group->appendRow(child);


    child = new QStandardItem(QString("type"));
    item = new QStandardItem(QString("%1").arg(QString::fromStdString(node.type)));
    child->appendRow(item);
    child = new QStandardItem(QString("package"));
    item = new QStandardItem(QString("%1").arg(QString::fromStdString(node.package)));
    b.setColor(Qt::blue);
    child->setForeground(b);
    child->appendRow(item);
    group->appendRow(child);

    child = new QStandardItem(QString("subscriptions"));
     for(std::list<Topic_Type>::iterator iter=node.subscriptions.begin();iter != node.subscriptions.end();iter++ )
     {
         item = new QStandardItem(QString::fromStdString(Topic_Type(*iter).topic));
         item2 = new QStandardItem(QString::fromStdString(Topic_Type(*iter).topictype));
         b.setColor(Qt::red);
         item->setForeground(b);
         b.setColor(Qt::gray);
         item2->setForeground(b);
         item->appendRow(item2);
         child->appendRow(item);
     }
     b.setColor(Qt::blue);
     child->setForeground(b);


    group->appendRow(child);

    child = new QStandardItem(QString("publications"));
    for(std::list<Topic_Type>::iterator iter=node.publications.begin();iter != node.publications.end();iter++ )
    {
        item = new QStandardItem(QString::fromStdString(Topic_Type(*iter).topic));
        item2 = new QStandardItem(QString::fromStdString(Topic_Type(*iter).topictype));
        b.setColor(Qt::red);
        item->setForeground(b);
        b.setColor(Qt::gray);
        item2->setForeground(b);
        item->appendRow(item2);
        child->appendRow(item);
    }
    b.setColor(Qt::blue);
    child->setForeground(b);


    group->appendRow(child);

    child = new QStandardItem(QString("services"));
    for(std::list<Topic_Type>::iterator iter=node.services.begin();iter != node.services.end();iter++ )
    {
        item = new QStandardItem(QString::fromStdString(Topic_Type(*iter).topic));
        item2 = new QStandardItem(QString::fromStdString(Topic_Type(*iter).topictype));
        b.setColor(Qt::red);
        item->setForeground(b);
        b.setColor(Qt::gray);
        item2->setForeground(b);
        item->appendRow(item2);
        child->appendRow(item);
    }
    b.setColor(Qt::blue);
    child->setForeground(b);

    group->appendRow(child);

    child = new QStandardItem(QString("parameters"));
    for(std::list<Name_Type_Default>::iterator iter=node.parameters.begin();iter != node.parameters.end();iter++ )
    {
        item = new QStandardItem(QString::fromStdString(Name_Type_Default(*iter).paramName));
        item2 = new QStandardItem("type: "+QString::fromStdString(Name_Type_Default(*iter).paramType));
        b.setColor(Qt::red);
        item->setForeground(b);
        b.setColor(Qt::gray);
        item2->setForeground(b);
        item->appendRow(item2);
        item2 = new QStandardItem("default: "+QString::fromStdString(Name_Type_Default(*iter).paramDefault));
        b.setColor(Qt::black);
        item2->setForeground(b);
        item->appendRow(item2);
        item2 = new QStandardItem("range: "+QString::fromStdString(Name_Type_Default(*iter).paramRange));
        b.setColor(Qt::gray);
        item2->setForeground(b);
        item->appendRow(item2);
        child->appendRow(item);
    }
    b.setColor(Qt::blue);
    child->setForeground(b);

    group->appendRow(child);
    b.setColor(Qt::darkBlue);
    QFont font;
    font.setBold(true);
    group->setFont(font);
    group->setForeground(b);

    // append group as new row to the model. model takes the ownership of the item
    if (!(node.type.length()==0) && !(node.package.length()==0))
        model_availableNodes->appendRow(group);
        ui->treeView_availableNodes->setAutoFillBackground(true);
}
예제 #22
0
/** Constructor */
BlogsDialog::BlogsDialog(QWidget *parent)
: MainPage (parent)
{
  	/* Invoke the Qt Designer generated object setup routine */
  	setupUi(this);

  	connect(actionCreate_Blog, SIGNAL(triggered()), this, SLOT(createBlog()));
  	connect(postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
  	connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeBlog ( void ) ) );
  	connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeBlog ( void ) ) );
  	
    connect(treeView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(selectBlog(const QModelIndex &)));
    connect(treeView, SIGNAL(activated(const QModelIndex &)), this, SLOT(toggleSelection(const QModelIndex &)));
    connect(treeView, SIGNAL(customContextMenuRequested( QPoint ) ), this, SLOT( blogListCustomPopupMenu( QPoint ) ) );

  	mBlogId = "";
  	mPeerId = rsPeers->getOwnId(); // add your id

    model = new QStandardItemModel(0, 2, this);
    model->setHeaderData(0, Qt::Horizontal, tr("Name"), Qt::DisplayRole);
    model->setHeaderData(1, Qt::Horizontal, tr("ID"), Qt::DisplayRole);

    treeView->setModel(model);
    treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);

    treeView->setItemDelegate(new ChanGroupDelegate());

    // hide header and id column
    treeView->setHeaderHidden(true);
    treeView->hideColumn(1);
    
    itemFont = QFont("ARIAL", 10);
    itemFont.setBold(true);
	
    QStandardItem *OwnBlogs = new QStandardItem(tr("My Blogs"));
    OwnBlogs->setForeground(QBrush(QColor(79, 79, 79)));
    OwnBlogs->setFont(itemFont);
    
    QStandardItem *SubscribedBlogs = new QStandardItem(tr("Subscribed Blogs"));
    SubscribedBlogs->setForeground(QBrush(QColor(79, 79, 79)));
    SubscribedBlogs->setFont(itemFont);

    QStandardItem *PopularBlogs = new QStandardItem(tr("Popular Blogs"));
    PopularBlogs->setForeground(QBrush(QColor(79, 79, 79)));
    PopularBlogs->setFont(itemFont);

    QStandardItem *OtherBlogs = new QStandardItem(tr("Other Blogs"));
    OtherBlogs->setForeground(QBrush(QColor(79, 79, 79)));        
    OtherBlogs->setFont(itemFont);

    model->appendRow(OwnBlogs);
    model->appendRow(SubscribedBlogs);
    model->appendRow(PopularBlogs);
    model->appendRow(OtherBlogs);

    //added from ahead
    updateBlogList();

    mBlogFont = QFont("MS SANS SERIF", 22);
    nameLabel->setFont(mBlogFont);    
    nameLabel->setMinimumWidth(20);
		   
    QMenu *blogmenu = new QMenu();
    blogmenu->addAction(actionCreate_Blog); 
    blogmenu->addSeparator();
    blogpushButton->setMenu(blogmenu);
	
    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
    timer->start(1000);
}
예제 #23
0
void TrackListView::contextPopupMenu(QPoint pos)/*{{{*/
{
    QModelIndex mindex = m_table->indexAt(pos);
    if(!mindex.isValid())
        return;
    //int row = mindex.row();
    QStandardItem* item = m_model->itemFromIndex(mindex);
    if(item)
    {
        m_selectedIndex = item->row();
        //Make it works even if you rightclick on the checkbox
        QString trackName = item->data(TrackNameRole).toString();
        int type = item->data(TrackRole).toInt();
        MidiTrack* track = song->findTrack(trackName);
        if(!track || !m_editor)
            return;
        QMenu* p = new QMenu(this);
        QString title(tr("Part Color"));
        int index = track->getDefaultPartColor();
        Part* npart = 0;
        if(type == 1)
            title = QString(tr("Default Part Color"));
        else
        {
            PartList* list = track->parts();
            int sn = item->data(PartRole).toInt();
            unsigned tick = item->data(TickRole).toInt();
            npart = list->find(tick, sn);
            if(npart)
                index = npart->colorIndex();
        }
        QMenu* colorPopup = p->addMenu(title);

        QMenu* colorSub;
        for (int i = 0; i < NUM_PARTCOLORS; ++i)
        {
            QString colorname(config.partColorNames[i]);
            if(colorname.contains("menu:", Qt::CaseSensitive))
            {
                colorSub = colorPopup->addMenu(colorname.replace("menu:", ""));
            }
            else
            {
                if(index == i)
                {
                    colorname = QString(config.partColorNames[i]);
                    colorPopup->setIcon(partColorIconsSelected.at(i));
                    colorPopup->setTitle(colorSub->title()+": "+colorname);

                    colorname = QString("* "+config.partColorNames[i]);
                    QAction *act_color = colorSub->addAction(partColorIconsSelected.at(i), colorname);
                    act_color->setData(20 + i);
                }
                else
                {
                    colorname = QString("     "+config.partColorNames[i]);
                    QAction *act_color = colorSub->addAction(partColorIcons.at(i), colorname);
                    act_color->setData(20 + i);
                }
            }
        }
        p->addAction(tr("Add Part"))->setData(1);
        p->addAction(tr("Add Part and Select"))->setData(2);
        if(type == 2)
            p->addAction(tr("Delete Part"))->setData(3);

        QAction* act = p->exec(QCursor::pos());
        if (act)
        {
            int selection = act->data().toInt();
            switch(selection)
            {
                case 1:
                {
                    CItem *citem = los->composer->addCanvasPart(track);
                    if(citem)
                    {
                        Part* mp = citem->part();
                        populateTable();//update check state
                        //Select and scroll to the added part
                        if(mp)
                        {
                            int psn = mp->sn();
                            for(int i = 0; i < m_model->rowCount(); ++i)
                            {
                                QStandardItem* item = m_model->item(i, 0);
                                if(item)
                                {
                                    int type = item->data(TrackRole).toInt();
                                    if(type == 1)
                                    {//TrackMode
                                        continue;
                                    }
                                    else
                                    {//PartMode
                                        int sn = item->data(PartRole).toInt();
                                        if(psn == sn)
                                        {
                                            //m_tempColor = item->foreground();
                                            m_model->blockSignals(true);
                                            item->setForeground(QColor(99, 36, 36));
                                            m_model->blockSignals(false);
                                            update();
                                            m_selectedIndex = item->row();
                                            m_table->selectRow(m_selectedIndex);
                                            m_table->scrollTo(m_model->index(m_selectedIndex, 0));
                                            m_colorRows.append(m_selectedIndex);
                                            QTimer::singleShot(350, this, SLOT(updateColor()));
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                break;
                case 2:
                {
                    CItem* citem = los->composer->addCanvasPart(track);
                    if(citem)
                    {
                        Part* mp = citem->part();
                        if(mp)
                        {
                            m_editor->addPart(mp);
                            populateTable();//update check state
                            updatePartSelection(mp);
                        }
                    }
                    break;
                }
                case 3:
                {
                    if(npart)
                    {
                        audio->msgRemovePart(npart);
                        populateTable();//update check state
                        scrollPos = pos;
                        /*if(row < m_model->rowCount())
                        {
                            QModelIndex rowIndex = m_table->indexAt(pos);
                            m_table->scrollTo(rowIndex, QAbstractItemView::PositionAtTop);
                        }*/
                    }
                    break;
                }
                case 20 ... NUM_PARTCOLORS + 20:
                {
                    int curColorIndex = selection - 20;
                    if(npart)
                    {
                        npart->setColorIndex(curColorIndex);
                        song->update(SC_PART_COLOR_MODIFIED);
                    }
                    else
                    {
                        track->setDefaultPartColor(curColorIndex);
                    }
                    populateTable();//update check state
                    break;
                }
            }
        }
        delete p;
    }
}/*}}}*/
예제 #24
0
void TrackListView::populateTable()/*{{{*/
{
    if(debugMsg)
        printf("TrackListView::populateTable\n");
    QScrollBar *bar = m_table->verticalScrollBar();
    int barPos = 0;
    if(bar)
        barPos = bar->sliderPosition();

    m_model->clear();
    for(iMidiTrack i = song->artracks()->begin(); i != song->artracks()->end(); ++i)
    {
        MidiTrack* track = (MidiTrack*)(*i);
        PartList* pl = track->parts();
        if(m_displayRole == PartRole && pl->empty())
        {
            continue;
        }

        QStandardItem* trackName = new QStandardItem();
        trackName->setForeground(QBrush(QColor(205,209,205)));
        trackName->setBackground(QBrush(QColor(20,20,20)));
        trackName->setFont(QFont("fixed-width", 10, QFont::Bold));
        trackName->setText(track->name());
        trackName->setCheckable(true);
        trackName->setCheckState(m_selectedTracks.contains(track->id()) ? Qt::Checked : Qt::Unchecked);

        trackName->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        trackName->setData(1, TrackRole);
        trackName->setData(track->name(), TrackNameRole);
        trackName->setData(track->id(), TrackIdRole);
        trackName->setEditable(true);
        m_model->appendRow(trackName);

        for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
        {
            Part* part = ip->second;
            QStandardItem* partName = new QStandardItem();
            partName->setFont(QFont("fixed-width", 9, QFont::Bold));
            partName->setText(part->name());
            partName->setData(part->sn(), PartRole);
            partName->setData(2, TrackRole);
            partName->setData(track->name(), TrackNameRole);
            partName->setData(part->name(), PartNameRole);
            partName->setData(part->tick(), TickRole);
            partName->setData(track->id(), TrackIdRole);
            partName->setEditable(true);
            partName->setCheckable(true);
            partName->setCheckState(m_editor->hasPart(part->sn()) ? Qt::Checked : Qt::Unchecked);

            if(!partColorIcons.isEmpty() && part->colorIndex() < partColorIcons.size())
                partName->setIcon(partColorIcons.at(part->colorIndex()));

            m_model->appendRow(partName);
        }
    }
    m_model->setHorizontalHeaderLabels(m_headers);
    if(m_selectedIndex < m_model->rowCount())
    {
        m_table->selectRow(m_selectedIndex);
        m_table->scrollTo(m_model->index(m_selectedIndex, 0));
    }
    if(bar)
        bar->setSliderPosition(barPos);
}/*}}}*/