当前位置: 首页>>代码示例>>C++>>正文


C++ QTreeWidgetItem类代码示例

本文整理汇总了C++中QTreeWidgetItem的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem类的具体用法?C++ QTreeWidgetItem怎么用?C++ QTreeWidgetItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QTreeWidgetItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MainPage

/** Constructor */
NetworkDialog::NetworkDialog(QWidget *parent)
: MainPage(parent), connectdialog(NULL)
{
  /* Invoke the Qt Designer generated object setup routine */
  ui.setupUi(this);

  connect( ui.connecttreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) );

  /* create a single connect dialog */
  connectdialog = new ConnectDialog();
  
  connect(ui.infoLog, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoLogMenu(const QPoint&)));
  
  /* hide the Tree +/- */
  ui.connecttreeWidget -> setRootIsDecorated( false );
  
  /* Set header resize modes and initial section sizes */
	QHeaderView * _header = ui.connecttreeWidget->header () ;   
	_header->setResizeMode (0, QHeaderView::Custom);
	_header->setResizeMode (1, QHeaderView::Interactive);
	_header->setResizeMode (2, QHeaderView::Interactive);
	_header->setResizeMode (3, QHeaderView::Interactive);
	_header->setResizeMode (4, QHeaderView::Interactive);
	_header->setResizeMode (5, QHeaderView::Interactive);
	_header->setResizeMode (6, QHeaderView::Interactive);
	_header->setResizeMode (7, QHeaderView::Interactive);
	_header->setResizeMode (8, QHeaderView::Interactive);
	_header->setResizeMode (9, QHeaderView::Interactive);
    
	_header->resizeSection ( 0, 25 );
	_header->resizeSection ( 1, 100 );
	_header->resizeSection ( 2, 100 );
	_header->resizeSection ( 3, 100 );
	_header->resizeSection ( 4, 100 );
	_header->resizeSection ( 5, 200);
	_header->resizeSection ( 6, 100 );
	_header->resizeSection ( 7, 100 );
	_header->resizeSection ( 8, 100 );
	_header->resizeSection ( 9, 100 );
	
	// set header text aligment
	QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem();
	headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
  headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(4, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(5, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(6, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(7, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(8, Qt::AlignHCenter | Qt::AlignVCenter);
	headerItem->setTextAlignment(9, Qt::AlignHCenter | Qt::AlignVCenter);
	
	/*networkview = new NetworkView(ui.networkviewTab);
	QVBoxLayout *layout = new QVBoxLayout;
	layout->addWidget(networkview);
	ui.networkviewTab->setLayout(layout);
	layout->setSpacing( 0 );
	layout->setMargin( 0 );*/

  ui.networkTab->addTab(new NetworkView(),QString(tr("Network View")));
	ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix")));
     
    // Set Log infos
    setLogInfo(tr("RetroShare %1 started.", "e.g: RetroShare v0.x started.").arg(retroshareVersion()));
    
    setLogInfo(tr("Welcome to RetroShare."), QString::fromUtf8("blue"));
      
    QMenu *menu = new QMenu(tr("View"));
    menu->addAction(ui.actionTabsright); 
    menu->addAction(ui.actionTabswest);
    menu->addAction(ui.actionTabssouth); 
    menu->addAction(ui.actionTabsnorth);
    menu->addSeparator();
    menu->addAction(ui.actionTabsTriangular); 
    menu->addAction(ui.actionTabsRounded);
    ui.viewButton->setMenu(menu);
    
    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(getNetworkStatus()));
    timer->start(100000);
    
    QTimer *timer2 = new QTimer(this);
    timer2->connect(timer, SIGNAL(timeout()), this, SLOT(updateNetworkStatus()));
    timer2->start(1000);
    
    getNetworkStatus();
    updateNetworkStatus();
    //load();
    

  /* Hide platform specific features */
#ifdef Q_WS_WIN

#endif
}
开发者ID:autoscatto,项目名称:retroshare,代码行数:97,代码来源:NetworkDialog.cpp

示例2: QTreeWidgetItem

void RoutePresenter::show()
{
    m_treeWidget->clear();

    QTreeWidgetItem* requestTop = new QTreeWidgetItem(m_treeWidget);
    requestTop->setText(0, "request");

    QTreeWidgetItem* modesItem = new QTreeWidgetItem(requestTop);
    modesItem->setText(0, "modes");
    showModes(modesItem, m_routeReply->request(), m_routeReply->request().travelModes());

    QTreeWidgetItem* waypointsItem = new QTreeWidgetItem(requestTop);
    waypointsItem->setText(0, "waypoints");
    waypointsItem->setText(1, QString().setNum(m_routeReply->request().waypoints().length()));
    showPoints(waypointsItem, m_routeReply->request().waypoints());

    QTreeWidgetItem* excludesItem = new QTreeWidgetItem(requestTop);
    excludesItem->setText(0, "exclude areas");
    excludesItem->setText(1, QString().setNum(m_routeReply->request().excludeAreas().length()));
    for (int i = 0; i < m_routeReply->request().excludeAreas().length(); ++i)
        showBoundingBox(excludesItem, m_routeReply->request().excludeAreas().at(i));

    QTreeWidgetItem* alternativesItem = new QTreeWidgetItem(requestTop);
    alternativesItem->setText(0, "alternatives");
    alternativesItem->setText(1, QString().setNum(m_routeReply->request().numberAlternativeRoutes()));

    showRoutes();
}
开发者ID:zccrs,项目名称:qt-mobility,代码行数:28,代码来源:routepresenter.cpp

示例3: while

void ByteViewTab::protoTreeItemChanged(QTreeWidgetItem *current) {
    if (current && cap_file_) {
        field_info *fi;

        fi = current->data(0, Qt::UserRole).value<field_info *>();

        int i = 0;
        ByteViewText *byte_view_text = qobject_cast<ByteViewText*>(widget(i));
        while (byte_view_text) {
            if (byte_view_text->hasDataSource(fi->ds_tvb)) {
                QTreeWidgetItem *parent = current->parent();
                field_info *parent_fi = NULL;
                int f_start = -1, f_end = -1, f_len = -1;
                guint32 bmask = 0x00;
                int fa_start = -1, fa_end = -1, fa_len = -1;
                int p_start = -1, p_end = -1, p_len = -1;
                guint len = tvb_length(fi->ds_tvb);

                // Find and highlight the protocol bytes
                while (parent && parent->parent()) {
                    parent = parent->parent();
                }
                if (parent) {
                    parent_fi = parent->data(0, Qt::UserRole).value<field_info *>();
                }
                if (parent_fi && parent_fi->ds_tvb == fi->ds_tvb) {
                    p_start = parent_fi->start;
                    p_len = parent_fi->length;
                }

                if (cap_file_->search_in_progress && (cap_file_->hex || (cap_file_->string && cap_file_->packet_data))) {
                    /* In the hex view, only highlight the target bytes or string. The entire
                       field can then be displayed by clicking on any of the bytes in the field. */
                    if (cap_file_->hex) {
                        f_len = (int)strlen(cap_file_->sfilter)/2;
                    } else {
                        f_len = (int)strlen(cap_file_->sfilter);
                    }
                    f_start = cap_file_->search_pos - (f_len-1);
                } else {
                    f_start = fi->start;
                    f_len = fi->length;
                }

                /* bmask = finfo->hfinfo->bitmask << finfo->hfinfo->bitshift; */ /* (value & mask) >> shift */
                if (fi->hfinfo) bmask = fi->hfinfo->bitmask;
                fa_start = fi->appendix_start;
                fa_len = fi->appendix_length;

                if (!FI_GET_FLAG(fi, FI_LITTLE_ENDIAN) &&
                    !FI_GET_FLAG(fi, FI_BIG_ENDIAN)) {
                    /* unknown endianess - disable mask */
                    bmask = 0x00;
                }

                if (bmask == 0x00) {
                    int bito = FI_GET_BITS_OFFSET(fi);
                    int bitc = FI_GET_BITS_SIZE(fi);
                    int bitt = bito + bitc;

                    /* construct mask using bito & bitc */
                    /* XXX, mask has only 32 bit, later we can store bito&bitc, and use them (which should be faster) */
                    if (bitt > 0 && bitt < 32) {

                        bmask = ((1 << bitc) - 1) << ((8-bitt) & 7);
                    }
                }

                if (p_start >= 0 && p_len > 0 && (guint)p_start < len) {
                    p_end = p_start + p_len;
                }
                if (f_start >= 0 && f_len > 0 && (guint)f_start < len) {
                    f_end = f_start + f_len;
                }
                if (fa_start >= 0 && fa_len > 0 && (guint)fa_start < len) {
                    fa_end = fa_start + fa_len;
                }

                if (f_end == -1 && fa_end != -1) {
                    f_start = fa_start;
                    bmask = 0x00;
                    f_end = fa_end;
                    fa_start = fa_end = -1;
                }

                /* don't exceed the end of available data */
                if (p_end != -1 && (guint)p_end > len) p_end = len;
                if (f_end != -1 && (guint)f_end > len) f_end = len;
                if (fa_end != -1 && (guint)fa_end > len) fa_end = len;

                // Protocol
                byte_view_text->setProtocolHighlight(p_start, p_end);

                // Field bytes
                byte_view_text->setFieldHighlight(f_start, f_end);

                // Appendix (trailer) bytes
                byte_view_text->setFieldAppendixHighlight(fa_start, fa_end);

                byte_view_text->renderBytes();
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: perform

bool CopyReplaceDlg::perform()
{
    bool b_ret = false;
    for (;;) {

        QString s_source = ui->le_source->currentText ().trimmed ();
        if (s_source.isEmpty ()) {
            PilesGui::showError (tr("A source must be provided"));
            break;
        }

        QString s_dest = ui->le_destination->currentText ().trimmed ();
        if (s_dest.isEmpty ()) {
            PilesGui::showError (tr("A destination must be provided"));
            break;
        }

        int i_max;

        QStringList sl_find;
        QStringList sl_replace;
        i_max = ui->tv_replace->topLevelItemCount ();
        for (int i = 0; i < i_max; ++i) {
            QTreeWidgetItem * current =
                    ui->tv_replace->topLevelItem (i);
            if (isNewCommandEntry (current)) continue;

            sl_find.append (current->text (0));
            sl_replace.append (current->text (1));
        }

        bool b_indep =
                ui->ck_case_independent->checkState () ==
                Qt::Checked;

        bool b_recursive =
                ui->ck_recursive->checkState () ==
                Qt::Checked;

        QStringList sl_filter;
        i_max = ui->tv_filter->topLevelItemCount ();
        for (int i = 0; i < i_max; ++i) {
            QTreeWidgetItem * current =
                    ui->tv_filter->topLevelItem (i);
            if (isNewCommandEntry (current)) continue;

            sl_filter.append (current->text (0));
        }

        b_ret = Replacer::inFiles (
                    s_source,
                    s_dest,
                    b_recursive,
                    sl_find,
                    sl_replace,
                    b_indep ? Qt::CaseInsensitive : Qt::CaseSensitive,
                    sl_filter);

        break;
    }

    return b_ret;
}
开发者ID:pile-contributors,项目名称:pile-gui,代码行数:63,代码来源:copyreplacedlg.cpp

示例5: type

 bool operator< (const QTreeWidgetItem &other) const
 {
     // We want rows with a UE to appear in the order they appear in the row_type enum.
     return type() < other.type();
 }
开发者ID:bbidulock,项目名称:wireshark,代码行数:5,代码来源:lte_mac_statistics_dialog.cpp

示例6: funcStr

void KatePluginSymbolViewerView::parseBashSymbols(void)
{
       if (!mainWindow()->activeView())
               return;

       QString currline;
       QString funcStr("function ");

       int i;
       //bool mainprog;

       QTreeWidgetItem *node = NULL;
       QTreeWidgetItem *funcNode = NULL;
       QTreeWidgetItem *lastFuncNode = NULL;

       QPixmap func( ( const char** ) class_xpm );

       //It is necessary to change names
       m_func->setText(i18n("Show Functions"));

       if(m_plugin->treeOn)
       {
               funcNode = new QTreeWidgetItem(m_symbols, QStringList(i18n("Functions") ) );
               funcNode->setIcon(0, QIcon(func));

               if (m_plugin->expandedOn)
               {
                       m_symbols->expandItem(funcNode);
               }

               lastFuncNode = funcNode;

               m_symbols->setRootIsDecorated(1);
       }
       else
               m_symbols->setRootIsDecorated(0);

       KTextEditor::Document *kDoc = mainWindow()->activeView()->document();

       for (i = 0; i < kDoc->lines(); i++)
       {
               currline = kDoc->line(i);
               currline = currline.trimmed();
               currline = currline.simplified();

               bool comment = false;
               //kDebug(13000)<<currline<<endl;
               if(currline == "") continue;
               if(currline.at(0) == '#') comment = true;

               //mainprog=false;
               if(!comment && func_on)
               {
                       QString funcName;

                       // skip line if no function defined
                       // note: function name must match regex: [a-zA-Z0-9-_]+
                       if(!currline.contains(QRegExp("^(function )*[a-zA-Z0-9-_]+ *\\( *\\)"))
                               && !currline.contains(QRegExp("^function [a-zA-Z0-9-_]+")))
                               continue;

                       // strip everything unneeded and get the function's name
                       currline.remove(QRegExp("^(function )*"));
                       funcName = currline.split(QRegExp("((\\( *\\))|[^a-zA-Z0-9-_])"))[0].simplified();
                       if(!funcName.size())
                               continue;
                       funcName.append("()");

                       if (m_plugin->treeOn)
                       {
                               node = new QTreeWidgetItem(funcNode, lastFuncNode);
                               lastFuncNode = node;
                       }
                       else
                               node = new QTreeWidgetItem(m_symbols);

                       node->setText(0, funcName);
                       node->setIcon(0, QIcon(func));
                       node->setText(1, QString::number( i, 10));
               }
       } //for i loop
}
开发者ID:dividedmind,项目名称:kate,代码行数:82,代码来源:bash_parser.cpp

示例7: QTreeWidgetItem

void KateBuildView::addError(const QString &filename, const QString &line,
                             const QString &column, const QString &message)
{
    bool isError=false;
    bool isWarning=false;
    QTreeWidgetItem* item = new QTreeWidgetItem(m_buildUi.errTreeWidget);
    item->setBackground(1, Qt::gray);
    // The strings are twice in case kate is translated but not make.
    if (message.contains(QStringLiteral("error")) ||
        message.contains(i18nc("The same word as 'make' uses to mark an error.","error")) ||
        message.contains(QStringLiteral("undefined reference")) ||
        message.contains(i18nc("The same word as 'ld' uses to mark an ...","undefined reference"))
       )
    {
        isError=true;
        item->setForeground(1, Qt::red);
        m_numErrors++;
        item->setHidden(false);
    }
    if (message.contains(QStringLiteral("warning")) ||
        message.contains(i18nc("The same word as 'make' uses to mark a warning.","warning"))
       )
    {
        isWarning=true;
        item->setForeground(1, Qt::yellow);
        m_numWarnings++;
        item->setHidden(m_buildUi.displayModeSlider->value() > 2);
    }
    item->setTextAlignment(1, Qt::AlignRight);

    // visible text
    //remove path from visible file name
    QFileInfo file(filename);
    item->setText(0, file.fileName());
    item->setText(1, line);
    item->setText(2, message.trimmed());

    // used to read from when activating an item
    item->setData(0, Qt::UserRole, filename);
    item->setData(1, Qt::UserRole, line);
    item->setData(2, Qt::UserRole, column);

    if ((isError==false) && (isWarning==false)) {
      item->setHidden(m_buildUi.displayModeSlider->value() > 1);
    }

    item->setData(0, IsErrorRole, isError);
    item->setData(0, IsWarningRole, isWarning);

    // add tooltips in all columns
    // The enclosing <qt>...</qt> enables word-wrap for long error messages
    item->setData(0, Qt::ToolTipRole, filename);
    item->setData(1, Qt::ToolTipRole, QStringLiteral("<qt>%1</qt>").arg(message));
    item->setData(2, Qt::ToolTipRole, QStringLiteral("<qt>%1</qt>").arg(message));
}
开发者ID:cmacq2,项目名称:kate,代码行数:55,代码来源:plugin_katebuild.cpp

示例8: QTreeWidgetItem

void ChangeProperties::updateProperties()
{
    bool hasControl = activex && !activex->isNull();
    tabWidget->setEnabled(hasControl);

    listProperties->clear();
    listEditRequests->clear();
    if (hasControl) {
	const QMetaObject *mo = activex->metaObject();
	const int numprops = mo->propertyCount();
	for (int i = mo->propertyOffset(); i < numprops; ++i) {
	    const QMetaProperty property = mo->property(i);
	    QTreeWidgetItem *item = new QTreeWidgetItem(listProperties);
	    item->setText(0, QString::fromLatin1(property.name()));
	    item->setText(1, QString::fromLatin1(property.typeName()));
            if (!property.isDesignable()) {
                item->setTextColor(0, Qt::gray);
                item->setTextColor(1, Qt::gray);
                item->setTextColor(2, Qt::gray);
            }
	    QVariant var = activex->property(property.name());
	    
	    switch (var.type()) {
	    case QVariant::Color:
		{
		    QColor col = qvariant_cast<QColor>(var);
		    item->setText(2, col.name());
		}
		break;
	    case QVariant::Font:
		{
		    QFont fnt = qvariant_cast<QFont>(var);
		    item->setText(2, fnt.toString());
		}
		break;
	    case QVariant::Bool:
		{
		    item->setText(2, var.toBool() ? QLatin1String("true") : QLatin1String("false"));
		}
		break;
	    case QVariant::Pixmap:
		{
		    QPixmap pm = qvariant_cast<QPixmap>(var);
		    item->setIcon(2, pm);
		}
		break;
	    case QVariant::List:
		{
		    QList<QVariant> varList = var.toList();
		    QStringList strList;
		    for (int i = 0; i < varList.count(); ++i) {
			QVariant var = varList.at(i);
			strList << var.toString();
		    }
		    item->setText(2, strList.join(QLatin1String(", ")));
		}
		break;
	    case QVariant::Int:
		if (property.isEnumType()) {
		    const QMetaEnum enumerator = mo->enumerator(mo->indexOfEnumerator(property.typeName()));
		    item->setText(2, QString::fromLatin1(enumerator.valueToKey(var.toInt())));
		    break;
		}
		//FALLTHROUGH
	    default:
		item->setText(2, var.toString());
		break;
	    }

            bool requesting = false;
#if 0
            {
                void *argv[] = { &requesting };
                activex->qt_metacall(QMetaObject::Call(0x10000000) /*RequestingEdit*/, i, argv);
            }
#endif
            if (requesting) {
		QTreeWidgetItem *check = new QTreeWidgetItem(listEditRequests);
                check->setText(0, QString::fromLatin1(property.name()));
                check->setCheckState(0, activex->propertyWritable(property.name()) ? Qt::Checked : Qt::Unchecked);
	    }
	}
        listProperties->setCurrentItem(listProperties->topLevelItem(0));
    } else {
        editValue->clear();
    }
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:87,代码来源:changeproperties.cpp

示例9: setLayout

InputSettingsWindow::InputSettingsWindow() {
  activeInput = 0;
  activeGroup = 0;
  groupIndex = 0;
  activeMouse = 0;

  layout = new QVBoxLayout;
  layout->setMargin(Style::WindowMargin);
  layout->setSpacing(Style::WidgetSpacing);
  setLayout(layout);

  list = new QTreeWidget;
  list->setColumnCount(2);
  list->setAllColumnsShowFocus(true);
  list->setSortingEnabled(false);
  list->header()->hide();
  list->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
  layout->addWidget(list);

  controlLayout = new QHBoxLayout;
  layout->addLayout(controlLayout);

  message = new QLabel;
  message->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
  controlLayout->addWidget(message);

  assignButton = new QPushButton("Assign");
  controlLayout->addWidget(assignButton);

  unassignButton = new QPushButton("Unassign");
  controlLayout->addWidget(unassignButton);

  buttonBox = new QLabel("Mouse Button");
  buttonBox->setFrameStyle(QFrame::Panel | QFrame::Raised);
  buttonBox->hide();
  controlLayout->addWidget(buttonBox);

  xAxisButton = new QPushButton("Mouse X-axis");
  xAxisButton->hide();
  controlLayout->addWidget(xAxisButton);

  yAxisButton = new QPushButton("Mouse Y-axis");
  yAxisButton->hide();
  controlLayout->addWidget(yAxisButton);

  stopButton = new QPushButton("Stop");
  stopButton->hide();
  controlLayout->addWidget(stopButton);

  connect(list, SIGNAL(itemSelectionChanged()), this, SLOT(synchronize()));
  connect(list, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(activateAssign()));
  connect(assignButton, SIGNAL(released()), this, SLOT(assign()));
  connect(unassignButton, SIGNAL(released()), this, SLOT(unassign()));
  connect(xAxisButton, SIGNAL(released()), this, SLOT(xAxisAssign()));
  connect(yAxisButton, SIGNAL(released()), this, SLOT(yAxisAssign()));
  connect(stopButton, SIGNAL(released()), this, SLOT(stop()));

  //initialize list

  port1 = new QTreeWidgetItem(list);
  port1->setData(0, Qt::UserRole, QVariant(-1));
  port1->setText(0, "Controller Port 1");

  port2 = new QTreeWidgetItem(list);
  port2->setData(0, Qt::UserRole, QVariant(-1));
  port2->setText(0, "Controller Port 2");

  userInterface = new QTreeWidgetItem(list);
  userInterface->setData(0, Qt::UserRole, QVariant(-1));
  userInterface->setText(0, "User Interface");

  for(unsigned i = 0; i < mapper().size(); i++) {
    InputGroup &group = *(mapper()[i]);

    QTreeWidgetItem *grandparent = 0;
    if(group.category == InputCategory::Port1) { grandparent = port1; }
    if(group.category == InputCategory::Port2) { grandparent = port2; }
    if(group.category == InputCategory::UserInterface) { grandparent = userInterface; }
    if(!grandparent) continue;

    QTreeWidgetItem *parent = new QTreeWidgetItem(grandparent);
    parent->setData(0, Qt::UserRole, QVariant(-1));
    parent->setText(0, group.label);

    for(unsigned i = 0; i < group.size(); i++) {
      QTreeWidgetItem *child = new QTreeWidgetItem(parent);
      child->setData(0, Qt::UserRole, QVariant(inputTable.size()));
      inputTable.append(group[i]);
    }
  }

  updateList();
  synchronize();
}
开发者ID:bazzinotti,项目名称:bsnes-classic,代码行数:94,代码来源:input.cpp

示例10: processListRoomsEvent

void RoomSelector::processListRoomsEvent(const Event_ListRooms &event)
{
    const int roomListSize = event.room_list_size();
    for (int i = 0; i < roomListSize; ++i) {
        const ServerInfo_Room &room = event.room_list(i);

        for (int j = 0; j < roomList->topLevelItemCount(); ++j) {
            QTreeWidgetItem *twi = roomList->topLevelItem(j);
            if (twi->data(0, Qt::UserRole).toInt() == room.room_id()) {
                if (room.has_name())
                    twi->setData(0, Qt::DisplayRole, QString::fromStdString(room.name()));
                if (room.has_description())
                    twi->setData(1, Qt::DisplayRole, QString::fromStdString(room.description()));
                if (room.has_player_count())
                    twi->setData(2, Qt::DisplayRole, room.player_count());
                if (room.has_game_count())
                    twi->setData(3, Qt::DisplayRole, room.game_count());
                return;
            }
        }
        QTreeWidgetItem *twi = new QTreeWidgetItem;
        twi->setData(0, Qt::UserRole, room.room_id());
        if (room.has_name())
            twi->setData(0, Qt::DisplayRole, QString::fromStdString(room.name()));
        if (room.has_description())
            twi->setData(1, Qt::DisplayRole, QString::fromStdString(room.description()));
        twi->setData(2, Qt::DisplayRole, room.player_count());
        twi->setData(3, Qt::DisplayRole, room.game_count());
        twi->setTextAlignment(2, Qt::AlignRight);
        twi->setTextAlignment(3, Qt::AlignRight);

        roomList->addTopLevelItem(twi);
        if (room.has_auto_join())
            if (room.auto_join())
                joinRoom(room.room_id(), false);
    }
}
开发者ID:mildmongrel,项目名称:Cockatrice,代码行数:37,代码来源:tab_server.cpp

示例11: activateAssign

//called when double-clicking any list item;
//double-clicking a group expands or collapses it,
//so avoid triggering assign() unless this is not a group
void InputSettingsWindow::activateAssign() {
  QTreeWidgetItem *item = list->currentItem();
  if(!item) return;
  signed index = item->data(0, Qt::UserRole).toInt();
  if(index >= 0) assign();
}
开发者ID:bazzinotti,项目名称:bsnes-classic,代码行数:9,代码来源:input.cpp

示例12: updateList

void InputSettingsWindow::updateList() {
  QList<QTreeWidgetItem*> all = list->findItems("", Qt::MatchContains);
  for(unsigned i = 0; i < all.size(); i++) {
    QTreeWidgetItem *grandparent = all[i];
    for(unsigned j = 0; j < grandparent->childCount(); j++) {
      QTreeWidgetItem *parent = grandparent->child(j);
      for(unsigned k = 0; k < parent->childCount(); k++) {
        QTreeWidgetItem *child = parent->child(k);
        signed index = child->data(0, Qt::UserRole).toInt();
        if(index == -1) continue;
        MappedInput *input = inputTable[index];
        child->setText(0, input->label);
        child->setText(1, string() << "= " << input->name);
        child->setForeground(1, QBrush(QColor(128, 128, 128)));
      }
    }
  }
}
开发者ID:bazzinotti,项目名称:bsnes-classic,代码行数:18,代码来源:input.cpp

示例13: blockSignals

void FunctionsTreeWidget::addFolder()
{
    blockSignals(true);
    if (selectedItems().isEmpty())
        return;

    QTreeWidgetItem *item = selectedItems().first();
    if (item->text(COL_PATH).isEmpty())
        item = item->parent();

    int type = item->data(COL_NAME, Qt::UserRole + 1).toInt();

    QString fullPath = item->text(COL_PATH);
    if (fullPath.endsWith('/') == false)
        fullPath.append("/");

    QString newName = "New folder";

    int folderCount = 1;

    while (m_foldersMap.contains(fullPath + newName))
    {
        newName = "New Folder " + QString::number(folderCount++);
    }

    fullPath += newName;

    QTreeWidgetItem *folder = new QTreeWidgetItem(item);
    folder->setText(COL_NAME, newName);
    folder->setIcon(COL_NAME, QIcon(":/folder.png"));
    folder->setData(COL_NAME, Qt::UserRole, Function::invalidId());
    folder->setData(COL_NAME, Qt::UserRole + 1, type);
    folder->setText(COL_PATH, fullPath);
    folder->setFlags(folder->flags() | Qt::ItemIsDropEnabled | Qt::ItemIsEditable);

    m_foldersMap[fullPath] = folder;
    item->setExpanded(true);

    blockSignals(false);

    scrollToItem(folder, QAbstractItemView::PositionAtCenter);
}
开发者ID:lynxis,项目名称:qlcplus,代码行数:42,代码来源:functionstreewidget.cpp

示例14: foreach

void GUIImport::updateViewConfig()
{
	for (StringMap::iterator it = m->viewConfig.begin(); it != m->viewConfig.end(); ++it)
	{
		if (strchr(it->first.c_str(), '.') == NULL)
		{
			// view
			QList<QTreeWidgetItem*> views = ui->viewTree->findItems(
				QString::fromStdString(it->first),
				Qt::MatchExactly, COL_ORGNAME);

			if (views.size() != 1)
			{
				DM::Logger(DM::Error) << "view tree corrupt";
				return;
			}

			QCheckBox* checkBox = (QCheckBox*)ui->viewTree->itemWidget(views.first(), COL_CHECKBOX);

			// note: if checked or partially checked -> take as if checked
			it->second = (checkBox->checkState() != Qt::Unchecked) ?
				views.first()->text(COL_NEWNAME).toStdString() : "";
		}
		else
		{
			// attribute
			QStringList parsedString = QString::fromStdString(it->first).split('.', QString::SkipEmptyParts);

			if (parsedString.size() != 2)
			{
				DM::Logger(DM::Error) << "view tree corrupt";
				return;
			}

			QList<QTreeWidgetItem*> attributes = ui->viewTree->findItems(
				parsedString.last(), Qt::MatchExactly | Qt::MatchRecursive, COL_ORGNAME);

			QTreeWidgetItem* attribute = NULL;
			foreach(QTreeWidgetItem* a, attributes)
			{
				if (a->parent() && a->parent()->text(COL_ORGNAME) == parsedString.first())
				{
					attribute = a;
					break;
				}
			}

			if (!attribute)
			{
				DM::Logger(DM::Error) << "view tree corrupt";
				return;
			}

			QCheckBox* checkBox = (QCheckBox*)ui->viewTree->itemWidget(attribute, COL_CHECKBOX);

			// note: if checked or partially checked -> take it
			it->second = (checkBox->checkState() != Qt::Unchecked) ?
				attribute->text(COL_NEWNAME).toStdString() : "";
		}
	}
	// epsg overwritings
	for (int i = 0; i < ui->viewTree->topLevelItemCount(); i++)
	{
		QTreeWidgetItem* it = ui->viewTree->topLevelItem(i);
		m->viewEPSGConfig[it->text(COL_ORGNAME).toStdString()] = it->text(COL_EPSG).toStdString();
	}
}
开发者ID:abroxos,项目名称:DynaMind-ToolBox,代码行数:67,代码来源:guiimport.cpp

示例15: on_buttonSet_clicked

void ChangeProperties::on_buttonSet_clicked()
{
    QTreeWidgetItem *item = listProperties->currentItem();
    if (!item)
	return;
    
    QString prop = item->text(0);
    QVariant value = activex->property(prop.toLatin1());
    QVariant::Type type = value.type();
    if (!value.isValid()) {
	const QMetaObject *mo = activex->metaObject();
	const QMetaProperty property = mo->property(mo->indexOfProperty(prop.toLatin1()));
	type = QVariant::nameToType(property.typeName());
    }
    switch (type) {
    case QVariant::Color:
	{
	    QColor col;
	    col.setNamedColor(editValue->text());
	    if (col.isValid()) {
		value = qVariantFromValue(col);
	    } else {
		QMessageBox::warning(this, tr("Can't parse input"), 
		                           tr("Failed to create a color from %1\n"
					                "The string has to be a valid color name (e.g. 'red')\n"
							"or a RGB triple of format '#rrggbb'."
							).arg(editValue->text()));
	    }
	}
	break;
    case QVariant::Font:
	{
	    QFont fnt;
	    if (fnt.fromString(editValue->text())) {
		value = qVariantFromValue(fnt);
	    } else {
		QMessageBox::warning(this, tr("Can't parse input"), 
		                           tr("Failed to create a font from %1\n"
					        "The string has to have a format family,<point size> or\n"
						"family,pointsize,stylehint,weight,italic,underline,strikeout,fixedpitch,rawmode."
							).arg(editValue->text()));
	    }
	}
	break;
    case QVariant::Pixmap:
	{
	    QString fileName = editValue->text();
	    if (fileName.isEmpty())
		fileName = QFileDialog::getOpenFileName(this);
	    QPixmap pm(fileName);
	    if (pm.isNull())
		return;

	    value = qVariantFromValue(pm);
	}
	break;
    case QVariant::Bool:
	{
	    QString txt = editValue->text().toLower();
	    value = QVariant(txt != QLatin1String("0") && txt != QLatin1String("false"));
	}
	break;
    case QVariant::List:
	{
	    QStringList txtList = editValue->text().split(QRegExp(QLatin1String("[,;]")));
	    QList<QVariant> varList;
	    for (int i = 0; i < txtList.count(); ++i) {
		QVariant svar(txtList.at(i));
		QString str = svar.toString();
		str = str.trimmed();
		bool ok;
		int n = str.toInt(&ok);
		if (ok) {
		    varList << n;
		    continue;
		}
		double d = str.toDouble(&ok);
		if (ok) {
		    varList << d;
		    continue;
		}
		varList << str;
	    }
	    value = varList;
	}
	break;

    default:
	value = editValue->text();
	break;
    }
 
    Q_ASSERT(activex->setProperty(prop.toLatin1(), value));
    updateProperties();
    listProperties->setCurrentItem(listProperties->findItems(prop, Qt::MatchExactly).at(0));
}
开发者ID:NikhilNJ,项目名称:screenplay-dx,代码行数:96,代码来源:changeproperties.cpp


注:本文中的QTreeWidgetItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。