[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/soc-kdesdk-dolphin-plugins-hg/dolphin-plugins/hg
From: Vishesh Yadav <vishesh3y () gmail ! com>
Date: 2011-05-31 22:50:15
Message-ID: 20110531225015.68696AC779 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1234375 by visheshyadav:
Added brach buttons and actions
M +1 -1 CMakeLists.txt
A branchdialog.cpp branchtag.cpp#1234266 [License: GPL (v2+)]
A branchdialog.h branchtag.h#1234266 [License: GPL (v2+)]
D branchtag.cpp
D branchtag.h
M +84 -23 commitdialog.cpp
M +24 -7 commitdialog.h
M +20 -10 hgwrapper.cpp
M +3 -3 hgwrapper.h
--- branches/work/soc-kdesdk-dolphin-plugins-hg/dolphin-plugins/hg/CMakeLists.txt #1234374:1234375
@@ -8,7 +8,7 @@
commitdialog.cpp
hgwrapper.cpp
statuslist.cpp
- branchtag.cpp
+ branchdialog.cpp
)
kde4_add_kcfg_files(fileviewhgplugin_SRCS fileviewhgpluginsettings.kcfgc)
--- branches/work/soc-kdesdk-dolphin-plugins-hg/dolphin-plugins/hg/commitdialog.cpp #1234374:1234375
@@ -21,19 +21,19 @@
#include "hgwrapper.h"
#include "fileviewhgpluginsettings.h"
-#include <klocale.h>
#include <QtGui/QGroupBox>
#include <QtGui/QHBoxLayout>
#include <QtGui/QVBoxLayout>
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
-#include <QtGui/QLabel>
#include <QtGui/QFrame>
#include <QtGui/QGroupBox>
#include <QtCore/QStringList>
+#include <QtGui/QActionGroup>
#include <QDebug>
-#include <kservice.h>
#include <kurl.h>
+#include <kpushbutton.h>
+#include <klocale.h>
HgCommitDialog::HgCommitDialog(QWidget* parent):
KDialog(parent, Qt::Dialog)
@@ -54,24 +54,64 @@
m_fileDiffView = qobject_cast<KTextEditor::View*>(m_fileDiffDoc->createView(this));
m_fileDiffDoc->setReadWrite(false);
+ // Top bar of buttons
QHBoxLayout *topBarLayout = new QHBoxLayout;
- m_optionsButton = new KPushButton;
- topBarLayout->addWidget(m_optionsButton);
+ KPushButton *copyMessageButton = new KPushButton(i18n("Copy Message"));
+ KPushButton *optionsButton = new KPushButton(i18n("Options"));
+ m_branchButton = new KPushButton(i18n("Branch"));
+ topBarLayout->addWidget(new QLabel(getParentForLabel()));
+ topBarLayout->addStretch();
+ topBarLayout->addWidget(copyMessageButton);
+ topBarLayout->addWidget(m_branchButton);
+ topBarLayout->addWidget(optionsButton);
+
+ m_noChanges= new KAction(this);
+ m_noChanges->setCheckable(true);
+ m_noChanges->setText(i18nc("@action:inmenu",
+ "No branch changes"));
+
+ m_newBranch = new KAction(this);
+ m_newBranch->setCheckable(true);
+ m_newBranch->setText(i18nc("@action:inmenu",
+ "Create new branch"));
+
+ m_closeBranch = new KAction(this);
+ m_closeBranch->setCheckable(true);
+ m_closeBranch->setText(i18nc("@action:inmenu",
+ "Close current branch"));
+
+ m_branchMenu = new KMenu;
+ m_branchMenu->addAction(m_noChanges);
+ m_branchMenu->addAction(m_newBranch);
+ m_branchMenu->addAction(m_closeBranch);
+
+ QActionGroup *branchActionGroup = new QActionGroup(this);
+ branchActionGroup->addAction(m_noChanges);
+ branchActionGroup->addAction(m_newBranch);
+ branchActionGroup->addAction(m_closeBranch);
+ m_noChanges->setChecked(true);
+ connect(branchActionGroup, SIGNAL(triggered(QAction*)),
+ this, SLOT(slotBranchActions(QAction*)));
+
+ m_branchButton->setMenu(m_branchMenu);
+
+ // the commit box itself
QGroupBox *messageGroupBox = new QGroupBox;
QVBoxLayout *commitLayout = new QVBoxLayout;
m_commitMessage = new QPlainTextEdit;
- commitLayout->addWidget(new QLabel(getParentBranchForLabel()));
commitLayout->addWidget(m_commitMessage);
messageGroupBox->setTitle(i18nc("@title:group", "Commit Message"));
messageGroupBox->setLayout(commitLayout);
+ // Show diff here
QGroupBox *diffGroupBox = new QGroupBox;
QVBoxLayout *diffLayout = new QVBoxLayout;
diffLayout->addWidget(m_fileDiffView);
diffGroupBox->setTitle(i18nc("@title:group", "Diff/Content"));
diffGroupBox->setLayout(diffLayout);
+ // Set up layout for Status, Commit and Diff boxes
QGridLayout *bodyLayout = new QGridLayout;
m_statusList = new HgStatusList;
bodyLayout->addWidget(m_statusList, 0, 0, 0, 1);
@@ -82,6 +122,7 @@
bodyLayout->setRowStretch(0, 1);
bodyLayout->setRowStretch(1, 1);
+ // Set up layout and container for main dialog
QFrame *frame = new QFrame;
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(topBarLayout);
@@ -89,38 +130,42 @@
frame->setLayout(mainLayout);
setMainWidget(frame);
- //this->setMinimumSize(QSize(900, 500)
+ // Load saved settings
FileViewHgPluginSettings* settings = FileViewHgPluginSettings::self();
this->setInitialSize(QSize(settings->commitDialogWidth(),
settings->commitDialogHeight()));
- this->enableButtonOk(false);
+ this->enableButtonOk(false); // since commit message is empty when loaded
+ //
connect(m_statusList, SIGNAL(itemSelectionChanged(const char, const QString&)),
- this, SLOT(itemSelectionChangedSlot(const char, const QString&)));
+ this, SLOT(slotItemSelectionChanged(const char, const QString&)));
connect(m_commitMessage, SIGNAL(textChanged()),
this, SLOT(slotMessageChanged()));
connect(this, SIGNAL(finished()), this, SLOT(saveGeometry()));
}
-QString HgCommitDialog::getParentBranchForLabel()
+QString HgCommitDialog::getParentForLabel()
{
HgWrapper *hgWrapper = HgWrapper::instance();
- QString command = QLatin1String("hg log -r tip --template {parents}\\n{branches}");
+ QString line("<b>parents:</b> ");
+ QString command = QLatin1String("hg parents");
hgWrapper->start(command);
- QString lines;
while (hgWrapper->waitForReadyRead()) {
char buffer[1024];
- hgWrapper->readLine(buffer, sizeof(buffer));
- lines += QString("<b>parent: </b>%1").arg(buffer).trimmed();
- hgWrapper->readLine(buffer, sizeof(buffer));
- lines += " | ";
- lines += QString("<b>branch: </b>%1").arg(buffer).trimmed();
+ while (hgWrapper->readLine(buffer, sizeof(buffer))) {
+ QString bufferString = QString(buffer);
+ if (bufferString.contains("changeset:")) {
+ QStringList parts = bufferString.split(" ", QString::SkipEmptyParts);
+ line += parts.takeLast().trimmed();
+ line += " ";
}
- return lines;
}
+ }
+ return line;
+}
-void HgCommitDialog::itemSelectionChangedSlot(const char status, const QString &fileName)
+void HgCommitDialog::slotItemSelectionChanged(const char status, const QString &fileName)
{
qDebug() << "Caught signal itemSelectionChanged from HgStatusList";
m_fileDiffDoc->setReadWrite(true);
@@ -154,8 +199,6 @@
void HgCommitDialog::slotMessageChanged()
{
- /*qDebug() << "Hg/Commit: Checking empty message. "
- << m_commitMessage->toPlainText().isEmpty();*/
enableButtonOk(!m_commitMessage->toPlainText().isEmpty());
}
@@ -173,11 +216,11 @@
KDialog::done(r);
}
else {
- KMessageBox::error(this, "Commit unsuccessful!");
+ KMessageBox::error(this, i18n("Commit unsuccessful!"));
}
}
else {
- KMessageBox::error(this, "No files for commit!");
+ KMessageBox::error(this, i18n("No files for commit!"));
}
}
else {
@@ -193,5 +236,23 @@
settings->writeConfig();
}
+void HgCommitDialog::slotBranchActions(QAction *action)
+{
+ if (action == m_noChanges) {
+ }
+ else if (action == m_newBranch) {
+ }
+ else if (action == m_closeBranch) {
+ }
+}
+
+
+/* Branch Dialog */
+
+HgCommitDialog::NewBranchDialog::NewBranchDialog(QWidget *parent):
+ KDialog(parent, Qt::Dialog)
+{
+}
+
#include "commitdialog.moc"
--- branches/work/soc-kdesdk-dolphin-plugins-hg/dolphin-plugins/hg/commitdialog.h #1234374:1234375
@@ -29,13 +29,11 @@
#include <KTextEditor/Editor>
#include <KTextEditor/EditorChooser>
#include <kmessagebox.h>
+#include <kmenu.h>
+#include <kaction.h>
#include <kdialog.h>
-#include <klineedit.h>
-#include <kfileitem.h>
-#include <kpushbutton.h>
-// TODO: Make upper toolbar strip.
// TODO: Ability to set commit options. eg user
// TODO: Filter in HgStatusList.
// TODO: Set branch.
@@ -48,24 +46,43 @@
HgCommitDialog(QWidget* parent = 0);
private slots:
- void itemSelectionChangedSlot(const char status, const QString &fileName);
+ void slotItemSelectionChanged(const char status, const QString &fileName);
void slotMessageChanged();
void saveGeometry();
+ void slotBranchActions(QAction *action);
private:
- QString getParentBranchForLabel();
+ QString getParentForLabel();
void done(int r);
private:
QString m_hgBaseDir;
QPlainTextEdit *m_commitMessage;
- KPushButton *m_optionsButton;
HgStatusList *m_statusList;
KTextEditor::View *m_fileDiffView;
KTextEditor::Document *m_fileDiffDoc;
+
+ KPushButton *m_branchButton;
+
+ KAction *m_closeBranch;
+ KAction *m_newBranch;
+ KAction *m_noChanges;
+ KMenu *m_branchMenu;
+
+ enum {CloseBranch, NewBranch, NoChanges} m_branchAction;
+ QString m_newBranchName;
+
+ class NewBranchDialog : public KDialog {
+ public:
+ NewBranchDialog(QWidget *parent=0);
+ private:
+
};
+};
+
+
#endif // HGCOMMITDIALOG_H
--- branches/work/soc-kdesdk-dolphin-plugins-hg/dolphin-plugins/hg/hgwrapper.cpp #1234374:1234375
@@ -19,6 +19,8 @@
#include "hgwrapper.h"
+#include <QDebug>
+
HgWrapper* HgWrapper::m_instance = 0;
bool HgWrapper::m_pendingOperation = 0;
@@ -29,8 +31,6 @@
this, SLOT(slotOperationCompleted(int, QProcess::ExitStatus)));
connect(this, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(slotOperationError()));
-
- getBranches();
}
HgWrapper* HgWrapper::instance()
@@ -94,8 +94,6 @@
void HgWrapper::setBaseAsWorkingDir()
{
setWorkingDirectory(getBaseDir());
- qDebug() << "Hg Working directory changed to: "
- << this->workingDirectory();
}
void HgWrapper::addFiles(const KFileItemList& fileList)
@@ -128,24 +126,36 @@
start(QLatin1String("hg"), m_arguments);
}
-void HgWrapper::commit(const QString &message, const QStringList &files)
+void HgWrapper::commit(const QString &message, const QStringList &files,
+ bool closeCurrentBranch)
{
QStringList args;
args << files;
args << QLatin1String("-m") << message;
+ if (closeCurrentBranch) {
+ args << "--close-branch";
+ }
executeCommand(QLatin1String("commit"), args);
}
QStringList HgWrapper::getBranches()
{
QStringList result;
+ executeCommand(QLatin1String("branches"));
+ while (waitForReadyRead()) {
+ char buffer[1048];
+ while (readLine(buffer, sizeof(buffer)) > 0) {
+ result << QString(buffer).remove(QRegExp("[\\s]+[\\d:a-zA-Z\\(\\)]*"));
+ }
+ }
+ return result;
+}
- executeCommand("branches");
+bool HgWrapper::createBranch(const QString &branchName)
+{
+ executeCommand("branch " + branchName);
waitForFinished();
- QString out = readAll();
- qDebug() << out;
- return result;
-
+ return (exitStatus()==QProcess::NormalExit) && (exitCode()==0);
}
#include "hgwrapper.moc"
--- branches/work/soc-kdesdk-dolphin-plugins-hg/dolphin-plugins/hg/hgwrapper.h #1234374:1234375
@@ -20,11 +20,9 @@
#ifndef HGWRAPPER_H
#define HGWRAPPER_H
-#include <QtCore/QObject>
#include <QtCore/QProcess>
#include <QtCore/QString>
#include <QtCore/QStringList>
-#include <QDebug>
#include <kfileitem.h>
class HgWrapper : public QProcess
@@ -43,9 +41,11 @@
void setBaseAsWorkingDir();
void addFiles(const KFileItemList& fileList);
void removeFiles(const KFileItemList& fileList);
- void commit(const QString &message, const QStringList &files=QStringList());
+ void commit(const QString &message, const QStringList &files=QStringList(),
+ bool closeCurrentBranch=false);
QStringList getBranches();
QStringList getTags();
+ bool createBranch(const QString &branchName);
private slots:
void slotOperationCompleted(int exitCode, QProcess::ExitStatus exitStatus);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic