本文整理汇总了C++中QTreeWidgetItem::setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeWidgetItem::setBackgroundColor方法的具体用法?C++ QTreeWidgetItem::setBackgroundColor怎么用?C++ QTreeWidgetItem::setBackgroundColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeWidgetItem
的用法示例。
在下文中一共展示了QTreeWidgetItem::setBackgroundColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onAddEntry
//! Add or update an entry in the cut list
void TTCutList::onAddEntry(int cutIn, int cutOut)
{
int cutIndex;
if ( ttAssigned(cutListData) ) {
if (editItemIndex < 0) {
cutIndex = cutListData->addItem( cutIn, cutOut );
QTreeWidgetItem* treeItem = new QTreeWidgetItem(videoCutList);
treeItem->setText(0, cutListData->streamFileName());
treeItem->setText(1, cutListData->cutInPosString(cutIndex));
treeItem->setText(2, cutListData->cutOutPosString(cutIndex));
treeItem->setText(3, cutListData->cutLengthString(cutIndex));
} else {
cutListData->updateItem(editItemIndex, cutIn, cutOut);
QTreeWidgetItem* editItem = videoCutList->topLevelItem(editItemIndex);
editItem->setText(0, cutListData->streamFileName());
editItem->setText(1, cutListData->cutInPosString(editItemIndex));
editItem->setText(2, cutListData->cutOutPosString(editItemIndex));
editItem->setText(3, cutListData->cutLengthString(editItemIndex));
editItem->setBackgroundColor(0, Qt::white);
editItem->setBackgroundColor(1, Qt::white);
editItem->setBackgroundColor(2, Qt::white);
editItem->setBackgroundColor(3, Qt::white);
editItem->setBackgroundColor(4, Qt::white);
editItemIndex = -1;
}
emit refreshDisplay();
//cutListData->print();
}
}
示例2: read
//! [1]
int AdcListReader::read(QIODevice *device, QTreeWidgetItem **retVal)
{
xml.setDevice(device);
if (xml.readNextStartElement()) {
QXmlStreamAttributes attr(xml.attributes());
if (xml.name() == "FileListing" && attr.value("Version") == "1") {
// Read extra metadata
treeWidget->setProperty("generator", attr.value("Generator").toString().trimmed());
treeWidget->setProperty("base", attr.value("Base").toString().trimmed());
QTreeWidgetItem *topLevelNode = createChildItem(0, ShowListing::DirFileTree::RootType);
topLevelNode->setBackgroundColor(0, QColor(240, 240, 255));
topLevelNode->setTextColor(0, Qt::darkMagenta);
topLevelNode->setText(0, attr.value("GeneratedDate").toString().trimmed() != "" ? QString("Date=%1").arg(attr.value("GeneratedDate").toString().trimmed()) : "");
topLevelNode->setIcon(0, treeWidget->catalogIcon);
topLevelNode->setData(1, Qt::UserRole, 0);
readAdcList(topLevelNode);
qulonglong totalSize = topLevelNode->data(1, Qt::UserRole).toLongLong();
topLevelNode->setText(1, QString("[ %1 ]").arg(humanizeBigNums(totalSize, 2)));
topLevelNode->setTextColor(1, getColorFromSize(totalSize));
if (retVal) {
*retVal = topLevelNode;
}
}
else {
xml.raiseError(QObject::tr("The file is not an ADC FileListing version 1 XML file. Found root element: %1")
.arg(xml.name().toString()));
}
}
return xml.hasError();
}
示例3: add
void SkladView::add(ShopItem *pItem, const bool isNew)
{
QTreeWidgetItem* pTreeItem = new QTreeWidgetItem();
pTreeItem->setText(sklad_view_num, "---");
pTreeItem->setText(sklad_view_code, pItem->code);
pTreeItem->setText(sklad_view_name, pItem->name);
pTreeItem->setText(sklad_view_count, QString::number(pItem->count));
pTreeItem->setText(sklad_view_sell_price, QString::number(pItem->selling_price));
pTreeItem->setText(sklad_view_buy_price, QString::number(pItem->buying_price));
pTreeItem->setText(sklad_view_discont, QString::number(pItem->discont));
pTreeItem->setText(sklad_view_bonus, QString::number(pItem->bonus));
pTreeItem->setText(sklad_view_bonus_pay, ShopState::flagToString(pItem->flags & si_flag_cant_pay_bonus));
pTreeItem->setText(sklad_view_free_price, ShopState::flagToString(pItem->flags & si_flag_free_price));
float finalPrice = pItem->selling_price*(1. - 0.01*pItem->discont);
pTreeItem->setText(sklad_view_final_price, QString::number(finalPrice));
pTreeItem->setData(sklad_view_num, sklad_view_role_item, QVariant::fromValue((void*)pItem));
pTreeItem->setData(sklad_view_num, sklad_view_role_state, isNew ? sklad_view_new_item : sklad_view_exs_item);
pTreeItem->setFlags(pTreeItem->flags() | Qt::ItemIsEditable);
if(isNew){
for(int n = 0; n < sklad_view_total; ++n)
pTreeItem->setBackgroundColor(n, QColor(200, 255, 200, 255));
} else{
pTreeItem->setText(sklad_view_added, pItem->added.toString());
pTreeItem->setText(sklad_view_last_change, pItem->changed.toString());
}
ui->view->addTopLevelItem(pTreeItem);
}
示例4: onModifyMacroAction
void DlgCustomKeyboardImp::onModifyMacroAction(const QByteArray& macro)
{
QVariant data = categoryBox->itemData(categoryBox->currentIndex(), Qt::UserRole);
QString group = data.toString();
if (group == QLatin1String("Macros"))
{
CommandManager & cCmdMgr = Application::Instance->commandManager();
Command* pCmd = cCmdMgr.getCommandByName(macro);
for (int i=0; i<commandTreeWidget->topLevelItemCount(); i++) {
QTreeWidgetItem* item = commandTreeWidget->topLevelItem(i);
QByteArray command = item->data(1, Qt::UserRole).toByteArray();
if (command == macro) {
item->setText(1, QString::fromUtf8(pCmd->getMenuText()));
item->setToolTip(1, QString::fromUtf8(pCmd->getToolTipText()));
item->setData(1, Qt::UserRole, macro);
item->setSizeHint(0, QSize(32, 32));
item->setBackgroundColor(0, Qt::lightGray);
if (pCmd->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme(pCmd->getPixmap()));
if (commandTreeWidget->isItemSelected(item))
textLabelDescription->setText(item->toolTip(1));
break;
}
}
}
}
示例5: CreateAudioAssetGameAssetBranch
AEResult GameAssetTreeWidget::CreateAudioAssetGameAssetBranch(AudioAsset* gameAsset)
{
////////////////////////////////////////////
//No need to lock this function as it is internal
//and calling function should lock it
////////////////////////////////////////////
if (!m_IsReady)
{
return AEResult::NotReady;
}
AEAssert(m_EngineViewer != nullptr);
if (m_EngineViewer == nullptr)
{
AETODO("Add new error GameAppNull");
return AEResult::NullObj;
}
AEAssert(gameAsset != nullptr);
if (gameAsset == nullptr)
{
return AEResult::NullParameter;
}
////////////////////////////////////////
//Create Branch
QTreeWidgetItem* branch = new QTreeWidgetItem();
branch->setData(0, Qt::ItemDataRole::DisplayRole, QString::fromStdWString(gameAsset->GetName()));
branch->setData(0, AE_QT_ITEM_DATA_ROLE_GAME_ASSET_UNIQUE_ID, QVariant(gameAsset->GetUniqueAssetID()));
////////////////////////////////////////
//Add to Main Tree
this->addTopLevelItem(branch);
////////////////////////////////////////
//Set background as red if it not loaded
if (!gameAsset->IsLoaded())
{
branch->setBackgroundColor(0, QColor(255, 0, 0));
branch->setBackgroundColor(1, QColor(255, 0, 0));
}
////////////////////////////////////////
//Game Content Type
QTreeWidgetItem* gameContentTypeChild = new QTreeWidgetItem();
gameContentTypeChild->setData(0, Qt::ItemDataRole::DisplayRole, "GCT");
gameContentTypeChild->setData(1, Qt::ItemDataRole::DisplayRole, "Audio");
gameContentTypeChild->setToolTip(0, "Game Content Type");
////////////////////////////////////////
//Add Child to Model Branch
branch->addChild(gameContentTypeChild);
////////////////////////////////////////
//Finish
return AEResult::Ok;
}
示例6: setupItem
void CompareSideBySideView::setupItem(DiffSingleNodeResult *node, QTreeWidgetItem *currentNodeItem, const bool isReference, QList<QTreeWidgetItem*> &itemsList, QList<DiffInfo*> &diffList, const bool isChildrenBlocked)
{
SourceElementDiffOperation *sourceRef = node->referenceElement();
SourceElementDiffOperation *compareRef = node->compareElement();
SourceElementDiffOperation *source = getSource(node, isReference);
bool isEmpty = isNodeEmpty(node, isReference);
QString text = getText(source, node->type(), isEmpty);
setGraphic(currentNodeItem, node->type(), isEmpty) ;
currentNodeItem->setText(0, text);
if(node->hasAttributes()) {
QTreeWidgetItem *attributeTextItem = newTreeItem(itemsList);
if(isReference) {
DiffInfo *info = NULL ;
// if blocked, use the last item
if(isChildrenBlocked) {
info = diffList.at(diffList.size() - 1);
}
setLastItemDiff(isReference, itemsList, diffList, info);
}
if(!isEmpty) {
//attributeTextItem->setBackgroundColor(0, colo);aaa
attributeTextItem->setBackgroundColor(0, currentNodeItem->backgroundColor(0));
attributeTextItem->setText(0, tr("Attributes:"));
} else {
attributeTextItem->setBackgroundColor(0, _chrome.emptyColor());
}
currentNodeItem->addChild(attributeTextItem);
// added only if it is the reference
bool emptyAddedAttributes = !isReference || isEmpty ;
bool emptyDeletedAttributes = isReference || isEmpty ;
if(NULL != sourceRef) {
appendAttributes(node, attributeTextItem, EDiff::ED_ADDED, isReference, emptyAddedAttributes, sourceRef->addedAttributes(), itemsList, diffList, isChildrenBlocked);
}
appendAttributes(node, attributeTextItem, EDiff::ED_MODIFIED, isReference, isEmpty, source->modifiedAttributes(), itemsList, diffList, isChildrenBlocked);
appendAttributes(node, attributeTextItem, EDiff::ED_EQUAL, isReference, isEmpty, node->equalsAttributes(), itemsList, diffList, isChildrenBlocked);
if(NULL != compareRef) {
appendAttributes(node, attributeTextItem, EDiff::ED_DELETED, isReference, emptyDeletedAttributes, compareRef->addedAttributes(), itemsList, diffList, isChildrenBlocked);
}
}
}
示例7: setGradientStops
/** Sets content of tree widget corresponding \a stops list.
* * \sa gradientStops()
*/
void GradientEditWidget::setGradientStops(const QGradientStops &stops) {
treeWidget->clear();
foreach (QGradientStop stop, stops) {
QStringList list;
list << QString::number(stop.first, 'f', 2) << "";
QTreeWidgetItem *item = new QTreeWidgetItem(list);
item->setBackgroundColor(1, stop.second);
treeWidget->addTopLevelItem(item);
}
示例8: SetItem
bool wxListCtrl::SetItem(wxListItem& info)
{
const long id = info.GetId();
QTreeWidgetItem *qitem = QtGetItem(id);
if ( qitem != NULL )
{
if ((info.m_mask & wxLIST_MASK_TEXT) && !info.GetText().IsNull() )
qitem->setText(info.GetColumn(), wxQtConvertString(info.GetText()));
qitem->setTextAlignment(info.GetColumn(), wxQtConvertTextAlign(info.GetAlign()));
if ( info.m_mask & wxLIST_MASK_DATA )
{
QVariant variant = qVariantFromValue(info.GetData());
qitem->setData(0, Qt::UserRole, variant);
}
if (info.m_mask & wxLIST_MASK_STATE)
{
if ((info.m_stateMask & wxLIST_STATE_FOCUSED) &&
(info.m_state & wxLIST_STATE_FOCUSED))
m_qtTreeWidget->setCurrentItem(qitem, 0);
if (info.m_stateMask & wxLIST_STATE_SELECTED)
qitem->setSelected(info.m_state & wxLIST_STATE_SELECTED);
}
if (info.m_mask & wxLIST_MASK_IMAGE)
{
if (info.m_image >= 0)
{
wxImageList *imglst = GetImageList(InReportView() ? wxIMAGE_LIST_SMALL : wxIMAGE_LIST_NORMAL);
wxCHECK_MSG(imglst, false, "invalid listctrl imagelist");
const wxBitmap* bitmap = imglst->GetBitmapPtr(info.m_image);
if (bitmap != NULL)
{
// set the new image:
qitem->setIcon( info.GetColumn(), QIcon( *bitmap->GetHandle() ));
}
}
else
{
// remove the image using and empty qt icon:
qitem->setIcon( info.GetColumn(), QIcon() );
}
}
for (int col=0; col<GetColumnCount(); col++)
{
if ( info.GetFont().IsOk() )
qitem->setFont(col, info.GetFont().GetHandle() );
if ( info.GetTextColour().IsOk() )
qitem->setTextColor(col, info.GetTextColour().GetHandle());
if ( info.GetBackgroundColour().IsOk() )
qitem->setBackgroundColor(col, info.GetBackgroundColour().GetHandle());
}
return true;
}
else
return false;
}
示例9: installSmartSettings
void QUTaskItem::installSmartSettings() {
task()->provideData(monty->unsupportedTags(), QUTask::UnsupportedTags);
foreach(QUSmartSettingInterface *smartSetting, task()->smartSettings()) {
QTreeWidgetItem *sItem = new QTreeWidgetItem();
sItem->setBackgroundColor(0, QColor(239, 239, 239));
addChild(sItem);
treeWidget()->setItemWidget(sItem, 0, smartSetting->editor());
connect(smartSetting, SIGNAL(changed()), this, SLOT(highlightChanges()));
}
示例10: onRunTestsStarted
void TestListView::onRunTestsStarted(void) {
// gray out all tests
const int programCount = topLevelItemCount();
for ( int i = 0; i < programCount; ++i ) {
QTreeWidgetItem* programItem = topLevelItem(i);
Q_ASSERT_X(programItem, Q_FUNC_INFO, "null tree item");
programItem->setBackgroundColor(0, m_noResultColor);
const int suiteCount = programItem->childCount();
for ( int j = 0; j < suiteCount; ++j ) {
QTreeWidgetItem* suiteItem = programItem->child(j);
Q_ASSERT_X(suiteItem, Q_FUNC_INFO, "null tree item");
suiteItem->setBackgroundColor(0, m_noResultColor);
const int testCount = suiteItem->childCount();
for ( int k = 0; k < testCount; ++k ) {
QTreeWidgetItem* testItem = suiteItem->child(k);
Q_ASSERT_X(testItem, Q_FUNC_INFO, "null tree item");
testItem->setBackgroundColor(0, m_noResultColor);
}
}
}
}
示例11: onAddMacroAction
void DlgCustomKeyboardImp::onAddMacroAction(const QByteArray& macro)
{
QVariant data = categoryBox->itemData(categoryBox->currentIndex(), Qt::UserRole);
QString group = data.toString();
if (group == QLatin1String("Macros"))
{
CommandManager & cCmdMgr = Application::Instance->commandManager();
Command* pCmd = cCmdMgr.getCommandByName(macro);
QTreeWidgetItem* item = new QTreeWidgetItem(commandTreeWidget);
item->setText(1, QString::fromUtf8(pCmd->getMenuText()));
item->setToolTip(1, QString::fromUtf8(pCmd->getToolTipText()));
item->setData(1, Qt::UserRole, macro);
item->setSizeHint(0, QSize(32, 32));
item->setBackgroundColor(0, Qt::lightGray);
if (pCmd->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme(pCmd->getPixmap()));
}
}
示例12: addChild
//Adds child to item in CFDP tree
int Item::addChild(int column, QColor color, QString text, QIcon icon)
{
//Creates child
QTreeWidgetItem *newChild = new QTreeWidgetItem();
//Creates item for timestamp, to become first child of child
QTreeWidgetItem *timeChild = new QTreeWidgetItem();
//Sets up child and timestamp based on parameters given to child
if(column == 0)
{
newChild->setText(0, text);
newChild->setBackgroundColor(0, color);
timeChild->setText(0, time());
timeChild->setTextColor(0, white);
}
else if(column == 1)
{
newChild->setText(1, " " + text);
newChild->setBackgroundColor(1, color);
timeChild->setText(1, " " + time());
timeChild->setTextColor(1, white);
}
else
{
newChild->setText(0, text);
newChild->setText(1, " " + text);
newChild->setBackgroundColor(0, color);
newChild->setBackgroundColor(1, color);
timeChild->setText(0, time());
timeChild->setText(1, " " + time());
timeChild->setTextColor(0, white);
timeChild->setTextColor(1, white);
}
//Sets text color (for easy viewing) and status (for easy sorting) based on color given to child
if(color == yellow)
{
newChild->setTextColor(0, black);
newChild->setTextColor(1, black);
status = 4;
}
else if(color == orange)
{
newChild->setTextColor(0, black);
newChild->setTextColor(1, black);
status = 3;
}
else if(color == none)
{
newChild->setTextColor(0, white);
newChild->setTextColor(1, white);
status = 5;
}
else
{
newChild->setTextColor(0, black);
newChild->setTextColor(1, black);
}
//Sets top level item icon
topLevelItem->setIcon(0, icon);
topLevelItem->setIcon(1, icon);
//Adds child and timestamp to top level item
topLevelItem->addChild(newChild);
children.push_back(newChild);
newChild->addChild(timeChild);
//Returns current number of children for easy access when adding grandchildren
return(children.size());
}
示例13: LabeledSectionGroup
OptionsFileLocations::OptionsFileLocations() :
LabeledSectionGroup(NULL)
{
// Path locations
QStringList columnNames;
columnNames.append("Type");
columnNames.append("Location");
mpPathTree = new CustomTreeWidget(this);
addSection(createLabeledSection(mpPathTree, columnNames, "Default Paths", this), 1000);
// File locations
columnNames.append("Arguments");
mpFileTree = new CustomTreeWidget(this);
addSection(createLabeledSection(mpFileTree, columnNames, "Default Files", this), 1000);
addStretch(1);
mFileLocations.push_back(FileLocationDescriptor("Default Export Path",
ConfigurationSettings::getSettingExportPathKey()));
mFileLocations.push_back(FileLocationDescriptor("Default Import Path",
ConfigurationSettings::getSettingImportPathKey()));
mFileLocations.push_back(FileLocationDescriptor("Default Session Save/Open Path",
ConfigurationSettings::getSettingSaveOpenSessionPathKey()));
FileBrowser* pTemplateFileBrowser = new FileBrowser(mpFileTree);
pTemplateFileBrowser->setBrowseCaption("Select Template File");
pTemplateFileBrowser->setBrowseFileFilters("Template Files (*.spg);;All Files (*)");
pTemplateFileBrowser->hide();
mFileLocations.push_back(FileLocationDescriptor("Default Product Template",
ProductView::getSettingTemplateFileKey(), pTemplateFileBrowser));
mFileLocations.push_back(FileLocationDescriptor("Message Log Path",
ConfigurationSettings::getSettingMessageLogPathKey()));
mFileLocations.push_back(FileLocationDescriptor("Product Template Path",
ProductView::getSettingTemplatePathKey()));
mFileLocations.push_back(FileLocationDescriptor("Temp Path",
ConfigurationSettings::getSettingTempPathKey()));
mFileLocations.push_back(FileLocationDescriptor("Support Files Path",
ConfigurationSettings::getSettingSupportFilesPathKey()));
mFileLocations.push_back(FileLocationDescriptor("Wizard Path",
ConfigurationSettings::getSettingWizardPathKey()));
FileBrowser* pTextEditorBrowser = new FileBrowser(mpFileTree);
pTextEditorBrowser->setBrowseCaption("Select Text Editor");
pTextEditorBrowser->setToolTip(
"If %1 is specified as an argument it will be replaced by the name of the file to be edited at run time.\n"
"Otherwise the name of the file will be appended to the command line after all of the specified arguments.");
#if defined(WIN_API)
pTextEditorBrowser->setBrowseFileFilters("Text Editors (*.exe);;All Files (*)");
#endif
pTextEditorBrowser->hide();
mFileLocations.push_back(FileLocationDescriptor("Text Editor", ConfigurationSettings::getSettingTextEditorKey(),
pTextEditorBrowser, ConfigurationSettings::getSettingTextEditorArgumentsKey()));
Service<ConfigurationSettings> pSettings;
for (vector<FileLocationDescriptor>::iterator iter = mFileLocations.begin(); iter != mFileLocations.end(); ++iter)
{
QString dir;
const Filename* pFilename = dv_cast<Filename>(&pSettings->getSetting(iter->getKey()));
if (pFilename != NULL)
{
dir = QString::fromStdString(pFilename->getFullPathAndName());
dir.replace(QRegExp("\\\\"), "/");
}
QTreeWidgetItem* pItem = new QTreeWidgetItem(iter->getFileBrowser() == NULL ? mpPathTree : mpFileTree);
if (pItem != NULL)
{
pItem->setText(0, QString::fromStdString(iter->getText()));
pItem->setText(1, dir);
if (iter->getFileBrowser() == NULL)
{
mpPathTree->setCellWidgetType(pItem, 1, CustomTreeWidget::BROWSE_DIR_EDIT);
}
else
{
mpFileTree->setCellWidgetType(pItem, 1, CustomTreeWidget::BROWSE_FILE_EDIT);
mpFileTree->setFileBrowser(pItem, 1, iter->getFileBrowser());
if (iter->getArgumentKey().empty())
{
pItem->setBackgroundColor(2, QColor(235, 235, 235));
}
else
{
const string& arguments = dv_cast<string>(pSettings->getSetting(iter->getArgumentKey()));
mpFileTree->setCellWidgetType(pItem, 2, CustomTreeWidget::LINE_EDIT);
pItem->setText(2, QString::fromStdString(arguments));
}
}
}
if (iter->getText() == "Wizard Path")
//.........这里部分代码省略.........
示例14: on_editShortcut_textChanged
/** Checks for an already occupied shortcut. */
void DlgCustomKeyboardImp::on_editShortcut_textChanged(const QString& sc)
{
assignedTreeWidget->clear();
QTreeWidgetItem* item = commandTreeWidget->currentItem();
if (!item)
return;
QVariant data = item->data(1, Qt::UserRole);
QByteArray name = data.toByteArray(); // command name
CommandManager & cCmdMgr = Application::Instance->commandManager();
Command* cmd = cCmdMgr.getCommandByName(name.constData());
if (cmd && !cmd->getAction()) {
buttonAssign->setEnabled(false); // command not in use
return;
}
buttonAssign->setEnabled(true);
QKeySequence ks(sc);
if (!ks.isEmpty()) {
int countAmbiguous = 0;
QString ambiguousCommand;
QString ambiguousMenu;
CommandManager & cCmdMgr = Application::Instance->commandManager();
std::vector<Command*> cmds = cCmdMgr.getAllCommands();
for (std::vector<Command*>::iterator it = cmds.begin(); it != cmds.end(); ++it) {
QList<QAction*> acts;
if ((*it)->getAction()) {
// A command may have several QAction's. So, check all of them if one of them matches (See bug #0002160)
QList<QAction*> acts = (*it)->getAction()->findChildren<QAction*>();
for (QList<QAction*>::iterator jt = acts.begin(); jt != acts.end(); ++jt) {
if ((*jt)->shortcut() == ks) {
++countAmbiguous;
ambiguousCommand = QString::fromAscii((*it)->getName()); // store the last one
ambiguousMenu = qApp->translate((*it)->className(), (*it)->getMenuText());
QTreeWidgetItem* item = new QTreeWidgetItem(assignedTreeWidget);
item->setText(1, qApp->translate((*it)->className(), (*it)->getMenuText()));
item->setToolTip(1, qApp->translate((*it)->className(), (*it)->getToolTipText()));
item->setData(1, Qt::UserRole, QByteArray((*it)->getName()));
item->setSizeHint(0, QSize(32, 32));
item->setBackgroundColor(0, Qt::lightGray);
if ((*it)->getPixmap())
item->setIcon(0, BitmapFactory().iconFromTheme((*it)->getPixmap()));
break;
}
}
}
}
if (countAmbiguous > 0)
assignedTreeWidget->resizeColumnToContents(0);
if (countAmbiguous > 1) {
QMessageBox::warning(this, tr("Multiple defined shortcut"),
tr("The shortcut '%1' is defined more than once. This could result into unexpected behaviour.").arg(sc) );
editShortcut->setFocus();
buttonAssign->setEnabled(false);
} else if (countAmbiguous == 1 && ambiguousCommand != QLatin1String(name)) {
QMessageBox::warning(this, tr("Already defined shortcut"),
tr("The shortcut '%1' is already assigned to '%2'.\n\nPlease define another shortcut.").arg(sc).arg(ambiguousMenu) );
editShortcut->setFocus();
buttonAssign->setEnabled(false);
} else {
if (cmd && cmd->getAction() && cmd->getAction()->shortcut() == ks)
buttonAssign->setEnabled(false);
}
} else {
if (cmd && cmd->getAction() && cmd->getAction()->shortcut().isEmpty())
buttonAssign->setEnabled(false); // both key sequences are empty
}
}
示例15: initialize
//.........这里部分代码省略.........
double pixelSize = pRasterDescriptor->getXPixelSize();
pXPixelSizeItem->setText(0, "X Pixel Size");
pXPixelSizeItem->setText(1, QString::number(pixelSize));
if (mReadOnly == false)
{
mpTreeWidget->setCellWidgetType(pXPixelSizeItem, 1, CustomTreeWidget::LINE_EDIT);
}
}
QTreeWidgetItem* pYPixelSizeItem = new QTreeWidgetItem(mpTreeWidget);
if (pYPixelSizeItem != NULL)
{
double pixelSize = pRasterDescriptor->getYPixelSize();
pYPixelSizeItem->setText(0, "Y Pixel Size");
pYPixelSizeItem->setText(1, QString::number(pixelSize));
if (mReadOnly == false)
{
mpTreeWidget->setCellWidgetType(pYPixelSizeItem, 1, CustomTreeWidget::LINE_EDIT);
}
}
// Units
const Units* pUnits = pRasterDescriptor->getUnits();
if (pUnits != NULL)
{
QTreeWidgetItem* pUnitsItem = new QTreeWidgetItem(mpTreeWidget);
if (pUnitsItem != NULL)
{
pUnitsItem->setText(0, "Units");
pUnitsItem->setBackgroundColor(1, Qt::lightGray);
// Name
QTreeWidgetItem* pNameItem = new QTreeWidgetItem(pUnitsItem);
if (pNameItem != NULL)
{
string unitsName = pUnits->getUnitName();
pNameItem->setText(0, "Name");
pNameItem->setText(1, QString::fromStdString(unitsName));
if (mReadOnly == false)
{
mpTreeWidget->setCellWidgetType(pNameItem, 1, CustomTreeWidget::LINE_EDIT);
}
}
// Type
QTreeWidgetItem* pTypeItem = new QTreeWidgetItem(pUnitsItem);
if (pTypeItem != NULL)
{
UnitType unitType = pUnits->getUnitType();
string unitTypeText = StringUtilities::toDisplayString(unitType);
pTypeItem->setText(0, "Type");
pTypeItem->setText(1, QString::fromStdString(unitTypeText));
if (mReadOnly == false)
{
QComboBox* pUnitTypeCombo = new QComboBox(mpTreeWidget);
pUnitTypeCombo->setEditable(false);
pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(ABSORBANCE)));
pUnitTypeCombo->addItem(QString::fromStdString(StringUtilities::toDisplayString(ABSORPTANCE)));