File indexing completed on 2024-04-28 16:26:33
0001 /***************************************************************************************** 0002 begin : Tue Aug 12 2003 0003 copyright : (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net) 0004 2006 - 2019 by Michel Ludwig (michel.ludwig@kdemail.net) 0005 *****************************************************************************************/ 0006 0007 /*************************************************************************** 0008 * * 0009 * This program is free software; you can redistribute it and/or modify * 0010 * it under the terms of the GNU General Public License as published by * 0011 * the Free Software Foundation; either version 2 of the License, or * 0012 * (at your option) any later version. * 0013 * * 0014 ***************************************************************************/ 0015 #ifndef PROJECTVIEW_H 0016 #define PROJECTVIEW_H 0017 0018 #include <QDropEvent> 0019 #include <QTreeWidget> 0020 0021 #include <KService> 0022 0023 #include "kileproject.h" 0024 0025 class QUrl; 0026 class QMenu; 0027 class KToggleAction; 0028 class KileInfo; 0029 0030 namespace KileType { 0031 enum ProjectView {Project = 0, ProjectItem, Bibliography, ProjectExtra, File, Folder}; 0032 } 0033 0034 namespace KileWidget { 0035 0036 class ProjectViewItem : public QObject, public QTreeWidgetItem 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 ProjectViewItem(QTreeWidget *parent, KileProjectItem *item, bool ar = false); 0042 ProjectViewItem(QTreeWidget *parent, QTreeWidgetItem *after, KileProjectItem *item, bool ar = false); 0043 ProjectViewItem(QTreeWidgetItem *parent, KileProjectItem *item, bool ar = false); 0044 0045 //use this to create folders 0046 ProjectViewItem(QTreeWidgetItem *parent, const QString& name); 0047 0048 //use this to create non-project files 0049 ProjectViewItem(QTreeWidget *parent, const QString& name); 0050 0051 ProjectViewItem(QTreeWidget *parent, const KileProject *project); 0052 0053 ~ProjectViewItem(); 0054 0055 KileProjectItem* projectItem(); 0056 0057 ProjectViewItem* parent(); 0058 ProjectViewItem* firstChild(); 0059 0060 void setInfo(KileDocument::Info *docinfo); 0061 KileDocument::Info * getInfo(); 0062 0063 void setType(KileType::ProjectView type); 0064 KileType::ProjectView type() const; 0065 0066 virtual bool operator<(const QTreeWidgetItem& other) const override; 0067 0068 void setURL(const QUrl &url); 0069 const QUrl &url(); 0070 0071 void setArchiveState(bool ar); 0072 0073 void setFolder(int folder); 0074 int folder() const; 0075 0076 public Q_SLOTS: 0077 /** 0078 * @warning Does nothing if "url" is empty ! 0079 **/ 0080 void urlChanged(const QUrl &url); 0081 void nameChanged(const QString& name); 0082 void isrootChanged(bool isroot); 0083 0084 private Q_SLOTS: 0085 /** 0086 * Dummy slot, simply forwarding to urlChanged(const QUrl &url). 0087 **/ 0088 void slotURLChanged(KileDocument::Info*, const QUrl &url); 0089 0090 0091 private: 0092 QUrl m_url; 0093 KileType::ProjectView m_type; 0094 KileDocument::Info *m_docinfo; 0095 int m_folder; 0096 KileProjectItem *m_projectItem; 0097 }; 0098 0099 class ProjectView : public QTreeWidget 0100 { 0101 Q_OBJECT 0102 0103 public: 0104 ProjectView(QWidget *parent, KileInfo *ki); 0105 0106 void addTree(KileProjectItem *item, ProjectViewItem *projvi); 0107 0108 ProjectViewItem* projectViewItemFor(const QUrl&); 0109 ProjectViewItem* itemFor(const QUrl&); 0110 ProjectViewItem* parentFor(const KileProjectItem *projitem, ProjectViewItem *projvi); 0111 0112 public Q_SLOTS: 0113 void slotClicked(QTreeWidgetItem* item = Q_NULLPTR); 0114 0115 void slotFile(int id); 0116 void slotProjectItem(int id); 0117 void slotProject(int id); 0118 0119 void slotRun(int id); 0120 0121 void refreshProjectTree(const KileProject *); 0122 void add(const QUrl &url); 0123 void add(const KileProject *project); 0124 void remove(const QUrl &url); 0125 void remove(const KileProject *project); 0126 void removeItem(const KileProjectItem *, bool); 0127 ProjectViewItem* add(KileProjectItem *item, ProjectViewItem *projvi = Q_NULLPTR); 0128 0129 Q_SIGNALS: 0130 void fileSelected(const KileProjectItem *); 0131 void fileSelected(const QUrl&); 0132 void saveURL(const QUrl&); 0133 void closeURL(const QUrl&); 0134 void projectOptions(const QUrl&); 0135 void projectArchive(const QUrl&); 0136 void addFiles(const QUrl&); 0137 void openAllFiles(const QUrl&); 0138 void toggleArchive(KileProjectItem*); 0139 void closeProject(const QUrl&); 0140 void addToProject(const QUrl&); 0141 void removeFromProject(KileProjectItem*); 0142 void buildProjectTree(const QUrl&); 0143 0144 protected: 0145 virtual void contextMenuEvent(QContextMenuEvent *event) override; 0146 virtual void dragEnterEvent(QDragEnterEvent *event) override; 0147 virtual void dragMoveEvent(QDragMoveEvent *event) override; 0148 virtual void dropEvent(QDropEvent *event) override; 0149 0150 private: 0151 0152 KileInfo *m_ki; 0153 uint m_nProjects; 0154 0155 KService::List m_offerList; 0156 0157 void makeTheConnection(ProjectViewItem *projectViewItem, KileDocument::TextInfo *textInfo = Q_NULLPTR); 0158 ProjectViewItem* folder(const KileProjectItem *item, ProjectViewItem *); 0159 0160 }; 0161 0162 } 0163 0164 #endif