From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- quanta/components/debugger/pathmapperdialog.cpp | 102 ++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 quanta/components/debugger/pathmapperdialog.cpp (limited to 'quanta/components/debugger/pathmapperdialog.cpp') diff --git a/quanta/components/debugger/pathmapperdialog.cpp b/quanta/components/debugger/pathmapperdialog.cpp new file mode 100644 index 00000000..8cfb949e --- /dev/null +++ b/quanta/components/debugger/pathmapperdialog.cpp @@ -0,0 +1,102 @@ +/*************************************************************************** + pathmapperdialog.cpp + -------------------- + begin : 2005-01-08 + copyright : (C) 2004 Linus McCabe + ***************************************************************************/ + +/**************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +#include "pathmapperdialog.h" +#include +#include +#include +#include +#include + +PathMapperDialog::PathMapperDialog(const QString& path, const PathMapperDialog::Direction direction) + : PathMapperDialogS(0, "PathMapperDialog", false, 0) +{ + m_direction = direction; + m_path = path; + linePath->setText(path); + + if(m_direction == LocalToServer) + ledTranslationExists->hide(); + + connect(listHistory, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged())); + connect(lineLocalPath, SIGNAL(textChanged(const QString&)), this, SLOT(slotPathsChanged())); + connect(lineServerPath, SIGNAL(textChanged(const QString&)), this, SLOT(slotPathsChanged())); +} + +PathMapperDialog::~PathMapperDialog() +{ +} + +void PathMapperDialog::addHistory(const QString &serverdir, const QString &localdir) +{ + new QListViewItem(listHistory, localdir, serverdir); +} + +void PathMapperDialog::slotSelectionChanged() +{ + lineLocalPath->setText(listHistory->currentItem()->text(0)); + lineServerPath->setText(listHistory->currentItem()->text(1)); +} + +void PathMapperDialog::slotPathsChanged() +{ + QString translated, from, to; + if(m_direction == ServerToLocal) + { + from = lineServerPath->text(); + to = lineLocalPath->text(); + } + else + { + to = lineServerPath->text(); + from = lineLocalPath->text(); + } + + translated = m_path; + + // Check if this dir is matched by the maps + if(m_path.startsWith(from, false)) + { + translated.remove(0, from.length()); + translated = to + translated; + } + + // Indicate wether local file exists + if(m_direction == ServerToLocal) + { + if(QExtFileInfo::exists(translated, true, this)) + ledTranslationExists->setColor(Qt::green); + else + ledTranslationExists->setColor(Qt::red); + ledTranslationExists->on(); + } + + lineTranslated->setText(translated); +} + +QString PathMapperDialog::serverPath() +{ + return lineServerPath->text(); +} + +QString PathMapperDialog::localPath() +{ + return lineLocalPath->text(); +} + +#include "pathmapperdialog.moc" + -- cgit v1.2.3