PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/mks-svn4458/monkey/src/xupmanager/core/XUPProjectItem.h

#
C Header | 188 lines | 88 code | 31 blank | 69 comment | 0 complexity | 14e652aff6d0e7b9ea3ff5e4abb61f71 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, LGPL-3.0, Zlib, AGPL-1.0
  1. /****************************************************************************
  2. Copyright (C) 2005 - 2011 Filipe AZEVEDO & The Monkey Studio Team
  3. http://monkeystudio.org licensing under the GNU GPL.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. ****************************************************************************/
  16. #ifndef XUPPROJECTITEM_H
  17. #define XUPPROJECTITEM_H
  18. #include <QObject>
  19. #include <QFileInfo>
  20. #include "MonkeyExport.h"
  21. #include "XUPItem.h"
  22. #include "xupmanager/core/ProjectTypesIndex.h"
  23. class QAction;
  24. class XUPPlugin;
  25. class XUPProjectItemCacheBackend;
  26. class XUPProjectItemCache;
  27. class UIXUPEditor;
  28. class pCommand;
  29. typedef QList<class XUPProjectItem*> XUPProjectItemList;
  30. #define XUP_VERSION "1.1.0"
  31. class Q_MONKEY_EXPORT XUPProjectItem : public QObject, public XUPItem
  32. {
  33. Q_OBJECT
  34. friend class XUPProjectItemCache;
  35. friend class DebugDockWidget;
  36. public:
  37. // target type
  38. enum TargetType {
  39. NoTarget = 0,
  40. ServicesTarget, // use QDesktopServices::openUrl()
  41. DesktopTarget, // use open or similar thing (open on mac, xdg-open on unix...)
  42. DefaultTarget,
  43. DebugTarget,
  44. ReleaseTarget
  45. };
  46. // ctor
  47. XUPProjectItem();
  48. // dtor
  49. virtual ~XUPProjectItem();
  50. // set last encounter error
  51. void showError( const QString& error );
  52. // return the project absolute filename
  53. QString fileName() const;
  54. // return the project absolute path
  55. QString path() const;
  56. // return an absolute file name according to project path
  57. QString filePath( const QString& filePath ) const;
  58. // return a filepath relative to project path
  59. QString relativeFilePath( const QString& filePath ) const;
  60. /* return the list of all source files for this project
  61. * Defautl implementation returns empty list
  62. */
  63. QStringList sourceFiles() const;
  64. // return the list of all source files for all projects from the root project
  65. QStringList topLevelProjectSourceFiles() const;
  66. // return the xup plugin associated with this project
  67. XUPPlugin* driver() const;
  68. /* When project is activated (selected as current), some plugins can be also enabled.
  69. * for example - PHP-Qt project will activate PHP interpreter plugin.
  70. * When project deselected - plugin will be disabled
  71. */
  72. QStringList autoActivatePlugins() const;
  73. /* Add files to the project.
  74. * Optional argument 'scope' allows to add files to the particular part of the project,
  75. * not to the project root.
  76. * It allows, for example, to add files to the particular scope in the QMake projects (win32, !unix ...)
  77. */
  78. virtual void addFiles( const QStringList& files, XUPItem* scope = 0 );
  79. // Remove file, subproject, or other item
  80. virtual void removeValue( XUPItem* item, bool deleteFiles );
  81. virtual QString quoteString() const;
  82. virtual QString defaultOperator() const;
  83. // return the direct parent proejct if one, else return itself
  84. XUPProjectItem* parentProject() const;
  85. // return the most toplevel project ( ie: the model root project )
  86. XUPProjectItem* topLevelProject() const;
  87. // return the parent project for include project ( recursive parent project for include project, else return project itself )
  88. XUPProjectItem* rootIncludeProject() const;
  89. // return children project recursively according to bool
  90. XUPProjectItemList childrenProjects( bool recursive ) const;
  91. // return a list of QFileInfo having corresponding partial file path
  92. virtual QFileInfoList findFile( const QString& partialFilePath ) const;
  93. // return all variable items named variableName until caller is found ( if define ) or until the complete tree is scanned
  94. // if recursive is true, then the scan recurse in each item, else not
  95. virtual XUPItemList getVariables( const XUPItem* root, const QString& variableName, bool recursive = true, const XUPItem* caller = 0 ) const;
  96. // return first found variable with name. 0 returned, if not found
  97. virtual XUPItem* getVariable( const XUPItem* root, const QString& variableName ) const;
  98. // return the project datas as qstring
  99. virtual QString toXml() const;
  100. virtual QString toNativeString() const;
  101. // return the project type id
  102. virtual QString projectType() const = 0;
  103. // open a project with codec
  104. virtual bool open( const QString& fileName, const QString& codec );
  105. // save the project
  106. virtual bool save();
  107. // return the project target file, ie the binary / library / file path, user might be asked for it via dialog
  108. virtual QString targetFilePath( XUPProjectItem::TargetType type = XUPProjectItem::DefaultTarget );
  109. // install custom project actions in menus
  110. virtual void installCommands();
  111. // uninstall custom project actions in menus
  112. virtual void uninstallCommands();
  113. // return the text codec used by this project
  114. QString codec() const;
  115. // show project settings dialog
  116. bool edit();
  117. // show project settings files editor dialog
  118. bool editProjectFiles();
  119. // return project document filters
  120. const DocumentFilterMap& documentFilters() const;
  121. /** Add pCommand console commands to the main menu. When menu item triggered - console command executed.
  122. * If more than one command set for the menu - commands will be executed one by one
  123. * XUPProjectItem remembers create QAction's and deletes it by uninstallCommands()
  124. */
  125. QAction* addSeparator( const QString& mnu );
  126. void addCommands( const QString& mnu, const QList<pCommand>& cmds );
  127. pCommand command( const QString& name ) const;
  128. pCommand command( QAction* action ) const;
  129. void executeCommand( const QString& name );
  130. virtual void addCommand( const QString& mnu, const pCommand& cmd );
  131. // return the cache backend used by cache()
  132. virtual XUPProjectItemCacheBackend* cacheBackend() const;
  133. // return the variable value
  134. QStringList cachedVariableValues( const QString& variableName ) const;
  135. QString cachedVariableValue( const QString& variableName ) const;
  136. static XUPProjectItemCache* cache();
  137. QString quotedValue( const QString& value ) const;
  138. QString unquotedValue( const QString& value ) const;
  139. protected:
  140. QDomDocument mDocument;
  141. QString mCodec;
  142. QString mFileName;
  143. // Action pointers stored here for delete it, when current project changed
  144. QHash<QString, QAction*> mInstalledActions;
  145. QHash<QString, pCommand> mCommands; // project installed commands by name pCommand::name()
  146. static XUPProjectItemCache mProjectsCache;
  147. static XUPProjectItemCacheBackend mProjectsCacheBackend;
  148. virtual UIXUPEditor* newEditDialog() const;
  149. protected slots:
  150. // Common handler for actions, which execute pCommand. Does few checks, then executes pCommand
  151. // Can be overrided if needed.
  152. virtual void projectCustomActionTriggered();
  153. };
  154. #endif // XUPPROJECTITEM_H