qdesigner_formwindowcommand.cpp
来自「奇趣公司比较新的qt/emd版本」· C++ 代码 · 共 147 行
CPP
147 行
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the Qt Designer of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file. Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "qdesigner_formwindowcommand_p.h"#include "qdesigner_objectinspector_p.h"#include "layout_p.h"#include <QtDesigner/QDesignerFormEditorInterface>#include <QtDesigner/QDesignerFormWindowInterface>#include <QtDesigner/QDesignerObjectInspectorInterface>#include <QtDesigner/QDesignerActionEditorInterface>#include <QtDesigner/QDesignerMetaDataBaseInterface>#include <QtDesigner/QDesignerPropertySheetExtension>#include <QtDesigner/QDesignerPropertyEditorInterface>#include <QtDesigner/QExtensionManager>#include <QtCore/QVariant>#include <QtGui/QWidget>#include <QtGui/QLabel>namespace qdesigner_internal {// ---- QDesignerFormWindowCommand ----QDesignerFormWindowCommand::QDesignerFormWindowCommand(const QString &description, QDesignerFormWindowInterface *formWindow) : QUndoCommand(description), m_formWindow(formWindow){}QDesignerFormWindowInterface *QDesignerFormWindowCommand::formWindow() const{ return m_formWindow;}QDesignerFormEditorInterface *QDesignerFormWindowCommand::core() const{ if (QDesignerFormWindowInterface *fw = formWindow()) return fw->core(); return 0;}void QDesignerFormWindowCommand::undo(){ cheapUpdate();}void QDesignerFormWindowCommand::redo(){ cheapUpdate();}void QDesignerFormWindowCommand::cheapUpdate(){ if (core()->objectInspector()) core()->objectInspector()->setFormWindow(formWindow()); if (core()->actionEditor()) core()->actionEditor()->setFormWindow(formWindow());}bool QDesignerFormWindowCommand::hasLayout(QWidget *widget) const{ QDesignerFormEditorInterface *core = formWindow()->core(); if (widget && LayoutInfo::layoutType(core, widget) != LayoutInfo::NoLayout) { const QDesignerMetaDataBaseItemInterface *item = core->metaDataBase()->item(widget); return item != 0; } return false;}QDesignerPropertySheetExtension* QDesignerFormWindowCommand::propertySheet(QObject *object) const{ return qt_extension<QDesignerPropertySheetExtension*>(formWindow()->core()->extensionManager(), object);}void QDesignerFormWindowCommand::updateBuddies(QDesignerFormWindowInterface *form, const QString &old_name, const QString &new_name){ QExtensionManager* extensionManager = form->core()->extensionManager(); typedef QList<QLabel*> LabelList; const LabelList label_list = qFindChildren<QLabel*>(form); if (label_list.empty()) return; const QString buddyProperty = QLatin1String("buddy"); const LabelList::const_iterator cend = label_list.constEnd(); for (LabelList::const_iterator it = label_list.constBegin(); it != cend; ++it ) { if (QDesignerPropertySheetExtension* sheet = qt_extension<QDesignerPropertySheetExtension*>(extensionManager, *it)) { const int idx = sheet->indexOf(buddyProperty); if (idx != -1 && sheet->property(idx).toString() == old_name) sheet->setProperty(idx, new_name); } }}void QDesignerFormWindowCommand::selectUnmanagedObject(QObject *unmanagedObject){ // Keep selection in sync if (QDesignerObjectInspector *oi = qobject_cast<QDesignerObjectInspector *>(core()->objectInspector())) { oi->clearSelection(); oi->selectObject(unmanagedObject); } core()->propertyEditor()->setObject(unmanagedObject);}} // namespace qdesigner_internal
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?