diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch) | |
tree | acaf47eb0fa12142d3896416a69e74cbf5a72242 /buildtools/autotools/autolistviewitems.cpp | |
download | tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip |
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/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'buildtools/autotools/autolistviewitems.cpp')
-rw-r--r-- | buildtools/autotools/autolistviewitems.cpp | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/buildtools/autotools/autolistviewitems.cpp b/buildtools/autotools/autolistviewitems.cpp new file mode 100644 index 00000000..454d12f5 --- /dev/null +++ b/buildtools/autotools/autolistviewitems.cpp @@ -0,0 +1,181 @@ +/*************************************************************************** +* Copyright (C) 2001-2002 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* Copyright (C) 2002 by Victor Rder * +* victor_roeder@gmx.de * +* * +* 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 <qpainter.h> +#include <qinputdialog.h> +#include <qregexp.h> + +#include <kiconloader.h> +#include "misc.h" +#include "autolistviewitems.h" +#include "autoprojectpart.h" +#include "autoprojectwidget.h" +#include "autodetailsview.h" + +/** +* Class ProjectItem +*/ + +ProjectItem::ProjectItem( Type type, QListView *parent, const QString &text ) + : QListViewItem( parent, text ), typ( type ) +{ + bld = false; +} + + +ProjectItem::ProjectItem( Type type, ProjectItem *parent, const QString &text ) + : QListViewItem( parent, text ), typ( type ) +{ + bld = false; +} + + +void ProjectItem::paintCell( QPainter *p, const QColorGroup &cg, + int column, int width, int alignment ) +{ + if ( isBold() ) + { + QFont font( p->font() ); + font.setBold( true ); + p->setFont( font ); + } + QListViewItem::paintCell( p, cg, column, width, alignment ); +} + + +/** +* Class SubprojectItem +*/ + +SubprojectItem::SubprojectItem( QListView *parent, const QString &text ) + : ProjectItem( Subproject, parent, text ) +{ + init(); +} + + +SubprojectItem::SubprojectItem( SubprojectItem *parent, const QString &text ) + : ProjectItem( Subproject, parent, text ) +{ + init(); +} + + +void SubprojectItem::init() +{ + targets.setAutoDelete( true ); + setPixmap( 0, SmallIcon( "folder" ) ); +} + + +QString SubprojectItem::relativePath() +{ + QString relpath = subdir; + + SubprojectItem *it = this; + while ( (it= dynamic_cast<SubprojectItem*>(it->parent())) ) + { + relpath.prepend(it->subdir + "/"); + } + relpath.remove(0, 2); + + return relpath; +} + + +/** +* Class TargetItem +*/ + +TargetItem::TargetItem( QListView *lv, bool group, const QString &text ) + : ProjectItem( Target, lv, text ) +{ + sources.setAutoDelete( true ); + setPixmap( 0, group ? SmallIcon( "tar" ) : SmallIcon( "binary" ) ); +} + + +/** +* Class FileItem +*/ + +FileItem::FileItem( QListView *lv, const QString &text, bool set_is_subst ) + : ProjectItem( File, lv, text ) , is_subst(set_is_subst) +{ + if(!is_subst) + { + setPixmap( 0, SmallIcon( "document" ) ); + } + else + { + setPixmap( 0, SmallIcon( "variablenew" ) ); + } +} + + +void FileItem::changeSubstitution() +{ +if(!is_subst) +return; + + bool ok; + QString text = QInputDialog::getText( + i18n("Edit Substitution"), i18n("Substitution:"), QLineEdit::Normal, + name, &ok ); + if ( ok && !text.isEmpty() ) + { + // user entered something and pressed OK + QString new_name = text; + if(new_name == name) + return; + setText(0,new_name); + changeMakefileEntry(new_name); + name = new_name; + } + else + { + // user entered nothing or pressed Cancel + + } +} + +void FileItem::changeMakefileEntry(const QString& new_name) +{ + TargetItem* target = dynamic_cast<TargetItem*>(parent()); + + QMap<QString,QString> replaceMap; + + QString canontargetname = AutoProjectTool::canonicalize(target->name); + QString varname; + if( target->primary == "PROGRAMS" || target->primary == "LIBRARIES" || target->primary == "LTLIBRARIES" ) + varname = canontargetname + "_SOURCES"; + else + varname = target->prefix + "_" + target->primary; + if( AutoDetailsView* lv = dynamic_cast<AutoDetailsView*>(listView()) ) + { + if ( SubprojectItem* subProject = lv->m_part->m_widget->selectedSubproject() ) + { + QStringList sources = QStringList::split(QRegExp("[ \t\n]"), subProject->variables[varname]); + QStringList::iterator it = sources.find(name); + (*it) = new_name; + subProject->variables[varname] = sources.join(" "); + replaceMap.insert(varname, subProject->variables[varname]); + + AutoProjectTool::addToMakefileam(subProject->path + "/Makefile.am", replaceMap); + + if(new_name == "") + target->sources.remove(this); + } + } +} |