• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kded
 

kded

vfolder_menu.h
00001 /* 
00002    This file is part of the KDE libraries
00003    Copyright (c) 2003 Waldo Bastian <bastian@kde.org>
00004    
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008    
00009    This library 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 GNU
00012    Library General Public License for more details.
00013    
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef _VFOLDER_MENU_H_
00021 #define _VFOLDER_MENU_H_
00022 
00023 #include <tqobject.h>
00024 #include <tqdom.h>
00025 #include <tqstringlist.h>
00026 #include <tqptrdict.h>
00027 #include <tqptrlist.h>
00028 #include <tqvaluestack.h>
00029 
00030 #include <kservice.h>
00031 
00032 class VFolderMenu : public TQObject
00033 {
00034   Q_OBJECT
00035 public:
00036   class appsInfo;
00037   class SubMenu {
00038   public:
00039      SubMenu() : items(43),isDeleted(false),apps_info(0) { }
00040      ~SubMenu() { subMenus.setAutoDelete(true); }
00041   
00042   public:
00043      TQString name;
00044      TQString directoryFile;
00045      TQPtrList<SubMenu> subMenus;
00046      TQDict<KService> items;
00047      TQDict<KService> excludeItems; // Needed when merging due to Move.
00048      TQDomElement defaultLayoutNode;
00049      TQDomElement layoutNode;
00050      bool isDeleted;
00051      TQStringList layoutList;
00052      appsInfo *apps_info;
00053   };
00054 
00055   VFolderMenu();
00056   ~VFolderMenu();
00057 
00067   SubMenu *parseMenu(const TQString &file, bool forceLegacyLoad=false);
00068   
00076   TQStringList allDirectories();
00077 
00082   void setTrackId(const TQString &id);
00083 
00084 signals:
00085   void newService(const TQString &path, KService **entry);
00086 
00087 public:
00088   struct MenuItem 
00089   {
00090     enum Type { MI_Service, MI_SubMenu, MI_Separator };
00091     Type type;
00092     union { 
00093        KService *service;
00094        SubMenu  *submenu;
00095     } data;
00096   };
00097 
00098 public:  
00099   TQStringList m_allDirectories; // A list of all the directories that we touch
00100 
00101   TQStringList m_defaultDataDirs;
00102   TQStringList m_defaultAppDirs;
00103   TQStringList m_defaultDirectoryDirs;
00104   TQStringList m_defaultMergeDirs;
00105   TQStringList m_defaultLegacyDirs;
00106 
00107   TQStringList m_directoryDirs; // Current set of applicable <DirectoryDir> dirs
00108   TQDict<SubMenu> m_legacyNodes; // Dictionary that stores Menu nodes 
00109                                 // associated with legacy tree.
00110 
00111   class docInfo {
00112   public:
00113      TQString baseDir; // Relative base dir of current menu file
00114      TQString baseName; // Filename of current menu file without ".menu"
00115      TQString path; // Full path of current menu file including ".menu"
00116   };
00117   
00118 
00119   docInfo m_docInfo; // docInfo for current doc
00120   TQValueStack<VFolderMenu::docInfo> m_docInfoStack;
00121 
00122   class appsInfo {
00123   public:
00124      appsInfo() : dictCategories(53), applications(997), appRelPaths(997)
00125      {
00126         dictCategories.setAutoDelete(true);
00127      }
00128 
00129      TQDict<KService::List> dictCategories; // category -> apps
00130      TQDict<KService> applications; // rel path -> service
00131      TQPtrDict<TQString> appRelPaths; // service -> rel path
00132   };
00133   
00134   appsInfo *m_appsInfo; // appsInfo for current menu
00135   TQPtrList<appsInfo> m_appsInfoStack; // All applicable appsInfo for current menu
00136   TQPtrList<appsInfo> m_appsInfoList; // List of all appsInfo objects.
00137   TQDict<KService> m_usedAppsDict; // all applications that have been allocated
00138   
00139   TQDomDocument m_doc;
00140   SubMenu *m_rootMenu;
00141   SubMenu *m_currentMenu;
00142   bool m_forcedLegacyLoad;
00143   bool m_legacyLoaded;
00144   bool m_track;
00145   TQString m_trackId;
00146 
00147 private:
00151   KService *findApplication(const TQString &relPath);
00152 
00156   TQPtrList<KService::List> findCategory(const TQString &category);
00157   
00161   void addApplication(const TQString &id, KService *service);
00162   
00166   void buildApplicationIndex(bool unusedOnly);
00167   
00171   void createAppsInfo();
00172 
00176   void loadAppsInfo();
00177 
00181   void unloadAppsInfo();
00182 
00183   TQDomDocument loadDoc();
00184   void mergeMenus(TQDomElement &docElem, TQString &name);
00185   void mergeFile(TQDomElement &docElem, const TQDomNode &mergeHere);
00186   void loadMenu(const TQString &filename);
00187 
00191   void includeItems(TQDict<KService> *items1, TQDict<KService> *items2);
00192 
00196   void matchItems(TQDict<KService> *items1, TQDict<KService> *items2);
00197 
00201   void excludeItems(TQDict<KService> *items1, TQDict<KService> *items2);
00202 
00210   SubMenu* takeSubMenu(SubMenu *parentMenu, const TQString &menuName);
00211 
00221   void insertSubMenu(VFolderMenu::SubMenu *parentMenu, const TQString &menuName, VFolderMenu::SubMenu *newMenu, bool reversePriority=false);
00222 
00228   void mergeMenu(SubMenu *menu1, SubMenu *menu2, bool reversePriority=false);
00229 
00234   void insertService(SubMenu *parentMenu, const TQString &name, KService *newService);
00235 
00240   void registerFile(const TQString &file);
00241 
00245   void markUsedApplications(TQDict<KService> *items);
00246 
00251   void registerDirectory(const TQString &directory);
00252 
00253   void processKDELegacyDirs();
00254   void processLegacyDir(const TQString &dir, const TQString &relDir, const TQString &prefix);
00255   void processMenu(TQDomElement &docElem, int pass);
00256   void layoutMenu(VFolderMenu::SubMenu *menu, TQStringList defaultLayout);
00257   void processCondition(TQDomElement &docElem, TQDict<KService> *items);
00258 
00259   void initDirs();
00260   
00261   void pushDocInfo(const TQString &fileName, const TQString &baseDir = TQString::null);
00262   void pushDocInfoParent(const TQString &basePath, const TQString &baseDir);
00263   void popDocInfo();
00264   
00265   TQString absoluteDir(const TQString &_dir, const TQString &baseDir, bool keepRelativeToCfg=false);
00266   TQString locateMenuFile(const TQString &fileName); 
00267   TQString locateDirectoryFile(const TQString &fileName);
00268   void loadApplications(const TQString&, const TQString&);
00269 };
00270 
00271 #endif

kded

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

kded

Skip menu "kded"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kded by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.