mainimpl.h

Go to the documentation of this file.
00001 /*
00002         Author: Marco Costalba (C) 2005-2006
00003 
00004         Copyright: See COPYING file that comes with this distribution
00005 
00006 */
00007 #ifndef MAINIMPL_H
00008 #define MAINIMPL_H
00009 
00010 #include <qguardedptr.h>
00011 #include <qregexp.h>
00012 #include <qprocess.h>
00013 #include <qptrvector.h>
00014 #include <qtimer.h>
00015 #include "exceptionmanager.h"
00016 #include "common.h"
00017 #include "mainbase.h"
00018 
00019 class QListViewItem;
00020 class QListBoxItem;
00021 class QPopupMenu;
00022 class QCustomEvent;
00023 class QAccel;
00024 class QTextEdit;
00025 class Git;
00026 class Domain;
00027 class ListViewItem;
00028 class RevsView;
00029 class FileView;
00030 class FileHistory;
00031 
00032 class MainImpl : public MainBase {
00033 Q_OBJECT
00034 public:
00035         MainImpl(const QString& curDir = "", QWidget* parent = 0);
00036         QString curWorkDir() const { return curDir; }
00037 
00038 signals:
00039         void highlightPatch(const QString&, bool);
00040         void updateRevDesc();
00041         void closeAllWindows();
00042         void closeAllTabs();
00043         void tabClosed(int tabPos);
00044         void repaintListViews(const QFont&);
00045         void closeTabButtonEnabled(bool);
00046 
00047 public slots:
00048         void tabWdg_currentChanged(QWidget*);
00049         void on_newRevsAdded(const FileHistory*, const QValueVector<QString>&);
00050 
00051 protected:
00052         virtual void customEvent(QCustomEvent* e);
00053 
00054 protected slots:
00055         void initWithEventLoopActive();
00056         void refreshRepo(bool setCurRevAfterLoad = true);
00057         void on_listViewLog_doubleClicked(QListViewItem*);
00058         void on_fileList_doubleClicked(QListBoxItem*);
00059         void on_treeView_doubleClicked(QListViewItem*);
00060         void on_histListView_doubleClicked(QListViewItem* item);
00061         void on_customActionListChanged(const QStringList& list);
00062         void on_openRecent_activated(int id);
00063         void on_customAction_activated(int id);
00064         void on_customAction_exited(const QString& name);
00065         void on_goRef_activated(int id);
00066         void on_changesCommitted(bool);
00067         void lineEditSHA_returnPressed();
00068         void lineEditFilter_returnPressed();
00069         void pushButtonCloseTab_clicked();
00070         void toolButtonFilter_toggled(bool);
00071         void toolButtonBold_toggled(bool);
00072         void accelActivated(int);
00073         void ActBack_activated();
00074         void ActForward_activated();
00075         void ActFind_activated();
00076         void ActFindNext_activated();
00077         void ActViewRev_activated();
00078         void ActViewFile_activated();
00079         void ActViewFileNewTab_activated();
00080         void ActViewDiff_activated();
00081         void ActViewDiffNewTab_activated();
00082         void ActExternalDiff_activated();
00083         void ActSplitView_activated();
00084         void ActShowDescHeader_toggled(bool);
00085         void ActOpenRepo_activated();
00086         void ActOpenRepoNewWindow_activated();
00087         void ActRefresh_activated();
00088         void ActSaveFile_activated();
00089         void ActMailFormatPatch_activated();
00090         void ActMailApplyPatch_activated();
00091         void ActSettings_activated();
00092         void ActCommit_activated();
00093         void ActTag_activated();
00094         void ActTagDelete_activated();
00095         void ActPush_activated();
00096         void ActPop_activated();
00097         void ActClose_activated();
00098         void ActExit_activated();
00099         void ActCustomActionSetup_activated();
00100         void ActCheckWorkDir_toggled(bool);
00101         void ActShowTree_toggled(bool);
00102         void ActFilterTree_toggled(bool);
00103         void ActAbout_activated();
00104         void ActHelp_activated();
00105         void closeEvent(QCloseEvent* ce);
00106 
00107 private:
00108         friend class FileView;
00109         friend class RevsView;
00110         friend class PatchView;
00111         friend class setRepoDelayed;
00112 
00113         virtual bool eventFilter(QObject* obj, QEvent* ev);
00114         void updateGlobalActions(bool b);
00115         void updateContextActions(SCRef newRevSha, SCRef newFileName, bool isDir, bool found);
00116         void setupAccelerator(QAccel* accel);
00117         int currentTabType(Domain** t);
00118         void filterList(bool isOn, bool onlyHighlight);
00119         bool passFilter(ListViewItem* i, const QRegExp& f, int cn, const QMap<QString,bool>& sm);
00120         void setRepository(SCRef wd, bool r, bool ks, QStringList* fl = NULL);
00121         void diffViewerUpdate(QListViewItem* item, bool newDiff);
00122         void getExternalDiffArgs(QStringList* args);
00123         void lineEditSHASetText(SCRef text);
00124         void updateCommitMenu(bool isStGITStack);
00125         void updateRecentRepoMenu(SCRef newEntry = "");
00126         void doUpdateRecentRepoMenu(SCRef newEntry);
00127         void doUpdateCustomActionMenu(const QStringList& list);
00128         void ActCommit_setEnabled(bool b);
00129         void doContexPopup(SCRef sha);
00130         void doFileContexPopup(SCRef fileName, int type);
00131         void adjustFontSize(int delta);
00132         void scrollTextEdit(int delta);
00133         void scrollListView(int delta);
00134         void goMatch(int delta);
00135         bool askApplyPatchParameters(bool* commit, bool* fold);
00136         QTextEdit* getCurrentTextEdit();
00137         template<class X> QPtrList<X>* getTabs(int tabPos = -1);
00138         template<class X> X* firstTab(int startPos = -1);
00139         void openFileTab(FileView* fv = NULL);
00140 
00141         EM_DECLARE(exExiting);
00142 
00143         Git* git;
00144         RevsView* rv;
00145 
00146         // curDir is the repository working dir, could be different from qgit running
00147         // directory QDir::current(). Note that qgit could be run from subdirectory
00148         // so only after git->isArchive() that updates curDir to point to working dir
00149         // we are sure is correct.
00150         QString curDir;
00151         QRegExp shortLogRE;
00152         QRegExp longLogRE;
00153         QGuardedPtr<QPopupMenu> contextMenu;
00154         QGuardedPtr<QPopupMenu> contextSubMenu;
00155         QGuardedPtr<QPopupMenu> contextRmtMenu;
00156         QString startUpDir;
00157         QString textToFind;
00158         QFont listViewFont;
00159         bool setRepositoryBusy;
00160         int recentRepoMenuPos;
00161 };
00162 
00163 class ExternalDiffProc : public QProcess {
00164 Q_OBJECT
00165 public:
00166         ExternalDiffProc(const QStringList& args, QObject* p) : QProcess(args, p) {
00167 
00168                 connect(this, SIGNAL(processExited()), this, SLOT(on_processExited()));
00169         }
00170         ~ExternalDiffProc() {
00171 
00172                 tryTerminate();
00173                 removeFiles();
00174         }
00175 private slots:
00176         void on_processExited() { deleteLater(); }
00177 
00178 private:
00179         void removeFiles() {
00180 
00181                 if (!arguments().empty()) {
00182                         QDir d; // remove temporary files to diff on
00183                         d.remove(arguments()[1]);
00184                         d.remove(arguments()[2]);
00185                 }
00186         }
00187 };
00188 
00189 class setRepoDelayed : public QObject {
00190 Q_OBJECT
00191 public:
00192         setRepoDelayed(MainImpl* mi, SCRef nd, bool r, bool ks, QStringList* fl) :
00193         QObject(mi), m(mi), newDir(nd), refresh(r), keepSelection(ks) {
00194 
00195                 if (fl)
00196                         filterList = *fl;
00197 
00198                 QTimer::singleShot(100, this, SLOT(on_timeout()));
00199         }
00200 private slots:
00201         void on_timeout() {
00202                 QStringList* fl = filterList.isEmpty() ? NULL : &filterList;
00203                 m->setRepository(newDir, refresh, keepSelection, fl);
00204                 deleteLater();
00205          }
00206 private:
00207         MainImpl* m;
00208         const QString newDir;
00209         bool refresh, keepSelection;
00210         QStringList filterList;
00211 };
00212 
00213 #endif

Generated on Fri Dec 7 21:57:38 2007 for QGit by  doxygen 1.5.3