#include <actioneditor_p.h>
Inheritance diagram for qdesigner_internal::ActionEditor:


Definition at line 52 of file actioneditor_p.h.
| qdesigner_internal::ActionEditor::ActionEditor | ( | QDesignerFormEditorInterface * | core, | |
| QWidget * | parent = 0, |
|||
| Qt::WindowFlags | flags = 0 | |||
| ) |
Definition at line 119 of file actioneditor.cpp.
References QToolBar::addAction(), QToolBar::addWidget(), QSplitter::addWidget(), QObject::connect(), contextMenuRequested(), qdesigner_internal::createIconSet(), editAction(), QSizePolicy::Expanding, QListView::Fixed, Qt::Horizontal, QListView::IconMode, itemActivated(), l, m_actionDelete, m_actionGroups, m_actionNew, m_actionRepository, m_filterWidget, QSizePolicy::Minimum, QAction::setEnabled(), QWidget::setEnabled(), QAction::setIcon(), QToolBar::setIconSize(), QAbstractItemView::setItemDelegate(), QWidget::setSizePolicy(), QWidget::setWindowTitle(), SIGNAL, SLOT, slotDeleteAction(), slotItemChanged(), slotNewAction(), splitter, QListView::Static, and QListView::TopToBottom.
00120 : QDesignerActionEditorInterface(parent, flags), 00121 m_core(core) 00122 { 00123 setWindowTitle(tr("Actions")); 00124 00125 QVBoxLayout *l = new QVBoxLayout(this); 00126 l->setMargin(0); 00127 l->setSpacing(0); 00128 00129 QToolBar *toolbar = new QToolBar(this); 00130 // toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); // ### style 00131 toolbar->setIconSize(QSize(24, 24)); 00132 toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); 00133 l->addWidget(toolbar); 00134 00135 m_actionNew = toolbar->addAction(tr("New...")); 00136 m_actionNew->setIcon(createIconSet("filenew.png")); 00137 m_actionNew->setEnabled(false); 00138 connect(m_actionNew, SIGNAL(triggered()), this, SLOT(slotNewAction())); 00139 00140 m_actionDelete = toolbar->addAction(tr("Delete")); 00141 m_actionDelete->setIcon(createIconSet("editdelete.png")); 00142 m_actionDelete->setEnabled(false); 00143 00144 m_filterWidget = new ActionFilterWidget(this, toolbar); 00145 m_filterWidget->setEnabled(false); 00146 toolbar->addWidget(m_filterWidget); 00147 00148 connect(m_actionDelete, SIGNAL(triggered()), this, SLOT(slotDeleteAction())); 00149 00150 splitter = new QSplitter(Qt::Horizontal, this); 00151 splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 00152 00153 l->addWidget(splitter); 00154 00155 #if 0 // ### implement me 00156 m_actionGroups = new QListWidget(splitter); 00157 splitter->addWidget(m_actionGroups); 00158 m_actionGroups->setItemDelegate(new ActionGroupDelegate(m_actionGroups)); 00159 m_actionGroups->setMovement(QListWidget::Static); 00160 m_actionGroups->setResizeMode(QListWidget::Fixed); 00161 m_actionGroups->setIconSize(QSize(48, 48)); 00162 m_actionGroups->setFlow(QListWidget::TopToBottom); 00163 m_actionGroups->setViewMode(QListWidget::IconMode); 00164 m_actionGroups->setWrapping(false); 00165 #endif 00166 00167 m_actionRepository = new ActionRepository(splitter); 00168 splitter->addWidget(m_actionRepository); 00169 00170 connect(m_actionRepository, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), 00171 this, SLOT(slotItemChanged(QListWidgetItem*))); 00172 // make it possible for vs integration to reimplement edit action dialog 00173 connect(m_actionRepository, SIGNAL(itemActivated(QListWidgetItem*)), 00174 this, SIGNAL(itemActivated(QListWidgetItem*))); 00175 connect(m_actionRepository, SIGNAL(contextMenuRequested(QContextMenuEvent*, QListWidgetItem*)), 00176 this, SIGNAL(contextMenuRequested(QContextMenuEvent*, QListWidgetItem*))); 00177 connect(this, SIGNAL(itemActivated(QListWidgetItem*)), 00178 this, SLOT(editAction(QListWidgetItem*))); 00179 }
Here is the call graph for this function:

| qdesigner_internal::ActionEditor::~ActionEditor | ( | ) | [virtual] |
| QDesignerFormWindowInterface * qdesigner_internal::ActionEditor::formWindow | ( | ) | const |
Definition at line 195 of file actioneditor.cpp.
References m_formWindow.
Referenced by editAction(), manageAction(), qdesigner_internal::NewActionDialog::on_iconButton_clicked(), setFormWindow(), slotDeleteAction(), slotItemChanged(), and slotNewAction().
00196 { 00197 return m_formWindow; 00198 }
| void qdesigner_internal::ActionEditor::setFormWindow | ( | QDesignerFormWindowInterface * | formWindow | ) | [virtual] |
Sets the currently selected form window to formWindow.
Implements QDesignerActionEditorInterface.
Definition at line 200 of file actioneditor.cpp.
References QListWidget::clear(), QObject::connect(), core(), createListWidgetItem(), QObject::disconnect(), formWindow(), QAction::isSeparator(), m_actionDelete, m_actionNew, m_actionRepository, m_filter, m_filterWidget, m_formWindow, QDesignerFormWindowInterface::mainContainer(), QAction::setEnabled(), QWidget::setEnabled(), setFilter(), SIGNAL, SLOT, and slotActionChanged().
00201 { 00202 if (formWindow != 0 && formWindow->mainContainer() == 0) 00203 formWindow = 0; 00204 00205 // we do NOT rely on this function to update the action editor 00206 if (m_formWindow == formWindow) 00207 return; 00208 00209 if (m_formWindow != 0) { 00210 QList<QAction*> actionList = qFindChildren<QAction*>(m_formWindow->mainContainer()); 00211 foreach (QAction *action, actionList) 00212 disconnect(action, SIGNAL(changed()), this, SLOT(slotActionChanged())); 00213 } 00214 00215 m_formWindow = formWindow; 00216 00217 m_actionRepository->clear(); 00218 00219 if (!formWindow || !formWindow->mainContainer()) { 00220 m_actionNew->setEnabled(false); 00221 m_actionDelete->setEnabled(false); 00222 m_filterWidget->setEnabled(false); 00223 return; 00224 } 00225 00226 m_actionNew->setEnabled(true); 00227 m_filterWidget->setEnabled(true); 00228 00229 QList<QAction*> actionList = qFindChildren<QAction*>(formWindow->mainContainer()); 00230 foreach (QAction *action, actionList) { 00231 if (!core()->metaDataBase()->item(action) 00232 || action->isSeparator() 00233 // ### || action->menu() 00234 ) { 00235 continue; 00236 } 00237 00238 createListWidgetItem(action); 00239 connect(action, SIGNAL(changed()), this, SLOT(slotActionChanged())); 00240 } 00241 00242 setFilter(m_filter); 00243 }
Here is the call graph for this function:

| QDesignerFormEditorInterface * qdesigner_internal::ActionEditor::core | ( | ) | const [virtual] |
Returns a pointer to 's current QDesignerFormEditorInterface object.
Reimplemented from QDesignerActionEditorInterface.
Definition at line 343 of file actioneditor.cpp.
References m_core.
Referenced by editAction(), manageAction(), setFormWindow(), slotItemChanged(), unmanageAction(), and updatePropertyEditor().
00344 { 00345 return m_core; 00346 }
| QAction * qdesigner_internal::ActionEditor::actionNew | ( | ) | const |
Definition at line 185 of file actioneditor.cpp.
References m_actionNew.
00186 { 00187 return m_actionNew; 00188 }
| QAction * qdesigner_internal::ActionEditor::actionDelete | ( | ) | const |
Definition at line 190 of file actioneditor.cpp.
References m_actionDelete.
00191 { 00192 return m_actionDelete; 00193 }
| QString qdesigner_internal::ActionEditor::filter | ( | ) | const |
Definition at line 348 of file actioneditor.cpp.
References m_filter.
00349 { 00350 return m_filter; 00351 }
| void qdesigner_internal::ActionEditor::manageAction | ( | QAction * | action | ) | [virtual] |
Instructs to manage the specified action. An action that is managed by is available in the action editor.
Implements QDesignerActionEditorInterface.
Definition at line 359 of file actioneditor.cpp.
References QDesignerMetaDataBaseInterface::add(), QObject::connect(), core(), createListWidgetItem(), QDesignerFormEditorInterface::extensionManager(), formWindow(), QAction::icon(), QDesignerPropertySheetExtension::indexOf(), QIcon::isNull(), QAction::isSeparator(), m_actionRepository, QAction::menu(), QDesignerFormEditorInterface::metaDataBase(), QDesignerPropertySheetExtension::setChanged(), QListWidget::setCurrentItem(), QObject::setParent(), SIGNAL, SLOT, and slotActionChanged().
00360 { 00361 action->setParent(formWindow()->mainContainer()); 00362 core()->metaDataBase()->add(action); 00363 00364 if (action->isSeparator() || action->menu() != 0) { 00365 /* QVariant actionData; 00366 qVariantSetValue(actionData, (QListWidgetItem*)0); 00367 action->setData(actionData); */ 00368 return; 00369 } 00370 00371 QDesignerPropertySheetExtension *sheet = 0; 00372 sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action); 00373 sheet->setChanged(sheet->indexOf("objectName"), true); 00374 sheet->setChanged(sheet->indexOf("text"), true); 00375 sheet->setChanged(sheet->indexOf("icon"), !action->icon().isNull()); 00376 00377 QListWidgetItem *item = createListWidgetItem(action); 00378 m_actionRepository->setCurrentItem(item); 00379 00380 connect(action, SIGNAL(changed()), this, SLOT(slotActionChanged())); 00381 }
Here is the call graph for this function:

| void qdesigner_internal::ActionEditor::unmanageAction | ( | QAction * | action | ) | [virtual] |
Instructs to ignore the specified action. An unmanaged action is not available in the action editor.
Implements QDesignerActionEditorInterface.
Definition at line 383 of file actioneditor.cpp.
References actionToItem(), core(), QObject::disconnect(), QDesignerFormEditorInterface::metaDataBase(), QDesignerMetaDataBaseInterface::remove(), QObject::setParent(), SIGNAL, SLOT, and slotActionChanged().
00384 { 00385 core()->metaDataBase()->remove(action); 00386 action->setParent(0); 00387 00388 disconnect(action, SIGNAL(changed()), this, SLOT(slotActionChanged())); 00389 00390 QListWidgetItem *item = actionToItem(action); 00391 if (item == 0) 00392 return; 00393 00394 /* QVariant actionData; 00395 qVariantSetValue(actionData, (QListWidgetItem*)0); 00396 action->setData(actionData); */ 00397 00398 delete item; 00399 }
Here is the call graph for this function:

Definition at line 477 of file actioneditor.cpp.
References name.
Referenced by QDesignerMenuBar::leaveEditMode(), and qdesigner_internal::NewActionDialog::on_editActionText_textEdited().
00478 { 00479 QString name = text; 00480 if (name.isEmpty()) 00481 return QString(); 00482 00483 name[0] = name.at(0).toUpper(); 00484 name.prepend(QLatin1String("action")); 00485 name.replace(QRegExp(QString("[^a-zA-Z_0-9]")), QString("_")); 00486 name.replace(QRegExp("__*"), QString("_")); 00487 if (name.endsWith("_")) 00488 name.truncate(name.size() - 1); 00489 00490 return name; 00491 }
| QAction * qdesigner_internal::ActionEditor::itemToAction | ( | QListWidgetItem * | item | ) | const |
Definition at line 320 of file actioneditor.cpp.
References qdesigner_internal::ActionRepository::ActionRole, and QListWidgetItem::data().
Referenced by actionToItem(), editAction(), slotDeleteAction(), and slotItemChanged().
00321 { 00322 return qvariant_cast<QAction*>(item->data(ActionRepository::ActionRole)); 00323 }
Here is the call graph for this function:

| QListWidgetItem * qdesigner_internal::ActionEditor::actionToItem | ( | QAction * | action | ) | const |
Definition at line 309 of file actioneditor.cpp.
References QListWidget::count(), i, QListWidget::item(), itemToAction(), and m_actionRepository.
Referenced by slotActionChanged(), and unmanageAction().
00310 { 00311 int cnt = m_actionRepository->count(); 00312 for (int i = 0; i < cnt; ++i) { 00313 QListWidgetItem *item = m_actionRepository->item(i); 00314 if (itemToAction(item) == action) 00315 return item; 00316 } 00317 return 0; 00318 }
Here is the call graph for this function:

| void qdesigner_internal::ActionEditor::setFilter | ( | const QString & | filter | ) | [slot] |
Definition at line 353 of file actioneditor.cpp.
References qdesigner_internal::ActionRepository::filter(), m_actionRepository, and m_filter.
Referenced by setFormWindow().
00354 { 00355 m_filter = f; 00356 m_actionRepository->filter(m_filter); 00357 }
| void qdesigner_internal::ActionEditor::slotItemChanged | ( | QListWidgetItem * | item | ) | [private, slot] |
Definition at line 292 of file actioneditor.cpp.
References core(), formWindow(), itemToAction(), m_actionDelete, QDesignerFormEditorInterface::propertyEditor(), QAction::setEnabled(), QDesignerPropertyEditorInterface::setObject(), and updatePropertyEditor().
Referenced by ActionEditor().
00293 { 00294 if (core()->propertyEditor() == 0 || formWindow() == 0) 00295 return; 00296 00297 m_actionDelete->setEnabled(item != 0); 00298 00299 if (!item) { 00300 core()->propertyEditor()->setObject(formWindow()->mainContainer()); 00301 return; 00302 } 00303 00304 if (QAction *action = itemToAction(item)) { 00305 updatePropertyEditor(action); 00306 } 00307 }
| void qdesigner_internal::ActionEditor::editAction | ( | QListWidgetItem * | item | ) | [private, slot] |
Definition at line 418 of file actioneditor.cpp.
References qdesigner_internal::NewActionDialog::actionIcon(), qdesigner_internal::NewActionDialog::actionName(), qdesigner_internal::NewActionDialog::actionText(), QDesignerFormWindowInterface::beginCommand(), QDesignerFormWindowInterface::commandHistory(), core(), QDesignerFormWindowInterface::endCommand(), QDialog::exec(), QDesignerFormEditorInterface::extensionManager(), formWindow(), QAction::icon(), QDesignerPropertySheetExtension::indexOf(), QIcon::isNull(), itemToAction(), QObject::objectName(), QUndoStack::push(), QIcon::serialNumber(), qdesigner_internal::NewActionDialog::setActionData(), QDesignerPropertySheetExtension::setChanged(), QWidget::setWindowTitle(), and QAction::text().
Referenced by ActionEditor().
00419 { 00420 if (!item) 00421 return; 00422 00423 QAction *action = itemToAction(item); 00424 if (action == 0) 00425 return; 00426 00427 NewActionDialog dlg(this); 00428 dlg.setWindowTitle(tr("Edit action")); 00429 dlg.setActionData(action->text(), action->objectName(), action->icon()); 00430 00431 if (!dlg.exec()) 00432 return; 00433 00434 formWindow()->beginCommand(QLatin1String("Edit action")); 00435 if (action->objectName() != dlg.actionName()) { 00436 SetPropertyCommand *cmd = new SetPropertyCommand(formWindow()); 00437 cmd->init(action, "objectName", dlg.actionName()); 00438 formWindow()->commandHistory()->push(cmd); 00439 } 00440 if (action->text() != dlg.actionText()) { 00441 SetPropertyCommand *cmd = new SetPropertyCommand(formWindow()); 00442 cmd->init(action, "text", dlg.actionText()); 00443 formWindow()->commandHistory()->push(cmd); 00444 } 00445 if (action->icon().serialNumber() != dlg.actionIcon().serialNumber()) { 00446 SetPropertyCommand *cmd = new SetPropertyCommand(formWindow()); 00447 cmd->init(action, "icon", dlg.actionIcon()); 00448 formWindow()->commandHistory()->push(cmd); 00449 } 00450 formWindow()->endCommand(); 00451 00452 QDesignerPropertySheetExtension *sheet = 0; 00453 sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), action); 00454 sheet->setChanged(sheet->indexOf("icon"), !action->icon().isNull()); 00455 }
| void qdesigner_internal::ActionEditor::slotActionChanged | ( | ) | [private, slot] |
Definition at line 325 of file actioneditor.cpp.
References actionToItem(), createListWidgetItem(), qdesigner_internal::fixActionIcon(), qdesigner_internal::fixActionText(), QAction::icon(), QAction::menu(), QObject::objectName(), QObject::sender(), and QListWidgetItem::setText().
Referenced by manageAction(), setFormWindow(), and unmanageAction().
00326 { 00327 QAction *action = qobject_cast<QAction*>(sender()); 00328 Q_ASSERT(action != 0); 00329 00330 QListWidgetItem *item = actionToItem(action); 00331 if (item == 0) { 00332 if (action->menu() == 0) // action got its menu deleted, create item 00333 createListWidgetItem(action); 00334 } else if (action->menu() != 0) { // action got its menu created, remove item 00335 delete item; 00336 } else { 00337 // action text or icon changed, update item 00338 item->setText(fixActionText(action->objectName())); 00339 item->setIcon(fixActionIcon(action->icon())); 00340 } 00341 }
| void qdesigner_internal::ActionEditor::slotNewAction | ( | ) | [private, slot] |
Definition at line 401 of file actioneditor.cpp.
References QDialog::Accepted, qdesigner_internal::NewActionDialog::actionIcon(), qdesigner_internal::NewActionDialog::actionName(), qdesigner_internal::NewActionDialog::actionText(), QDesignerFormWindowInterface::commandHistory(), QDialog::exec(), formWindow(), qdesigner_internal::AddActionCommand::init(), QUndoStack::push(), and QWidget::setWindowTitle().
Referenced by ActionEditor().
00402 { 00403 NewActionDialog dlg(this); 00404 dlg.setWindowTitle(tr("New action")); 00405 00406 if (dlg.exec() == QDialog::Accepted) { 00407 QAction *action = new QAction(formWindow()); 00408 action->setObjectName(dlg.actionName()); 00409 action->setText(dlg.actionText()); 00410 action->setIcon(dlg.actionIcon()); 00411 00412 AddActionCommand *cmd = new AddActionCommand(formWindow()); 00413 cmd->init(action); 00414 formWindow()->commandHistory()->push(cmd); 00415 } 00416 }
| void qdesigner_internal::ActionEditor::slotDeleteAction | ( | ) | [private, slot] |
Definition at line 457 of file actioneditor.cpp.
References QDesignerFormWindowInterface::commandHistory(), QListWidget::currentItem(), formWindow(), qdesigner_internal::RemoveActionCommand::init(), itemToAction(), m_actionRepository, and QUndoStack::push().
Referenced by ActionEditor().
00458 { 00459 QListWidgetItem *item = m_actionRepository->currentItem(); 00460 if (item == 0) 00461 return; 00462 00463 QAction *action = itemToAction(item); 00464 if (action == 0) 00465 return; 00466 00467 RemoveActionCommand *cmd = new RemoveActionCommand(formWindow()); 00468 cmd->init(action); 00469 formWindow()->commandHistory()->push(cmd); 00470 }
| void qdesigner_internal::ActionEditor::slotNotImplemented | ( | ) | [private, slot] |
Definition at line 472 of file actioneditor.cpp.
References QMessageBox::information().
00473 { 00474 QMessageBox::information(this, tr("Designer"), tr("Feature not implemented!")); 00475 }
| void qdesigner_internal::ActionEditor::itemActivated | ( | QListWidgetItem * | item | ) | [signal] |
Referenced by ActionEditor().
| void qdesigner_internal::ActionEditor::contextMenuRequested | ( | QContextMenuEvent * | , | |
| QListWidgetItem * | item | |||
| ) | [signal] |
Referenced by ActionEditor().
| QListWidgetItem * qdesigner_internal::ActionEditor::createListWidgetItem | ( | QAction * | action | ) | [private] |
Definition at line 258 of file actioneditor.cpp.
References qdesigner_internal::ActionRepository::ActionRole, qdesigner_internal::fixActionIcon(), qdesigner_internal::fixActionText(), QAction::icon(), QAbstractItemView::iconSize(), m_actionRepository, QAction::menu(), QObject::objectName(), qVariantSetValue(), s, QListWidgetItem::setData(), QListWidgetItem::setIcon(), QListWidgetItem::setSizeHint(), and QListWidgetItem::setText().
Referenced by manageAction(), setFormWindow(), and slotActionChanged().
00259 { 00260 if (action->menu()) 00261 return 0; 00262 00263 QListWidgetItem *item = new QListWidgetItem(m_actionRepository); 00264 QSize s = m_actionRepository->iconSize(); 00265 item->setSizeHint(QSize(s.width()*3, s.height()*2)); 00266 item->setText(fixActionText(action->objectName())); 00267 item->setIcon(fixActionIcon(action->icon())); 00268 00269 QVariant itemData; 00270 qVariantSetValue(itemData, action); 00271 item->setData(ActionRepository::ActionRole, itemData); 00272 00273 /* QVariant actionData; 00274 qVariantSetValue(actionData, item); 00275 action->setData(actionData); */ 00276 00277 return item; 00278 }
Here is the call graph for this function:

| void qdesigner_internal::ActionEditor::updatePropertyEditor | ( | QAction * | action | ) | [private] |
Definition at line 280 of file actioneditor.cpp.
References core(), QAction::menu(), QDesignerFormEditorInterface::propertyEditor(), and QDesignerPropertyEditorInterface::setObject().
Referenced by slotItemChanged().
00281 { 00282 if (!action || !core()->propertyEditor()) 00283 return; 00284 00285 QObject *sel = action; 00286 if (action->menu()) 00287 sel = action->menu(); 00288 00289 core()->propertyEditor()->setObject(sel); 00290 }
Here is the call graph for this function:

Definition at line 100 of file actioneditor_p.h.
Referenced by ActionEditor(), actionToItem(), createListWidgetItem(), manageAction(), setFilter(), setFormWindow(), and slotDeleteAction().
Definition at line 101 of file actioneditor_p.h.
Referenced by ActionEditor(), actionNew(), and setFormWindow().
Definition at line 102 of file actioneditor_p.h.
Referenced by actionDelete(), ActionEditor(), setFormWindow(), and slotItemChanged().
Definition at line 103 of file actioneditor_p.h.
Referenced by filter(), setFilter(), and setFormWindow().
1.5.1