Exemplo n.º 1
0
void VegetationWidget::buildList()
{
	QStringList extList;
	extList << ".png" << ".tga" << ".osgb";
	std::string plantDir = g_SystemContext._workContextDir;
	plantDir.append(CONTEXT_DIR);
	plantDir.append("/Plant/");
	QString grassDir = chineseTextUTF8ToQString(plantDir + "Grass");
	QStringList returnList;
	findAllFilesByExt(grassDir, extList, returnList);
	QStandardItemModel* grassModel = qobject_cast<QStandardItemModel*>(_grassListView->model());
	grassModel->clear();
	for (int i = 0; i < returnList.size(); ++i)
	{
		QFileInfo fileInfo = returnList.at(i);
		QStandardItem* newItem = new QStandardItem(fileInfo.fileName());
		setupIcon(newItem, "grass");
		newItem->setCheckable(true);
		grassModel->appendRow(newItem);
	}
	QString treeDir = chineseTextUTF8ToQString(plantDir + "Tree");
	returnList.clear();
	findAllFilesByExt(treeDir, extList, returnList);
	QStandardItemModel* treeModel = qobject_cast<QStandardItemModel*>(_treeListView->model());
	treeModel->clear();
	for (int i = 0; i < returnList.size(); ++i)
	{
		QFileInfo fileInfo = returnList.at(i);
		QStandardItem* newItem = new QStandardItem(fileInfo.fileName());
		setupIcon(newItem, "tree");
		newItem->setCheckable(true);
		treeModel->appendRow(newItem);
	}
}
Exemplo n.º 2
0
void TreeView::showExample(void)
{
    this->setColumn(1, 100,QStringLiteral("GPRS_STRUCT"));
    for(int i = 0; i < 10; ++i)
    {
        QList<QStandardItem *>  leve0;
        QStandardItem * item = new QStandardItem(QString("GRPS_%0").arg(i));
        item->setCheckable(1);//使能复选框
        item->setIcon(QIcon(":/image/Aqua Ball.ico"));
        leve0.append(item);

        mode->appendRow(leve0);

        for(int j = 0; j < 5; ++j)
        {
            QList<QStandardItem *> leve1;
            QStandardItem * item = new QStandardItem(QString("Sensor_%0").arg(j));
            item->setCheckable(1);//使能复选框
            item->setIcon(QIcon(":/image/Aqua Ball Green.ico"));
            leve1.append(item);
         /*   for(int i = 1; i < 4; ++i)
            {
                QStandardItem * item = new QStandardItem(QString("state_%0").arg(i));
                leve1.append(item);
            }*/
            leve0.at(0)->appendRow(leve1);
        }

    }

   // ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);//设置多选
    this->setEditTriggers(0);//取消双击修改
   this->setContextMenuPolicy(Qt::CustomContextMenu);//设置treeView右键单击产生相应信号,并设置连接
}
Exemplo n.º 3
0
// Переключение режима отображения:
// checkable - с чек-боксами.
void qCheckboxFilterModel::setShowCheckboxes(bool checkable)
{
  ShowCheckboxes = checkable;

  if(checkable)
  {
    for(int r = 0; r < srcModel.rowCount(); ++r)
    {
      QStandardItem* item = actualSrcItem(r);
      QString id = getSrcId(r);

      item->setCheckable(true);
      item->setData(VisibleItems[id]? Qt::Checked:Qt::Unchecked, Qt::CheckStateRole);
    }
  }
  else
  {
    VisibleItems.clear();

    for(int r = 0; r < srcModel.rowCount(); ++r)
    {
      QStandardItem* item = actualSrcItem(r);
      QString id = getSrcId(r);

      bool checked = (item->data(Qt::CheckStateRole).toInt() == Qt::Checked);
      VisibleItems[id] = checked;

      item->setCheckable(false);
      item->setData(QVariant(), Qt::CheckStateRole);
    }
  }

  invalidate();
}
  QStandardItem* getColumnItem(QStandardItem* parent, QString name, T& proxy)
  {
    QStandardItem* item = NULL;
    QList<QStandardItem*> items = findChildItems(parent, name);
    if (items.count() == 0)
    {
      // Create a new item because we did not find this item already
      item = new QStandardItem(proxy.name);
      item->setCheckState( (proxy.flag == 2 ? Qt::Checked : Qt::Unchecked) );
      item->setCheckable(true);
      parent->appendRow(item);
    }
    else if (items.count() > 1)
    {
      item = NULL;
    }
    else
    {
      item = items.at(0);
      item->setCheckState( (proxy.flag == 2 ? Qt::Checked : Qt::Unchecked) );
      item->setCheckable(true);
    }

    return item;
  }
