kate Library API Documentation

kateprojectviews.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
00003    Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
00004    Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include "kateprojectviews.h"
00022 #include "kateprojectviews.moc"
00023 
00024 #include "kateprojectmanager.h"
00025 #include "katemainwindow.h"
00026 #include "kactionselector.h"
00027 #include "kateprojecttreeview.h"
00028 
00029 #include <qapplication.h>
00030 #include <qlayout.h>
00031 #include <qstringlist.h>
00032 
00033 #include <klocale.h>
00034 
00035 
00036 KateProjectViews::KateProjectViews (KateMainWindow *_mainWindow, QWidget * parent, const char * name ):  QWidget (parent, name)
00037 {
00038   setFocusPolicy ((QWidget::FocusPolicy)0);
00039 
00040   QVBoxLayout* lo = new QVBoxLayout(this);
00041 
00042   m_mainWindow = _mainWindow;
00043 
00044   m_stack = new QWidgetStack (this);
00045   lo->addWidget(m_stack);
00046   lo->setStretchFactor(m_stack, 2);
00047 
00048   // init of the combo box
00049   for (uint i = 0; i < KateProjectManager::self()->projects(); i++)
00050     projectCreated (KateProjectManager::self()->project(i));
00051 
00052   projectChanged ();
00053 
00054   // connecting
00055   connect(KateProjectManager::self()->projectManager(),SIGNAL(projectCreated(Kate::Project *)),this,SLOT(projectCreated(Kate::Project *)));
00056   connect(KateProjectManager::self()->projectManager(),SIGNAL(projectDeleted(uint)),this,SLOT(projectDeleted(uint)));
00057   connect(m_mainWindow->mainWindow(),SIGNAL(projectChanged()),this,SLOT(projectChanged()));
00058 }
00059 
00060 KateProjectViews::~KateProjectViews ()
00061 {
00062 }
00063 
00064 void KateProjectViews::projectChanged ()
00065 {
00066   Kate::Project *p = 0;
00067 
00068   if (!(p = m_mainWindow->activeProject()))
00069     return;
00070 
00071   m_stack->raiseWidget (m_wMap[p->projectNumber()]);
00072 }
00073 
00074 void KateProjectViews::projectCreated (Kate::Project *project)
00075 {
00076   if (!project)
00077     return;
00078 
00079   KateProjectTreeViewContainer *c =
00080       new KateProjectTreeViewContainer( project, m_mainWindow, m_stack ) ;
00081 
00082   m_wMap[project->projectNumber()] = c;
00083 
00084   m_stack->raiseWidget (c);
00085 }
00086 
00087 void KateProjectViews::projectDeleted (uint projectNumber)
00088 {
00089   QWidget *w = m_wMap[projectNumber];
00090 
00091   if (!w)
00092     return;
00093 
00094   m_wMap.remove (projectNumber);
00095   m_stack->removeWidget (w);
00096   delete w;
00097 }
KDE Logo
This file is part of the documentation for kate Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 13 19:27:53 2006 by doxygen 1.4.3 written by Dimitri van Heesch, © 1997-2003