forward various options and make cancelling not leave the tree dirty
[vng.git] / src / commands / Record.h
blob17daaa3c37a391f2c14d918a28efc246bfdbadd7
1 /*
2 * This file is part of the vng project
3 * Copyright (C) 2008 Thomas Zander <tzander@trolltech.com>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef RECORD_H
19 #define RECORD_H
21 #include "AbstractCommand.h"
23 class ChangeSet;
25 /// The command to record a set of changes into a patch.
26 class Record : public AbstractCommand
28 public:
29 enum UsageMode {
30 Unset, ///< Use the command line options for usage mode
31 InteractiveSelection, ///< give the user a prompt to select which hunks to record
32 AllChanges, ///< Add all changes to the patch
33 Index ///< Use the git index without change
36 Record();
38 /**
39 * Set the message that will be placed in the recorded patch.
41 void setPatchName(const QByteArray &patchName);
42 /// returns the message
43 QByteArray patchName() const;
45 /**
46 * Set the way that the patches to be recorded will be decided based on the usage mode.
48 void setUsageMode(UsageMode mode);
49 /// retuns the sha1 of the recorded patch after run() has successfully concluded.
50 QString sha1() const;
52 // is set to true, force the editor to be started, if false use the command line options
53 void setEditComment(bool on) { m_editComment = on; }
55 void setRecordAll(bool all) { m_all = all; }
56 bool recordAll() const { return m_all; }
58 void setAuthor(const QString &author) { m_author = author; }
59 QString author() const { return m_author; }
61 // actually records
62 ReturnCodes record();
64 protected:
65 // this method just relays to record();
66 virtual ReturnCodes run();
67 virtual QString argumentDescription() const;
68 virtual QString commandDescription() const;
70 private:
71 ReturnCodes addFilesPerAcceptance(const ChangeSet &changeSet, bool allChanges);
73 UsageMode m_mode;
74 QByteArray m_patchName;
75 QString m_sha1;
76 bool m_editComment;
77 bool m_all;
78 QString m_author;
81 #endif