Exemplo n.º 5
0
void GlobalSettingsConfig::populateInputs()/*{{{*/
{
    m_inputsModel->clear();
    QStringList alsaList;
    QStringList jackList;
    if(gInputList.size())
    {
        //Select the rows
        for(int i = 0; i < gInputList.size(); ++i)
        {
            QPair<int, QString> input = gInputList.at(i);
            if(input.first == MidiDevice::JACK_MIDI)
                jackList.append(input.second);
            else
                alsaList.append(input.second);
        }
    }
    for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
    {
        if ((*i)->deviceType() == MidiDevice::ALSA_MIDI)
        {
            if ((*i)->rwFlags() & 0x2)
            {
                QStandardItem* item = new QStandardItem(QString((*i)->name()).append(" (ALSA)"));
                item->setData((*i)->name(), Qt::UserRole+1);
                item->setData(MidiDevice::ALSA_MIDI, Qt::UserRole+2);
                item->setEditable(false);
                item->setCheckable(true);
                if(alsaList.contains((*i)->name()))
                    item->setCheckState(Qt::Checked);
                m_inputsModel->appendRow(item);
            }
        }
    }
    if(audioDevice->deviceType() != AudioDevice::JACK_AUDIO)
        return;
    std::list<QString> sl = audioDevice->outputPorts(true, false);//No aliases
    for (std::list<QString>::iterator ip = sl.begin(); ip != sl.end(); ++ip)
    {
        QStandardItem* item = new QStandardItem(QString(*ip).append(" (JACK)"));
        item->setData(*ip, Qt::UserRole+1);
        item->setData(MidiDevice::JACK_MIDI, Qt::UserRole+2);
        item->setEditable(false);
        item->setCheckable(true);
        if(jackList.contains(*ip))
            item->setCheckState(Qt::Checked);
        m_inputsModel->appendRow(item);
    }
}/*}}}*/
Exemplo n.º 6
0
void WidgetBox::appendItem(const QString& text, QStandardItem* parent)
{
	QStandardItem *item = new QStandardItem(text);
	item->setEditable(false);
	item->setCheckable(true);
	parent->appendRow(item);
}
Exemplo n.º 7
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);
    }
}
Exemplo n.º 8
0
void CComDlg::fillList()
//////////////////////////
{
  QStandardItemModel *model = (QStandardItemModel *)ui->listView->model();

  model->removeRows(0, model->rowCount());

  setCursor(Qt::WaitCursor);
  QApplication::processEvents();

  for (int i = 0; i < tComets.count(); i++)
  {
    comet_t *a = &tComets[i];
    QStandardItem *item = new QStandardItem;

    item->setText(a->name);
    item->setCheckable(true);
    item->setCheckState(a->selected ? Qt::Checked : Qt::Unchecked);
    item->setEditable(false);
    model->appendRow(item);

    if ((i % 10000) == 0)
      QApplication::processEvents();
  }

  setCursor(Qt::ArrowCursor);
}
Exemplo n.º 9
0
/////////////////////////////////////////
// add new item
void CComDlg::on_pushButton_6_clicked()
/////////////////////////////////////////
{
  comet_t a;

  CComEdit dlg(this, true, &a);

  if (dlg.exec() == DL_OK)
  {
    if (a.perihelionDate < minJD) minJD = a.perihelionDate;
    if (a.perihelionDate > maxJD) maxJD = a.perihelionDate;

    QStandardItemModel *model = (QStandardItemModel *)ui->listView->model();
    QStandardItem      *item = new QStandardItem;

    a.selected = true;

    item->setText(a.name);
    item->setCheckable(true);
    item->setCheckState(a.selected ? Qt::Checked : Qt::Unchecked);
    item->setEditable(false);
    model->appendRow(item);
    tComets.append(a);
  }
}
Exemplo n.º 10
0
void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
{
    QStandardItemModel model(3, 1);
    for (int i = 0; i < 3; ++i) {
        QStandardItem *item = new QStandardItem(QLatin1String("Item ") + QString::number(i));
        item->setCheckable(true);
        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
        model.setItem(i, item);
    }
    QTableView view;
    view.setModel(&model);
    view.setItemDelegate(new TestItemDelegate);
    view.show();
    view.selectAll();
    QVERIFY(QTest::qWaitForWindowExposed(&view));
    QStyleOptionViewItem option;
    option.rect = view.visualRect(model.index(0, 0));
    // mimic QStyledItemDelegate::initStyleOption logic
    option.features = QStyleOptionViewItem::HasDisplay | QStyleOptionViewItem::HasCheckIndicator;
    option.checkState = Qt::CheckState(model.index(0, 0).data(Qt::CheckStateRole).toInt());
    const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
    QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center()
                 + QPoint(checkMargin, 0);
    QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pos);
    QTRY_VERIFY(view.selectionModel()->isColumnSelected(0, QModelIndex()));
    QCOMPARE(model.item(0)->checkState(), Qt::Checked);
}
Exemplo n.º 11
0
	void ShowConfigDialog::reloadSettings ()
	{
		QSettings settings (QCoreApplication::organizationName (),
				QCoreApplication::applicationName () + "_Sidebar");
		settings.beginGroup (Context_);
		const int size = settings.beginReadArray ("Actions");

		for (int i = 0; i < size; ++i)
		{
			settings.setArrayIndex (i);

			const auto& icon = settings.value ("Icon").value<QIcon> ();
			QStandardItem *item = new QStandardItem (icon,
					settings.value ("Text").toString ());
			item->setCheckState (settings.value ("Enabled").toBool () ?
						Qt::Checked :
						Qt::Unchecked);
			item->setToolTip (settings.value ("Tooltip").toString ());
			item->setData (settings.value ("ID"), Roles::ActionID);
			item->setCheckable (true);
			item->setEditable (false);
			Model_->appendRow (item);
		}

		settings.endArray ();
		settings.endGroup ();
	}
