gitconsole.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef GITCONSOLE_H
  2. #define GITCONSOLE_H
  3. #include <QObject>
  4. #include <QPointer>
  5. #include <QList>
  6. #include <QString>
  7. class QProcess;
  8. class GitRepository;
  9. class GitConsole : public QObject
  10. {
  11. Q_OBJECT
  12. Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged)
  13. Q_PROPERTY(QString recent READ recent NOTIFY recentChanged)
  14. public:
  15. GitConsole(QObject* parent = 0);
  16. ~GitConsole();
  17. Q_INVOKABLE void exec(const QString& command);
  18. bool busy() const
  19. {
  20. return m_busy;
  21. }
  22. QString recent() const
  23. {
  24. if(m_recentIndex < 0) {
  25. return QString();
  26. }
  27. return m_recentContainer.at(m_recentIndex);
  28. }
  29. public slots:
  30. void setRepository(GitRepository* repo);
  31. void setBusy(bool busy)
  32. {
  33. if (m_busy == busy)
  34. return;
  35. m_busy = busy;
  36. emit busyChanged(busy);
  37. }
  38. void onFinished(int exitCode);
  39. void onOutputReady();
  40. Q_INVOKABLE void recentUp();
  41. Q_INVOKABLE void recentDown();
  42. Q_INVOKABLE void requestAutocomplete(const QString& current);
  43. Q_INVOKABLE void requestPredictions(QString current);
  44. signals:
  45. void busyChanged(bool busy);
  46. void commandLog(const QString& data, bool prepend);
  47. void resetLog();
  48. void commandError();
  49. void recentChanged(QString recent);
  50. void autocomplete(const QString& value);
  51. void predict(const QList<QString>& predictions);
  52. private:
  53. QProcess* m_process;
  54. QPointer<GitRepository> m_repo;
  55. bool m_busy;
  56. QList<QString> m_recentContainer;
  57. int m_recentIndex;
  58. };
  59. #endif // GITCONSOLE_H