<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <title>kate Library: kateprojectmanager.cpp Source File (kate Library)</title> <link href="../../common/doxygen.css" rel="stylesheet" type="text/css"> </head> <div class="header"> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td rowspan="2" width="92"> <a href="../../index.html" title="The API documentation main page"><img src="../../common/docheadergears.png" style="border:0px;" alt=""></a> </td> <td width="95%"> <h1>kate Library API Documentation</h1> </td> </tr> <tr> <td valign="bottom"> <table class="links" border=0 cellspacing=0> <tr> <td><a href="index.html">Overview</a></td> <td><a href="hierarchy.html" title="Inheritance list, sorted roughly alphabetically">Class Hierarchy</a></td> <td><a href="classes.html" title="Alphabetical list of classes">Classes</a></td> <td><a href="annotated.html" title="Classes, structs, unions and interfaces with brief descriptions">Classes (annotated)</a></td> <td><a href="functions.html" title="Documented class members with links to the classes they belong to">Members</a></td> <td><a href="namespaces.html" title="All documented namespaces with brief descriptions">Namespaces</a></td> <td><a href="files.html" title="A list of all documented files with brief descriptions">Source Files</a></td> </tr> </table> </td></tr></table> </div> <div id="hgrad"></div> <div class="text"> <!-- Generated by Doxygen 1.4.4 --> <div class="nav"> <a class="el" href="dir_000002.html">app</a></div> <h1>kateprojectmanager.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* This file is part of the KDE project</span> <a name="l00002"></a>00002 <span class="comment"> Copyright (C) 2002 Christoph Cullmann <cullmann@kde.org></span> <a name="l00003"></a>00003 <span class="comment"></span> <a name="l00004"></a>00004 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00005"></a>00005 <span class="comment"> modify it under the terms of the GNU Library General Public</span> <a name="l00006"></a>00006 <span class="comment"> License version 2 as published by the Free Software Foundation.</span> <a name="l00007"></a>00007 <span class="comment"></span> <a name="l00008"></a>00008 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00009"></a>00009 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00010"></a>00010 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00011"></a>00011 <span class="comment"> Library General Public License for more details.</span> <a name="l00012"></a>00012 <span class="comment"></span> <a name="l00013"></a>00013 <span class="comment"> You should have received a copy of the GNU Library General Public License</span> <a name="l00014"></a>00014 <span class="comment"> along with this library; see the file COPYING.LIB. If not, write to</span> <a name="l00015"></a>00015 <span class="comment"> the Free Software Foundation, Inc., 59 Temple Place - Suite 330,</span> <a name="l00016"></a>00016 <span class="comment"> Boston, MA 02111-1307, USA.</span> <a name="l00017"></a>00017 <span class="comment">*/</span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#include "kateprojectmanager.h"</span> <a name="l00020"></a>00020 <span class="preprocessor">#include "kateprojectmanager.moc"</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="preprocessor">#include "kateapp.h"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "katemainwindow.h"</span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="preprocessor">#include <kconfig.h></span> <a name="l00026"></a>00026 <span class="preprocessor">#include <kcombobox.h></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <kdialogbase.h></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <kurlrequester.h></span> <a name="l00029"></a>00029 <span class="preprocessor">#include <klineedit.h></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <klocale.h></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <kmessagebox.h></span> <a name="l00032"></a>00032 <span class="preprocessor">#include <kfiledialog.h></span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="preprocessor">#include <qfile.h></span> <a name="l00035"></a>00035 <span class="preprocessor">#include <qlayout.h></span> <a name="l00036"></a>00036 <span class="preprocessor">#include <qlabel.h></span> <a name="l00037"></a>00037 <a name="l00038"></a><a class="code" href="classKateProjectManager.html#a0">00038</a> <a class="code" href="classKateProjectManager.html#a0">KateProjectManager::KateProjectManager</a> (QObject *parent) : QObject (parent) <a name="l00039"></a>00039 { <a name="l00040"></a>00040 m_projects.setAutoDelete (<span class="keyword">true</span>); <a name="l00041"></a>00041 m_projectManager = <span class="keyword">new</span> <a class="code" href="classKate_1_1ProjectManager.html">Kate::ProjectManager</a> (<span class="keyword">this</span>); <a name="l00042"></a>00042 setupPluginList (); <a name="l00043"></a>00043 } <a name="l00044"></a>00044 <a name="l00045"></a><a class="code" href="classKateProjectManager.html#a1">00045</a> <a class="code" href="classKateProjectManager.html#a1">KateProjectManager::~KateProjectManager</a>() <a name="l00046"></a>00046 { <a name="l00047"></a>00047 <span class="keywordflow">while</span> (!m_projects.isEmpty()) <a name="l00048"></a>00048 { <a name="l00049"></a>00049 <a class="code" href="classKateProjectManager.html#a5">close</a> (m_projects.at(m_projects.count()-1), <span class="keyword">true</span>); <a name="l00050"></a>00050 } <a name="l00051"></a>00051 <a name="l00052"></a>00052 m_pluginList.setAutoDelete(<span class="keyword">true</span>); <a name="l00053"></a>00053 m_pluginList.clear(); <a name="l00054"></a>00054 } <a name="l00055"></a>00055 <a name="l00056"></a><a class="code" href="classKateProjectManager.html#e0">00056</a> <a class="code" href="classKateProjectManager.html">KateProjectManager</a> *<a class="code" href="classKateProjectManager.html#e0">KateProjectManager::self</a> () <a name="l00057"></a>00057 { <a name="l00058"></a>00058 <span class="keywordflow">return</span> <a class="code" href="classKateApp.html#e0">KateApp::self</a>()-><a class="code" href="classKateApp.html#a6">kateProjectManager</a> (); <a name="l00059"></a>00059 } <a name="l00060"></a>00060 <a name="l00061"></a>00061 <span class="keywordtype">void</span> KateProjectManager::setupPluginList () <a name="l00062"></a>00062 { <a name="l00063"></a>00063 QValueList<KService::Ptr> traderList= KTrader::self()->query(<span class="stringliteral">"Kate/ProjectPlugin"</span>); <a name="l00064"></a>00064 <a name="l00065"></a>00065 KTrader::OfferList::Iterator it(traderList.begin()); <a name="l00066"></a>00066 <span class="keywordflow">for</span>( ; it != traderList.end(); ++it) <a name="l00067"></a>00067 { <a name="l00068"></a>00068 KService::Ptr ptr = (*it); <a name="l00069"></a>00069 <a name="l00070"></a>00070 QString pVersion = ptr->property(<span class="stringliteral">"X-Kate-Version"</span>).toString(); <a name="l00071"></a>00071 <a name="l00072"></a>00072 <span class="keywordflow">if</span> ((pVersion >= <span class="stringliteral">"2.2"</span>) && (pVersion <= KATE_VERSION)) <a name="l00073"></a>00073 { <a name="l00074"></a>00074 <a class="code" href="classProjectPluginInfo.html">ProjectPluginInfo</a> *info=<span class="keyword">new</span> <a class="code" href="classProjectPluginInfo.html">ProjectPluginInfo</a>; <a name="l00075"></a>00075 <a name="l00076"></a>00076 info-><a class="code" href="classProjectPluginInfo.html#o0">service</a> = ptr; <a name="l00077"></a>00077 info-><a class="code" href="classProjectPluginInfo.html#o1">projectType</a>=info-><a class="code" href="classProjectPluginInfo.html#o0">service</a>->property(<span class="stringliteral">"X-Kate-ProjectType"</span>).toString(); <a name="l00078"></a>00078 <a name="l00079"></a>00079 m_pluginList.append(info); <a name="l00080"></a>00080 } <a name="l00081"></a>00081 } <a name="l00082"></a>00082 } <a name="l00083"></a>00083 <a name="l00084"></a><a class="code" href="classKateProjectManager.html#a13">00084</a> <span class="keywordtype">void</span> <a class="code" href="classKateProjectManager.html#a13">KateProjectManager::setCurrentProject</a> (<a class="code" href="classKate_1_1Project.html">Kate::Project</a> *project) <a name="l00085"></a>00085 { <a name="l00086"></a>00086 m_currentProject = project; <a name="l00087"></a>00087 <a name="l00088"></a>00088 emit m_projectManager-><a class="code" href="classKate_1_1ProjectManager.html#l0">projectChanged</a> (); <a name="l00089"></a>00089 } <a name="l00090"></a>00090 <a name="l00091"></a><a class="code" href="classKateProjectManager.html#a3">00091</a> <a class="code" href="classKate_1_1Project.html">Kate::Project</a> *<a class="code" href="classKateProjectManager.html#a3">KateProjectManager::create</a> (<span class="keyword">const</span> QString &type, <span class="keyword">const</span> QString &name, <span class="keyword">const</span> QString &filename) <a name="l00092"></a>00092 { <a name="l00093"></a>00093 KConfig *c = <span class="keyword">new</span> KConfig (filename, <span class="keyword">false</span>, <span class="keyword">false</span>); <a name="l00094"></a>00094 <a name="l00095"></a>00095 c->setGroup(<span class="stringliteral">"Project File"</span>); <a name="l00096"></a>00096 c->writeEntry (<span class="stringliteral">"Type"</span>, type); <a name="l00097"></a>00097 c->writeEntry (<span class="stringliteral">"Name"</span>, name); <a name="l00098"></a>00098 c->sync (); <a name="l00099"></a>00099 <a name="l00100"></a>00100 <span class="keyword">delete</span> c; <a name="l00101"></a>00101 <a name="l00102"></a>00102 <span class="keywordflow">return</span> <a class="code" href="classKateProjectManager.html#a4">open</a> (filename); <a name="l00103"></a>00103 } <a name="l00104"></a>00104 <a name="l00105"></a><a class="code" href="classKateProjectManager.html#a4">00105</a> <a class="code" href="classKate_1_1Project.html">Kate::Project</a> *<a class="code" href="classKateProjectManager.html#a4">KateProjectManager::open</a> (<span class="keyword">const</span> QString &filename) <a name="l00106"></a>00106 { <a name="l00107"></a>00107 <span class="comment">// don't open a project 2 times</span> <a name="l00108"></a>00108 <span class="keywordflow">for</span> (uint z=0; z < m_projects.count(); z++) <a name="l00109"></a>00109 <span class="keywordflow">if</span> (m_projects.at(z)->fileName() == filename) <a name="l00110"></a>00110 <span class="keywordflow">return</span> 0; <a name="l00111"></a>00111 <a name="l00112"></a>00112 <a class="code" href="classKateInternalProjectData.html">KateInternalProjectData</a> *data = <span class="keyword">new</span> <a class="code" href="classKateInternalProjectData.html">KateInternalProjectData</a> (); <a name="l00113"></a>00113 data-><a class="code" href="classKateInternalProjectData.html#o0">proMan</a> = <span class="keyword">this</span>; <a name="l00114"></a>00114 data-><a class="code" href="classKateInternalProjectData.html#o1">fileName</a> = filename; <a name="l00115"></a>00115 <a name="l00116"></a>00116 <a class="code" href="classKate_1_1Project.html">Kate::Project</a> *<a class="code" href="classKateProjectManager.html#a6">project</a> = <span class="keyword">new</span> <a class="code" href="classKate_1_1Project.html">Kate::Project</a> ((<span class="keywordtype">void</span> *) data); <a name="l00117"></a>00117 <a name="l00118"></a>00118 m_projects.append (project); <a name="l00119"></a>00119 <a name="l00120"></a>00120 emit m_projectManager-><a class="code" href="classKate_1_1ProjectManager.html#l1">projectCreated</a> (project); <a name="l00121"></a>00121 <a name="l00122"></a>00122 <span class="keywordflow">return</span> project; <a name="l00123"></a>00123 } <a name="l00124"></a>00124 <a name="l00125"></a><a class="code" href="classKateProjectManager.html#a5">00125</a> <span class="keywordtype">bool</span> <a class="code" href="classKateProjectManager.html#a5">KateProjectManager::close</a> (<a class="code" href="classKate_1_1Project.html">Kate::Project</a> *project, <span class="keywordtype">bool</span> force) <a name="l00126"></a>00126 { <a name="l00127"></a>00127 <span class="keywordflow">if</span> (project) <a name="l00128"></a>00128 { <a name="l00129"></a>00129 <span class="keywordflow">if</span> (project-><a class="code" href="classKate_1_1Project.html#a15">close</a>() || force) <a name="l00130"></a>00130 { <a name="l00131"></a>00131 uint <span class="keywordtype">id</span> = project-><a class="code" href="classKate_1_1Project.html#a2">projectNumber</a> (); <a name="l00132"></a>00132 <span class="keywordtype">int</span> n = m_projects.findRef (project); <a name="l00133"></a>00133 <a name="l00134"></a>00134 <span class="keywordflow">if</span> (n >= 0) <a name="l00135"></a>00135 { <a name="l00136"></a>00136 <span class="keywordflow">if</span> (<a class="code" href="namespaceKate.html#a4">Kate::pluginViewInterface</a>(project-><a class="code" href="classKate_1_1Project.html#a4">plugin</a>())) <a name="l00137"></a>00137 { <a name="l00138"></a>00138 <span class="keywordflow">for</span> (uint i=0; i< ((<a class="code" href="classKateApp.html">KateApp</a>*)parent())->mainWindows(); i++) <a name="l00139"></a>00139 { <a name="l00140"></a>00140 <a class="code" href="namespaceKate.html#a4">Kate::pluginViewInterface</a>(project-><a class="code" href="classKate_1_1Project.html#a4">plugin</a>())->removeView(((<a class="code" href="classKateApp.html">KateApp</a>*)parent())-><a class="code" href="classKateMainWindow.html#a2">mainWindow</a>(i)); <a name="l00141"></a>00141 } <a name="l00142"></a>00142 } <a name="l00143"></a>00143 <a name="l00144"></a>00144 m_projects.remove (n); <a name="l00145"></a>00145 <a name="l00146"></a>00146 emit m_projectManager-><a class="code" href="classKate_1_1ProjectManager.html#l2">projectDeleted</a> (<span class="keywordtype">id</span>); <a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00149"></a>00149 } <a name="l00150"></a>00150 } <a name="l00151"></a>00151 } <a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00154"></a>00154 } <a name="l00155"></a>00155 <a name="l00156"></a><a class="code" href="classKateProjectManager.html#a6">00156</a> <a class="code" href="classKate_1_1Project.html">Kate::Project</a> *<a class="code" href="classKateProjectManager.html#a6">KateProjectManager::project</a> (uint n) <a name="l00157"></a>00157 { <a name="l00158"></a>00158 <span class="keywordflow">if</span> (n >= m_projects.count()) <a name="l00159"></a>00159 <span class="keywordflow">return</span> 0; <a name="l00160"></a>00160 <a name="l00161"></a>00161 <span class="keywordflow">return</span> m_projects.at(n); <a name="l00162"></a>00162 } <a name="l00163"></a>00163 <a name="l00164"></a><a class="code" href="classKateProjectManager.html#a7">00164</a> uint <a class="code" href="classKateProjectManager.html#a7">KateProjectManager::projects</a> () <a name="l00165"></a>00165 { <a name="l00166"></a>00166 <span class="keywordflow">return</span> m_projects.count (); <a name="l00167"></a>00167 } <a name="l00168"></a>00168 <a name="l00169"></a><a class="code" href="classKateProjectManager.html#a8">00169</a> <a class="code" href="classKate_1_1ProjectPlugin.html">Kate::ProjectPlugin</a> *<a class="code" href="classKateProjectManager.html#a8">KateProjectManager::createPlugin</a> (<a class="code" href="classKate_1_1Project.html">Kate::Project</a> *project) <a name="l00170"></a>00170 { <a name="l00171"></a>00171 <a class="code" href="classProjectPluginInfo.html">ProjectPluginInfo</a> *def = 0; <a name="l00172"></a>00172 <a class="code" href="classProjectPluginInfo.html">ProjectPluginInfo</a> *info = 0; <a name="l00173"></a>00173 <a name="l00174"></a>00174 <span class="keywordflow">for</span> (uint i=0; i<m_pluginList.count(); i++) <a name="l00175"></a>00175 { <a name="l00176"></a>00176 <span class="keywordflow">if</span> (m_pluginList.at(i)->projectType == project-><a class="code" href="classKate_1_1Project.html#a9">type</a>()) <a name="l00177"></a>00177 { <a name="l00178"></a>00178 info = m_pluginList.at(i); <a name="l00179"></a>00179 <span class="keywordflow">break</span>; <a name="l00180"></a>00180 } <a name="l00181"></a>00181 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (m_pluginList.at(i)->projectType == QString (<span class="stringliteral">"Default"</span>)) <a name="l00182"></a>00182 def = m_pluginList.at(i); <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <a name="l00185"></a>00185 <span class="keywordflow">if</span> (!info) <a name="l00186"></a>00186 info = def; <a name="l00187"></a>00187 <a name="l00188"></a>00188 <span class="keywordflow">return</span> <a class="code" href="namespaceKate.html#a3">Kate::createProjectPlugin</a> (QFile::encodeName(info-><a class="code" href="classProjectPluginInfo.html#o0">service</a>->library()), project); <a name="l00189"></a>00189 } <a name="l00190"></a>00190 <a name="l00191"></a><a class="code" href="classKateProjectManager.html#a9">00191</a> <span class="keywordtype">void</span> <a class="code" href="classKateProjectManager.html#a9">KateProjectManager::enableProjectGUI</a> (<a class="code" href="classKate_1_1Project.html">Kate::Project</a> *project, <a class="code" href="classKateMainWindow.html">KateMainWindow</a> *win) <a name="l00192"></a>00192 { <a name="l00193"></a>00193 <span class="keywordflow">if</span> (!project-><a class="code" href="classKate_1_1Project.html#a4">plugin</a>()) <span class="keywordflow">return</span>; <a name="l00194"></a>00194 <span class="keywordflow">if</span> (!<a class="code" href="namespaceKate.html#a4">Kate::pluginViewInterface</a>(project-><a class="code" href="classKate_1_1Project.html#a4">plugin</a>())) <span class="keywordflow">return</span>; <a name="l00195"></a>00195 <a name="l00196"></a>00196 <a class="code" href="namespaceKate.html#a4">Kate::pluginViewInterface</a>(project-><a class="code" href="classKate_1_1Project.html#a4">plugin</a>())->addView(win-><a class="code" href="classKateMainWindow.html#a2">mainWindow</a>()); <a name="l00197"></a>00197 } <a name="l00198"></a>00198 <a name="l00199"></a><a class="code" href="classKateProjectManager.html#a10">00199</a> <span class="keywordtype">void</span> <a class="code" href="classKateProjectManager.html#a10">KateProjectManager::disableProjectGUI</a> (<a class="code" href="classKate_1_1Project.html">Kate::Project</a> *project, <a class="code" href="classKateMainWindow.html">KateMainWindow</a> *win) <a name="l00200"></a>00200 { <a name="l00201"></a>00201 <span class="keywordflow">if</span> (!project-><a class="code" href="classKate_1_1Project.html#a4">plugin</a>()) <span class="keywordflow">return</span>; <a name="l00202"></a>00202 <span class="keywordflow">if</span> (!<a class="code" href="namespaceKate.html#a4">Kate::pluginViewInterface</a>(project-><a class="code" href="classKate_1_1Project.html#a4">plugin</a>())) <span class="keywordflow">return</span>; <a name="l00203"></a>00203 <a name="l00204"></a>00204 <a class="code" href="namespaceKate.html#a4">Kate::pluginViewInterface</a>(project-><a class="code" href="classKate_1_1Project.html#a4">plugin</a>())->removeView(win-><a class="code" href="classKateMainWindow.html#a2">mainWindow</a>()); <a name="l00205"></a>00205 } <a name="l00206"></a>00206 <a name="l00207"></a><a class="code" href="classKateProjectManager.html#a11">00207</a> <a class="code" href="classProjectInfo.html">ProjectInfo</a> *<a class="code" href="classKateProjectManager.html#a11">KateProjectManager::newProjectDialog</a> (QWidget *parent) <a name="l00208"></a>00208 { <a name="l00209"></a>00209 <a class="code" href="classProjectInfo.html">ProjectInfo</a> *info = 0; <a name="l00210"></a>00210 <a name="l00211"></a>00211 <a class="code" href="classKateProjectDialogNew.html">KateProjectDialogNew</a>* dlg = <span class="keyword">new</span> <a class="code" href="classKateProjectDialogNew.html">KateProjectDialogNew</a> (parent); <a name="l00212"></a>00212 <a name="l00213"></a>00213 <span class="keywordtype">int</span> n = dlg-><a class="code" href="classKateProjectDialogNew.html#a2">exec</a>(); <a name="l00214"></a>00214 <a name="l00215"></a>00215 <span class="keywordflow">if</span> (n) <a name="l00216"></a>00216 { <a name="l00217"></a>00217 info = <span class="keyword">new</span> <a class="code" href="classProjectInfo.html">ProjectInfo</a> (); <a name="l00218"></a>00218 info-><a class="code" href="classProjectInfo.html#o0">type</a> = dlg-><a class="code" href="classKateProjectDialogNew.html#o0">type</a>; <a name="l00219"></a>00219 info-><a class="code" href="classProjectInfo.html#o1">name</a> = dlg-><a class="code" href="classKateProjectDialogNew.html#o1">name</a>; <a name="l00220"></a>00220 info-><a class="code" href="classProjectInfo.html#o2">fileName</a> = dlg-><a class="code" href="classKateProjectDialogNew.html#o2">fileName</a>; <a name="l00221"></a>00221 } <a name="l00222"></a>00222 <a name="l00223"></a>00223 <span class="keyword">delete</span> dlg; <a name="l00224"></a>00224 <span class="keywordflow">return</span> info; <a name="l00225"></a>00225 } <a name="l00226"></a>00226 <a name="l00227"></a><a class="code" href="classKateProjectManager.html#a12">00227</a> QStringList <a class="code" href="classKateProjectManager.html#a12">KateProjectManager::pluginStringList</a> () <a name="l00228"></a>00228 { <a name="l00229"></a>00229 QStringList list; <a name="l00230"></a>00230 <a name="l00231"></a>00231 <span class="keywordflow">for</span> (uint i=0; i<m_pluginList.count(); i++) <a name="l00232"></a>00232 list.push_back (m_pluginList.at(i)->projectType); <a name="l00233"></a>00233 <a name="l00234"></a>00234 <span class="keywordflow">return</span> list; <a name="l00235"></a>00235 } <a name="l00236"></a>00236 <a name="l00237"></a><a class="code" href="classKateProjectManager.html#a14">00237</a> <span class="keywordtype">bool</span> <a class="code" href="classKateProjectManager.html#a14">KateProjectManager::queryCloseAll</a> () <a name="l00238"></a>00238 { <a name="l00239"></a>00239 <span class="keywordflow">for</span> (uint z=0; z < m_projects.count(); z++) <a name="l00240"></a>00240 <span class="keywordflow">if</span> (!m_projects.at(z)->queryClose()) <a name="l00241"></a>00241 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00242"></a>00242 <a name="l00243"></a>00243 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00244"></a>00244 } <a name="l00245"></a>00245 <a name="l00246"></a><a class="code" href="classKateProjectManager.html#a15">00246</a> <span class="keywordtype">bool</span> <a class="code" href="classKateProjectManager.html#a15">KateProjectManager::closeAll</a> () <a name="l00247"></a>00247 { <a name="l00248"></a>00248 <span class="keywordflow">while</span> (!m_projects.isEmpty()) <a name="l00249"></a>00249 { <a name="l00250"></a>00250 <span class="keywordflow">if</span> (!<a class="code" href="classKateProjectManager.html#a5">close</a>(m_projects.at(m_projects.count()-1))) <a name="l00251"></a>00251 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00252"></a>00252 } <a name="l00253"></a>00253 <a name="l00254"></a>00254 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00255"></a>00255 } <a name="l00256"></a>00256 <a name="l00257"></a><a class="code" href="classKateProjectManager.html#a16">00257</a> <span class="keywordtype">void</span> <a class="code" href="classKateProjectManager.html#a16">KateProjectManager::saveProjectList</a> (<span class="keyword">class</span> KConfig *config) <a name="l00258"></a>00258 { <a name="l00259"></a>00259 QString prevGrp=config->group(); <a name="l00260"></a>00260 config->setGroup (<span class="stringliteral">"Open Projects"</span>); <a name="l00261"></a>00261 <a name="l00262"></a>00262 config->writeEntry (<span class="stringliteral">"Count"</span>, m_projects.count()); <a name="l00263"></a>00263 <a name="l00264"></a>00264 <span class="keywordflow">for</span> (uint z=0; z < m_projects.count(); z++) <a name="l00265"></a>00265 config->writeEntry( QString(<span class="stringliteral">"Project %1"</span>).arg(z), m_projects.at(z)->fileName() ); <a name="l00266"></a>00266 <a name="l00267"></a>00267 config->setGroup(prevGrp); <a name="l00268"></a>00268 } <a name="l00269"></a>00269 <a name="l00270"></a><a class="code" href="classKateProjectManager.html#a17">00270</a> <span class="keywordtype">void</span> <a class="code" href="classKateProjectManager.html#a17">KateProjectManager::restoreProjectList</a> (<span class="keyword">class</span> KConfig *config) <a name="l00271"></a>00271 { <a name="l00272"></a>00272 config->setGroup (<span class="stringliteral">"Open Projects"</span>); <a name="l00273"></a>00273 <a name="l00274"></a>00274 <span class="keywordtype">int</span> count = config->readNumEntry(<span class="stringliteral">"Count"</span>); <a name="l00275"></a>00275 <a name="l00276"></a>00276 <span class="keywordtype">int</span> i = 0; <a name="l00277"></a>00277 <span class="keywordflow">while</span> ((i < count) && config->hasKey(QString(<span class="stringliteral">"Project %1"</span>).arg(i))) <a name="l00278"></a>00278 { <a name="l00279"></a>00279 QString fn = config->readEntry( QString(<span class="stringliteral">"Project %1"</span>).arg( i ) ); <a name="l00280"></a>00280 <a name="l00281"></a>00281 <span class="keywordflow">if</span> ( !fn.isEmpty() ) <a name="l00282"></a>00282 <a class="code" href="classKateProjectManager.html#a4">open</a> (fn); <a name="l00283"></a>00283 <a name="l00284"></a>00284 i++; <a name="l00285"></a>00285 } <a name="l00286"></a>00286 } <a name="l00287"></a>00287 <a name="l00288"></a>00288 <span class="comment">//</span> <a name="l00289"></a>00289 <span class="comment">// "New Project" Dialog</span> <a name="l00290"></a>00290 <span class="comment">//</span> <a name="l00291"></a>00291 <a name="l00292"></a><a class="code" href="classKateProjectDialogNew.html#a0">00292</a> <a class="code" href="classKateProjectDialogNew.html#a0">KateProjectDialogNew::KateProjectDialogNew</a> (QWidget *parent) <a name="l00293"></a>00293 : KDialogBase (parent, <span class="stringliteral">"project_new"</span>, true, i18n (<span class="stringliteral">"New Project"</span>), KDialogBase::Ok|KDialogBase::Cancel) <a name="l00294"></a>00294 { <a name="l00295"></a>00295 QWidget *page = <span class="keyword">new</span> QWidget( <span class="keyword">this</span> ); <a name="l00296"></a>00296 setMainWidget(page); <a name="l00297"></a>00297 <a name="l00298"></a>00298 QGridLayout *grid = <span class="keyword">new</span> QGridLayout (page, 3, 2, 0, spacingHint()); <a name="l00299"></a>00299 <a name="l00300"></a>00300 grid->addWidget (<span class="keyword">new</span> QLabel (i18n(<span class="stringliteral">"Project type:"</span>), page), 0, 0); <a name="l00301"></a>00301 m_typeCombo = <span class="keyword">new</span> KComboBox (page); <a name="l00302"></a>00302 grid->addWidget (m_typeCombo, 0, 1); <a name="l00303"></a>00303 <a name="l00304"></a>00304 m_typeCombo->insertStringList (<a class="code" href="classKateProjectManager.html#e0">KateProjectManager::self</a>()->pluginStringList ()); <a name="l00305"></a>00305 <a name="l00306"></a>00306 grid->addWidget (<span class="keyword">new</span> QLabel (i18n(<span class="stringliteral">"Project name:"</span>), page), 1, 0); <a name="l00307"></a>00307 m_nameEdit = <span class="keyword">new</span> KLineEdit (page); <a name="l00308"></a>00308 grid->addWidget (m_nameEdit, 1, 1); <a name="l00309"></a>00309 connect( m_nameEdit, SIGNAL( textChanged ( <span class="keyword">const</span> QString & )),<span class="keyword">this</span>,SLOT(slotTextChanged())); <a name="l00310"></a>00310 grid->addWidget (<span class="keyword">new</span> QLabel (i18n(<span class="stringliteral">"Project file:"</span>), page), 2, 0); <a name="l00311"></a>00311 m_urlRequester = <span class="keyword">new</span> KURLRequester (page); <a name="l00312"></a>00312 grid->addWidget (m_urlRequester, 2, 1); <a name="l00313"></a>00313 m_nameEdit->setFocus(); <a name="l00314"></a>00314 <a name="l00315"></a>00315 m_urlRequester->setMode (KFile::LocalOnly); <a name="l00316"></a>00316 m_urlRequester->fileDialog()->setOperationMode (KFileDialog::Saving); <a name="l00317"></a>00317 m_urlRequester->setFilter (QString (<span class="stringliteral">"*.kateproject|"</span>) <a name="l00318"></a>00318 + i18n(<span class="stringliteral">"Kate Project Files"</span>) + QString (<span class="stringliteral">" (*.kateproject)"</span>)); <a name="l00319"></a>00319 connect( m_urlRequester->lineEdit(), SIGNAL( textChanged ( <span class="keyword">const</span> QString & )),<span class="keyword">this</span>,SLOT(slotTextChanged())); <a name="l00320"></a>00320 slotTextChanged(); <a name="l00321"></a>00321 } <a name="l00322"></a>00322 <a name="l00323"></a><a class="code" href="classKateProjectDialogNew.html#a1">00323</a> <a class="code" href="classKateProjectDialogNew.html#a1">KateProjectDialogNew::~KateProjectDialogNew</a> () <a name="l00324"></a>00324 { <a name="l00325"></a>00325 } <a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="keywordtype">void</span> KateProjectDialogNew::slotTextChanged() <a name="l00328"></a>00328 { <a name="l00329"></a>00329 enableButtonOK( !m_urlRequester->lineEdit()->text().isEmpty() && !m_nameEdit->text().isEmpty()); <a name="l00330"></a>00330 } <a name="l00331"></a>00331 <a name="l00332"></a><a class="code" href="classKateProjectDialogNew.html#a2">00332</a> <span class="keywordtype">int</span> <a class="code" href="classKateProjectDialogNew.html#a2">KateProjectDialogNew::exec</a>() <a name="l00333"></a>00333 { <a name="l00334"></a>00334 <span class="keywordtype">int</span> n = 0; <a name="l00335"></a>00335 <a name="l00336"></a>00336 <span class="keywordflow">while</span> ((n = KDialogBase::exec())) <a name="l00337"></a>00337 { <a name="l00338"></a>00338 <a class="code" href="classKateProjectDialogNew.html#o0">type</a> = m_typeCombo->currentText (); <a name="l00339"></a>00339 <a class="code" href="classKateProjectDialogNew.html#o1">name</a> = m_nameEdit->text (); <a name="l00340"></a>00340 <a class="code" href="classKateProjectDialogNew.html#o2">fileName</a> = m_urlRequester->url (); <a name="l00341"></a>00341 <a name="l00342"></a>00342 <span class="keywordflow">if</span> (!<a class="code" href="classKateProjectDialogNew.html#o1">name</a>.isEmpty() && !<a class="code" href="classKateProjectDialogNew.html#o2">fileName</a>.isEmpty()) <a name="l00343"></a>00343 <span class="keywordflow">break</span>; <a name="l00344"></a>00344 <span class="keywordflow">else</span> <a name="l00345"></a>00345 KMessageBox::sorry (<span class="keyword">this</span>, i18n (<span class="stringliteral">"You must enter a project name and file"</span>)); <a name="l00346"></a>00346 } <a name="l00347"></a>00347 <a name="l00348"></a>00348 <span class="keywordflow">if</span> (!<a class="code" href="classKateProjectDialogNew.html#o2">fileName</a>.endsWith (<span class="stringliteral">".kateproject"</span>)) <a name="l00349"></a>00349 <a class="code" href="classKateProjectDialogNew.html#o2">fileName</a>.append (<span class="stringliteral">".kateproject"</span>); <a name="l00350"></a>00350 <a name="l00351"></a>00351 <span class="keywordflow">return</span> n; <a name="l00352"></a>00352 } </pre></div></div> <div id="bottom-nav"> <img src="../../common/bottom2.png" align="right" height="59" width="227" alt="KDE Logo"> </div> <div class="bottom"> This file is part of the documentation for kate Library Version 3.4.2. </div> <div class="bottom" style="color:#cccccc"> Documentation copyright © 1996-2004 the KDE developers.<br> Generated on Wed Jun 14 19:05:33 2006 by <a href="http://www.doxygen.org/index.html">doxygen</a> 1.4.4 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2003 </div> </body> </html>