diff --git a/debugger/variable/variablecollection.h b/debugger/variable/variablecollection.h index ca7546c7e8..deacba0bda 100644 --- a/debugger/variable/variablecollection.h +++ b/debugger/variable/variablecollection.h @@ -1,228 +1,227 @@ /* * KDevelop Debugger Support * * Copyright 2007 Hamish Rodda * Copyright 2008 Vladimir Prus * Copyright 2009 Niko Sams * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEV_VARIABLECOLLECTION_H #define KDEV_VARIABLECOLLECTION_H #include #include -#include #include #include #include "../util/treemodel.h" #include "../util/treeitem.h" #include "../../interfaces/idocument.h" #include "../debuggerexport.h" #include "../interfaces/idebugsession.h" #include "../../interfaces/idebugcontroller.h" namespace GDBDebugger { class GdbTest; } namespace KDevelop { class VariableToolTip; class KDEVPLATFORMDEBUGGER_EXPORT Variable : public TreeItem { Q_OBJECT friend class GDBDebugger::GdbTest; public: protected: Variable(TreeModel* model, TreeItem* parent, const QString& expression, const QString& display = ""); public: enum format_t { Natural, Binary, Octal, Decimal, Hexadecimal }; static format_t str2format(const QString& str); static QString format2str(format_t format); QString expression() const; bool inScope() const; void setInScope(bool v); void setValue(const QString &v); QString value() const; void setTopLevel(bool v); using TreeItem::setHasMore; using TreeItem::setHasMoreInitial; using TreeItem::appendChild; using TreeItem::deleteChildren; using TreeItem::isExpanded; using TreeItem::parent; using TreeItem::model; ~Variable(); /* Connects this variable to debugger, fetching the current value and otherwise preparing this variable to be displayed everywhere. The attempt may fail, for example if the expression is invalid. Calls slot 'callbackMethod' in 'callback' to notify of the result. The slot should be taking 'bool ok' parameter. */ virtual void attachMaybe(QObject *callback = 0, const char *callbackMethod = 0) = 0; virtual bool canSetFormat() const { return false; } void setFormat(format_t format); format_t format() const { return m_format; } virtual void formatChanged(); // get/set 'changed' state, if the variable changed it will be highlighted bool isChanged() const { return changed_; } void setChanged(bool c); void resetChanged(); public slots: void die(); protected: bool topLevel() const { return topLevel_; } private: // TreeItem overrides QVariant data(int column, int role) const; private: QString expression_; bool inScope_; bool topLevel_; bool changed_; format_t m_format; }; class KDEVPLATFORMDEBUGGER_EXPORT TooltipRoot : public TreeItem { public: TooltipRoot(TreeModel* model) : TreeItem(model) {} void init(Variable *var) { appendChild(var); } void fetchMoreChildren() {} }; class KDEVPLATFORMDEBUGGER_EXPORT Watches : public TreeItem { friend class GDBDebugger::GdbTest; public: Watches(TreeModel* model, TreeItem* parent); Variable* add(const QString& expression); void reinstall(); Variable *addFinishResult(const QString& convenienceVarible); void removeFinishResult(); void resetChanged(); using TreeItem::childCount; friend class VariableCollection; friend class IVariableController; private: QVariant data(int column, int role) const; void fetchMoreChildren() {} Variable* finishResult_; }; class KDEVPLATFORMDEBUGGER_EXPORT Locals : public TreeItem { public: Locals(TreeModel* model, TreeItem* parent, const QString &name); QList updateLocals(QStringList locals); void resetChanged(); using TreeItem::deleteChildren; using TreeItem::setHasMore; friend class VariableCollection; friend class IVariableController; private: void fetchMoreChildren() {} }; class KDEVPLATFORMDEBUGGER_EXPORT VariablesRoot : public TreeItem { public: VariablesRoot(TreeModel* model); Watches *watches() const { return watches_; } Locals *locals(const QString &name = "Locals"); QHash allLocals() const; void fetchMoreChildren() {} void resetChanged(); private: Watches *watches_; QHash locals_; }; class KDEVPLATFORMDEBUGGER_EXPORT VariableCollection : public TreeModel { Q_OBJECT public: VariableCollection(IDebugController* parent); virtual ~VariableCollection(); VariablesRoot* root() const { return universe_; } Watches* watches() const { return universe_->watches(); } Locals* locals(const QString &name = "Locals") const { return universe_->locals(name); } QHash allLocals() const { return universe_->allLocals(); } public Q_SLOTS: void variableWidgetShown(); void variableWidgetHidden(); private Q_SLOTS: void updateAutoUpdate(KDevelop::IDebugSession* session = 0); private Q_SLOTS: void textDocumentCreated( KDevelop::IDocument*); void viewCreated(KTextEditor::Document*, KTextEditor::View*); void textHintRequested(const KTextEditor::Cursor&, QString&); private: VariablesRoot* universe_; - QPointer activeTooltip_; + QWeakPointer activeTooltip_; bool m_widgetVisible; }; } #endif diff --git a/util/activetooltip.cpp b/util/activetooltip.cpp index 3d14f77da7..964552d100 100644 --- a/util/activetooltip.cpp +++ b/util/activetooltip.cpp @@ -1,358 +1,357 @@ /* This file is part of the KDE project Copyright 2007 Vladimir Prus Copyright 2009-2010 David Nolden This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "activetooltip.h" #include #include #include #include #include #include #include -#include #include #include #include #include namespace KDevelop { class ActiveToolTipPrivate { public: uint previousDistance_; QRect rect_; QRegion rectExtensions_; - QList > friendWidgets_; + QList > friendWidgets_; int mouseOut_; }; ActiveToolTip::ActiveToolTip(QWidget *parent, const QPoint& position) : QWidget(parent, Qt::ToolTip), d(new ActiveToolTipPrivate) { Q_ASSERT(parent); d->mouseOut_ = 0; d->previousDistance_ = std::numeric_limits::max(); setMouseTracking(true); d->rect_ = QRect(position, position); d->rect_.adjust(-10, -10, 10, 10); move(position); QPalette p; // adjust background color to use tooltip colors p.setColor(backgroundRole(), p.color(QPalette::ToolTipBase)); p.setColor(QPalette::Base, p.color(QPalette::ToolTipBase)); // adjust foreground color to use tooltip colors p.setColor(foregroundRole(), p.color(QPalette::ToolTipText)); p.setColor(QPalette::Text, p.color(QPalette::ToolTipText)); setPalette(p); qApp->installEventFilter(this); } ActiveToolTip::~ActiveToolTip() { delete d; } bool ActiveToolTip::eventFilter(QObject *object, QEvent *e) { switch (e->type()) { case QEvent::WindowActivate: case QEvent::WindowDeactivate: { if(insideThis(object)) return false; if(isVisible()) kDebug() << "closing because of window activation"; close(); } case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: case QEvent::Wheel: /* If the click is within tooltip, it's fine. Clicks outside close it. */ { //Do not close the widget when NoFocus widgets are used QWidget* widget = dynamic_cast(object); if(widget && widget->focusPolicy() == Qt::NoFocus) return false; } if (!insideThis(object)) { if(isVisible()) kDebug() << "closing because of click into" << object; close(); } // FIXME: revisit this code later. #if 0 case QEvent::FocusIn: case QEvent::FocusOut: close(); break; #endif case QEvent::MouseMove: { QPoint globalPos = static_cast(e)->globalPos(); if (!d->rect_.isNull() && !d->rect_.contains(globalPos) && !d->rectExtensions_.contains(globalPos) && !insideThis(object)) { int distance = (d->rect_.center() - static_cast(e)->globalPos()).manhattanLength(); // On X, when the cursor leaves the tooltip and enters // the parent, we sometimes get some wrong Y coordinate. // Don't know why, so wait for two out-of-range mouse // positions before closing. //Additional test: When the cursor has been moved towards the tooltip, don't close it. if(distance > (int)d->previousDistance_) { ++d->mouseOut_; emit mouseOut(); }else d->previousDistance_ = distance; } else{ d->mouseOut_ = 0; emit mouseIn(); } if (d->mouseOut_ == 2) { kDebug() << "closing because of mouse move"; close(); } } default: break; } return false; } void ActiveToolTip::addFriendWidget(QWidget* widget) { d->friendWidgets_.append((QObject*)widget); } bool ActiveToolTip::insideThis(QObject* object) { while (object) { if(dynamic_cast(object)) return true; if (object == this || d->friendWidgets_.contains(object)) { return true; } object = object->parent(); } return false; } void ActiveToolTip::showEvent(QShowEvent*) { adjustRect(); } void ActiveToolTip::updateMouseDistance() { d->previousDistance_ = (d->rect_.center() - QCursor::pos()).manhattanLength(); } void ActiveToolTip::moveEvent(QMoveEvent* ev) { QWidget::moveEvent(ev); updateMouseDistance(); } void ActiveToolTip::resizeEvent(QResizeEvent*) { adjustRect(); // set mask from style QStyleOptionFrame opt; opt.init(this); QStyleHintReturnMask mask; if( style()->styleHint( QStyle::SH_ToolTip_Mask, &opt, this, &mask ) && !mask.region.isEmpty() ) { setMask( mask.region ); } emit resized(); updateMouseDistance(); } void ActiveToolTip::paintEvent(QPaintEvent* event) { QStylePainter painter( this ); painter.setClipRegion( event->region() ); QStyleOptionFrame opt; opt.init(this); painter.drawPrimitive(QStyle::PE_PanelTipLabel, opt); } void ActiveToolTip::addExtendRect(const QRect& rect) { d->rectExtensions_ += rect; } void ActiveToolTip::adjustRect() { // For tooltip widget, geometry() returns global coordinates. QRect r = geometry(); r.adjust(-10, -10, 10, 10); d->rect_ = r; updateMouseDistance(); } void ActiveToolTip::setBoundingGeometry(const QRect& geometry) { d->rect_ = geometry; d->rect_.adjust(-10, -10, 10, 10); } namespace { - typedef QMultiMap, QString> > ToolTipPriorityMap; + typedef QMultiMap, QString> > ToolTipPriorityMap; static ToolTipPriorityMap registeredToolTips; ActiveToolTipManager manager; QWidget* masterWidget(QWidget* w) { while(w && w->parent() && qobject_cast(w->parent())) w = qobject_cast(w->parent()); return w; } } void ActiveToolTipManager::doVisibility() { bool exclusive = false; int lastBottomPosition = -1; int lastLeftPosition = -1; QRect fullGeometry; //Geometry of all visible tooltips together for(ToolTipPriorityMap::const_iterator it = registeredToolTips.constBegin(); it != registeredToolTips.constEnd(); ++it) { - QPointer< ActiveToolTip > w = (*it).first; + QWeakPointer< ActiveToolTip > w = (*it).first; if(w) { if(exclusive) { - (w)->hide(); + (w.data())->hide(); }else{ - QRect geom = (w)->geometry(); - if((w)->geometry().top() < lastBottomPosition) { + QRect geom = (w.data())->geometry(); + if((w.data())->geometry().top() < lastBottomPosition) { geom.moveTop(lastBottomPosition); } if(lastLeftPosition != -1) geom.moveLeft(lastLeftPosition); - (w)->setGeometry(geom); -// (w)->show(); + (w.data())->setGeometry(geom); +// (w.data())->show(); - lastBottomPosition = (w)->geometry().bottom(); - lastLeftPosition = (w)->geometry().left(); + lastBottomPosition = (w.data())->geometry().bottom(); + lastLeftPosition = (w.data())->geometry().left(); if(it == registeredToolTips.constBegin()) - fullGeometry = (w)->geometry(); + fullGeometry = (w.data())->geometry(); else - fullGeometry = fullGeometry.united((w)->geometry()); + fullGeometry = fullGeometry.united((w.data())->geometry()); } if(it.key() == 0) { exclusive = true; } } } if(!fullGeometry.isEmpty()) { QRect oldFullGeometry = fullGeometry; QRect screenGeometry = QApplication::desktop()->screenGeometry(fullGeometry.topLeft()); if(fullGeometry.bottom() > screenGeometry.bottom()) { //Move up, avoiding the mouse-cursor fullGeometry.moveBottom(fullGeometry.top()-10); if(fullGeometry.adjusted(-20, -20, 20, 20).contains(QCursor::pos())) fullGeometry.moveBottom(QCursor::pos().y() - 20); } if(fullGeometry.right() > screenGeometry.right()) { //Move to left, avoiding the mouse-cursor fullGeometry.moveRight(fullGeometry.left()-10); if(fullGeometry.adjusted(-20, -20, 20, 20).contains(QCursor::pos())) fullGeometry.moveRight(QCursor::pos().x() - 20); } // Now fit this to screen if (fullGeometry.left() < 0) { fullGeometry.setLeft(0); } if (fullGeometry.top() < 0) { fullGeometry.setTop(0); } QPoint offset = fullGeometry.topLeft() - oldFullGeometry.topLeft(); if(!offset.isNull()) { for(ToolTipPriorityMap::const_iterator it = registeredToolTips.constBegin(); it != registeredToolTips.constEnd(); ++it) if((*it).first) { - (*it).first->move((*it).first->pos() + offset); + (*it).first.data()->move((*it).first.data()->pos() + offset); } } } //Set bounding geometry, and remove old tooltips for(ToolTipPriorityMap::iterator it = registeredToolTips.begin(); it != registeredToolTips.end(); ) { if(!(*it).first) { it = registeredToolTips.erase(it); }else{ - (*it).first->setBoundingGeometry(fullGeometry); + (*it).first.data()->setBoundingGeometry(fullGeometry); ++it; } } //Final step: Show tooltips for(ToolTipPriorityMap::const_iterator it = registeredToolTips.constBegin(); it != registeredToolTips.constEnd(); ++it) { - if(it->first && masterWidget(it->first)->isActiveWindow()) - (*it).first->show(); + if(it->first.data() && masterWidget(it->first.data())->isActiveWindow()) + (*it).first.data()->show(); if(exclusive) break; } } void ActiveToolTip::showToolTip(KDevelop::ActiveToolTip* tooltip, float priority, QString uniqueId) { if(!uniqueId.isEmpty()) { - for(QMap< float, QPair< QPointer< ActiveToolTip >, QString > >::const_iterator it = registeredToolTips.constBegin(); it != registeredToolTips.constEnd(); ++it) { + for(QMap< float, QPair< QWeakPointer< ActiveToolTip >, QString > >::const_iterator it = registeredToolTips.constBegin(); it != registeredToolTips.constEnd(); ++it) { if((*it).second == uniqueId) - delete (*it).first; + delete (*it).first.data(); } } - registeredToolTips.insert(priority, qMakePair(QPointer(tooltip), uniqueId)); + registeredToolTips.insert(priority, qMakePair(QWeakPointer(tooltip), uniqueId)); connect(tooltip, SIGNAL(resized()), &manager, SLOT(doVisibility())); QMetaObject::invokeMethod(&manager, "doVisibility", Qt::QueuedConnection); } void ActiveToolTip::closeEvent(QCloseEvent* event) { QWidget::closeEvent(event); deleteLater(); } } #include "activetooltip.moc" diff --git a/vcs/widgets/vcsdiffpatchsources.cpp b/vcs/widgets/vcsdiffpatchsources.cpp index 4d3d24e51b..bfcd6c8e1b 100644 --- a/vcs/widgets/vcsdiffpatchsources.cpp +++ b/vcs/widgets/vcsdiffpatchsources.cpp @@ -1,274 +1,274 @@ /* Copyright 2009 David Nolden This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "vcsdiffpatchsources.h" #include #include #include #include #include #include #include #include #include "vcsjob.h" #include "vcsdiff.h" #include #include #include #include using namespace KDevelop; VCSCommitDiffPatchSource::VCSCommitDiffPatchSource(VCSDiffUpdater* updater, const KUrl& url, IBasicVersionControl* vcs) : VCSDiffPatchSource(updater), m_vcs(vcs) { Q_ASSERT(m_vcs); QScopedPointer statusJob(vcs->status(url)); QVariant varlist; if( statusJob->exec() && statusJob->status() == VcsJob::JobSucceeded ) { varlist = statusJob->fetchResults(); foreach( const QVariant &var, varlist.toList() ) { VcsStatusInfo info = qVariantValue( var ); m_infos += info; if(info.state()!=VcsStatusInfo::ItemUpToDate) m_selectable[info.url()] = info.state(); } } else kDebug() << "Couldn't get status for urls: " << url; m_commitMessageWidget = new QWidget; - QVBoxLayout* layout = new QVBoxLayout(m_commitMessageWidget); + QVBoxLayout* layout = new QVBoxLayout(m_commitMessageWidget.data()); m_commitMessageEdit = new QTextEdit; - m_commitMessageEdit->setFont( KGlobalSettings::fixedFont() ); + m_commitMessageEdit.data()->setFont( KGlobalSettings::fixedFont() ); QHBoxLayout* titleLayout = new QHBoxLayout; titleLayout->addWidget(new QLabel(i18n("Commit Message:"))); m_oldMessages = new KComboBox; m_oldMessages->addItem(i18n("Old Messages")); foreach(QString message, oldMessages()) m_oldMessages->addItem(message, message); m_oldMessages->setMaximumWidth(200); connect(m_oldMessages, SIGNAL(currentIndexChanged(QString)), this, SLOT(oldMessageChanged(QString))); titleLayout->addWidget(m_oldMessages); layout->addLayout(titleLayout); - layout->addWidget(m_commitMessageEdit); + layout->addWidget(m_commitMessageEdit.data()); } QStringList VCSCommitDiffPatchSource::oldMessages() const { KConfigGroup vcsGroup(ICore::self()->activeSession()->config(), "VCS"); return vcsGroup.readEntry("OldCommitMessages", QStringList()); } void VCSCommitDiffPatchSource::oldMessageChanged(QString text) { if(m_oldMessages->currentIndex() != 0) { m_oldMessages->setCurrentIndex(0); - m_commitMessageEdit->setText(text); + m_commitMessageEdit.data()->setText(text); } } VCSDiffPatchSource::VCSDiffPatchSource(VCSDiffUpdater* updater) : m_updater(updater) { update(); } VCSDiffPatchSource::VCSDiffPatchSource(const KDevelop::VcsDiff& diff) : m_updater(0) { updateFromDiff(diff); } VCSDiffPatchSource::~VCSDiffPatchSource() { QFile::remove(m_file.toLocalFile()); delete m_updater; } KUrl VCSDiffPatchSource::baseDir() const { return m_base; } KUrl VCSDiffPatchSource::file() const { return m_file; } QString VCSDiffPatchSource::name() const { return m_name; } void VCSDiffPatchSource::updateFromDiff(VcsDiff vcsdiff) { if(!m_file.isValid()) { KTemporaryFile temp2; temp2.setSuffix("2.patch"); temp2.setAutoRemove(false); temp2.open(); QTextStream t2(&temp2); t2 << vcsdiff.diff(); kDebug() << "filename:" << temp2.fileName(); m_file = KUrl(temp2.fileName()); temp2.close(); }else{ QFile file(m_file.path()); file.open(QIODevice::WriteOnly); QTextStream t2(&file); t2 << vcsdiff.diff(); } kDebug() << "using file" << m_file << vcsdiff.diff(); m_name = "VCS Diff"; m_base = vcsdiff.baseDiff(); emit patchChanged(); } void VCSDiffPatchSource::update() { if(!m_updater) return; updateFromDiff(m_updater->update()); } VCSCommitDiffPatchSource::~VCSCommitDiffPatchSource() { - delete m_commitMessageWidget; + delete m_commitMessageWidget.data(); } bool VCSCommitDiffPatchSource::canSelectFiles() const { return true; } QMap< KUrl, KDevelop::VcsStatusInfo::State> VCSCommitDiffPatchSource::additionalSelectableFiles() const { return m_selectable; } QWidget* VCSCommitDiffPatchSource::customWidget() const { - return m_commitMessageWidget; + return m_commitMessageWidget.data(); } QString VCSCommitDiffPatchSource::finishReviewCustomText() const { return i18n("Commit"); } bool VCSCommitDiffPatchSource::canCancel() const { return true; } void VCSCommitDiffPatchSource::cancelReview() { QString message; if (m_commitMessageEdit) - message = m_commitMessageEdit->toPlainText(); + message = m_commitMessageEdit.data()->toPlainText(); emit reviewCancelled(message); deleteLater(); } bool VCSCommitDiffPatchSource::finishReview(QList< KUrl > selection) { QString message; if (m_commitMessageEdit) - message = m_commitMessageEdit->toPlainText(); + message = m_commitMessageEdit.data()->toPlainText(); kDebug() << "Finishing with selection" << selection; QString text = i18n("Files will be committed:\n"); foreach(const KUrl& url, selection) text += ICore::self()->projectController()->prettyFileName(url, KDevelop::IProjectController::FormatPlain) + '\n'; text += i18n("\nWith message:\n %1", message); int res = KMessageBox::warningContinueCancel(0, text, i18n("About to commit to repository")); if (res != KMessageBox::Continue) { return false; } emit reviewFinished(message, selection); VcsJob* job=m_vcs->commit(message, selection, KDevelop::IBasicVersionControl::NonRecursive); ICore::self()->runController()->registerJob(job); deleteLater(); return true; } static KDevelop::IPatchSource::Ptr currentShownDiff; bool showVcsDiff(IPatchSource* vcsDiff) { KDevelop::IPatchReview* patchReview = ICore::self()->pluginController()->extensionForPlugin("org.kdevelop.IPatchReview"); //Only give one VCS diff at a time to the patch review plugin delete currentShownDiff; currentShownDiff = vcsDiff; if( patchReview ) { patchReview->startReview(currentShownDiff); return true; } else { kWarning() << "Patch review plugin not found"; return false; } } VcsDiff VCSStandardDiffUpdater::update() const { QScopedPointer diffJob(m_vcs->diff(m_url, KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Base), KDevelop::VcsRevision::createSpecialRevision(KDevelop::VcsRevision::Working))); VcsDiff diff; bool correctDiff = diffJob->exec(); if (correctDiff) diff = diffJob->fetchResults().value(); if (!correctDiff) KMessageBox::error(0, i18n("Could not create a patch for the current version.")); return diff; } VCSStandardDiffUpdater::VCSStandardDiffUpdater(IBasicVersionControl* vcs, KUrl url) : m_vcs(vcs), m_url(url) { } VCSStandardDiffUpdater::~VCSStandardDiffUpdater() { } VCSDiffUpdater::~VCSDiffUpdater() { } #include "vcsdiffpatchsources.moc" diff --git a/vcs/widgets/vcsdiffpatchsources.h b/vcs/widgets/vcsdiffpatchsources.h index 8c60e4413d..f4be887dfa 100644 --- a/vcs/widgets/vcsdiffpatchsources.h +++ b/vcs/widgets/vcsdiffpatchsources.h @@ -1,126 +1,126 @@ /* Copyright 2009 David Nolden This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** * This is an internal header */ #ifndef VCSDIFFPATCHSOURCES_H #define VCSDIFFPATCHSOURCES_H #include #include #include #include #include #include "vcs/vcsstatusinfo.h" #include "../vcsexport.h" class KComboBox; namespace KDevelop { class VcsCommitDialog; class IBasicVersionControl; class VcsDiff; } class QWidget; class VCSDiffUpdater { public: virtual ~VCSDiffUpdater(); virtual KDevelop::VcsDiff update() const = 0; }; class KDEVPLATFORMVCS_EXPORT VCSStandardDiffUpdater : public VCSDiffUpdater { public: VCSStandardDiffUpdater(KDevelop::IBasicVersionControl* vcs, KUrl url); virtual ~VCSStandardDiffUpdater(); virtual KDevelop::VcsDiff update() const; private: KDevelop::IBasicVersionControl* m_vcs; KUrl m_url; }; class KDEVPLATFORMVCS_EXPORT VCSDiffPatchSource : public KDevelop::IPatchSource { public: /// The ownership of the updater is taken VCSDiffPatchSource(VCSDiffUpdater* updater); VCSDiffPatchSource(const KDevelop::VcsDiff& diff); virtual ~VCSDiffPatchSource(); virtual KUrl baseDir() const ; virtual KUrl file() const ; virtual QString name() const ; virtual void update() ; virtual bool isAlreadyApplied() const { return true; } KUrl m_base, m_file; QString m_name; VCSDiffUpdater* m_updater; private: void updateFromDiff(KDevelop::VcsDiff diff); }; class KDEVPLATFORMVCS_EXPORT VCSCommitDiffPatchSource : public VCSDiffPatchSource { Q_OBJECT public: /// The ownership of the updater is taken VCSCommitDiffPatchSource(VCSDiffUpdater* updater, const KUrl& base, KDevelop::IBasicVersionControl* vcs); ~VCSCommitDiffPatchSource() ; QStringList oldMessages() const; virtual bool canSelectFiles() const ; QMap additionalSelectableFiles() const ; virtual QWidget* customWidget() const ; virtual QString finishReviewCustomText() const ; virtual bool canCancel() const; virtual void cancelReview(); virtual bool finishReview(QList< KUrl > selection) ; QList infos() const { return m_infos; } Q_SIGNALS: void reviewFinished(QString message, QList selection); void reviewCancelled(QString message); public: - QPointer m_commitMessageWidget; - QPointer m_commitMessageEdit; + QWeakPointer m_commitMessageWidget; + QWeakPointer m_commitMessageEdit; QList m_infos; QMap m_selectable; KDevelop::IBasicVersionControl* m_vcs; KComboBox* m_oldMessages; public slots: void oldMessageChanged(QString); }; ///Sends the diff to the patch-review plugin. ///Returns whether the diff was shown successfully. bool KDEVPLATFORMVCS_EXPORT showVcsDiff(KDevelop::IPatchSource* vcsDiff); #endif // VCSDIFFPATCHSOURCES_H