# HG changeset patch # User Chris Cannam # Date 1290546242 0 # Node ID 879af4608c5eac77d7636edaf8c6de25e884f2ad # Parent b43355c2473a5b827701e2ca17eb49b32c8fb217 * Remove some old code in preparation for rebuilding it with the newer structure diff -r b43355c2473a -r 879af4608c5e hgexpwidget.cpp --- a/hgexpwidget.cpp Tue Nov 23 16:35:49 2010 +0000 +++ b/hgexpwidget.cpp Tue Nov 23 21:04:02 2010 +0000 @@ -31,85 +31,12 @@ #include -#define REMOTE_REPO_STR "Remote repository: " -#define LOCAL_REPO_STR "Local repository: " -#define WORKFOLDER_STR "Working folder: " - - -const char hgStatViewOptions[NUM_STAT_FILE_TYPES] = {'m','a','r','d','u','c','i'}; - -const char *statFilesStr[NUM_STAT_FILE_TYPES] = { "M: Modified", - "A: To be added on next commit", - "R: To be removed on next commit", - "!: Tracked, locally deleted", - "?: Unknown, not yet tracked", - "C: Clean (not changed)", - "I: Ignored (via .hgignore file)"}; - - HgExpWidget::HgExpWidget(QWidget *parent, QString remoteRepo, QString workFolderPath, unsigned char viewFileTypesBits) : QTabWidget(parent) { - //Work page - //Work page - //Work page - - //Remote repo - grpRemoteRepo = new QGroupBox(tr(REMOTE_REPO_STR) + remoteRepo); - grpRemoteRepo -> setMinimumHeight(24); - - //Local Repo - grpLocalRepo = new QGroupBox(tr(LOCAL_REPO_STR) + workFolderPath + getHgDirName()); - parentsLabel = new QLabel(tr("Working folder parent(s):")); - localRepoHgParentsList = new QListWidget; - localRepoHgParentsList -> setSelectionMode(QAbstractItemView::NoSelection); - parentsLayout = new QVBoxLayout; - parentsLayout -> addWidget(parentsLabel); - parentsLayout -> addWidget(localRepoHgParentsList); - grpLocalRepo -> setLayout(parentsLayout); - copyCommentAct = new QAction("Copy comment", localRepoHgParentsList); - userListMenu = new QMenu(localRepoHgParentsList); - userListMenu -> addAction(copyCommentAct); - connect(copyCommentAct, SIGNAL(triggered()), this, SLOT(copyComment())); - - //Workfolder - grpWorkFolder = new QGroupBox(tr(WORKFOLDER_STR) + workFolderPath); - workFolderLayout = new QHBoxLayout; - workFolderFileList = new QListWidget; - workFolderFileList -> setSelectionMode(QAbstractItemView::ExtendedSelection); - grpViewFileTypes = new QGroupBox; - fileTypesLayout = new QVBoxLayout; - - for(int i = 0; i < NUM_STAT_FILE_TYPES; i++) - { - chkViewFileTypes[i] = new QCheckBox(statFilesStr[i]); - if ((1U << i) & viewFileTypesBits) - { - chkViewFileTypes[i]->setChecked(true); - } - else - { - chkViewFileTypes[i]->setChecked(false); - } - connect(chkViewFileTypes[i], SIGNAL(stateChanged(int)), this, SIGNAL(workFolderViewTypesChanged())); - fileTypesLayout -> addWidget(chkViewFileTypes[i]); - } - - grpViewFileTypes -> setLayout(fileTypesLayout); - workFolderLayout->addWidget(workFolderFileList, 3); - workFolderLayout->addWidget(grpViewFileTypes, 1); - grpWorkFolder -> setLayout(workFolderLayout); - - workPageWidget = new QWidget; - mainLayout = new QVBoxLayout(workPageWidget); - mainLayout -> addWidget(grpRemoteRepo, 1); - mainLayout -> addWidget(grpLocalRepo, 8); - mainLayout -> addWidget(grpWorkFolder, 12); -//!!! addTab(workPageWidget, tr("My work")); - - // New work page + // Work page fileStatusWidget = new FileStatusWidget; fileStatusWidget->setLocalPath(workFolderPath); fileStatusWidget->setRemoteURL(remoteRepo); @@ -128,76 +55,6 @@ panner->connectToPanned(panned); historyGraphPageWidget->setLayout(layout); addTab(historyGraphPageWidget, tr("History")); - - - //History page - //History page - //History page - historyPageWidget = new QWidget; - localRepoHgLogList = new QListWidget; - localRepoHgLogList->setFont(QFont("Courier New")); - localRepoHgLogList -> setSelectionMode(QAbstractItemView::ExtendedSelection); - - historyLayout = new QVBoxLayout(historyPageWidget); - historyLayout->addWidget(localRepoHgLogList); -//!!! addTab(historyPageWidget, tr("History (log)")); - - //Heads page - //Heads page - //Heads page - headsPageWidget = new QWidget; - localRepoHeadsList = new QListWidget; - localRepoHeadsList -> setSelectionMode(QAbstractItemView::ExtendedSelection); - - headsLayout = new QVBoxLayout(headsPageWidget); - headsLayout->addWidget(localRepoHeadsList); -//!!! addTab(headsPageWidget, tr("Heads")); - - //Initially, only work page is active -//!!! setTabEnabled(HEADSTAB, false); -//!!! setTabEnabled(HISTORYTAB, false); -} - -void HgExpWidget::contextMenuEvent(QContextMenuEvent * event) -{ - if (copyCommentAct -> isEnabled()) - { - QPoint topL; - QPoint bottomR; - - topL = localRepoHgParentsList-> - mapToGlobal(QPoint(0, 0)); - bottomR = localRepoHgParentsList-> - mapToGlobal(QPoint(localRepoHgParentsList -> width(), localRepoHgParentsList -> height())); - - if ((event -> globalPos().x() > topL.x()) && (event -> globalPos().x() < bottomR.x())) - { - if ((event -> globalPos().y() > topL.y()) && (event -> globalPos().y() < bottomR.y())) - { - userListMenu->exec(event -> globalPos()); - } - } - } -} - -void HgExpWidget::copyComment() -{ - if (localRepoHgParentsList -> count() >= 1) - { - QListWidgetItem *it = localRepoHgParentsList -> item(0); - QString tmp = it -> text(); - int ind = tmp.indexOf("summary:"); - if (ind != -1) - { - QString comment; - ind += 11; //jump over word "summary:" - - comment = tmp.mid(ind); - - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(comment); - } - } } bool HgExpWidget::canCommit() const @@ -205,86 +62,14 @@ return fileStatusWidget->haveChangesToCommit(); } -QString HgExpWidget::getStatFlags() -{ - QString ret; - - for(int i = 0; i < NUM_STAT_FILE_TYPES; i++) - { - if (Qt::Checked == chkViewFileTypes[i]->checkState()) - { - ret += hgStatViewOptions[i]; - } - } - - return ret; -} - - -unsigned char HgExpWidget::getFileTypesBits() -{ - unsigned char ret; - - ret = 0; - - for(int i = 0; i < NUM_STAT_FILE_TYPES; i++) - { - if (Qt::Checked == chkViewFileTypes[i]->checkState()) - { - ret |= (1U << i); - } - } - - return ret; -} - - void HgExpWidget::updateWorkFolderFileList(QString fileList) { statParser = StatParser(fileList); - fileStatusWidget->setStatParser(statParser); - - workFolderFileList-> clear(); - workFolderFileList -> addItems(fileList.split("\n")); -} - -void HgExpWidget::updateLocalRepoHeadsList(QString headList) -{ - localRepoHeadsList-> clear(); - localRepoHeadsList -> addItems(splitChangeSets(headList)); - - //heads list is interesting only when we have 2 or more - if (localRepoHeadsList-> count() < 2) - { - setTabEnabled(HEADSTAB, false); - } - else - { - setTabEnabled(HEADSTAB, true); - } -} - - -void HgExpWidget::clearLists() -{ - localRepoHeadsList-> clear(); - localRepoHgParentsList-> clear(); - workFolderFileList-> clear(); - localRepoHgLogList -> clear(); -} - -void HgExpWidget::updateLocalRepoParentsList(QString parentsList) -{ - localRepoHgParentsList-> clear(); - localRepoHgParentsList -> addItems(splitChangeSets(parentsList)); } void HgExpWidget::updateLocalRepoHgLogList(QString hgLogList) { - localRepoHgLogList -> clear(); - localRepoHgLogList -> addItems(splitChangeSets(hgLogList)); - //!!! Panned *panned = static_cast(historyGraphWidget); Panner *panner = static_cast(historyGraphPanner); @@ -305,71 +90,6 @@ if (tipItem) tipItem->ensureVisible(); } - - -int HgExpWidget::findLineStart(int nowIndex, QString str) -{ - if (nowIndex < 0) - { - return -1; - } - - while(str.at(nowIndex) != '\n') - { - if (nowIndex == 0) - { - return nowIndex; - } - nowIndex--; - } - return nowIndex + 1; -} - - -QStringList HgExpWidget::splitChangeSets(QString chgSetsStr) -{ - return LogParser(chgSetsStr).split(); - /* - int currChgSet; - int currChgSetLineStart; - - int prevChgSet; - QStringList tmp; - - currChgSet = chgSetsStr.indexOf(CHGSET); - currChgSetLineStart = findLineStart(currChgSet, chgSetsStr); - prevChgSet = -1; - while (currChgSet != -1) - { - if (prevChgSet != -1) - { - tmp.append(chgSetsStr.mid(prevChgSet, (currChgSetLineStart - prevChgSet - 1))); - } - - prevChgSet = currChgSetLineStart; - - currChgSet = chgSetsStr.indexOf(CHGSET, currChgSet + 1); - currChgSetLineStart = findLineStart(currChgSet, chgSetsStr); - } - - if (prevChgSet != -1) - { - //Last changeset - tmp.append(chgSetsStr.mid(prevChgSet)); - } - else - { - //Only changeset (if any) - if (!chgSetsStr.isEmpty()) - { - tmp.append(chgSetsStr.mid(0)); - } - } - - return tmp; - */ -} - Changesets HgExpWidget::parseChangeSets(QString changeSetsStr) { Changesets csets; @@ -400,154 +120,8 @@ return csets; } -QString HgExpWidget::getCurrentFileListLine() -{ - if (workFolderFileList -> currentItem() != NULL) - { - return workFolderFileList -> currentItem()->text(); - } - return ""; -} - void HgExpWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath) { - grpRemoteRepo -> setTitle(tr(REMOTE_REPO_STR) + remoteRepoPath); - grpLocalRepo -> setTitle(tr(LOCAL_REPO_STR) + workFolderPath + getHgDirName()); - grpWorkFolder -> setTitle(tr(WORKFOLDER_STR) + workFolderPath); - fileStatusWidget->setLocalPath(workFolderPath); fileStatusWidget->setRemoteURL(remoteRepoPath); } - -#define MERC_SHA1_MARKER_LEN 12 -QString HgExpWidget::findRev(QString itemText, QString & smallRev) -{ - QString tmp(itemText); - int i; - int j; - - smallRev ="0"; - - i = tmp.indexOf(CHGSET); - if (i != -1) - { - j = i + 10; - i = tmp.indexOf(":", j); //xx:yyyyyy after changeset: - - if (i != -1) - { - smallRev = tmp.mid(j, (i-j)); - return tmp.mid(i+1, MERC_SHA1_MARKER_LEN); - } - } - - return ""; -} - -void HgExpWidget::getHistoryDiffRevisions(QString& revA, QString& revB) -{ - QList histList = localRepoHgLogList->selectedItems(); - QList headList = localRepoHeadsList->selectedItems(); - - QString revATmp; - QString revBTmp; - QString smallRevA; - QString smallRevB; - QString txtA; - QString txtB; - - if (histList.count() == REQUIRED_CHGSET_DIFF_COUNT) - { - txtA = histList.last()->text(); - txtB = histList.first()->text(); - - } - else if (headList.count() == REQUIRED_CHGSET_DIFF_COUNT) - { - txtA = headList.last()->text(); - txtB = headList.first()->text(); - } - else - { - revA = ""; - revB = ""; - return; - } - - revATmp = findRev(txtA, smallRevA); - revBTmp = findRev(txtB, smallRevB); - - //Switch order according to repo small revision number (user can select items from list in "wrong" order) - if (smallRevB.toULongLong() > smallRevA.toULongLong()) - { - revA = revATmp; - revB = revBTmp; - } - else - { - revA = revBTmp; - revB = revATmp; - } -} - - -void HgExpWidget::getUpdateToRevRevision(QString& rev) -{ - QList histList = localRepoHgLogList->selectedItems(); - QString txt; - QString smallRev; - - - if (histList.count() == 1) - { - txt = histList.first()->text(); - rev = findRev(txt, smallRev); - } - else - { - rev = ""; - } -} - - -void HgExpWidget::enableDisableOtherTabs(int tabPage) -{ - static int oldTabPage = -1; - - if (tabPage != oldTabPage) - { - oldTabPage = tabPage; - if (tabPage == WORKTAB) - { - copyCommentAct -> setEnabled(true); - } - else - { - copyCommentAct -> setEnabled(false); - } - } - - //history list is only interesting when we have something in it ;-) - if (localRepoHgLogList -> count() < 2) - { - setTabEnabled(HISTORYTAB, false); - } - else - { - setTabEnabled(HISTORYTAB, true); - } - - //history list is only interesting when we have something in it ;-) - if (localRepoHgLogList -> count() < 2) - { - setTabEnabled(HISTORYTAB, false); - } - else - { - setTabEnabled(HISTORYTAB, true); - } -} - - - - diff -r b43355c2473a -r 879af4608c5e hgexpwidget.h --- a/hgexpwidget.h Tue Nov 23 16:35:49 2010 +0000 +++ b/hgexpwidget.h Tue Nov 23 21:04:02 2010 +0000 @@ -42,72 +42,27 @@ public: HgExpWidget(QWidget *parent, QString remoteRepo, QString workFolderPath, unsigned char viewFileTypesBits = DEFAULT_HG_STAT_BITS); + void updateWorkFolderFileList(QString fileList); - void updateLocalRepoHeadsList(QString headList); void updateLocalRepoHgLogList(QString hgLogList); - void updateLocalRepoParentsList(QString parentsList); void setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath); - QString getCurrentFileListLine(); - void getHistoryDiffRevisions(QString& revA, QString& revB); - void getUpdateToRevRevision(QString& rev); - void clearLists(); - void enableDisableOtherTabs(int tabPage); - QString getStatFlags(void); - unsigned char getFileTypesBits(); //!!! StatParser really should be renamed to express "status state" rather than activity StatParser getStatParser() { return statParser; } bool canCommit() const; - QListWidget *workFolderFileList; - QListWidget *localRepoHeadsList; - QListWidget *localRepoHgLogList; - -signals: - void workFolderViewTypesChanged(); - -private slots: - void copyComment(); - private: FileStatusWidget *fileStatusWidget; - QGroupBox *grpRemoteRepo; - QWidget *workPageWidget; - QWidget *historyGraphPageWidget; - QWidget *historyGraphWidget; - QWidget *historyGraphPanner; - QWidget *historyPageWidget; - QWidget *headsPageWidget; + QWidget *historyGraphPageWidget; + QWidget *historyGraphWidget; + QWidget *historyGraphPanner; + QWidget *historyPageWidget; - QGroupBox *grpLocalRepo; - QVBoxLayout *mainLayout; - QVBoxLayout *localRepoLayout; - QVBoxLayout *parentsLayout; - QListWidget *localRepoHgParentsList; - QLabel *parentsLabel; - QMenu *userListMenu; - QAction *copyCommentAct; + StatParser statParser; - QGroupBox *grpWorkFolder; - QHBoxLayout *workFolderLayout; - QGroupBox *grpViewFileTypes; - QVBoxLayout *fileTypesLayout; - QCheckBox *chkViewFileTypes[NUM_STAT_FILE_TYPES]; - - QVBoxLayout *historyLayout; - - QVBoxLayout *headsLayout; - - StatParser statParser; - - QString findRev(QString itemText, QString& smallRev); - QStringList splitChangeSets(QString chgSetsStr); - Changesets parseChangeSets(QString changeSetsStr); - - int findLineStart(int nowIndex, QString chgSetsStr); - void contextMenuEvent (QContextMenuEvent * event); + Changesets parseChangeSets(QString changeSetsStr); }; #endif // HGEXPWIDGET_H diff -r b43355c2473a -r 879af4608c5e mainwindow.cpp --- a/mainwindow.cpp Tue Nov 23 16:35:49 2010 +0000 +++ b/mainwindow.cpp Tue Nov 23 21:04:02 2010 +0000 @@ -137,16 +137,7 @@ { QStringList params; - QString statFlags = hgExp -> getStatFlags(); - if (statFlags.isEmpty()) - { - params << "stat"; - } - else - { - params << "stat" << "-" + statFlags; - } - + params << "stat" << "-ardum"; runner -> startHgCommand(workFolderPath, params); runningAction = ACT_STAT; @@ -212,7 +203,7 @@ if (runningAction == ACT_NONE) { QStringList params; - QString currentFile = hgExp -> getCurrentFileListLine(); + QString currentFile;//!!! = hgExp -> getCurrentFileListLine(); if (!currentFile.isEmpty()) { @@ -233,7 +224,7 @@ if (runningAction == ACT_NONE) { QStringList params; - QString currentFile = hgExp -> getCurrentFileListLine(); + QString currentFile;//!!! = hgExp -> getCurrentFileListLine(); if (!currentFile.isEmpty()) { @@ -251,7 +242,7 @@ if (runningAction == ACT_NONE) { QStringList params; - QString currentFile = hgExp -> getCurrentFileListLine(); + QString currentFile;//!!! = hgExp -> getCurrentFileListLine(); if (!currentFile.isEmpty()) { @@ -285,8 +276,8 @@ { QStringList params; - QString currentFile = hgExp -> getCurrentFileListLine(); - + QString currentFile;//!!! = hgExp -> getCurrentFileListLine(); +/*!!! if (areAllSelectedUntracked(hgExp -> workFolderFileList)) { //User wants to add selected file(s) @@ -308,6 +299,7 @@ runner -> startHgCommand(workFolderPath, params); runningAction = ACT_ADD; + */ } } @@ -366,6 +358,7 @@ { if (!comment.isEmpty()) { + /*!!! if ((justMerged == false) && (areAllSelectedCommitable(hgExp -> workFolderFileList))) { //User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files) @@ -386,6 +379,7 @@ runner -> startHgCommand(workFolderPath, params); runningAction = ACT_COMMIT; + */ } } } @@ -463,7 +457,7 @@ if (runningAction == ACT_NONE) { QStringList params; - +/*!!! QString currentFile = hgExp -> getCurrentFileListLine(); if (!currentFile.isEmpty()) @@ -473,6 +467,7 @@ runner -> startHgCommand(workFolderPath, params); runningAction = ACT_FILEDIFF; } + */ } } @@ -500,7 +495,7 @@ //Diff 2 history log versions against each other QString revA; QString revB; - +/*!!! hgExp -> getHistoryDiffRevisions(revA, revB); if ((!revA.isEmpty()) && (!revB.isEmpty())) @@ -513,6 +508,7 @@ { QMessageBox::information(this, tr("Changeset diff"), tr("Please select two changesets from history list or heads list first.")); } + */ } } @@ -540,7 +536,7 @@ { QStringList params; QString rev; - +/*!!! hgExp -> getUpdateToRevRevision(rev); hgExp -> setCurrentIndex(WORKTAB); @@ -551,6 +547,7 @@ runner -> startHgCommand(workFolderPath, params); runningAction = ACT_UPDATE; + */ } } @@ -559,6 +556,7 @@ { if (runningAction == ACT_NONE) { + /*!!! QStringList params; QString currentFile = hgExp -> getCurrentFileListLine(); @@ -566,6 +564,7 @@ runner -> startHgCommand(workFolderPath, params); runningAction = ACT_REVERT; + */ } } @@ -767,10 +766,10 @@ } if (result) { - hgExp->clearLists(); enableDisableActions(); hgPaths(); - done = true; } + done = true; + } } else { @@ -1361,21 +1360,19 @@ break; case ACT_LOG: - { - hgExp -> updateLocalRepoHgLogList(runner -> getOutput()); - } + hgExp -> updateLocalRepoHgLogList(runner -> getOutput()); break; case ACT_PARENTS: { - hgExp -> updateLocalRepoParentsList(runner -> getOutput()); + //!!! hgExp -> updateLocalRepoParentsList(runner -> getOutput()); } break; case ACT_HEADS: { QString stdOut = runner -> getOutput(); - hgExp -> updateLocalRepoHeadsList(stdOut); + //!!! hgExp -> updateLocalRepoHeadsList(stdOut); } break; @@ -1569,7 +1566,7 @@ hgTagAct -> setEnabled(localRepoActionsEnabled); hgIgnoreAct -> setEnabled(localRepoActionsEnabled); - hgExp -> enableDisableOtherTabs(tabPage); + //!!!hgExp -> enableDisableOtherTabs(tabPage); DEBUG << "localRepoActionsEnabled = " << localRepoActionsEnabled << endl; DEBUG << "canCommit = " << hgExp->canCommit() << endl; @@ -1890,7 +1887,7 @@ settings.setValue("remoterepopath", remoteRepoPath); settings.setValue("workfolderpath", workFolderPath); settings.setValue("firststart", firstStart); - settings.setValue("viewFileTypes", hgExp -> getFileTypesBits()); + //!!!settings.setValue("viewFileTypes", hgExp -> getFileTypesBits()); }