Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/sublime/tests/test_toolviewtoolbar.cpp
Context not available. | |||||
39 | explicit ToolViewToolBarFactory(const QString &id): SimpleToolWidgetFactory<QTextEdit>(id) {} | 39 | explicit ToolViewToolBarFactory(const QString &id): SimpleToolWidgetFactory<QTextEdit>(id) {} | ||
---|---|---|---|---|---|
40 | QList<QAction*> toolBarActions( QWidget* ) const override | 40 | QList<QAction*> toolBarActions( QWidget* ) const override | ||
41 | { | 41 | { | ||
42 | QAction* action = new QAction(actionText, nullptr); | 42 | return actionList; | ||
43 | return QList<QAction*>() << action; | | |||
44 | } | 43 | } | ||
45 | QString actionText; | 44 | | ||
45 | ~ToolViewToolBarFactory() override | ||||
46 | { | ||||
47 | qDeleteAll(actionList); | ||||
48 | } | ||||
49 | | ||||
50 | void addAction(const QString &text) | ||||
51 | { | ||||
52 | QAction* action = new QAction(text, nullptr); | ||||
53 | actionList.append(action); | ||||
54 | } | ||||
55 | | ||||
56 | private: | ||||
57 | QList<QAction*> actionList; | ||||
46 | }; | 58 | }; | ||
47 | 59 | | |||
48 | void TestToolViewToolBar::init() | 60 | void TestToolViewToolBar::init() | ||
Context not available. | |||||
55 | // a horizontal tool with toolbar | 67 | // a horizontal tool with toolbar | ||
56 | ToolViewToolBarFactory* factoryT1 = new ToolViewToolBarFactory(QStringLiteral("tool1factory")); | 68 | ToolViewToolBarFactory* factoryT1 = new ToolViewToolBarFactory(QStringLiteral("tool1factory")); | ||
57 | actionTextT1 = QStringLiteral("Tool1Action"); | 69 | actionTextT1 = QStringLiteral("Tool1Action"); | ||
58 | factoryT1->actionText = actionTextT1; | 70 | factoryT1->addAction(actionTextT1); | ||
59 | tool1 = new ToolDocument( QStringLiteral("tool1"), controller, factoryT1 ); | 71 | tool1 = new ToolDocument( QStringLiteral("tool1"), controller, factoryT1 ); | ||
60 | viewT11 = tool1->createView(); | 72 | viewT11 = tool1->createView(); | ||
61 | area->addToolView( viewT11, Sublime::Bottom ); | 73 | area->addToolView( viewT11, Sublime::Bottom ); | ||
Context not available. | |||||
63 | // a vertical tool with toolbar | 75 | // a vertical tool with toolbar | ||
64 | ToolViewToolBarFactory* factoryT2 = new ToolViewToolBarFactory(QStringLiteral("tool2factory")); | 76 | ToolViewToolBarFactory* factoryT2 = new ToolViewToolBarFactory(QStringLiteral("tool2factory")); | ||
65 | actionTextT2 = QStringLiteral("Tool2Action"); | 77 | actionTextT2 = QStringLiteral("Tool2Action"); | ||
66 | factoryT2->actionText = actionTextT2; | 78 | factoryT2->addAction(actionTextT2); | ||
67 | tool2 = new ToolDocument( QStringLiteral("tool2"), controller, factoryT2 ); | 79 | tool2 = new ToolDocument( QStringLiteral("tool2"), controller, factoryT2 ); | ||
68 | viewT21 = tool2->createView(); | 80 | viewT21 = tool2->createView(); | ||
69 | area->addToolView( viewT21, Sublime::Left ); | 81 | area->addToolView( viewT21, Sublime::Left ); | ||
Context not available. | |||||
90 | char* failMsg = qstrdup(QStringLiteral("Expected to find a toolbar but found %1").arg(barCount).toLatin1().data()); | 102 | char* failMsg = qstrdup(QStringLiteral("Expected to find a toolbar but found %1").arg(barCount).toLatin1().data()); | ||
91 | Q_UNUSED(failMsg); | 103 | Q_UNUSED(failMsg); | ||
92 | Q_ASSERT_X(barCount == 1, loc, failMsg); | 104 | Q_ASSERT_X(barCount == 1, loc, failMsg); | ||
105 | delete [] failMsg; | ||||
93 | return toolBars.at(0); | 106 | return toolBars.at(0); | ||
94 | } | 107 | } | ||
95 | 108 | | |||
Context not available. |