• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

sublime

example1main.cpp

00001 /***************************************************************************
00002  *   Copyright 2006-2007 Alexander Dymo  <adymo@kdevelop.org>              *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU Library General Public License as       *
00006  *   published by the Free Software Foundation; either version 2 of the    *
00007  *   License, or (at your option) any later version.                       *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Library General Public     *
00015  *   License along with this program; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
00018  ***************************************************************************/
00019 #include "example1main.h"
00020 
00021 #include <QMenu>
00022 #include <QMenuBar>
00023 #include <QListView>
00024 #include <QTextEdit>
00025 #include <QLayout>
00026 #include <QPushButton>
00027 
00028 #include <kurl.h>
00029 #include <kdebug.h>
00030 #include <kmenubar.h>
00031 
00032 #include <sublime/view.h>
00033 #include <sublime/area.h>
00034 #include <sublime/sublimedefs.h>
00035 #include <sublime/tooldocument.h>
00036 #include <sublime/urldocument.h>
00037 #include <sublime/controller.h>
00038 #include <sublime/mainwindow.h>
00039 
00040 Example1Main::Example1Main()
00041     :KXmlGuiWindow(0)
00042 {
00043     //documents
00044     m_controller = new Sublime::Controller(this);
00045     Sublime::Document *doc1 = new Sublime::UrlDocument(m_controller, KUrl::fromPath("~/foo.cpp"));
00046     Sublime::Document *doc2 = new Sublime::UrlDocument(m_controller, KUrl::fromPath("~/boo.cpp"));
00047     Sublime::Document *doc3 = new Sublime::UrlDocument(m_controller, KUrl::fromPath("~/moo.cpp"));
00048 
00049     //documents for toolviews
00050     Sublime::Document *tool1 = new Sublime::ToolDocument("ListView", m_controller,
00051         new Sublime::SimpleToolWidgetFactory<QListView>("ListView"));
00052     Sublime::Document *tool2 = new Sublime::ToolDocument("TextEdit", m_controller,
00053         new Sublime::SimpleToolWidgetFactory<QTextEdit>("TextEdit"));
00054 
00055     //areas (aka perspectives)
00056     kDebug(9504) << "constructing area 1";
00057     m_area1 = new Sublime::Area(m_controller, "Area 1");
00058     m_area1->addView(doc1->createView());
00059     m_area1->addView(doc2->createView());
00060     m_area1->addView(doc3->createView());
00061     m_area1->addToolView(tool1->createView(), Sublime::Left);
00062     m_area1->addToolView(tool2->createView(), Sublime::Bottom);
00063 
00064     kDebug(9504) << "constructing area 2";
00065     m_area2 = new Sublime::Area(m_controller, "Area 2");
00066     Sublime::View *view1 = doc1->createView();
00067     m_area2->addView(view1);
00068     Sublime::View *view2 = doc2->createView();
00069     m_area2->addView(view2, view1, Qt::Vertical);
00070     m_area2->addView(doc3->createView(), view2, Qt::Horizontal);
00071     m_area2->addToolView(tool1->createView(), Sublime::Bottom);
00072     m_area2->addToolView(tool2->createView(), Sublime::Right);
00073 
00074     //example main window stuff
00075     QWidget *w = new QWidget(this);
00076     setCentralWidget(w);
00077     QVBoxLayout *l = new QVBoxLayout(w);
00078     QMenu *areaMenu = menuBar()->addMenu("Areas");
00079     areaMenu->addAction("Area 1", this, SLOT(selectArea1()));
00080     areaMenu->addAction("Area 2", this, SLOT(selectArea2()));
00081     QPushButton *b1 = new QPushButton("Area 1", this);
00082     connect(b1, SIGNAL(clicked()), this, SLOT(selectArea1()));
00083     l->addWidget(b1);
00084     QPushButton *b2 = new QPushButton("Area 2", this);
00085     connect(b2, SIGNAL(clicked()), this, SLOT(selectArea2()));
00086     l->addWidget(b2);
00087 }
00088 
00089 void Example1Main::selectArea1()
00090 {
00091     Sublime::MainWindow *main = new Sublime::MainWindow(m_controller);
00092     connect(main, SIGNAL(areaChanged(Sublime::Area*)), this, SLOT(updateTitle(Sublime::Area*)));
00093     m_controller->showArea(m_area1, main);
00094     main->show();
00095 }
00096 
00097 void Example1Main::selectArea2()
00098 {
00099     Sublime::MainWindow *main = new Sublime::MainWindow(m_controller);
00100     connect(main, SIGNAL(areaChanged(Sublime::Area*)), this, SLOT(updateTitle(Sublime::Area*)));
00101     m_controller->showArea(m_area2, main);
00102     main->show();
00103 }
00104 
00105 void Example1Main::updateTitle(Sublime::Area *area)
00106 {
00107     Sublime::MainWindow *main = qobject_cast<Sublime::MainWindow*>(sender());
00108     main->setWindowTitle(area->objectName());
00109 }
00110 
00111 #include "example1main.moc"
00112 

sublime

Skip menu "sublime"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  •     interfaces
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal