void FormWindowBase::reloadProperties() { pixmapCache()->clear(); iconCache()->clear(); QMapIterator<QDesignerPropertySheet *, QMap<int, bool> > itSheet(m_d->m_reloadableResources); while (itSheet.hasNext()) { QDesignerPropertySheet *sheet = itSheet.next().key(); QMapIterator<int, bool> itIndex(itSheet.value()); while (itIndex.hasNext()) { const int index = itIndex.next().key(); const QVariant newValue = sheet->property(index); if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) { const PropertySheetStringValue newString = qvariant_cast<PropertySheetStringValue>(newValue); // optimize a bit, reset only if the text value might contain a reference to qt resources // (however reloading of icons other than taken from resources might not work here) if (newString.value().contains(QLatin1String(":/"))) { const QVariant resetValue = QVariant::fromValue(PropertySheetStringValue()); sheet->setProperty(index, resetValue); } } sheet->setProperty(index, newValue); } if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) { const int count = tabWidget->count(); const int current = tabWidget->currentIndex(); const QString currentTabIcon = QLatin1String("currentTabIcon"); for (int i = 0; i < count; i++) { tabWidget->setCurrentIndex(i); const int index = sheet->indexOf(currentTabIcon); sheet->setProperty(index, sheet->property(index)); } tabWidget->setCurrentIndex(current); } else if (QToolBox *toolBox = qobject_cast<QToolBox *>(sheet->object())) { const int count = toolBox->count(); const int current = toolBox->currentIndex(); const QString currentItemIcon = QLatin1String("currentItemIcon"); for (int i = 0; i < count; i++) { toolBox->setCurrentIndex(i); const int index = sheet->indexOf(currentItemIcon); sheet->setProperty(index, sheet->property(index)); } toolBox->setCurrentIndex(current); } } QMapIterator<QDesignerPropertySheet *, QObject *> itSh(m_d->m_reloadablePropertySheets); while (itSh.hasNext()) { QObject *object = itSh.next().value(); reloadIconResources(iconCache(), object); } }
TreeWidgetEditor::TreeWidgetEditor(QDesignerFormWindowInterface *form, QWidget *parent) : AbstractItemEditor(form, parent), m_updatingBrowser(false) { m_columnEditor = new ItemListEditor(form, this); m_columnEditor->setObjectName(QLatin1String("columnEditor")); m_columnEditor->setNewItemText(tr("New Column")); ui.setupUi(this); injectPropertyBrowser(ui.itemsTab, ui.widget); connect(ui.showPropertiesButton, SIGNAL(clicked()), this, SLOT(togglePropertyBrowser())); togglePropertyBrowser(); ui.tabWidget->insertTab(0, m_columnEditor, tr("&Columns")); ui.tabWidget->setCurrentIndex(0); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); ui.newItemButton->setIcon(createIconSet(QString::fromUtf8("plus.png"))); ui.newSubItemButton->setIcon(createIconSet(QString::fromUtf8("downplus.png"))); ui.deleteItemButton->setIcon(createIconSet(QString::fromUtf8("minus.png"))); ui.moveItemUpButton->setIcon(createIconSet(QString::fromUtf8("up.png"))); ui.moveItemDownButton->setIcon(createIconSet(QString::fromUtf8("down.png"))); ui.moveItemRightButton->setIcon(createIconSet(QString::fromUtf8("leveldown.png"))); ui.moveItemLeftButton->setIcon(createIconSet(QString::fromUtf8("levelup.png"))); ui.treeWidget->header()->setMovable(false); connect(iconCache(), SIGNAL(reloaded()), this, SLOT(cacheReloaded())); }
void FormWindowBase::resourceSetActivated(QtResourceSet *resource, bool resourceSetChanged) { if (resource == resourceSet() && resourceSetChanged) { reloadProperties(); emit pixmapCache()->reloaded(); emit iconCache()->reloaded(); if (QDesignerPropertyEditor *propertyEditor = qobject_cast<QDesignerPropertyEditor *>(core()->propertyEditor())) propertyEditor->reloadResourceProperties(); } }
TableWidgetEditor::TableWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog) : AbstractItemEditor(form, 0), m_updatingBrowser(false) { m_columnEditor = new ItemListEditor(form, this); m_columnEditor->setObjectName(QLatin1String("columnEditor")); m_columnEditor->setNewItemText(tr("New Column")); m_rowEditor = new ItemListEditor(form, this); m_rowEditor->setObjectName(QLatin1String("rowEditor")); m_rowEditor->setNewItemText(tr("New Row")); ui.setupUi(dialog); injectPropertyBrowser(ui.itemsTab, ui.widget); connect(ui.showPropertiesButton, SIGNAL(clicked()), this, SLOT(togglePropertyBrowser())); setPropertyBrowserVisible(false); ui.tabWidget->insertTab(0, m_columnEditor, tr("&Columns")); ui.tabWidget->insertTab(1, m_rowEditor, tr("&Rows")); ui.tabWidget->setCurrentIndex(0); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); ui.tableWidget->setSelectionMode(QAbstractItemView::SingleSelection); connect(iconCache(), SIGNAL(reloaded()), this, SLOT(cacheReloaded())); connect(ui.tableWidget, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(on_tableWidget_currentCellChanged(int,int,int,int))); connect(ui.tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(on_tableWidget_itemChanged(QTableWidgetItem*))); connect(m_columnEditor, SIGNAL(indexChanged(int)), this, SLOT(on_columnEditor_indexChanged(int))); connect(m_columnEditor, SIGNAL(itemChanged(int,int,QVariant)), this, SLOT(on_columnEditor_itemChanged(int,int,QVariant))); connect(m_columnEditor, SIGNAL(itemInserted(int)), this, SLOT(on_columnEditor_itemInserted(int))); connect(m_columnEditor, SIGNAL(itemDeleted(int)), this, SLOT(on_columnEditor_itemDeleted(int))); connect(m_columnEditor, SIGNAL(itemMovedUp(int)), this, SLOT(on_columnEditor_itemMovedUp(int))); connect(m_columnEditor, SIGNAL(itemMovedDown(int)), this, SLOT(on_columnEditor_itemMovedDown(int))); connect(m_rowEditor, SIGNAL(indexChanged(int)), this, SLOT(on_rowEditor_indexChanged(int))); connect(m_rowEditor, SIGNAL(itemChanged(int,int,QVariant)), this, SLOT(on_rowEditor_itemChanged(int,int,QVariant))); connect(m_rowEditor, SIGNAL(itemInserted(int)), this, SLOT(on_rowEditor_itemInserted(int))); connect(m_rowEditor, SIGNAL(itemDeleted(int)), this, SLOT(on_rowEditor_itemDeleted(int))); connect(m_rowEditor, SIGNAL(itemMovedUp(int)), this, SLOT(on_rowEditor_itemMovedUp(int))); connect(m_rowEditor, SIGNAL(itemMovedDown(int)), this, SLOT(on_rowEditor_itemMovedDown(int))); }
TreeWidgetEditor::TreeWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog) : AbstractItemEditor(form, 0), m_updatingBrowser(false) { m_columnEditor = new ItemListEditor(form, this); m_columnEditor->setObjectName(QStringLiteral("columnEditor")); m_columnEditor->setNewItemText(tr("New Column")); ui.setupUi(dialog); injectPropertyBrowser(ui.itemsTab, ui.widget); connect(ui.showPropertiesButton, SIGNAL(clicked()), this, SLOT(togglePropertyBrowser())); setPropertyBrowserVisible(false); ui.tabWidget->insertTab(0, m_columnEditor, tr("&Columns")); ui.tabWidget->setCurrentIndex(0); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); ui.newItemButton->setIcon(createIconSet(QString::fromUtf8("plus.png"))); ui.newSubItemButton->setIcon(createIconSet(QString::fromUtf8("downplus.png"))); ui.deleteItemButton->setIcon(createIconSet(QString::fromUtf8("minus.png"))); ui.moveItemUpButton->setIcon(createIconSet(QString::fromUtf8("up.png"))); ui.moveItemDownButton->setIcon(createIconSet(QString::fromUtf8("down.png"))); ui.moveItemRightButton->setIcon(createIconSet(QString::fromUtf8("leveldown.png"))); ui.moveItemLeftButton->setIcon(createIconSet(QString::fromUtf8("levelup.png"))); ui.treeWidget->header()->setSectionsMovable(false); connect(ui.newItemButton, SIGNAL(clicked()), this, SLOT(on_newItemButton_clicked())); connect(ui.newSubItemButton, SIGNAL(clicked()), this, SLOT(on_newSubItemButton_clicked())); connect(ui.moveItemUpButton, SIGNAL(clicked()), this, SLOT(on_moveItemUpButton_clicked())); connect(ui.moveItemDownButton, SIGNAL(clicked()), this, SLOT(on_moveItemDownButton_clicked())); connect(ui.moveItemRightButton, SIGNAL(clicked()), this, SLOT(on_moveItemRightButton_clicked())); connect(ui.moveItemLeftButton, SIGNAL(clicked()), this, SLOT(on_moveItemLeftButton_clicked())); connect(ui.deleteItemButton, SIGNAL(clicked()), this, SLOT(on_deleteItemButton_clicked())); connect(ui.treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(on_treeWidget_currentItemChanged())); connect(ui.treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(on_treeWidget_itemChanged(QTreeWidgetItem*,int))); connect(m_columnEditor, SIGNAL(indexChanged(int)), this, SLOT(on_columnEditor_indexChanged(int))); connect(m_columnEditor, SIGNAL(itemChanged(int,int,QVariant)), this, SLOT(on_columnEditor_itemChanged(int,int,QVariant))); connect(m_columnEditor, SIGNAL(itemInserted(int)), this, SLOT(on_columnEditor_itemInserted(int))); connect(m_columnEditor, SIGNAL(itemDeleted(int)), this, SLOT(on_columnEditor_itemDeleted(int))); connect(m_columnEditor, SIGNAL(itemMovedUp(int)), this, SLOT(on_columnEditor_itemMovedUp(int))); connect(m_columnEditor, SIGNAL(itemMovedDown(int)), this, SLOT(on_columnEditor_itemMovedDown(int))); connect(iconCache(), SIGNAL(reloaded()), this, SLOT(cacheReloaded())); }
TableWidgetContents TableWidgetEditor::fillContentsFromTableWidget(QTableWidget *tableWidget) { TableWidgetContents tblCont; tblCont.fromTableWidget(tableWidget, false); tblCont.applyToTableWidget(ui.tableWidget, iconCache(), true); tblCont.m_verticalHeader.applyToListWidget(m_rowEditor->listWidget(), iconCache(), true); m_rowEditor->setupEditor(tableWidget, tableHeaderPropList); tblCont.m_horizontalHeader.applyToListWidget(m_columnEditor->listWidget(), iconCache(), true); m_columnEditor->setupEditor(tableWidget, tableHeaderPropList); setupEditor(tableWidget, tableItemPropList); if (ui.tableWidget->columnCount() > 0 && ui.tableWidget->rowCount() > 0) ui.tableWidget->setCurrentCell(0, 0); updateEditor(); return tblCont; }
void FormWindowBase::reloadProperties() { pixmapCache()->clear(); iconCache()->clear(); QMapIterator<QDesignerPropertySheet *, QMap<int, bool> > itSheet(m_d->m_reloadableResources); while (itSheet.hasNext()) { QDesignerPropertySheet *sheet = itSheet.next().key(); QMapIterator<int, bool> itIndex(itSheet.value()); while (itIndex.hasNext()) { const int index = itIndex.next().key(); sheet->setProperty(index, sheet->property(index)); } if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) { const int count = tabWidget->count(); const int current = tabWidget->currentIndex(); const QString currentTabIcon = QLatin1String("currentTabIcon"); for (int i = 0; i < count; i++) { tabWidget->setCurrentIndex(i); const int index = sheet->indexOf(currentTabIcon); sheet->setProperty(index, sheet->property(index)); } tabWidget->setCurrentIndex(current); } else if (QToolBox *toolBox = qobject_cast<QToolBox *>(sheet->object())) { const int count = toolBox->count(); const int current = toolBox->currentIndex(); const QString currentItemIcon = QLatin1String("currentItemIcon"); for (int i = 0; i < count; i++) { toolBox->setCurrentIndex(i); const int index = sheet->indexOf(currentItemIcon); sheet->setProperty(index, sheet->property(index)); } toolBox->setCurrentIndex(current); } } QMapIterator<QDesignerPropertySheet *, QObject *> itSh(m_d->m_reloadablePropertySheets); while (itSh.hasNext()) { QObject *object = itSh.next().value(); reloadIconResources(iconCache(), object); } }
TreeWidgetContents TreeWidgetEditor::fillContentsFromTreeWidget(QTreeWidget *treeWidget) { TreeWidgetContents treeCont; treeCont.fromTreeWidget(treeWidget, false); treeCont.applyToTreeWidget(ui.treeWidget, iconCache(), true); treeCont.m_headerItem.applyToListWidget(m_columnEditor->listWidget(), iconCache(), true); m_columnEditor->setupEditor(treeWidget, treeHeaderPropList); QList<QtVariantProperty*> rootProperties; rootProperties.append(setupPropertyGroup(tr("Per column properties"), treeItemColumnPropList)); rootProperties.append(setupPropertyGroup(tr("Common properties"), treeItemCommonPropList)); m_rootProperties = rootProperties; m_propertyBrowser->setPropertiesWithoutValueMarked(true); m_propertyBrowser->setRootIsDecorated(false); setupObject(treeWidget); if (ui.treeWidget->topLevelItemCount() > 0) ui.treeWidget->setCurrentItem(ui.treeWidget->topLevelItem(0)); updateEditor(); return treeCont; }
void AbstractItemEditor::propertyChanged(QtProperty *property) { if (m_updatingBrowser) return; BoolBlocker block(m_updatingBrowser); QtVariantProperty *prop = m_propertyManager->variantProperty(property); int role; if ((role = m_propertyToRole.value(prop, -1)) == -1) // Subproperty return; if ((role == ItemFlagsShadowRole && prop->value().toInt() == (int)QListWidgetItem().flags()) || (role == Qt::DecorationPropertyRole && !qVariantValue<PropertySheetIconValue>(prop->value()).mask()) || (role == Qt::FontRole && !qVariantValue<QFont>(prop->value()).resolve())) { prop->setModified(false); setItemData(role, QVariant()); } else { prop->setModified(true); setItemData(role, prop->value()); } switch (role) { case Qt::DecorationPropertyRole: setItemData(Qt::DecorationRole, qVariantFromValue(iconCache()->icon(qVariantValue<PropertySheetIconValue>(prop->value())))); break; case Qt::DisplayPropertyRole: setItemData(Qt::EditRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); break; case Qt::ToolTipPropertyRole: setItemData(Qt::ToolTipRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); break; case Qt::StatusTipPropertyRole: setItemData(Qt::StatusTipRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); break; case Qt::WhatsThisPropertyRole: setItemData(Qt::WhatsThisRole, qVariantFromValue(qVariantValue<PropertySheetStringValue>(prop->value()).value())); break; default: break; } prop->setValue(getItemData(role)); }
void TreeWidgetEditor::cacheReloaded() { reloadIconResources(iconCache(), ui.treeWidget); }