Commit ac132dbb authored by Christian Loose's avatar Christian Loose

* Added new AddRemoveDialog (extracted from CommitDialog)

* Make functionality to view diff in CommitDialog more visible
   by adding diff button.

svn path=/trunk/kdesdk/cervisia/; revision=199053
parent 6a30e5af
......@@ -3,6 +3,9 @@
* Added help button to CommitDialog
* Use DCOP service to retrieve Tags and Branches for TagDialog,
MergeDialog und UpdateDialog
* Added new AddRemoveDialog (extracted from CommitDialog)
* Make functionality to view diff in CommitDialog more visible
by adding diff button.
2003-01-09 Christian Loose <christian.loose@hamburg.de>
......
......@@ -812,25 +812,71 @@ void CervisiaPart::slotMerge()
void CervisiaPart::slotCommit()
{
commitOrAddOrRemove(CommitDialog::Commit);
QStringList list = update->multipleSelection();
if (list.isEmpty())
return;
// modal dialog
CommitDialog dlg(widget());
dlg.setLogMessage(changelogstr);
dlg.setLogHistory(sandbox, repository, recentCommits);
dlg.setFileList(list);
if (dlg.exec())
{
QString msg = dlg.logMessage();
if( !recentCommits.contains( msg ) )
{
recentCommits.prepend( msg );
while (recentCommits.count() > 50)
recentCommits.remove( recentCommits.last() );
KConfig* conf = config();
conf->setGroup( "CommitLogs" );
conf->writeEntry( sandbox, recentCommits, COMMIT_SPLIT_CHAR );
}
update->prepareJob(opt_commitRecursive, UpdateView::Commit);
QString cmdline = cvsClient(repository) + " commit ";
if (opt_commitRecursive)
cmdline += "-R ";
else
cmdline += "-l ";
cmdline += "-m ";
cmdline += KShellProcess::quote(dlg.logMessage());
cmdline += " ";
cmdline += joinLine(list);
cmdline += " 2>&1";
if (protocol->startJob(sandbox, repository, cmdline))
{
showJobStart(cmdline);
connect( protocol, SIGNAL(jobFinished(bool, int)),
update, SLOT(finishJob(bool, int)) );
connect( protocol, SIGNAL(jobFinished(bool, int)),
this, SLOT(slotJobFinished()) );
}
}
}
void CervisiaPart::slotAdd()
{
commitOrAddOrRemove(CommitDialog::Add);
addOrRemove(AddRemoveDialog::Add);
}
void CervisiaPart::slotAddBinary()
{
commitOrAddOrRemove(CommitDialog::AddBinary);
addOrRemove(AddRemoveDialog::AddBinary);
}
void CervisiaPart::slotRemove()
{
commitOrAddOrRemove(CommitDialog::Remove);
addOrRemove(AddRemoveDialog::Remove);
}
......@@ -863,63 +909,32 @@ void CervisiaPart::updateSandbox(const QString &extraopt)
}
void CervisiaPart::commitOrAddOrRemove(CommitDialog::ActionType action)
void CervisiaPart::addOrRemove(AddRemoveDialog::ActionType action)
{
QStringList list = update->multipleSelection();
if (list.isEmpty())
return;
// modal dialog
CommitDialog *l = new CommitDialog(action, widget());
if (action == CommitDialog::Commit)
{
l->setLogMessage(changelogstr);
l->setLogHistory(sandbox, repository, recentCommits);
}
l->setFileList(list);
AddRemoveDialog dlg(action, widget());
dlg.setFileList(list);
if (l->exec())
if (dlg.exec())
{
QString cmdline;
switch (action)
{
case CommitDialog::Commit:
{
QString msg = l->logMessage();
if( !recentCommits.contains( msg ) )
{
recentCommits.prepend( msg );
while (recentCommits.count() > 50)
recentCommits.remove( recentCommits.last() );
KConfig* conf = config();
conf->setGroup( "CommitLogs" );
conf->writeEntry( sandbox, recentCommits, COMMIT_SPLIT_CHAR );
}
update->prepareJob(opt_commitRecursive, UpdateView::Commit);
cmdline = cvsClient(repository) + " commit ";
if (opt_commitRecursive)
cmdline += "-R ";
else
cmdline += "-l ";
cmdline += "-m ";
cmdline += KShellProcess::quote(l->logMessage());
cmdline += " ";
}
break;
case CommitDialog::Add:
case AddRemoveDialog::Add:
update->prepareJob(false, UpdateView::Add);
cmdline = cvsClient(repository) + " add ";
break;
case CommitDialog::AddBinary:
case AddRemoveDialog::AddBinary:
update->prepareJob(false, UpdateView::Add);
cmdline = cvsClient(repository) + " add -kb ";
break;
case CommitDialog::Remove:
case AddRemoveDialog::Remove:
update->prepareJob(opt_commitRecursive, UpdateView::Remove);
cmdline = cvsClient(repository) + " remove -f ";
if (opt_commitRecursive)
......@@ -941,8 +956,6 @@ void CervisiaPart::commitOrAddOrRemove(CommitDialog::ActionType action)
this, SLOT(slotJobFinished()) );
}
}
delete l;
}
void CervisiaPart::slotBrowseLog()
......
......@@ -19,6 +19,7 @@
#include <kparts/browserextension.h>
#include <kparts/genericfactory.h>
#include "addremovedlg.h"
#include "commitdlg.h"
#include "checkoutdlg.h"
#include "watchdlg.h"
......@@ -138,7 +139,7 @@ private:
void openSandbox(const QString &dirname);
void updateSandbox(const QString &extraopt = QString::null);
void commitOrAddOrRemove(CommitDialog::ActionType action);
void addOrRemove(AddRemoveDialog::ActionType action);
void addOrRemoveWatch(WatchDialog::ActionType action);
void importOrCheckout(CheckoutDialog::ActionType action);
void createOrDeleteTag(TagDialog::ActionType action);
......
......@@ -27,72 +27,59 @@
CommitDialog::Options *CommitDialog::options = 0;
CommitDialog::CommitDialog(ActionType action, QWidget *parent, const char *name)
: KDialogBase(parent, name, true, QString::null,
Ok | Cancel | Help, Ok, true),
edit(0)
CommitDialog::CommitDialog(QWidget *parent, const char *name)
: KDialogBase(parent, name, true, i18n("CVS Commit"),
Ok | Cancel | Help | User1, Ok, true)
{
setCaption( (action==Add)? i18n("CVS Add") :
(action==AddBinary)? i18n("CVS Add Binary") :
(action==Remove)? i18n("CVS Remove") :
i18n("CVS Commit") );
QFrame* mainWidget = makeMainWidget();
QBoxLayout *layout = new QVBoxLayout(mainWidget, 0, spacingHint());
QLabel *textlabel = new QLabel
( (action==Add)? i18n("Add the following files to the repository:") :
(action==AddBinary)? i18n("Add the following binary files to the repository:") :
(action==Remove)? i18n("Remove the following files from the repository:") :
i18n("Commit the following &files:"),
mainWidget );
QLabel *textlabel = new QLabel( i18n("Commit the following &files:"), mainWidget );
layout->addWidget(textlabel);
listbox = new QListBox(mainWidget);
textlabel->setBuddy(listbox);
connect( listbox, SIGNAL(selected(int)), this, SLOT(fileSelected(int)));
connect( listbox, SIGNAL(highlighted(int)), this, SLOT(fileHighlighted(int)));
layout->addWidget(listbox, 5);
if (action == Commit)
{
QLabel *archivelabel = new QLabel(i18n("Older &messages:"), mainWidget);
layout->addWidget(archivelabel);
QLabel *archivelabel = new QLabel(i18n("Older &messages:"), mainWidget);
layout->addWidget(archivelabel);
combo = new QComboBox(mainWidget);
archivelabel->setBuddy(combo);
connect( combo, SIGNAL(activated(int)), this, SLOT(comboActivated(int)) );
// make sure that combobox is smaller than the screen
combo->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
layout->addWidget(combo);
combo = new QComboBox(mainWidget);
archivelabel->setBuddy(combo);
connect( combo, SIGNAL(activated(int)), this, SLOT(comboActivated(int)) );
// make sure that combobox is smaller than the screen
combo->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
layout->addWidget(combo);
QLabel *messagelabel = new QLabel(i18n("&Log message:"), mainWidget);
layout->addWidget(messagelabel);
edit = new QMultiLineEdit(mainWidget);
messagelabel->setBuddy(edit);
edit->setFocus();
edit->setMinimumSize(400, 100);
layout->addWidget(edit, 10);
}
else
listbox->setEnabled(false);
QLabel *messagelabel = new QLabel(i18n("&Log message:"), mainWidget);
layout->addWidget(messagelabel);
edit = new QMultiLineEdit(mainWidget);
messagelabel->setBuddy(edit);
edit->setFocus();
edit->setMinimumSize(400, 100);
layout->addWidget(edit, 10);
setButtonText(User1, i18n("&Diff"));
enableButton(User1, false);
connect( this, SIGNAL(user1Clicked()),
this, SLOT(diffClicked()) );
setHelp("commitingfiles");
if (options && edit) // Only for commits
if (options)
resize(options->size);
}
CommitDialog::~CommitDialog()
{
if (edit) // Only for commits
{
if (!options)
options = new Options;
options->size = size();
}
if (!options)
options = new Options;
options->size = size();
}
......@@ -195,6 +182,28 @@ void CommitDialog::fileSelected(int index)
delete l;
}
void CommitDialog::fileHighlighted(int index)
{
highlightedFile = index;
enableButton(User1, true);
}
void CommitDialog::diffClicked()
{
QListBoxItem *item = listbox->item(highlightedFile);
if ( !item )
return;
QString filename = item->text();
DiffDialog *l = new DiffDialog(this, "diffdialog", true);
if (l->parseCvsDiff(sandbox, repository, filename, "", ""))
l->show();
else
delete l;
}
#include "commitdlg.moc"
......
......@@ -31,10 +31,8 @@ class CommitDialog : public KDialogBase
{
Q_OBJECT
public:
enum ActionType { Commit, Add, AddBinary, Remove };
explicit CommitDialog( ActionType action, QWidget *parent=0, const char *name=0 );
public:
explicit CommitDialog( QWidget *parent=0, const char *name=0 );
virtual ~CommitDialog();
......@@ -49,6 +47,8 @@ public:
private slots:
void comboActivated(int);
void fileSelected(int);
void fileHighlighted(int);
void diffClicked();
private:
struct Options {
......@@ -64,6 +64,7 @@ private:
QString current_text;
QString sandbox;
QString repository;
int highlightedFile;
};
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment