本文整理汇总了C++中QTreeWidgetItem::checkState方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::checkState方法的具体用法?C++ QTreeWidgetItem::checkState怎么用?C++ QTreeWidgetItem::checkState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::checkState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: install
void SettingsJavaPluginForm::install()
{
m_toInstall.clear();
for (int i = 0; i < treeAvailable->topLevelItemCount(); i++)
{
QTreeWidgetItem* item = treeAvailable->topLevelItem(i);
if (item->checkState(0) == Qt::Checked)
m_toInstall << QPair<QString,bool>(item->text(0), false);
}
for (int i = 0; i < treeUpdates->topLevelItemCount(); i++)
{
QTreeWidgetItem* item = treeUpdates->topLevelItem(i);
if (item->checkState(0) == Qt::Checked)
m_toInstall << QPair<QString,bool>(item->text(0), true);
}
if (!m_toInstall.isEmpty())
{
connect(m_network, SIGNAL(finished(QNetworkReply*)), this, SLOT(finishedDownload(QNetworkReply*)));
m_dlgProgress.setNumSteps(m_toInstall.size());
m_dlgProgress.show();
downloadNext();
}
示例2: refreshTree
void TabManagerWidget::refreshTree()
{
if (m_refreshBlocked) {
return;
}
if (m_isRefreshing && !m_webPage) {
return;
}
// store selected items
QList<QWidget*> selectedTabs;
for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i);
if (winItem->checkState(0) == Qt::Unchecked) {
continue;
}
for (int j = 0; j < winItem->childCount(); ++j) {
QTreeWidgetItem* tabItem = winItem->child(j);
if (tabItem->checkState(0) == Qt::Unchecked) {
continue;
}
selectedTabs << qvariant_cast<QWidget*>(tabItem->data(0, WebTabPointerRole));
}
}
ui->treeWidget->clear();
if (m_groupType == GroupByHost) {
groupByDomainName(true);
}
else if (m_groupType == GroupByDomain) {
groupByDomainName();
}
else { // fallback to GroupByWindow
m_groupType = GroupByWindow;
groupByWindow();
}
// restore selected items
for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i);
for (int j = 0; j < winItem->childCount(); ++j) {
QTreeWidgetItem* tabItem = winItem->child(j);
if (selectedTabs.contains(qvariant_cast<QWidget*>(tabItem->data(0, WebTabPointerRole)))) {
tabItem->setCheckState(0, Qt::Checked);
}
}
}
filterChanged(m_filterText, true);
ui->treeWidget->expandAll();
m_isRefreshing = false;
m_waitForRefresh = false;
}
示例3: updateParentItem
//向上递归判断
void XMLInfoDialog::updateParentItem(QTreeWidgetItem *item)
{
QTreeWidgetItem* parent = item->parent();
if (parent == NULL)
return;
//选中的子节点个数
int selectedCount = 0;
int childCount = parent->childCount();
for (int i = 0; i < childCount; i++)
{
QTreeWidgetItem* childItem = parent->child(i);
if (childItem->checkState(0) == Qt::Checked)
selectedCount++;
}
if (selectedCount <= 0)
{
parent->setCheckState(0, Qt::Unchecked);//全没选状态
}
else if (selectedCount > 0 && selectedCount < childCount)
{
parent->setCheckState(0, Qt::PartiallyChecked);//设置为部分选中状态
updateParentItem(parent);
}
else if (selectedCount == childCount)
{
parent->setCheckState(0, Qt::Checked);//全选中状态
}
}
示例4:
std::vector<Property*> PropertySelectionTreeWidget::getSelectedProperties(ProcessorNetwork* processorNetwork) {
std::vector<Property*> selectedProperties;
int workspaceCount = propertySelectionTree_->topLevelItemCount();
for (int i=0; i<workspaceCount; i++) {
QTreeWidgetItem* wrokspaceItem = propertySelectionTree_->topLevelItem(i);
int processorCount = wrokspaceItem->childCount();
for (int j=0; j<processorCount; j++) {
QTreeWidgetItem* processorItem = wrokspaceItem->child(j);
int propertyCount = processorItem->childCount();
QString qproecessorId = processorItem->text(0);
std::string proecessorId = qproecessorId.toLocal8Bit().constData();
for (int k=0; k<propertyCount; k++) {
QTreeWidgetItem* propertyItem = processorItem->child(k);
if (propertyItem->checkState(0) == Qt::Checked) {
QString propertyId = propertyItem->text(0);
std::string prop = propertyId.toLocal8Bit().constData();
QString workspaceName = wrokspaceItem->text(0);
std::string workspace = workspaceName.toLocal8Bit().constData();
Processor* processor = processorNetwork->getProcessorByIdentifier(proecessorId);
Property* selectedProperty = processor->getPropertyByIdentifier(prop);
if (selectedProperty)
selectedProperties.push_back(selectedProperty);
}
}
}
}
return selectedProperties;
}
示例5: columnsDoNext
bool DatabaseDialog::columnsDoNext()
{
QStringList columns;
for (int row = 0; row < m_columnView->topLevelItemCount(); ++row) {
QTreeWidgetItem* item = m_columnView->topLevelItem(row);
if (item->checkState(0) == Qt::Checked) {
columns.append(item->text(1) + '.' + item->text(0));
}
}
if (columns.empty()) {
KMessageBox::error(this, i18n("You have to select at least one column."));
return false;
}
m_columns_1->clear();
m_columns_2->clear();
m_columns_3->clear();
m_columns_1->insertItems(0, columns);
m_columns_2->insertItems(0, columns);
m_columns_3->insertItems(0, columns);
m_columnsSort_1->clear();
m_columnsSort_2->clear();
m_columnsSort_1->insertItem(0, i18n("None"));
m_columnsSort_2->insertItem(0, i18n("None"));
m_columnsSort_1->insertItems(1, columns);
m_columnsSort_2->insertItems(2, columns);
setValid(m_options, true);
return true;
}
示例6: handleAccepted
void StartupFirstPage::handleAccepted ()
{
for (int i = 0; i < Ui_.Tree_->topLevelItemCount (); ++i)
{
QTreeWidgetItem *item = Ui_.Tree_->topLevelItem (i);
if (item->checkState (0) != Qt::Checked)
continue;
QString set = item->data (0, RoleSet).toString ();
QString filename = item->data (0, RoleFile).toString ();
QString full = QString (":/resources/default/%1/%2")
.arg (set)
.arg (filename);
QFile file (full);
if (!file.open (QIODevice::ReadOnly))
{
qWarning () << Q_FUNC_INFO
<< "could not open file for read only"
<< full
<< file.errorString ();
continue;
}
QString contents = QTextCodec::codecForName ("UTF-8")->
toUnicode (file.readAll ());
Core::Instance ().HandleEntity (contents,
static_cast<QLineEdit*> (Ui_.Tree_->itemWidget (item, 1))->text ());
}
}
示例7: eventFilter
/**
* @brief RsCollectionDialog::eventFilter: Proccess event in object
* @param obj: object where event occured
* @param event: event occured
* @return If we don't have to process event in parent.
*/
bool RsCollectionDialog::eventFilter(QObject *obj, QEvent *event)
{
if (obj == ui._fileEntriesTW) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent && (keyEvent->key() == Qt::Key_Space)) {
// Space pressed
// get state of current item
QTreeWidgetItem *item = ui._fileEntriesTW->currentItem();
if (item) {
Qt::CheckState checkState = (item->checkState(COLUMN_FILE) == Qt::Checked) ? Qt::Unchecked : Qt::Checked;
// set state of all selected items
QList<QTreeWidgetItem*> selectedItems = ui._fileEntriesTW->selectedItems();
QList<QTreeWidgetItem*>::iterator it;
for (it = selectedItems.begin(); it != selectedItems.end(); ++it) {
if ((*it)->checkState(COLUMN_FILE) != checkState)
(*it)->setCheckState(COLUMN_FILE, checkState);
}//for (it
}//if (item)
return true; // eat event
}//if (keyEvent && keyEvent->key() == Qt::Key_Space)
if (keyEvent && (keyEvent->key() == Qt::Key_Delete)) {
// Delete pressed
remove();
return true; // eat event
}//if (keyEvent && keyEvent->key() == Qt::Key_Delete)
if (keyEvent && (keyEvent->key() == Qt::Key_Plus)) {
// Plus pressed
makeDir();
return true; // eat event
}//if (keyEvent && keyEvent->key() == Qt::Key_Plus)
}//if (event->type() == QEvent::KeyPress)
}//if (obj == ui._fileEntriesTW)
if (obj == ui._systemFileTW) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent && ((keyEvent->key() == Qt::Key_Enter)
|| keyEvent->key() == Qt::Key_Return)) {
// Enter pressed
if (keyEvent->modifiers() == Qt::ShiftModifier)
addRecursive();
else if(keyEvent->modifiers() == Qt::NoModifier) {
add();
}
return true; // eat event
}//if (keyEvent && keyEvent->key() == Qt::Key_Enter...
}//if (event->type() == QEvent::KeyPress)
}//if (obj == ui._systemFileTW)
// pass the event on to the parent class
return QDialog::eventFilter(obj, event);
}
示例8: getPortToPlot
void
PlanSimSubpanel::onTreeItemSelected()
{
QTreeWidgetItem* item = right->ui->treeSimViews->currentItem();
bool itemVisility = false;
if (item) {
QString viewName = item->data(0, Qt::UserRole + 1).toString();
QString portName = item->data(0, Qt::UserRole + 2).toString();
if (portName == "") {
itemVisility = false;
} else {
int state = item->checkState(0);
if (state == Qt::Checked) {
itemVisility = true;
portToPlot* port = getPortToPlot(viewName, portName);
QString style = "border:1px solid; ";
style += QString("background-color: rgb(%1, %2, %3);")
.arg(port->color.red())
.arg(port->color.green())
.arg(port->color.blue());
right->ui->butSimColor->setStyleSheet(style);
} else {
itemVisility = false;
}
}
}
right->ui->widSimStyle->setVisible(itemVisility);
}
示例9: eventFilter
bool RsCollectionDialog::eventFilter(QObject *obj, QEvent *event)
{
if (obj == _fileEntriesTW) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent && keyEvent->key() == Qt::Key_Space) {
// Space pressed
// get state of current item
QTreeWidgetItem *item = _fileEntriesTW->currentItem();
if (item) {
Qt::CheckState checkState = (item->checkState(0) == Qt::Checked) ? Qt::Unchecked : Qt::Checked;
connectUpdate(false);
// set state of all selected items
QList<QTreeWidgetItem*> selectedItems = _fileEntriesTW->selectedItems();
QList<QTreeWidgetItem*>::iterator it;
for (it = selectedItems.begin(); it != selectedItems.end(); ++it) {
(*it)->setCheckState(0, checkState);
}
updateSizes();
connectUpdate(true);
}
return true; // eat event
}
}
}
// pass the event on to the parent class
return QDialog::eventFilter(obj, event);
}
示例10: detectTablesAndCreate
//Détecte les cases cochées pour savoir quelle table recrée, supprime toutes les tables dans la base de données, puis crée les nouvelles
void CServiceSendDataBase::detectTablesAndCreate()
{
QString list_tables = "";
for (int i=0 ; i < m_list_data_service->count() ; i++)
{
QString id = m_list_data_service->index(i,INFORMATIONS_CONNECTIONS_SETTINGS).getValueData("ID").toString();
bool exist_child_checked = false;
for (int j = 0 ; j < m_list_data_service->index(i)->count() && exist_child_checked==false ; j++)
{
for (int k = 0 ; k < m_list_data_service->index(i,j).count() && exist_child_checked==false ;k++)
{
QTreeWidgetItem *item = m_tree_widget->topLevelItem(i)->child(j)->child(k);
if (item->checkState(0) == Qt::Checked)
{
exist_child_checked = true;
}
}
}
if (exist_child_checked == true)
{
list_tables += id+"-";
}
}
//Suppression du dernier -
list_tables.remove (list_tables.count() - 1 , 1);
QNetworkReply *reply = createTablesDataBase(list_tables);
m_list_network_reply.append (reply);
}
示例11: uninstall
void SettingsJavaPluginForm::uninstall()
{
if (QMessageBox::warning(getMainWindow(), "FatRat", tr("Do you really wish to uninstall the selected extensions?"), QMessageBox::Yes|QMessageBox::Cancel) != QMessageBox::Yes)
{
return;
}
QString baseDir = QDir::homePath() + USER_PROFILE_PATH "/data/java/";
QDir dir(baseDir);
int numRemoved = 0;
for (int i = 0; i < treeInstalled->topLevelItemCount(); i++)
{
QTreeWidgetItem* item = treeInstalled->topLevelItem(i);
if (item->checkState(0) != Qt::Checked)
continue;
QString fileName = item->text(0) + ".jar";
if (!dir.remove(fileName))
QMessageBox::critical(getMainWindow(), "FatRat", tr("Failed to remove \"%1\", check the file permissions.").arg(fileName));
numRemoved++;
}
if (numRemoved)
askRestart();
}
示例12: getPattern
QString DeviceFilterGUIDialog::getPattern()
{
if (ui->allDevicesCheckBox->isChecked())
{
return "all";
}
else
{
QString pattern = "";
for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++)
{
QTreeWidgetItem* groupItem = ui->treeWidget->topLevelItem(i);
for (int j = 0; j < groupItem->childCount(); j++)
{
QTreeWidgetItem* item = groupItem->child(j);
if (item->checkState(0) == Qt::Checked)
{
if (pattern != "")
pattern += "; ";
const DeviceAPOInfo* apoInfo = item->data(0, Qt::UserRole).value<const DeviceAPOInfo*>();
wstring deviceString = apoInfo->connectionName + L" " + apoInfo->deviceName + L" " + apoInfo->deviceGuid;
pattern += QString::fromStdWString(deviceString);
}
}
}
return pattern;
}
}
示例13: checkState
int QTreeWidgetItemProto::checkState(int column) const
{
QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
if (item)
return item->checkState(column);
return 0;
}
示例14: reset
inline void reset( const char* const* _items, int _itemLen, char _sep, const char* _states, int _defaultState )
{
/// save previous selection state
std::string states;
if ( _states ) {
states = std::string( _states );
}
/// clear
clear();
/// reset
if ( widget_ && _items && _itemLen > 0 ) {
widget_->setSuspendUpdate( true );
widget_->itemIndices().reserve( _itemLen );
int stateLen( static_cast< int >( states.size() ) );
QTreeWidgetItem* parent = NULL;
std::string fullPath;
for ( int idx( 0 ); idx < _itemLen; ++idx ) {
parent = NULL;
fullPath.clear();
/// this variable denotes the item state, also considers the
/// parent nodes
bool itemState( true );
QStringList tokens;
if ( _sep != '\0' ) {
tokens = QStringList( QString::fromStdString( _items[ idx ] ).split( _sep, QString::SkipEmptyParts) );
} else {
tokens = QStringList( QString::fromStdString( _items[ idx ] ) );
}
for ( int tokenIdx( 0 ); tokenIdx < tokens.size(); ++tokenIdx ) {
QString itemStr( tokens.at( tokenIdx ) );
if ( !parent ) {
parent = createWidgetItem( widget_, widget_, itemStr, fullPath, stateLen, states, _defaultState );
} else {
parent = createWidgetItem( parent, parent->child( 0 ), itemStr, fullPath, stateLen, states, _defaultState );
}
if ( parent && itemState && ! parent->checkState( 0 ) ) {
itemState = false;
}
fullPath = fullPath + "/" + itemStr.toStdString();
}
widget_->itemIndices().append( QPair< QString, QTreeWidgetItem* >( fullPath.c_str(), parent ) );
itemStatesStr_.push_back( itemState ? '1' : '0' );
}
widget_->expandAll();
widget_->setSuspendUpdate( false );
}
}
示例15: on_copyToolButton_clicked
void FilterExpressionsPreferencesFrame::on_copyToolButton_clicked()
{
if (!ui->expressionTreeWidget->currentItem()) return;
QTreeWidgetItem *ti = ui->expressionTreeWidget->currentItem();
addExpression(ti->checkState(enabled_col_) == Qt::Checked,
ti->text(label_col_), ti->text(expression_col_));
}