Commit 51408748 authored by Eike Ziller's avatar Eike Ziller
Browse files
parents cbf4de03 f77a7571
......@@ -2198,31 +2198,31 @@
\list
\li Locating any open document
\li Locating any open document (o)
\li Locating files anywhere on your file system
\li Locating files anywhere on your file system (f)
\li Locating files belonging to your project, such as source, header
resource, and .ui files
\li Locating files belonging to your project (p), such as source, header
resource, and .ui files, or to any project (a)
\li Locating class, enum, and function definitions in your project or anywhere
referenced from your project
\li Locating class (c), enum, and function (m) definitions in your
project or anywhere referenced from your project (:)
\li Locating symbols in the current document
\li Locating symbols in the current document (.)
\li Locating a specific line and column in the document displayed in
your editor
your editor (l)
\li Opening help topics, including Qt documentation
\li Opening help topics, including Qt documentation (?)
\li Performing web searches
\li Performing web searches (r)
\li Running text editing macros that you record and save. For more
\li Running text editing macros that you record and save (rm). For more
information, see \l{Using Text Editing Macros}
\li Executing shell commands
\li Executing shell commands (!)
\li Executing version control system commands. For more information, see
\li Executing version control system commands (git). For more information, see
\l{Using Version Control Systems}
\endlist
......@@ -2250,6 +2250,10 @@
Filters locating class and function definitions also accept namespaces,
such as \c {Utils::*View}.
For example, to create a new file and open it in the editor, type \c f
followed by \key Space, followed by path and file name, and then press
\key Enter.
By default, the following filters are enabled and you do not need to use
their prefixes explicitly:
......
......@@ -219,26 +219,28 @@ void QuickItemNodeInstance::doComponentComplete()
quickItem()->update();
}
static QList<QQuickItem *> allItems(QQuickItem *parentItem)
static QList<QQuickItem *> allChildItemsRecursive(QQuickItem *parentItem)
{
QList<QQuickItem *> itemList;
itemList.append(parentItem);
itemList.append(parentItem->childItems());
foreach (QQuickItem *childItem, parentItem->childItems()) {
itemList.append(allItems(childItem));
}
foreach (QQuickItem *childItem, parentItem->childItems())
itemList.append(allChildItemsRecursive(childItem));
return itemList;
}
QList<QQuickItem *> QuickItemNodeInstance::allItemsRecursive() const
{
if (quickItem())
return allItems(quickItem());
QList<QQuickItem *> itemList;
if (quickItem()) {
itemList.append(quickItem());
itemList.append(allChildItemsRecursive(quickItem()));
}
return QList<QQuickItem *>();
return itemList;
}
QRectF QuickItemNodeInstance::contentItemBoundingBox() const
......
VPATH += $$PWD
SOURCES += modelnodecontextmenu.cpp
SOURCES += addtabtotabviewdialog.cpp
SOURCES += designeractionmanagerview.cpp
SOURCES += tabviewdesigneraction.cpp
SOURCES += defaultdesigneraction.cpp
SOURCES += modelnodecontextmenu_helper.cpp
SOURCES += selectioncontext.cpp
......@@ -12,9 +10,7 @@ SOURCES += modelnodeoperations.cpp
SOURCES += crumblebar.cpp
HEADERS += modelnodecontextmenu.h
HEADERS += addtabtotabviewdialog.h
HEADERS += designeractionmanagerview.h
HEADERS += tabviewdesigneraction.h
HEADERS += defaultdesigneraction.h
HEADERS += modelnodecontextmenu_helper.h
HEADERS += selectioncontext.h
......@@ -24,4 +20,3 @@ HEADERS += modelnodeoperations.h
HEADERS += abstractdesigneraction.h
HEADERS += crumblebar.h
FORMS += addtabtotabviewdialog.ui
......@@ -31,7 +31,6 @@
#include <selectioncontext.h>
#include <abstractdesigneraction.h>
#include "tabviewdesigneraction.h"
namespace QmlDesigner {
......@@ -42,8 +41,6 @@ DesignerActionManagerView::DesignerActionManagerView()
m_setupContextDirty(false)
{
m_designerActionManager.createDefaultDesignerActions();
m_designerActionManager.addDesignerAction(new TabViewDesignerAction);
}
void DesignerActionManagerView::modelAttached(Model *model)
......
......@@ -27,25 +27,20 @@
**
****************************************************************************/
#include "tabviewdesigneraction.h"
#include "addtabdesigneraction.h"
#include "addtabtotabviewdialog.h"
#include <QCoreApplication>
#include <QMessageBox>
#include <QUrl>
#include <QFileInfo>
#include <QMessageBox>
#include <utils/textfileformat.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/icore.h>
#include <documentmanager.h>
#include <nodemetainfo.h>
#include <modelnode.h>
#include <nodeabstractproperty.h>
#include "addtabtotabviewdialog.h"
#include <qmldesignerplugin.h>
namespace QmlDesigner {
......@@ -61,33 +56,33 @@ bool isTabAndParentIsTabView(const ModelNode &modelNode)
&& modelNode.parentProperty().parentModelNode().metaInfo().isSubclassOf("QtQuick.Controls.TabView", -1, -1);
}
TabViewDesignerAction::TabViewDesignerAction()
AddTabDesignerAction::AddTabDesignerAction()
: DefaultDesignerAction(QCoreApplication::translate("TabViewToolAction","Add Tab..."))
{
connect(action(), SIGNAL(triggered()), this, SLOT(addNewTab()));
}
QByteArray TabViewDesignerAction::category() const
QByteArray AddTabDesignerAction::category() const
{
return QByteArray();
}
QByteArray TabViewDesignerAction::menuId() const
QByteArray AddTabDesignerAction::menuId() const
{
return "TabViewAction";
}
int TabViewDesignerAction::priority() const
int AddTabDesignerAction::priority() const
{
return CustomActionsPriority;
}
AbstractDesignerAction::Type TabViewDesignerAction::type() const
AbstractDesignerAction::Type AddTabDesignerAction::type() const
{
return Action;
}
bool TabViewDesignerAction::isVisible(const SelectionContext &selectionContext) const
bool AddTabDesignerAction::isVisible(const SelectionContext &selectionContext) const
{
if (selectionContext.singleNodeIsSelected()) {
ModelNode selectedModelNode = selectionContext.currentSingleSelectedNode();
......@@ -97,40 +92,11 @@ bool TabViewDesignerAction::isVisible(const SelectionContext &selectionContext)
return false;
}
bool TabViewDesignerAction::isEnabled(const SelectionContext &selectionContext) const
bool AddTabDesignerAction::isEnabled(const SelectionContext &selectionContext) const
{
return isVisible(selectionContext);
}
bool TabViewDesignerAction::createFile(const QString &filePath)
{
Utils::TextFileFormat textFileFormat;
textFileFormat.codec = Core::EditorManager::defaultTextCodec();
QString errorMessage;
const QString componentString("import QtQuick 2.1\nimport QtQuick.Controls 1.0\n\nItem {\n\n}");
return textFileFormat.writeFile(filePath, componentString, &errorMessage);
}
void TabViewDesignerAction::addNewFileToVersionControl(const QString &directoryPath, const QString &newFilePath)
{
Core::IVersionControl *versionControl = Core::VcsManager::findVersionControlForDirectory(directoryPath);
if (versionControl && versionControl->supportsOperation(Core::IVersionControl::AddOperation)) {
const QMessageBox::StandardButton button =
QMessageBox::question(Core::ICore::mainWindow(),
Core::VcsManager::msgAddToVcsTitle(),
Core::VcsManager::msgPromptToAddToVcs(QStringList(newFilePath), versionControl),
QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes && !versionControl->vcsAdd(newFilePath)) {
QMessageBox::warning(Core::ICore::mainWindow(),
Core::VcsManager::msgAddToVcsFailedTitle(),
Core::VcsManager::msgToAddToVcsFailed(QStringList(newFilePath), versionControl));
}
}
}
static ModelNode findTabViewModelNode(const ModelNode &currentModelNode)
{
if (currentModelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView", -1, -1))
......@@ -139,7 +105,7 @@ static ModelNode findTabViewModelNode(const ModelNode &currentModelNode)
return findTabViewModelNode(currentModelNode.parentProperty().parentModelNode());
}
void TabViewDesignerAction::addNewTab()
void AddTabDesignerAction::addNewTab()
{
QString tabName = AddTabToTabViewDialog::create(QStringLiteral("Tab"), Core::ICore::mainWindow());
......@@ -150,10 +116,10 @@ void TabViewDesignerAction::addNewTab()
if (QFileInfo(newFilePath).exists()) {
QMessageBox::warning(Core::ICore::mainWindow(), tr("Naming Error"), tr("Component already exists."));
} else {
bool fileCreated = createFile(newFilePath);
bool fileCreated = DocumentManager::createFile(newFilePath, QStringLiteral("import QtQuick 2.1\nimport QtQuick.Controls 1.0\n\nItem {\n\n}"));
if (fileCreated) {
addNewFileToVersionControl(directoryPath, newFilePath);
DocumentManager::addFileToVersionControl(directoryPath, newFilePath);
ModelNode tabViewModelNode = findTabViewModelNode(selectionContext().currentSingleSelectedNode());
......
......@@ -34,11 +34,11 @@
namespace QmlDesigner {
class TabViewDesignerAction : public QObject, public DefaultDesignerAction
class AddTabDesignerAction : public QObject, public DefaultDesignerAction
{
Q_OBJECT
public:
TabViewDesignerAction();
AddTabDesignerAction();
QByteArray category() const;
QByteArray menuId() const;
......@@ -49,9 +49,6 @@ protected:
bool isVisible(const SelectionContext &selectionContext) const;
bool isEnabled(const SelectionContext &selectionContext) const;
bool createFile(const QString &filePath);
void addNewFileToVersionControl(const QString &directoryPath, const QString &newFileName);
private slots:
void addNewTab();
};
......
......@@ -30,6 +30,11 @@
#include "componentsplugin.h"
#include "tabviewindexmodel.h"
#include "addtabdesigneraction.h"
#include <viewmanager.h>
#include <qmldesignerplugin.h>
#include <QtPlugin>
namespace QmlDesigner {
......@@ -38,6 +43,7 @@ namespace QmlDesigner {
ComponentsPlugin::ComponentsPlugin()
{
TabViewIndexModel::registerDeclarativeType();
QmlDesignerPlugin::instance()->viewManager().designerActionManager().addDesignerAction(new AddTabDesignerAction);
}
QString ComponentsPlugin::pluginName() const
......
......@@ -9,6 +9,8 @@ include (../qmldesigner_dependencies.pri)
LIBS += -L$$IDE_PLUGIN_PATH
LIBS += -l$$qtLibraryName(QmlDesigner)
LIBS += -l$$qtLibraryName(Core)
LIBS += -l$$qtLibraryName(utils)
DEFINES += COMPONENTS_LIBRARY
......@@ -17,11 +19,18 @@ RESOURCES += $$PWD/componentsplugin.qrc
HEADERS += \
$$PWD/tabviewindexmodel.h \
$$PWD/componentsplugin.h \
$$PWD/../designercore/include/iwidgetplugin.h
$$PWD/../designercore/include/iwidgetplugin.h \
$$PWD/addtabdesigneraction.h \
$$PWD/addtabtotabviewdialog.h
SOURCES += \
$$PWD/componentsplugin.cpp \
$$PWD/tabviewindexmodel.cpp
$$PWD/tabviewindexmodel.cpp \
$$PWD/addtabdesigneraction.cpp \
$$PWD/addtabtotabviewdialog.cpp
FORMS += \
$$PWD/addtabtotabviewdialog.ui
OTHER_FILES += $$PWD/components.metainfo
......@@ -37,6 +37,14 @@
#include <bindingproperty.h>
#include <variantproperty.h>
#include <utils/textfileformat.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/icore.h>
#include <QMessageBox>
namespace QmlDesigner {
static inline DesignDocument* currentDesignDocument()
......@@ -262,5 +270,31 @@ void DocumentManager::goIntoComponent(const ModelNode &modelNode)
}
}
bool DocumentManager::createFile(const QString &filePath, const QString &contents)
{
Utils::TextFileFormat textFileFormat;
textFileFormat.codec = Core::EditorManager::defaultTextCodec();
QString errorMessage;
return textFileFormat.writeFile(filePath, contents, &errorMessage);
}
void DocumentManager::addFileToVersionControl(const QString &directoryPath, const QString &newFilePath)
{
Core::IVersionControl *versionControl = Core::VcsManager::findVersionControlForDirectory(directoryPath);
if (versionControl && versionControl->supportsOperation(Core::IVersionControl::AddOperation)) {
const QMessageBox::StandardButton button =
QMessageBox::question(Core::ICore::mainWindow(),
Core::VcsManager::msgAddToVcsTitle(),
Core::VcsManager::msgPromptToAddToVcs(QStringList(newFilePath), versionControl),
QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes && !versionControl->vcsAdd(newFilePath)) {
QMessageBox::warning(Core::ICore::mainWindow(),
Core::VcsManager::msgAddToVcsFailedTitle(),
Core::VcsManager::msgToAddToVcsFailed(QStringList(newFilePath), versionControl));
}
}
}
} // namespace QmlDesigner
......@@ -55,6 +55,9 @@ public:
static void goIntoComponent(const ModelNode &modelNode);
static bool createFile(const QString &filePath, const QString &contents);
static void addFileToVersionControl(const QString &directoryPath, const QString &newFilePath);
private:
QHash<Core::IEditor *,QPointer<DesignDocument> > m_designDocumentHash;
QPointer<DesignDocument> m_currentDesignDocument;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment