00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <qcombobox.h>
00010 #include <qlineedit.h>
00011 #include <qcheckbox.h>
00012 #include <qsettings.h>
00013 #include <qregexp.h>
00014 #include "common.h"
00015 #include "git.h"
00016 #include "rangeselectimpl.h"
00017
00018 using namespace QGit;
00019
00020 RangeSelectImpl::RangeSelectImpl(QWidget* par, QString* r, const QStringList& tl,
00021 bool* q, Git* g) : RangeSelectBase(par, 0, true) {
00022 range = r;
00023 quit = q;
00024 git = g;
00025 *quit = true;
00026
00027 QStringList otl;
00028 orderTags(tl, otl);
00029
00030
00031 if (!otl.empty()) {
00032 const QString tagSha(git->getRefSha(otl.first(), Git::TAG, false));
00033 if (git->checkRef(tagSha, Git::CUR_BRANCH))
00034
00035 otl.pop_front();
00036 }
00037 comboBoxTo->insertStringList(otl);
00038 comboBoxTo->insertItem("HEAD", 0);
00039 comboBoxFrom->insertStringList(otl);
00040 comboBoxFrom->setFocus();
00041
00042 int f = flags();
00043 checkBoxDiffCache->setChecked(f & DIFF_INDEX_F);
00044 checkBoxShowAll->setChecked(f & ALL_BRANCHES_F);
00045 checkBoxShowWholeHistory->setChecked(f & WHOLE_HISTORY_F);
00046 checkBoxShowDialog->setChecked(f & RANGE_SELECT_F);
00047 }
00048
00049 void RangeSelectImpl::orderTags(const QStringList& src, QStringList& dst) {
00050
00051
00052
00053
00054 QRegExp re("[\\d\\.]+([^\\d\\.]+\\d+$)");
00055
00056
00057
00058
00059
00060
00061 const QString rcMark(" $$%%");
00062 const QString noRcMark("!$$%%");
00063
00064 typedef QMap<QString, QString> OrderedMap;
00065 QRegExp verRE("([^\\d])(\\d{1,2})(?=[^\\d])");
00066 OrderedMap map;
00067
00068 FOREACH_SL (it, src) {
00069
00070 QString tmpStr(*it);
00071
00072 if (re.search(tmpStr) != -1)
00073 tmpStr.insert(re.pos(1), rcMark);
00074 else
00075 tmpStr += noRcMark;
00076
00077
00078
00079
00080
00081
00082 while (tmpStr.contains(verRE))
00083 tmpStr.replace(verRE, "\\10\\2");
00084
00085 map[tmpStr] = *it;
00086 }
00087 dst.clear();
00088 FOREACH (OrderedMap, it, map)
00089 dst.prepend(it.data());
00090 }
00091
00092 void RangeSelectImpl::checkBoxDiffCache_toggled(bool b) {
00093
00094 setFlag(DIFF_INDEX_F, b);
00095 }
00096
00097 void RangeSelectImpl::checkBoxShowDialog_toggled(bool b) {
00098
00099 setFlag(RANGE_SELECT_F, b);
00100 }
00101
00102 void RangeSelectImpl::pushButtonOk_clicked() {
00103
00104 *range = comboBoxFrom->currentText();
00105 if (!range->isEmpty())
00106 range->append("..");
00107
00108 range->append(comboBoxTo->currentText());
00109 range->prepend(lineEditOptions->text() + " ");
00110 *range = range->stripWhiteSpace();
00111 *quit = false;
00112 close();
00113 }
00114
00115 void RangeSelectImpl::checkBoxShowAll_toggled(bool b) {
00116
00117 QString opt(lineEditOptions->text());
00118 opt.remove("--all");
00119 if (b)
00120 opt.append(" --all");
00121
00122 lineEditOptions->setText(opt.stripWhiteSpace());
00123 setFlag(ALL_BRANCHES_F, b);
00124 }
00125
00126 void RangeSelectImpl::checkBoxShowWholeHistory_toggled(bool b) {
00127
00128 if (b) {
00129 fromBckUp = comboBoxFrom->currentText();
00130 toBckUp = comboBoxTo->currentText();
00131 comboBoxFrom->setCurrentText("");
00132 comboBoxTo->setCurrentText("HEAD");
00133
00134 } else {
00135 comboBoxFrom->setCurrentText(fromBckUp);
00136 comboBoxTo->setCurrentText(toBckUp);
00137 }
00138 comboBoxFrom->setEnabled(!b);
00139 comboBoxTo->setEnabled(!b);
00140 setFlag(WHOLE_HISTORY_F, b);
00141 }