MCPcopy Create free account
hub / github.com/KDE/kdevelop / Example1Main

Method Example1Main

kdevplatform/sublime/examples/example1main.cpp:26–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24#include <sublime/mainwindow.h>
25
26Example1Main::Example1Main()
27 :KXmlGuiWindow(nullptr)
28{
29 //documents
30 m_controller = new Sublime::Controller(this);
31 Sublime::Document *doc1 = new Sublime::UrlDocument(m_controller, QUrl::fromLocalFile(QStringLiteral("~/foo.cpp")));
32 Sublime::Document *doc2 = new Sublime::UrlDocument(m_controller, QUrl::fromLocalFile(QStringLiteral("~/boo.cpp")));
33 Sublime::Document *doc3 = new Sublime::UrlDocument(m_controller, QUrl::fromLocalFile(QStringLiteral("~/moo.cpp")));
34
35 //documents for tool views
36 Sublime::Document *tool1 = new Sublime::ToolDocument(QStringLiteral("ListView"), m_controller,
37 new Sublime::SimpleToolWidgetFactory<QListView>(QStringLiteral("ListView")));
38 Sublime::Document *tool2 = new Sublime::ToolDocument(QStringLiteral("TextEdit"), m_controller,
39 new Sublime::SimpleToolWidgetFactory<QTextEdit>(QStringLiteral("TextEdit")));
40
41 //areas (aka perspectives)
42 qDebug() << "constructing area 1";
43 m_area1 = new Sublime::Area(m_controller, QStringLiteral("Area 1"));
44 m_controller->addDefaultArea(m_area1);
45 m_area1->addView(doc1->createView());
46 m_area1->addView(doc2->createView());
47 m_area1->addView(doc3->createView());
48 m_area1->addToolView(tool1->createView(), Sublime::Left);
49 m_area1->addToolView(tool2->createView(), Sublime::Bottom);
50
51 qDebug() << "constructing area 2";
52 m_area2 = new Sublime::Area(m_controller, QStringLiteral("Area 2"));
53 m_controller->addDefaultArea(m_area2);
54 Sublime::View *view1 = doc1->createView();
55 m_area2->addView(view1);
56 Sublime::View *view2 = doc2->createView();
57 m_area2->addView(view2, view1, Qt::Vertical);
58 m_area2->addView(doc3->createView(), view2, Qt::Horizontal);
59 m_area2->addToolView(tool1->createView(), Sublime::Bottom);
60 m_area2->addToolView(tool2->createView(), Sublime::Right);
61
62 //example main window stuff
63 auto* w = new QWidget(this);
64 setCentralWidget(w);
65 auto *l = new QVBoxLayout(w);
66 QMenu *areaMenu = menuBar()->addMenu(QStringLiteral("Areas"));
67 areaMenu->addAction(QStringLiteral("Area 1"), this, SLOT(selectArea1()));
68 areaMenu->addAction(QStringLiteral("Area 2"), this, SLOT(selectArea2()));
69 auto* b1 = new QPushButton(QStringLiteral("Area 1"), this);
70 connect(b1, &QPushButton::clicked, this, &Example1Main::selectArea1);
71 l->addWidget(b1);
72 auto* b2 = new QPushButton(QStringLiteral("Area 2"), this);
73 connect(b2, &QPushButton::clicked, this, &Example1Main::selectArea2);
74 l->addWidget(b2);
75}
76
77void Example1Main::selectArea1()
78{

Callers

nothing calls this directly

Calls 6

addDefaultAreaMethod · 0.80
addViewMethod · 0.45
createViewMethod · 0.45
addToolViewMethod · 0.45
addActionMethod · 0.45
addWidgetMethod · 0.45

Tested by

no test coverage detected