void ImageContainerWidget::addImage(const cv::Mat& image)
{
   qDebug() << "saving image";
   // push back image towards container
   _images.push_back(image);

   // save image to file
   QString filename;
   filename = "cali_images/image_" + QString::number(_images.size()) + ".png";
   cv::imwrite(filename.toStdString(), image);


   QStandardItemModel *model = static_cast<QStandardItemModel*>(_ui->tableView->model());

   QStandardItem* item       = new QStandardItem(filename);
   item->setCheckable(true);
   item->setCheckState(Qt::Checked);
   model->setItem(_images.size(), 0, item);

   for(unsigned int i=0 ; i<model->rowCount() ; i++)
   {
      QStandardItem* itemToCheck = model->item(i);
   }

}
Exemplo n.º 13
0
void PluginDialog::parsePluginNode(QDomNode node)
{
    QString name = node.firstChildElement("name").text();
    QString shortname = node.firstChildElement("shortname").text();
    QString iconUrl = node.firstChildElement("icon").text();
    QString category = node.firstChildElement("category").text();
    QString downloadUrl = node.firstChildElement("download").text();
    QString version = node.firstChildElement("version").text();
    QIcon icon = NetworkUtils::getIconFromUrl(QUrl(iconUrl));

    QList<QStandardItem *> rowItems;
    QStandardItem* pluginItem = new QStandardItem(icon, name);
    pluginItem->setData(shortname, Qt::UserRole);
    pluginItem->setData(downloadUrl, Qt::UserRole + 1);
    pluginItem->setData(version, Qt::UserRole + 2);
    rowItems << pluginItem;
    QStandardItem* enableItem = new QStandardItem("");
    enableItem->setCheckable(true);
    if(pluginManager->isInstalled(shortname))
    {
        enableItem->setCheckState(Qt::Checked);
    }
    rowItems << enableItem;
    if(category != "local")
    {
        categoryOnline->appendRow(rowItems);
    }else
    {
        categoryLocal->appendRow(rowItems);
    }
}
Exemplo n.º 14
0
void TreeView::showExample2(void)
{
    this->setColumn(4, 100, QStringLiteral("Abnormal sensor"), QStringLiteral("state"));

    for(int i = 0; i < 10; ++i)
    {
        QList<QStandardItem *>  leve2;
        QStandardItem * item = new QStandardItem(QString("GRPS_%0").arg(i));
        item->setCheckable(1);//使能复选框
        item->setIcon(QIcon(":/image/Aqua Ball Red.ico"));
        item->setText(QString("%0").arg(i));
        leve2.append(item);
        for(int i = 1; i < 4; ++i)
       {
           QStandardItem * item = new QStandardItem(QString("state_%0").arg(i));
           leve2.append(item);
       }

        mode->appendRow(leve2);

    }

   // ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);//设置多选
    this->setEditTriggers(0);//取消双击修改
   this->setContextMenuPolicy(Qt::CustomContextMenu);//设置treeView右键单击产生相应信号,并设置连接
}
Exemplo n.º 15
0
bool FeedModel::initFromRPC(QVariant *resp)
{
    QList<QVariant> elements(resp->toList());

   for (int i = 0; i < elements.size(); ++i) {
       // parse element
       QMap<QString, QVariant> tags = elements[i].toMap();
       QString rssTitle;
       QString imageUrl;
       int rssId;

       rssTitle = tags.value("title").toString();
       rssId = tags.value("iid").toInt();
       imageUrl = tags.value("image").toString();

       QStandardItem *item = new QStandardItem(rssTitle);
       item->setCheckable( true );
       if(!imageUrl.isEmpty()) {
           ResourceManager *rm = static_cast<NewsApplication*>(qApp)->getRM();
       }

       item->setData(rssId);

      // m_root->appendRow(item);
   }
    return true;
}
Exemplo n.º 16
0
void TreeView::addRoot(QString rootName)
{
        QStandardItem * item = new QStandardItem(rootName);
        item->setCheckable(1);
        item->setIcon(QIcon(":/image/Aqua Ball.ico"));
        mode->appendRow(item);
}
Exemplo n.º 17
0
void QgsOSMExportDialog::onLoadTags()
{
  if ( !openDatabase() )
    return;

  QApplication::setOverrideCursor( Qt::WaitCursor );

  QList<QgsOSMTagCountPair> pairs = mDatabase->usedTags( !radPoints->isChecked() );
  mDatabase->close();

  mTagsModel->setColumnCount( 3 );
  mTagsModel->setRowCount( pairs.count() );

  for ( int i = 0; i < pairs.count(); ++i )
  {
    const QgsOSMTagCountPair& p = pairs[i];
    QStandardItem* item = new QStandardItem( p.first );
    item->setCheckable( true );
    mTagsModel->setItem( i, 0, item );

    QStandardItem* item2 = new QStandardItem();
    item2->setData( p.second, Qt::DisplayRole );
    mTagsModel->setItem( i, 1, item2 );

    QStandardItem* item3 = new QStandardItem();
    item3->setData( "Not null", Qt::DisplayRole );
    item3->setCheckable( true );
    mTagsModel->setItem( i, 2, item3 );
  }

  viewTags->resizeColumnToContents( 0 );
  viewTags->sortByColumn( 1, Qt::DescendingOrder );

  QApplication::restoreOverrideCursor();
}
Exemplo n.º 18
0
void TreeView::insertNode(int rootID, int nodeID, QString nodeName)
{
        QStandardItem * item = new QStandardItem(nodeName);
        item->setCheckable(1);//使能复选框
        item->setIcon(QIcon(":/image/Aqua Ball Green.ico"));
        mode->item(rootID-1)->insertRow(nodeID, item);
}
Exemplo n.º 19
0
void TreeView::addNode(void)
{
    QModelIndex index = currentIndex();

    if(index.parent().row() == -1)
    {
        bool isOK;

        QString text = QInputDialog::getText(NULL, "Input Dialog",
                                                           "Please input the node name",
                                                           QLineEdit::Normal,
                                                           "sensor_",
                                                            &isOK);
        if(isOK)
        {
            QStandardItem * item = new QStandardItem(text);
            item->setCheckable(1);//使能复选框
            item->setIcon(QIcon(":/image/Aqua Ball Green.ico"));
            mode->item(index.row())->appendRow(item);


        }


    }
}
Exemplo n.º 20
0
QStandardItem *GoodsTVStandardItemModel::createCheckedItem() {
    QStandardItem* item = new QStandardItem(true);
    item->setCheckable(true);
    item->setCheckState(Qt::Unchecked);
    item->setEditable(false);
    return item;
}
Exemplo n.º 21
0
void PluginsDialog::appendInfo(const LiteApi::PluginInfo *info)
{
    if (!info) {
        return;
    }
    QList<QStandardItem*> items;
    items.append(new QStandardItem(info->name()));
    QStandardItem *load = new QStandardItem();
    load->setCheckable(true);
    load->setData(info->id());
    if (info->isMustLoad()) {
        load->setEnabled(false);
    }
    bool b = m_liteApp->settings()->value(QString("liteapp/%1_load").arg(info->id()),true).toBool();
    if (b) {
        load->setCheckState(Qt::Checked);
    } else {
        load->setCheckState(Qt::Unchecked);
    }
    items.append(load);
    items.append(new QStandardItem(info->info()));
    items.append(new QStandardItem(info->author()));
    items.append(new QStandardItem(info->ver()));
    items.append(new QStandardItem(QFileInfo(info->filePath()).fileName()));
    items.at(5)->setToolTip(info->filePath());
    m_model->appendRow(items);
}
Exemplo n.º 22
0
void QgsStyleManagerDialog::populateSymbols( const QStringList& symbolNames, bool check )
{
  QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
  model->clear();

  int type = currentItemType();

  for ( int i = 0; i < symbolNames.count(); ++i )
  {
    QString name = symbolNames[i];
    QgsSymbol* symbol = mStyle->symbol( name );
    if ( symbol && symbol->type() == type )
    {
      QStandardItem* item = new QStandardItem( name );
      QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize() );
      item->setIcon( icon );
      item->setData( name ); // used to find out original name when user edited the name
      item->setCheckable( check );
      item->setToolTip( name );
      // add to model
      model->appendRow( item );
    }
    delete symbol;
  }
  selectedSymbolsChanged( QItemSelection(), QItemSelection() );
  symbolSelected( listItems->currentIndex() );
}
Exemplo n.º 23
0
QgsSvgSelectorGroupsModel::QgsSvgSelectorGroupsModel( QObject* parent )
    : QStandardItemModel( parent )
{
  QStringList svgPaths = QgsApplication::svgPaths();
  QStandardItem *parentItem = invisibleRootItem();

  for ( int i = 0; i < svgPaths.size(); i++ )
  {
    QDir dir( svgPaths[i] );
    QStandardItem *baseGroup;

    if ( dir.path().contains( QgsApplication::pkgDataPath() ) )
    {
      baseGroup = new QStandardItem( tr( "App Symbols" ) );
    }
    else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) )
    {
      baseGroup = new QStandardItem( tr( "User Symbols" ) );
    }
    else
    {
      baseGroup = new QStandardItem( dir.dirName() );
    }
    baseGroup->setData( QVariant( svgPaths[i] ) );
    baseGroup->setEditable( false );
    baseGroup->setCheckable( false );
    baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) );
    baseGroup->setToolTip( dir.path() );
    parentItem->appendRow( baseGroup );
    createTree( baseGroup );
    QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) );
  }
}
Exemplo n.º 24
0
QStandardItem *ResultsTree::CreateCheckboxItem(bool checked)
{
    QStandardItem *item = new QStandardItem;
    item->setCheckable(true);
    item->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    item->setEnabled(false);
    return item;
}
Exemplo n.º 25
0
void TreeView::insertRoot(int rootID, QString rootName)
{

        QStandardItem * item = new QStandardItem(rootName);
        item->setCheckable(1);//使能复选框
        item->setIcon(QIcon(":/image/Aqua Ball.ico"));
        mode->insertRow(rootID-1, item);
}
Exemplo n.º 26
0
QList<QStandardItem *> TreeItem::get_list_representation(const TreeItemViewFormat & view_format)
{
	// http://www.qtforum.org/article/34069/store-user-data-void-with-qstandarditem-in-qstandarditemmodel.html

	QList<QStandardItem *> items;
	QVariant variant;

	const QString tooltip = this->get_tooltip();

	for (const TreeItemViewColumn & col : view_format.columns) {

		QStandardItem * item = NULL;

		switch (col.id) {
		case TreeItemPropertyID::TheItem:
			item = new QStandardItem(this->name);
			item->setToolTip(tooltip);
			item->setEditable(this->editable);
			variant = QVariant::fromValue(this);
			item->setData(variant, RoleLayerData);
			if (!this->icon.isNull()) { /* Icon can be set with ::apply_tree_item_icon(). */
				item->setIcon(this->icon);
			}
			//item->moveToThread(QApplication::instance()->thread())
			items << item;
			break;

		case TreeItemPropertyID::Visibility:
			item = new QStandardItem();
			item->setCheckable(true);
			item->setCheckState(this->visible ? Qt::Checked : Qt::Unchecked);
			//item->moveToThread(QApplication::instance()->thread())
			items << item;
			break;


		case TreeItemPropertyID::Editable:
			item = new QStandardItem();
			variant = QVariant::fromValue(this->editable);
			item->setData(variant, RoleLayerData);
			//item->moveToThread(QApplication::instance()->thread())
			items << item;
			break;

		case TreeItemPropertyID::Timestamp:
			/* Value in this column can be set with ::apply_tree_item_timestamp(). */
			item = new QStandardItem(this->timestamp.get_value());
			//item->moveToThread(QApplication::instance()->thread())
			items << item;
			break;
		default:
			qDebug() << SG_PREFIX_N << "Unexpected tree item column id" << (int) col.id;
			break;
		}
	}

	return items;
}
Exemplo n.º 27
0
    // Returns the root tree item containing the whole datapack information
    QStandardItem *packToItem(const QString &absPathToDescriptionFile, const PackCreationQueue &queue)
    {
        // Read datapack description file
        DataPack::Pack pack;
        pack.fromXmlFile(absPathToDescriptionFile);

        // Create datapack items
        QStandardItem *packItem = new QStandardItem(pack.name());
        QFont bold;
        bold.setBold(true);
        packItem->setFont(bold);
        packItem->setCheckable(true);
        packItem->setCheckState(Qt::Checked);

        QStandardItem *item = 0;
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::TYPE))
                                 .arg(pack.dataTypeName()));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::LICENSE))
                                 .arg(pack.description().data(PackDescription::LicenseName).toString()));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::VERSION))
                                 .arg(pack.version()));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::VENDOR))
                                 .arg(pack.vendor()));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::CREATION_DATE_TIME))
                                 .arg(QLocale().toString(pack.description().data(PackDescription::CreationDate).toDate())));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::LAST_MODIFICATION))
                                 .arg(QLocale().toString(pack.description().data(PackDescription::LastModificationDate).toDate())));
        item->setToolTip(item->text());
        packItem->appendRow(item);

        if (_format == PackCreationModel::ShowByServer) {
            item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                     .arg(tkTr(Trans::Constants::QUEUE))
                                     .arg(queue.sourceAbsolutePathFile()));
            item->setToolTip(item->text());
            packItem->appendRow(item);
        }

        _packItems.insert(pack.originalXmlConfigFileName(), packItem);

        return packItem;
    }
Exemplo n.º 28
0
NavigatorTreeModel::ItemRow NavigatorTreeModel::createItemRow(const ModelNode &node)
{
    Q_ASSERT(node.isValid());

    uint hash = node.internalId();

    const bool dropEnabled = node.metaInfo().isValid();

    QStandardItem *idItem = new QStandardItem;
    idItem->setDragEnabled(true);
    idItem->setDropEnabled(dropEnabled);
    idItem->setEditable(true);
    idItem->setData(hash, NavigatorRole);
    if (node.metaInfo().isValid())
        idItem->setToolTip(node.type());
    else
        idItem->setToolTip(msgUnknownItem(node.type()));
#    ifdef _LOCK_ITEMS_
    QStandardItem *lockItem = new QStandardItem;
    lockItem->setDragEnabled(true);
    lockItem->setDropEnabled(dropEnabled);
    lockItem->setEditable(false);
    lockItem->setCheckable(true);
    lockItem->setData(hash, NavigatorRole);
#    endif

    QStandardItem *visibilityItem = new QStandardItem;
    visibilityItem->setDropEnabled(dropEnabled);
    visibilityItem->setCheckable(true);
    visibilityItem->setEditable(false);
    visibilityItem->setData(hash, NavigatorRole);
    if (node.isRootNode())
        visibilityItem->setCheckable(false);

    QMap<QString, QStandardItem *> propertyItems;
    foreach (const QString &propertyName, visibleProperties(node)) {
        QStandardItem *propertyItem = new QStandardItem;
        propertyItem->setSelectable(false);
        propertyItem->setDragEnabled(false);
        propertyItem->setDropEnabled(dropEnabled);
        propertyItem->setEditable(false);
        propertyItem->setData(propertyName, Qt::DisplayRole);
        propertyItems.insert(propertyName, propertyItem);
        idItem->appendRow(propertyItem);
    }
	AcceptRIEXDialog::AcceptRIEXDialog (const QList<RIEXItem>& items,
			QObject *entryObj, QString message, QWidget *parent)
	: QDialog (parent)
	, Model_ (new QStandardItemModel (this))
	{
		Ui_.setupUi (this);

		Model_->setHorizontalHeaderLabels ({ tr ("Action"), tr ("ID"), tr ("Name"), tr ("Groups") });

		for (const RIEXItem& item : items)
		{
			QList<QStandardItem*> row;

			QStandardItem *action = new QStandardItem;
			action->setCheckState (Qt::Checked);
			action->setCheckable (true);
			switch (item.Action_)
			{
			case RIEXItem::AAdd:
				action->setText (tr ("add"));
				break;
			case RIEXItem::ADelete:
				action->setText (tr ("delete"));
				break;
			case RIEXItem::AModify:
				action->setText (tr ("modify"));
				break;
			default:
				action->setText (tr ("(unknown)"));
				break;
			}

			action->setData (QVariant::fromValue<RIEXItem> (item));

			row << action;
			row << new QStandardItem (item.ID_);
			row << new QStandardItem (item.Nick_);
			row << new QStandardItem (item.Groups_.join ("; "));

			Model_->appendRow (row);
		}

		Ui_.ItemsTree_->setModel (Model_);

		ICLEntry *entry = qobject_cast<ICLEntry*> (entryObj);
		const QString& id = entry->GetEntryName ().isEmpty () ?
				entry->GetHumanReadableID () :
				entry->GetEntryName () + " (" + entry->GetHumanReadableID () + ")";

		const QString& text = message.isEmpty () ?
				tr ("%1 has suggested to modify your contact list:")
					.arg (id) :
				tr ("%1 has suggested to modify your contact list:\n%2")
					.arg (id)
					.arg (message);
		Ui_.MessageLabel_->setText (text);
	}
Exemplo n.º 30
0
void SaveChangesDialog::addRow(ConnectionPageTab *tab, const QIcon &icon, const QString &title)
{
    QStandardItem *tabItem = new QStandardItem(icon, title);
    tabItem->setCheckable(true);
    tabItem->setCheckState(Qt::Checked);
    tabItem->setData(QVariant::fromValue((void*)tab));
    tabItem->setData(1, Qt::UserRole + 2);
    currentParentItem->appendRow(tabItem);
}