From 114a878c64ce6f8223cfd22d76a20eb16d177e5e 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/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- buildtools/autotools/Makefile.am | 38 + buildtools/autotools/README | 1 + buildtools/autotools/README.dox | 39 + buildtools/autotools/addapplicationdlg.cpp | 207 +++ buildtools/autotools/addapplicationdlg.h | 45 + buildtools/autotools/addapplicationdlgbase.ui | 552 ++++++++ buildtools/autotools/addexistingdirectoriesdlg.cpp | 388 ++++++ buildtools/autotools/addexistingdirectoriesdlg.h | 74 + buildtools/autotools/addexistingdlgbase.ui | 459 ++++++ buildtools/autotools/addexistingfilesdlg.cpp | 451 ++++++ buildtools/autotools/addexistingfilesdlg.h | 77 + buildtools/autotools/addfiledlg.cpp | 135 ++ buildtools/autotools/addfiledlg.h | 47 + buildtools/autotools/addfiledlgbase.ui | 289 ++++ buildtools/autotools/addicondlg.cpp | 115 ++ buildtools/autotools/addicondlg.h | 44 + buildtools/autotools/addicondlgbase.ui | 273 ++++ buildtools/autotools/addprefixdlg.cpp | 76 + buildtools/autotools/addprefixdlg.h | 45 + buildtools/autotools/addservicedlg.cpp | 233 ++++ buildtools/autotools/addservicedlg.h | 46 + buildtools/autotools/addservicedlgbase.ui | 544 ++++++++ buildtools/autotools/addsubprojectdlg.cpp | 198 +++ buildtools/autotools/addsubprojectdlg.h | 44 + buildtools/autotools/addsubprojectdlgbase.ui | 198 +++ buildtools/autotools/addtargetdlg.cpp | 226 +++ buildtools/autotools/addtargetdlg.h | 43 + buildtools/autotools/addtargetdlgbase.ui | 348 +++++ buildtools/autotools/addtranslationdlg.cpp | 109 ++ buildtools/autotools/addtranslationdlg.h | 36 + buildtools/autotools/autodetailsview.cpp | 728 ++++++++++ buildtools/autotools/autodetailsview.h | 88 ++ buildtools/autotools/autolistviewitems.cpp | 181 +++ buildtools/autotools/autolistviewitems.h | 143 ++ buildtools/autotools/autoprojectpart.cpp | 1474 ++++++++++++++++++++ buildtools/autotools/autoprojectpart.h | 153 ++ buildtools/autotools/autoprojectviewbase.ui | 123 ++ buildtools/autotools/autoprojectwidget.cpp | 748 ++++++++++ buildtools/autotools/autoprojectwidget.h | 229 +++ buildtools/autotools/autosubprojectview.cpp | 1137 +++++++++++++++ buildtools/autotools/autosubprojectview.h | 130 ++ buildtools/autotools/autotoolsaction.cpp | 156 +++ buildtools/autotools/autotoolsaction.h | 70 + buildtools/autotools/choosetargetdialog.cpp | 348 +++++ buildtools/autotools/choosetargetdialog.h | 57 + buildtools/autotools/choosetargetdlgbase.ui | 222 +++ buildtools/autotools/configureoptionswidget.cpp | 431 ++++++ buildtools/autotools/configureoptionswidget.h | 69 + buildtools/autotools/configureoptionswidgetbase.ui | 1040 ++++++++++++++ buildtools/autotools/fileselectorwidget.cpp | 243 ++++ buildtools/autotools/fileselectorwidget.h | 96 ++ buildtools/autotools/kdevautoproject.desktop | 97 ++ buildtools/autotools/kdevautoproject.rc | 30 + buildtools/autotools/kdevkdeautoproject.desktop | 92 ++ buildtools/autotools/kfilednddetailview.cpp | 212 +++ buildtools/autotools/kfilednddetailview.h | 136 ++ buildtools/autotools/kfiledndiconview.cpp | 194 +++ buildtools/autotools/kfiledndiconview.h | 128 ++ buildtools/autotools/kimporticonview.cpp | 87 ++ buildtools/autotools/kimporticonview.h | 44 + buildtools/autotools/makefilehandler.cpp | 166 +++ buildtools/autotools/makefilehandler.h | 76 + buildtools/autotools/managecustomcommand.cpp | 49 + buildtools/autotools/managecustomcommand.h | 37 + buildtools/autotools/managecustomcommandsbase.ui | 125 ++ buildtools/autotools/misc.cpp | 999 +++++++++++++ buildtools/autotools/misc.h | 65 + buildtools/autotools/removefiledlg.cpp | 182 +++ buildtools/autotools/removefiledlg.h | 51 + buildtools/autotools/removefiledlgbase.ui | 233 ++++ buildtools/autotools/removetargetdlg.cpp | 279 ++++ buildtools/autotools/removetargetdlg.h | 55 + buildtools/autotools/removetargetdlgbase.ui | 264 ++++ buildtools/autotools/subprojectoptionsdlg.cpp | 404 ++++++ buildtools/autotools/subprojectoptionsdlg.h | 63 + buildtools/autotools/subprojectoptionsdlgbase.ui | 989 +++++++++++++ buildtools/autotools/targetoptionsdlg.cpp | 357 +++++ buildtools/autotools/targetoptionsdlg.h | 49 + buildtools/autotools/targetoptionsdlgbase.ui | 726 ++++++++++ 79 files changed, 19435 insertions(+) create mode 100644 buildtools/autotools/Makefile.am create mode 100644 buildtools/autotools/README create mode 100644 buildtools/autotools/README.dox create mode 100644 buildtools/autotools/addapplicationdlg.cpp create mode 100644 buildtools/autotools/addapplicationdlg.h create mode 100644 buildtools/autotools/addapplicationdlgbase.ui create mode 100644 buildtools/autotools/addexistingdirectoriesdlg.cpp create mode 100644 buildtools/autotools/addexistingdirectoriesdlg.h create mode 100644 buildtools/autotools/addexistingdlgbase.ui create mode 100644 buildtools/autotools/addexistingfilesdlg.cpp create mode 100644 buildtools/autotools/addexistingfilesdlg.h create mode 100644 buildtools/autotools/addfiledlg.cpp create mode 100644 buildtools/autotools/addfiledlg.h create mode 100644 buildtools/autotools/addfiledlgbase.ui create mode 100644 buildtools/autotools/addicondlg.cpp create mode 100644 buildtools/autotools/addicondlg.h create mode 100644 buildtools/autotools/addicondlgbase.ui create mode 100644 buildtools/autotools/addprefixdlg.cpp create mode 100644 buildtools/autotools/addprefixdlg.h create mode 100644 buildtools/autotools/addservicedlg.cpp create mode 100644 buildtools/autotools/addservicedlg.h create mode 100644 buildtools/autotools/addservicedlgbase.ui create mode 100644 buildtools/autotools/addsubprojectdlg.cpp create mode 100644 buildtools/autotools/addsubprojectdlg.h create mode 100644 buildtools/autotools/addsubprojectdlgbase.ui create mode 100644 buildtools/autotools/addtargetdlg.cpp create mode 100644 buildtools/autotools/addtargetdlg.h create mode 100644 buildtools/autotools/addtargetdlgbase.ui create mode 100644 buildtools/autotools/addtranslationdlg.cpp create mode 100644 buildtools/autotools/addtranslationdlg.h create mode 100644 buildtools/autotools/autodetailsview.cpp create mode 100644 buildtools/autotools/autodetailsview.h create mode 100644 buildtools/autotools/autolistviewitems.cpp create mode 100644 buildtools/autotools/autolistviewitems.h create mode 100644 buildtools/autotools/autoprojectpart.cpp create mode 100644 buildtools/autotools/autoprojectpart.h create mode 100644 buildtools/autotools/autoprojectviewbase.ui create mode 100644 buildtools/autotools/autoprojectwidget.cpp create mode 100644 buildtools/autotools/autoprojectwidget.h create mode 100644 buildtools/autotools/autosubprojectview.cpp create mode 100644 buildtools/autotools/autosubprojectview.h create mode 100644 buildtools/autotools/autotoolsaction.cpp create mode 100644 buildtools/autotools/autotoolsaction.h create mode 100644 buildtools/autotools/choosetargetdialog.cpp create mode 100644 buildtools/autotools/choosetargetdialog.h create mode 100644 buildtools/autotools/choosetargetdlgbase.ui create mode 100644 buildtools/autotools/configureoptionswidget.cpp create mode 100644 buildtools/autotools/configureoptionswidget.h create mode 100644 buildtools/autotools/configureoptionswidgetbase.ui create mode 100644 buildtools/autotools/fileselectorwidget.cpp create mode 100644 buildtools/autotools/fileselectorwidget.h create mode 100644 buildtools/autotools/kdevautoproject.desktop create mode 100644 buildtools/autotools/kdevautoproject.rc create mode 100644 buildtools/autotools/kdevkdeautoproject.desktop create mode 100644 buildtools/autotools/kfilednddetailview.cpp create mode 100644 buildtools/autotools/kfilednddetailview.h create mode 100644 buildtools/autotools/kfiledndiconview.cpp create mode 100644 buildtools/autotools/kfiledndiconview.h create mode 100644 buildtools/autotools/kimporticonview.cpp create mode 100644 buildtools/autotools/kimporticonview.h create mode 100644 buildtools/autotools/makefilehandler.cpp create mode 100644 buildtools/autotools/makefilehandler.h create mode 100644 buildtools/autotools/managecustomcommand.cpp create mode 100644 buildtools/autotools/managecustomcommand.h create mode 100644 buildtools/autotools/managecustomcommandsbase.ui create mode 100644 buildtools/autotools/misc.cpp create mode 100644 buildtools/autotools/misc.h create mode 100644 buildtools/autotools/removefiledlg.cpp create mode 100644 buildtools/autotools/removefiledlg.h create mode 100644 buildtools/autotools/removefiledlgbase.ui create mode 100644 buildtools/autotools/removetargetdlg.cpp create mode 100644 buildtools/autotools/removetargetdlg.h create mode 100644 buildtools/autotools/removetargetdlgbase.ui create mode 100644 buildtools/autotools/subprojectoptionsdlg.cpp create mode 100644 buildtools/autotools/subprojectoptionsdlg.h create mode 100644 buildtools/autotools/subprojectoptionsdlgbase.ui create mode 100644 buildtools/autotools/targetoptionsdlg.cpp create mode 100644 buildtools/autotools/targetoptionsdlg.h create mode 100644 buildtools/autotools/targetoptionsdlgbase.ui (limited to 'buildtools/autotools') diff --git a/buildtools/autotools/Makefile.am b/buildtools/autotools/Makefile.am new file mode 100644 index 00000000..5972b662 --- /dev/null +++ b/buildtools/autotools/Makefile.am @@ -0,0 +1,38 @@ +# Here resides the automake project part. + +INCLUDES = -I$(top_srcdir)/buildtools/lib -I$(top_srcdir)/buildtools/lib/base \ + -I$(top_srcdir)/buildtools/lib/parsers/autotools -I$(top_srcdir)/buildtools/lib/widgets -I$(top_srcdir)/lib/interfaces \ + -I$(top_srcdir)/lib/interfaces/extensions -I$(top_srcdir)/lib/interfaces/external \ + -I$(top_srcdir)/lib/interfaces/extras -I$(top_srcdir)/lib/util $(all_includes) \ + -I$(top_builddir)/buildtools/lib/widgets + + +kde_module_LTLIBRARIES = libkdevautoproject.la +libkdevautoproject_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkdevautoproject_la_LIBADD = \ + $(top_builddir)/buildtools/lib/base/libkdevbuildbase.la \ + $(top_builddir)/buildtools/lib/parsers/autotools/libkdevautotoolsparser.la $(top_builddir)/buildtools/lib/widgets/libkdevbuildtoolswidgets.la \ + $(top_builddir)/lib/interfaces/extras/libkdevextras.la $(top_builddir)/lib/libkdevelop.la + +libkdevautoproject_la_SOURCES = autoprojectpart.cpp autoprojectwidget.cpp \ + configureoptionswidget.cpp configureoptionswidgetbase.ui subprojectoptionsdlg.cpp \ + subprojectoptionsdlgbase.ui targetoptionsdlg.cpp targetoptionsdlgbase.ui addservicedlg.cpp \ + addservicedlgbase.ui addapplicationdlg.cpp addapplicationdlgbase.ui addtargetdlg.cpp \ + addtargetdlgbase.ui addsubprojectdlg.cpp addfiledlgbase.ui addfiledlg.cpp \ + removefiledlgbase.ui removefiledlg.cpp addicondlgbase.ui addicondlg.cpp \ + addtranslationdlg.cpp addprefixdlg.cpp kfilednddetailview.cpp kfiledndiconview.cpp \ + fileselectorwidget.cpp misc.cpp addsubprojectdlgbase.ui removetargetdlg.cpp \ + removetargetdlgbase.ui choosetargetdialog.cpp choosetargetdlgbase.ui addexistingdlgbase.ui \ + addexistingfilesdlg.cpp addexistingdirectoriesdlg.cpp kimporticonview.cpp \ + autosubprojectview.cpp autodetailsview.cpp autolistviewitems.cpp managecustomcommandsbase.ui \ + managecustomcommand.cpp autoprojectviewbase.ui autotoolsaction.cpp makefilehandler.cpp + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir) +service_DATA = kdevautoproject.desktop kdevkdeautoproject.desktop + +rcdir = $(kde_datadir)/kdevautoproject +rc_DATA = kdevautoproject.rc + +noinst_HEADERS = managecustomcommand.h autotoolsaction.h makefilehandler.h diff --git a/buildtools/autotools/README b/buildtools/autotools/README new file mode 100644 index 00000000..487cec41 --- /dev/null +++ b/buildtools/autotools/README @@ -0,0 +1 @@ +Please read the README.dox file diff --git a/buildtools/autotools/README.dox b/buildtools/autotools/README.dox new file mode 100644 index 00000000..acad3e64 --- /dev/null +++ b/buildtools/autotools/README.dox @@ -0,0 +1,39 @@ +/** \class AutoProjectPart +Autoprojectpart is a projectmanager for Automake based projects. + +Loads and maintains Makefile.am files. + +\authors Bernd Gehrmann + +\maintainer Victor Rder +\maintainer Amilcar do Carmo Lucas + +\feature supports creating subprojects, targets, services (.desktop) and applications (.desktop). +\feature Automake projects can be configured on subprojects, targets (except DATA and HEADER targets). +\feature It will regenerate the projects Makefile.am files dynamically as you add or +reconfigure subprojects**. +\feature Unsupported automake features will be left unchanged +(hopefully), no major testing has been run yet (at least not by myself). + +\bug bugs in autoproject component at Bugzilla database +\bug Lower Automake Manager view does not update it's view when adding a subproject (and targets, etc to the new subproject) +\bug If removing the Active Target, update the .kdevelop file, too! + + +\note +If you want to change the default implemention for running/starting the binary +please add the following to your project file +\verbatim + + + true + + +\endverbatim +with this configuration the "Automake Manager" doesn't insert the menuentry "execute program" +and doesn't show the "Run Options" in the project configuration.
+Now you can implement this features with your own special plugin. +For an example please look at the projects generated for GBA using the VisualBoy Advance Plugin. +This plugin starts a GBA binary with an emulator. -- Sandy Meier + +*/ diff --git a/buildtools/autotools/addapplicationdlg.cpp b/buildtools/autotools/addapplicationdlg.cpp new file mode 100644 index 00000000..04e132dd --- /dev/null +++ b/buildtools/autotools/addapplicationdlg.cpp @@ -0,0 +1,207 @@ +/*************************************************************************** + * Copyright (C) 2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "addapplicationdlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "autolistviewitems.h" + +#include "misc.h" +#include "autoprojectwidget.h" +#include "autoprojectpart.h" + + +AddApplicationDialog::AddApplicationDialog(AutoProjectWidget *widget, SubprojectItem *spitem, + QWidget *parent, const char *name) + : AddApplicationDialogBase(parent, name, true) +{ + filename_edit->setText(".desktop"); + filename_edit->home(false); + filename_edit->setFocus(); + chosentypes_listview->header()->hide(); + availtypes_listview->header()->hide(); + QString addApplication = add_button->text(); + QString removeApplication = remove_button->text(); + + add_button->setText( QApplication::reverseLayout() ? removeApplication : addApplication ); + remove_button->setText( QApplication::reverseLayout() ? addApplication : removeApplication ); + + m_widget = widget; + subProject = spitem; + + // Fill the combo box with program names in the directory + QPtrListIterator tit(spitem->targets); + for (; tit.current(); ++tit) { + if ((*tit)->primary == "PROGRAMS") + executable_combo->insertItem(QString((*tit)->name)); + } + + // Fill the list of available mime types + KMimeType::List l = KMimeType::allMimeTypes(); + KMimeType::List::Iterator it; + for (it = l.begin(); it != l.end(); ++it) + new QListViewItem(availtypes_listview, (*it)->name()); + + setIcon ( SmallIcon ( "window_new" ) ); +} + + +AddApplicationDialog::~AddApplicationDialog() +{} + + +void AddApplicationDialog::iconClicked() +{ + KIconLoader *loader = AutoProjectFactory::instance()->iconLoader(); + QString name = KIconDialog::getIcon(KIcon::Desktop); + if (!name.isNull()) { + iconName = name; + icon_button->setPixmap(loader->loadIcon(name, KIcon::Desktop)); + } +} + + +void AddApplicationDialog::addTypeClicked() +{ + QListViewItem *selitem = availtypes_listview->selectedItem(); + if (!selitem) + return; + + QListViewItem *olditem = chosentypes_listview->firstChild(); + while (olditem) { + if (selitem->text(0) == olditem->text(0)) + return; + olditem = olditem->nextSibling(); + } + new QListViewItem(chosentypes_listview, selitem->text(0)); +} + + +void AddApplicationDialog::removeTypeClicked() +{ + delete chosentypes_listview->currentItem(); +} + + +void AddApplicationDialog::accept() +{ + // Create list of mime types + QStringList mimeTypes; + QListViewItem *item = chosentypes_listview->firstChild(); + while (item) { + mimeTypes.append(item->text(0)); + item = item->nextSibling(); + } + + // Some plausibility tests + QString fileName = filename_edit->text(); + if (fileName.isEmpty() || fileName == ".desktop") { + KMessageBox::sorry(this, i18n("You have to enter a file name.")); + filename_edit->setFocus(); + return; + } + + QString executable = executable_combo->currentText(); + if (executable.isEmpty()) { + KMessageBox::sorry(this, i18n("You have to enter the file name of an executable program.")); + executable_combo->setFocus(); + return; + } + + QString name = name_edit->text(); + if (name.isEmpty()) { + KMessageBox::sorry(this, i18n("You have to enter an application name.")); + name_edit->setFocus(); + return; + } + + QFile f(subProject->path + "/" + fileName); + if (f.exists()) { + KMessageBox::sorry(this, i18n("A file with this name exists already.")); + filename_edit->setFocus(); + return; + } + if (!f.open(IO_WriteOnly)) { + KMessageBox::sorry(this, i18n("Could not open file for writing.")); + return; + } + + QTextStream stream(&f); + stream << "[Desktop Entry]" << endl; + stream << "Type=Application" << endl; + stream << "Name=" << name << endl; + stream << "Exec=" << (executable + " -caption \"%c\" %i %m %u") << endl; + stream << "Comment=" << comment_edit->text() << endl; + if (!iconName.isNull()) + stream << "Icon=" << iconName << endl; + stream << "MimeTypes=" << mimeTypes.join(";") << endl; + stream << "Terminal=" << (terminal_box->isChecked()? "true" : "false") << endl; + f.close(); + + // Find a prefix that points to the applnk directory. + // If there is none, use appslnksection + QString section = section_combo->currentText(); + QString appsdir = "$(kde_appsdir)/" + section; + QMap::ConstIterator it; + for (it = subProject->prefixes.begin(); it != subProject->prefixes.end(); ++it) + if (it.data() == appsdir) + break; + + QMap replaceMap; + QString prefix; + if (it == subProject->prefixes.end()) { + prefix = "applnk" + section; + replaceMap.insert(prefix + "dir", appsdir); + subProject->prefixes.insert(prefix, appsdir); + } else { + prefix = it.key(); + } + QString varname = prefix + "_DATA"; + + // Look if a list view item for this prefix exists already. + // Create a new one otherwise + TargetItem *titem = 0; + for (uint i=0; i < subProject->targets.count(); ++i) { + TargetItem *tmptitem = subProject->targets.at(i); + if ("DATA" == tmptitem->primary && prefix == tmptitem->prefix) { + titem = tmptitem; + break; + } + } + if (!titem) { + titem = m_widget->createTargetItem("", prefix, "DATA", false); + subProject->targets.append(titem); + } + // Add this file to the target + FileItem *fitem = m_widget->createFileItem(fileName, subProject); + titem->sources.append(fitem); + + subProject->variables[varname] += (" " + fileName); + replaceMap.insert(varname, subProject->variables[varname]); + AutoProjectTool::addToMakefileam(subProject->path + "/Makefile.am", replaceMap); + + QDialog::accept(); +} + +#include "addapplicationdlg.moc" diff --git a/buildtools/autotools/addapplicationdlg.h b/buildtools/autotools/addapplicationdlg.h new file mode 100644 index 00000000..d9f8e6fc --- /dev/null +++ b/buildtools/autotools/addapplicationdlg.h @@ -0,0 +1,45 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _ADDAPPLICATIONDLG_H_ +#define _ADDAPPLICATIONDLG_H_ + +#include "addapplicationdlgbase.h" + +class AutoProjectWidget; +class SubprojectItem; +class TargetItem; + + +class AddApplicationDialog : public AddApplicationDialogBase +{ + Q_OBJECT + +public: + AddApplicationDialog( AutoProjectWidget *widget, SubprojectItem *spitem, + QWidget *parent = 0, const char *name = 0 ); + ~AddApplicationDialog(); + +protected: + virtual void iconClicked(); + virtual void addTypeClicked(); + virtual void removeTypeClicked(); + virtual void accept(); + +private: + AutoProjectWidget *m_widget; + SubprojectItem *subProject; + QString iconName; +}; + +#endif +// kate: indent-mode csands; tab-width 4; + diff --git a/buildtools/autotools/addapplicationdlgbase.ui b/buildtools/autotools/addapplicationdlgbase.ui new file mode 100644 index 00000000..5e6def81 --- /dev/null +++ b/buildtools/autotools/addapplicationdlgbase.ui @@ -0,0 +1,552 @@ + +AddApplicationDialogBase + + + add_application_dialog + + + + 0 + 0 + 586 + 425 + + + + Add New Application .desktop File + + + false + + + + unnamed + + + + GroupBox7 + + + &Application File + + + + unnamed + + + + terminal_box + + + Start in t&erminal + + + + + comment_edit + + + + + filename_edit + + + + + Layout2 + + + + unnamed + + + 0 + + + + icon_button + + + + 24 + 24 + + + + + + + false + + + + + Spacer1 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + executable_combo + + + true + + + + + name_edit + + + + + + Application + + + + + Games + + + + + Development + + + + + Editors + + + + + Graphics + + + + + Internet + + + + + Multimedia + + + + + Office + + + + + Settings + + + + + System + + + + + Toys + + + + + Utilities + + + + + WordProcessing + + + + section_combo + + + + + name_label_2 + + + + + + + E&xecutable: + + + AlignVCenter|AlignRight + + + executable_combo + + + + + icon_label + + + + + + + &Icon: + + + AlignVCenter|AlignRight + + + icon_button + + + + + section_label + + + + + + + &Section: + + + AlignVCenter|AlignRight + + + section_combo + + + + + filename_label + + + + + + + &File name: + + + AlignVCenter|AlignRight + + + filename_edit + + + + + name_label + + + + + + + &Name: + + + AlignVCenter|AlignRight + + + name_edit + + + + + comment_label + + + + + + + Co&mment: + + + AlignVCenter|AlignRight + + + comment_edit + + + + + + + Spacer11 + + + Vertical + + + Preferred + + + + 20 + 20 + + + + + + GroupBox6 + + + Mime &Types + + + + unnamed + + + + Layout5 + + + + unnamed + + + 0 + + + + + + + + true + + + true + + + + chosentypes_listview + + + LastColumn + + + + + Layout3 + + + + unnamed + + + 0 + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + add_button + + + <- + + + + + remove_button + + + -> + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + + + true + + + true + + + + availtypes_listview + + + LastColumn + + + + + + + + + Layout1 + + + + unnamed + + + 0 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + okbutton + + + &OK + + + true + + + true + + + + + cancelbutton + + + &Cancel + + + true + + + + + + + + + cancelbutton + clicked() + add_application_dialog + reject() + + + okbutton + clicked() + add_application_dialog + accept() + + + icon_button + clicked() + add_application_dialog + iconClicked() + + + add_button + clicked() + add_application_dialog + addTypeClicked() + + + remove_button + clicked() + add_application_dialog + removeTypeClicked() + + + + filename_edit + executable_combo + name_edit + icon_button + terminal_box + section_combo + comment_edit + chosentypes_listview + add_button + remove_button + availtypes_listview + okbutton + cancelbutton + + + kdialog.h + + + addTypeClicked() + iconClicked() + removeTypeClicked() + + + + diff --git a/buildtools/autotools/addexistingdirectoriesdlg.cpp b/buildtools/autotools/addexistingdirectoriesdlg.cpp new file mode 100644 index 00000000..625d6af1 --- /dev/null +++ b/buildtools/autotools/addexistingdirectoriesdlg.cpp @@ -0,0 +1,388 @@ +/*************************************************************************** + ------------------- + begin : 12/21/2002 + copyright : (C) 2002 by Victor R�er + email : 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 +#include + +#include +#include +#include +#include + +#include "autolistviewitems.h" +#include "autosubprojectview.h" + +#include "autoprojectwidget.h" +#include "autoprojectpart.h" + +#include "kimporticonview.h" + +#include "urlutil.h" + +#include "addexistingdirectoriesdlg.h" + +AddExistingDirectoriesDialog::AddExistingDirectoriesDialog ( AutoProjectPart* part, AutoProjectWidget *widget, SubprojectItem* spitem, QWidget* parent, const char* name, bool modal, WFlags fl ) + : AddExistingDlgBase ( parent, name, modal, fl ) +{ + setIcon ( SmallIcon ( "fileimport.png" ) ); + + m_spitem = spitem; + + m_part = part; + m_widget = widget; + + KFile::Mode mode = KFile::Directory; + +// if ( spitem && spitem->type() == ProjectItem::Subproject ) +// { +// destStaticLabel->setText ( i18n ( "Subproject:" ) ); +// destLabel->setText ( spitem->subdir ); +// targetLabel->setText ( i18n ( "none" ) ); +// directoryLabel->setText ( i18n ( spitem->path ) ); +// } + + sourceSelector = new FileSelectorWidget ( part, mode, sourceGroupBox, "source file selector" ); + sourceGroupBoxLayout->addWidget ( sourceSelector ); + + importView = new KImportIconView ( i18n("Drag one or more directories with an existing Makefile.am from the left view and drop it here."), destGroupBox, "destination icon view" ); + destGroupBoxLayout->addWidget ( importView ); + + setIcon ( SmallIcon ( "fileimport.png" ) ); + + QWidget::setTabOrder(sourceSelector, addAllButton); + QWidget::setTabOrder(addAllButton, addSelectedButton); + QWidget::setTabOrder(addSelectedButton, importView); + QWidget::setTabOrder(importView, removeAllButton); + QWidget::setTabOrder(removeAllButton, removeSelectedButton); + QWidget::setTabOrder(removeSelectedButton, okButton); + QWidget::setTabOrder(okButton, cancelButton); + + sourceSelector->setFocus(); + + init(); +} + + +AddExistingDirectoriesDialog::~AddExistingDirectoriesDialog() +{ +} + +void AddExistingDirectoriesDialog::init() +{ + progressBar->hide(); + + importView->setMode ( KIconView::Select ); + importView->setItemsMovable ( false ); + + connect ( okButton, SIGNAL ( clicked () ), this, SLOT ( slotOk () ) ); + + connect ( addSelectedButton, SIGNAL ( clicked () ), this, SLOT ( slotAddSelected() ) ); + connect ( addAllButton, SIGNAL ( clicked () ), this, SLOT ( slotAddAll() ) ); + connect ( removeSelectedButton, SIGNAL ( clicked () ), this, SLOT ( slotRemoveSelected() ) ); + connect ( removeAllButton, SIGNAL ( clicked () ), this, SLOT ( slotRemoveAll() ) ); + + connect ( importView, SIGNAL ( dropped( QDropEvent* ) ), this, SLOT ( slotDropped ( QDropEvent* ) ) ); + + importView->setSelectionMode ( KFile::Multi ); + + sourceSelector->setDir ( m_spitem->path ); +} + +void AddExistingDirectoriesDialog::importItems() +{ + if( !importView->items() ) + return; + + // items added via button or drag 'n drop + KFileItemListIterator itemList ( m_importList ); + + // items already added to the importView + KFileItemListIterator importedList ( *importView->items() ); + + QStringList duplicateList; + + importedList.toFirst(); + + for ( ; importedList.current(); ++importedList ) + { + itemList.toFirst(); + + for ( ; itemList.current(); ++itemList ) + { + if ( ( *importedList )->name() == ( *itemList )->name() ) + { + m_importList.remove ( ( *itemList ) ); + + // to avoid that a item is added twice + if ( !duplicateList.remove ( ( *importedList )->name() ) ) + { + duplicateList.append ( ( *importedList )->name() ); + } + } + } + } + + itemList.toFirst(); + + for ( ; itemList.current(); ++itemList ) + { + KURL amURL = itemList.current()->url(); + amURL.addPath("Makefile.am"); + if (KIO::NetAccess::exists(amURL)) + { + importView->insertItem ( ( *itemList ) ); + } + } + + importView->somethingDropped ( true ); + + m_importList.clear(); + + importView->update (); +} + +void AddExistingDirectoriesDialog::slotOk() +{ + if ( importView->items()->count() == 0 ) QDialog::reject(); + + KFileItemListIterator items ( *importView->items() ); + + QStringList dirs; + + for ( ; items.current(); ++items ) + { + //if the directory is outside the project directory +// kdDebug( 9020 ) << "dir to add " << items.current()->url().path() << " subproject " << m_spitem->path << endl; + if (items.current()->url().path() != m_spitem->path) + { + //copy + //FIXME: check this after 3.0 release and add a possibility to link, not just copy + KProcess proc; + + proc << "cp"; + proc << "-r"; + proc << items.current()->url().path(); + proc << m_spitem->path; + proc.start(KProcess::Block); + } + dirs << items.current()->name(); + } + + for (QStringList::const_iterator it = dirs.begin(); it != dirs.end(); ++it) + { + QString name = *it; + + // Adjust SUBDIRS variable in containing Makefile.am + if (m_spitem->variables["SUBDIRS"].find("$(TOPSUBDIRS)") != -1) + { + QFile subdirsfile( m_spitem->path + "/subdirs" ); + if ( subdirsfile.open( IO_WriteOnly | IO_Append ) ) + { + QTextStream subdirsstream( &subdirsfile ); + subdirsstream << name << endl; + subdirsfile.close(); + } + } + else if (m_spitem->variables["SUBDIRS"].find("$(AUTODIRS)") != -1) + { + } + else + { + m_spitem->variables["SUBDIRS"] += (" " + name); + QMap replaceMap; + replaceMap.insert("SUBDIRS", m_spitem->variables["SUBDIRS"]); + AutoProjectTool::addToMakefileam(m_spitem->path + "/Makefile.am", replaceMap); + } + + // Create new item in tree view + SubprojectItem *newitem = new SubprojectItem(m_spitem, name); + newitem->subdir = name; + newitem->path = m_spitem->path + "/" + name; + newitem->variables["INCLUDES"] = m_spitem->variables["INCLUDES"]; + newitem->setOpen(true); + + // Move to the bottom of the list + QListViewItem *lastItem = m_spitem->firstChild(); + while (lastItem->nextSibling()) + lastItem = lastItem->nextSibling(); + if (lastItem != newitem) + newitem->moveItem(lastItem); + + // Create a Makefile in the new subdirectory + + QDir dir( m_spitem->path + "/" + name ); + QFile f( dir.filePath("Makefile.am") ); + if (f.exists()) { + m_widget->getSubprojectView()->parse( newitem ); + } else { + if (!f.open(IO_WriteOnly)) { +// KMessageBox::sorry(this, i18n("Could not create Makefile.am in subdirectory %1.").arg(name)); + continue; + } + QTextStream stream(&f); + stream << "INCLUDES = " << newitem->variables["INCLUDES"] << endl << "METASOURCES = AUTO" << endl; + f.close(); + } + + + + // if !isKDE: add the new sub-proj to configure.in or configure.ac + if ( !m_part->isKDE() ) { + QString projroot = m_part->projectDirectory() + "/"; + QString subdirectory = dir.path(); + QString relpath = subdirectory.replace(0, projroot.length(),""); + + QString configureFile = m_part->getAutoConfFile(projroot); + + QStringList list = AutoProjectTool::configureinLoadMakefiles(configureFile); + if ( !list.isEmpty() ) + { + list.push_back( relpath + "/Makefile" ); + AutoProjectTool::configureinSaveMakefiles(configureFile, list); + } + } + + m_part->needMakefileCvs(); + + } + QDialog::accept(); +} + +void AddExistingDirectoriesDialog::slotAddSelected() +{ + KFileItemListIterator it ( *sourceSelector->dirOperator()->selectedItems() ); + + for ( ; it.current(); ++it ) + { + QString relPath = URLUtil::extractPathNameRelative(m_part->projectDirectory(), ( *it )->url()); + if (relPath[relPath.length()-1] == '/') + relPath = relPath.left(relPath.length()-1); + if ( (relPath.isEmpty()) || (! m_widget->allSubprojects().contains( relPath )) ) + { + m_importList.append ( ( *it ) ); + } + } + + importItems(); +} + +void AddExistingDirectoriesDialog::slotAddAll() +{ + KFileItemListIterator it ( *sourceSelector->dirOperator()->view()->items() ); + + for ( ; it.current(); ++it ) + { + QString relPath = URLUtil::extractPathNameRelative(m_part->projectDirectory(), ( *it )->url()); + if (relPath[relPath.length()-1] == '/') + relPath = relPath.left(relPath.length()-1); + if ( (relPath.isEmpty()) || ( ! m_widget->allSubprojects().contains( relPath )) ) + { + m_importList.append ( ( *it ) ); + } + } + + importItems(); +} + +void AddExistingDirectoriesDialog::slotRemoveAll() +{ + KURL::List deletedFiles; + KFileItemListIterator it ( *importView->items() ); + + for ( ; it.current(); ++it ) + { + kdDebug ( 9020 ) << "AddExistingDirectoriesDialog::slotRemoveAll()" << endl; + //deletedFiles.append ( ( *it )->url() ); + if ( (*it ) ) importView->removeItem ( *it ); + } + + importView->somethingDropped ( false ); + + importView->viewport()->update(); +} + +void AddExistingDirectoriesDialog::slotRemoveSelected() +{ + KFileItemListIterator items ( *importView->items() ); + + KFileItemList* selectedList = (KFileItemList*) importView->selectedItems(); + + KFileItem * deleteItem = 0L; + + for ( ; items.current(); ++items ) + { + deleteItem = selectedList->first(); + + while ( deleteItem ) + { + if ( deleteItem == ( *items ) ) + { + importView->removeItem ( deleteItem ); + deleteItem = selectedList->current(); + } + else + { + deleteItem = selectedList->next(); + } + } + } + + if ( importView->items()->count() == 0 ) importView->somethingDropped ( false ); + + importView->viewport()->update(); +} + +void AddExistingDirectoriesDialog::slotDropped ( QDropEvent* ev ) +{ + kdDebug ( 9020 ) << "AddExistingDirectoriesDialog::dropped()" << endl; + + KURL::List urls; + + KURLDrag::decode( ev, urls ); + + KFileItem* item = 0L; + KMimeType::Ptr type = 0L; + + + for ( KURL::List::Iterator it = urls.begin(); it != urls.end(); ++it ) + { + //check if this subproject is already in project + QString relPath = URLUtil::extractPathNameRelative(m_part->projectDirectory(), *it); + if (relPath[relPath.length()-1] == '/') + relPath = relPath.left(relPath.length()-1); + if ( (relPath.isEmpty()) || ( ! m_widget->allSubprojects().contains( relPath )) ) + { + type = KMimeType::findByURL ( ( *it ) ); + + if ( type->name() != KMimeType::defaultMimeType() ) + { + item = new KFileItem ( ( *it ) , type->name(), 0 ); + } + else + { + item = new KFileItem ( ( *it ), "inode/directory", 0 ); + } + + m_importList.append ( item ); + } + } + + importItems(); +} + +#include "addexistingdirectoriesdlg.moc" + +//kate: indent-mode csands; tab-width 4; space-indent off; diff --git a/buildtools/autotools/addexistingdirectoriesdlg.h b/buildtools/autotools/addexistingdirectoriesdlg.h new file mode 100644 index 00000000..c4dd048e --- /dev/null +++ b/buildtools/autotools/addexistingdirectoriesdlg.h @@ -0,0 +1,74 @@ +/*************************************************************************** + ------------------- + begin : 12/21/2002 + copyright : (C) 2002 by Victor R�er + email : 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. * + * * + ***************************************************************************/ + +#ifndef _ADDEXISTINGDIRECTORIESDLG_H_ +#define _ADDEXISTINGDIRECTORIESDLG_H_ + +#include "addexistingdlgbase.h" + +#include +#include + +#include "misc.h" +#include "fileselectorwidget.h" + +class FileSelectorWidget; +class AutoProjectWidget; +class AutoProjectPart; +class SubprojectItem; +class TargetItem; +class KFileItem; +class KImportIconView; + +class AddExistingDirectoriesDialog : public AddExistingDlgBase +{ + Q_OBJECT + +public: + AddExistingDirectoriesDialog ( AutoProjectPart* part, AutoProjectWidget *widget, + SubprojectItem* spitem, QWidget* parent = 0, + const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~AddExistingDirectoriesDialog(); + +private: + FileSelectorWidget* sourceSelector; + KImportIconView* importView; + + AutoProjectPart* m_part; + AutoProjectWidget* m_widget; + + TargetItem* m_titem; + SubprojectItem* m_spitem; + + KFileItemList m_importList; + +protected: + void init(); + void importItems (); + +protected slots: + void slotAddSelected(); + void slotAddAll(); + void slotRemoveAll(); + void slotRemoveSelected(); + void slotDropped ( QDropEvent* ev ); + + void slotOk(); +}; + +#endif +// kate: indent-mode csands; tab-width 4; + diff --git a/buildtools/autotools/addexistingdlgbase.ui b/buildtools/autotools/addexistingdlgbase.ui new file mode 100644 index 00000000..cf73ee21 --- /dev/null +++ b/buildtools/autotools/addexistingdlgbase.ui @@ -0,0 +1,459 @@ + +AddExistingDlgBase + + + AddExistingDlgBase + + + + 0 + 0 + 592 + 445 + + + + + 5 + 5 + 0 + 0 + + + + ImportExistingDlgBase + + + + unnamed + + + + layout10 + + + + unnamed + + + + buttonSpacer + + + Horizontal + + + Expanding + + + + 317 + 20 + + + + + + okButton + + + &OK + + + true + + + + + cancelButton + + + &Cancel + + + + + + + progressBar + + + true + + + + + infoGroupBox + + + + 5 + 0 + 0 + 0 + + + + + 32767 + 32767 + + + + Box + + + Sunken + + + Subproject Information + + + + unnamed + + + + infoLayout1 + + + + unnamed + + + 0 + + + + directoryStaticLabel + + + + 0 + 5 + 0 + 0 + + + + + + + + Directory: + + + + + targetStaticLabel + + + + 0 + 5 + 0 + 0 + + + + + + + + Target: + + + + + + + infoLayout2 + + + + unnamed + + + 0 + + + + directoryLabel + + + + 5 + 5 + 0 + 0 + + + + [DIRECTORY] + + + + + targetLabel + + + [TARGET] + + + + + + + + + splitter2 + + + + 7 + 7 + 0 + 0 + + + + Horizontal + + + + layout12 + + + + unnamed + + + + layout10 + + + + unnamed + + + + arrowSpacer1 + + + Horizontal + + + Expanding + + + + 84 + 20 + + + + + + addAllButton + + + A&dd All + + + Import by creating symbolic links (recommended) + + + + + addSelectedButton + + + &Add Selected + + + Import by copying (not recommended) + + + + + arrowSpacer2 + + + Horizontal + + + Expanding + + + + 84 + 20 + + + + + + + + sourceGroupBox + + + + 240 + 250 + + + + + 32767 + 32767 + + + + &Source Directory + + + + + + + unnamed + + + + + + + + layout13 + + + + unnamed + + + + layout11 + + + + unnamed + + + + arrowSpacer1_2 + + + Horizontal + + + Expanding + + + + 21 + 20 + + + + + + removeAllButton + + + R&emove All + + + Removes all added files. + + + + + removeSelectedButton + + + &Remove Selected + + + Removes the selected files. + + + + + arrowSpacer2_2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + destGroupBox + + + + 140 + 100 + + + + + 32767 + 32767 + + + + Add &Following + + + + unnamed + + + + + + + + + + + + + cancelButton + clicked() + AddExistingDlgBase + reject() + + + + addAllButton + addSelectedButton + removeAllButton + removeSelectedButton + okButton + cancelButton + + + ksqueezedtextlabel.h + kprogress.h + kdialog.h + + + + + kprogress.h + ksqueezedtextlabel.h + + diff --git a/buildtools/autotools/addexistingfilesdlg.cpp b/buildtools/autotools/addexistingfilesdlg.cpp new file mode 100644 index 00000000..00f3e61b --- /dev/null +++ b/buildtools/autotools/addexistingfilesdlg.cpp @@ -0,0 +1,451 @@ +/*************************************************************************** + ------------------- + begin : Frag' mich was leichteres + copyright : (C) 2002 by Victor Rder + email : 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. * + * * + ***************************************************************************/ + +/** Here resides the Import-existing-files-dialog of the Automake Manager (a KDevelop build tool part) **/ + +#include +#include +#include +//#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "urlutil.h" + +#include "autolistviewitems.h" + +#include "autoprojectwidget.h" +#include "autoprojectpart.h" + +#include "kimporticonview.h" + +#include "addexistingfilesdlg.h" + +/* + * Constructs a AddExistingFilesDialog which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ + +AddExistingFilesDialog::AddExistingFilesDialog ( AutoProjectPart* part, AutoProjectWidget *widget, SubprojectItem* spitem, TargetItem* titem, QWidget* parent, const char* name, bool modal, WFlags fl ) + : AddExistingDlgBase ( parent, name, modal, fl ) +{ + m_spitem = spitem; + m_titem = titem; + + m_part = part; + m_widget = widget; + + KFile::Mode mode = KFile::Files; + + if ( titem && spitem && titem->type() == ProjectItem::Target && spitem->type() == ProjectItem::Subproject ) + { + + if ( titem->name.isEmpty() ) + { + QString target = i18n ( "%1 in %2" ).arg ( titem->primary ).arg ( titem->prefix ); + targetLabel->setText ( target ); + } + else + { + targetLabel->setText ( titem->name ); + } + directoryLabel->setText ( spitem->path ); + } + + sourceSelector = new FileSelectorWidget ( m_part, mode, sourceGroupBox, "source file selector" ); + sourceGroupBoxLayout->addWidget ( sourceSelector ); + + importView = new KImportIconView ( i18n ( "Drag one or more files from the left view and drop it here." ), destGroupBox, "destination icon view" ); + destGroupBoxLayout->addWidget ( importView ); + //destGroupBoxLayout->setStretchFactor(dir, 2); + + QWidget::setTabOrder(sourceSelector, addAllButton); + QWidget::setTabOrder(addAllButton, addSelectedButton); + QWidget::setTabOrder(addSelectedButton, importView); + QWidget::setTabOrder(importView, removeAllButton); + QWidget::setTabOrder(removeAllButton, removeSelectedButton); + QWidget::setTabOrder(removeSelectedButton, okButton); + QWidget::setTabOrder(okButton, cancelButton); + + sourceSelector->setFocus(); + + setIcon ( SmallIcon ( "fileimport.png" ) ); + + init(); +} + + +/* + * Destroys the object and frees any allocated resources + */ +AddExistingFilesDialog::~AddExistingFilesDialog() +{ + // no need to delete child widgets, Qt does it all for me +} + + +// void AddExistingFilesDialog::resizeEvent ( QResizeEvent* ev ) +// { +// AddExistingDlgBase::resizeEvent ( ev ); +// //importView->update(); +// } + + +void AddExistingFilesDialog::init() +{ + progressBar->hide(); + + importView->setMode ( KIconView::Select ); + importView->setItemsMovable ( false ); + + connect ( okButton, SIGNAL ( clicked () ), this, SLOT ( slotOk () ) ); + + connect ( addSelectedButton, SIGNAL ( clicked () ), this, SLOT ( slotAddSelected() ) ); + connect ( addAllButton, SIGNAL ( clicked () ), this, SLOT ( slotAddAll() ) ); + connect ( removeSelectedButton, SIGNAL ( clicked () ), this, SLOT ( slotRemoveSelected() ) ); + connect ( removeAllButton, SIGNAL ( clicked () ), this, SLOT ( slotRemoveAll() ) ); + + connect ( importView, SIGNAL ( dropped( QDropEvent* ) ), this, SLOT ( slotDropped ( QDropEvent* ) ) ); + + importView->setSelectionMode ( KFile::Multi ); + + Q_ASSERT( m_spitem ); + sourceSelector->setDir ( m_spitem->path ); +} + +void AddExistingFilesDialog::importItems() +{ + if( !importView->items() ) + return; + + // items added via button or drag 'n drop + KFileItemListIterator itemList ( m_importList ); + + // items already added to the importView + KFileItemListIterator importedList ( *importView->items() ); + + QListViewItem* child = m_titem->firstChild(); + + QStringList duplicateList; + + while ( child ) + { + FileItem* curItem = static_cast ( child ); + + itemList.toFirst(); + + for ( ; itemList.current(); ++itemList ) + { + if ( ( *itemList )->name() == curItem->name ) + { + duplicateList.append ( ( *itemList )->name() ); + m_importList.remove ( ( *itemList ) ); + } + } + + child = child->nextSibling(); + } + + importedList.toFirst(); + + for ( ; importedList.current(); ++importedList ) + { + itemList.toFirst(); + + for ( ; itemList.current(); ++itemList ) + { + if ( ( *importedList )->name() == ( *itemList )->name() ) + { + m_importList.remove ( ( *itemList ) ); + + // to avoid that a item is added twice + if ( !duplicateList.remove ( ( *importedList )->name() ) ) + { + duplicateList.append ( ( *importedList )->name() ); + } + } + } + } + + if ( duplicateList.count() > 0 ) + { + if ( KMessageBox::warningContinueCancelList ( this, i18n ( + "The following file(s) already exist(s) in the target!\n" + "Press Continue to import only the new files.\n" + "Press Cancel to abort the complete import." ), + duplicateList, "Warning", KGuiItem ( i18n ( "Continue" ) ) ) == KMessageBox::Cancel ) + { + m_importList.clear(); + return; + } + } + + itemList.toFirst(); + + for ( ; itemList.current(); ++itemList ) + { + if ( !( *itemList )->isDir() ) + { + importView->insertItem ( ( *itemList ) ); + } + } + + importView->somethingDropped ( true ); + + m_importList.clear(); + + importView->update (); +} + +void AddExistingFilesDialog::slotOk() +{ + if ( importView->items()->count() == 0 ) QDialog::reject(); + + progressBar->show(); + progressBar->setFormat ( i18n ( "Importing... %p%" ) ); + + qApp->processEvents(); + + KFileItemListIterator items ( *importView->items() ); + + // contains at the end only the imported files outside the subproject directory + KFileItemList outsideList; + + QStringList stringList; + + for ( ; items.current(); ++items ) + { + // kdDebug ( 9020 ) << " **** " << ( *items )->url().directory() << "***** " << m_spitem->path << endl; + if ( ( *items )->url().directory() != m_spitem->path ) + { + stringList.append ( ( *items )->name() ); + outsideList.append ( ( *items ) ); + } + } + + progressBar->setTotalSteps ( outsideList.count() + importView->items()->count() ); + + if ( outsideList.count() > 0 ) + { + if ( KMessageBox::questionYesNoList ( this, i18n ( + "The following file(s) are not in the Subproject directory.\n" + "Press Link to add the files by creating symbolic links.\n" + "Press Copy to copy the files into the directory." ), + stringList, i18n("Warning"), KGuiItem ( i18n ( "Link (recommended)" ) ), KGuiItem ( i18n ( "Copy (not recommended)" ) ) ) == KMessageBox::No ) + { + // Copy files into the Subproject directory + KFileItemListIterator it ( outsideList ) ; + + for ( ; it.current(); ++it ) + { + KProcess proc; + + proc << "cp"; + proc << ( *it )->url().path(); + proc << m_spitem->path; + proc.start(KProcess::DontCare); + + progressBar->setValue ( progressBar->value() + 1 ); + } + } + else + { + // Link them into the Subproject directory + KFileItemListIterator it ( outsideList ) ; + + for ( ; it.current(); ++it ) + { + KProcess proc; + + proc << "ln"; + proc << "-s"; + proc << URLUtil::relativePathToFile( m_spitem->path, ( *it )->url().path() ); + proc << m_spitem->path; + proc.start(KProcess::DontCare); + + progressBar->setValue ( progressBar->value() + 1 ); + } + } + } + + items.toFirst(); + + QString canontargetname = AutoProjectTool::canonicalize ( m_titem->name ); + QString varname; + if( m_titem->primary == "PROGRAMS" || m_titem->primary == "LIBRARIES" || m_titem->primary == "LTLIBRARIES" ) + varname = canontargetname + "_SOURCES"; + else + varname = m_titem->prefix + "_" + m_titem->primary; + + QMap replaceMap; + FileItem* fitem = 0L; + QStringList fileList; + + for ( ; items.current(); ++items ) + { + m_spitem->variables [ varname ] += ( " " + ( *items )->name() ); + replaceMap.insert ( varname, m_spitem->variables [ varname ] ); + + fitem = m_widget->createFileItem ( ( *items )->name(), m_spitem ); + m_titem->sources.append ( fitem ); + m_titem->insertItem ( fitem ); + + fileList.append ( m_spitem->path.mid ( m_part->projectDirectory().length() + 1 ) + "/" + ( *items )->name() ); + + progressBar->setValue ( progressBar->value() + 1 ); + } + + m_widget->emitAddedFiles ( fileList ); + + AutoProjectTool::addToMakefileam ( m_spitem->path + "/Makefile.am", replaceMap ); + + QDialog::accept(); + +} + +void AddExistingFilesDialog::slotAddSelected() +{ + KFileItemListIterator it ( *sourceSelector->dirOperator()->selectedItems() ); + + for ( ; it.current(); ++it ) + { + if ( ( *it )->url().isLocalFile() ) // maybe unnecessary + { + m_importList.append ( ( *it ) ); + } + } + + importItems(); +} + + +void AddExistingFilesDialog::slotAddAll() +{ + KFileItemListIterator it ( *sourceSelector->dirOperator()->view()->items() ); + + for ( ; it.current(); ++it ) + { + if ( ( *it )->url().isLocalFile() ) // maybe unnecessary + { + m_importList.append ( ( *it ) ); + } + } + + importItems(); +} + +void AddExistingFilesDialog::slotRemoveAll() +{ + KURL::List deletedFiles; + KFileItemListIterator it ( *importView->items() ); + + for ( ; it.current(); ++it ) + { + kdDebug ( 9020 ) << "AddExistingFilesDialog::slotRemoveAll()" << endl; + //deletedFiles.append ( ( *it )->url() ); + if ( (*it ) ) importView->removeItem ( *it ); + } + + importView->somethingDropped ( false ); + + importView->viewport()->update(); +} + +void AddExistingFilesDialog::slotRemoveSelected() +{ + KFileItemListIterator items ( *importView->items() ); + + KFileItemList* selectedList = (KFileItemList*) importView->selectedItems(); + + KFileItem * deleteItem = 0L; + + for ( ; items.current(); ++items ) + { + deleteItem = selectedList->first(); + + while ( deleteItem ) + { + if ( deleteItem == ( *items ) ) + { + importView->removeItem ( deleteItem ); + deleteItem = selectedList->current(); + } + else + { + deleteItem = selectedList->next(); + } + } + } + + if ( importView->items()->count() == 0 ) importView->somethingDropped ( false ); + + importView->viewport()->update(); +} + + +void AddExistingFilesDialog::slotDropped ( QDropEvent* ev ) +{ + kdDebug ( 9020 ) << "AddExistingFilesDialog::dropped()" << endl; + + KURL::List urls; + + KURLDrag::decode( ev, urls ); + + KFileItem* item = 0L; + KMimeType::Ptr type = 0L; + + + for ( KURL::List::Iterator it = urls.begin(); it != urls.end(); ++it ) + { + if ( ( *it ).isLocalFile() ) // maybe unnecessary + { + type = KMimeType::findByURL ( ( *it ) ); + + if ( type->name() != KMimeType::defaultMimeType() ) + { + item = new KFileItem ( ( *it ) , type->name(), 0 ); + } + else + { + // take a text-file-icon instead of the ugly question-mark-icon + item = new KFileItem ( ( *it ), "text/plain", 0 ); + } + + m_importList.append ( item ); + } + } + + importItems(); +} + +#include "addexistingfilesdlg.moc" diff --git a/buildtools/autotools/addexistingfilesdlg.h b/buildtools/autotools/addexistingfilesdlg.h new file mode 100644 index 00000000..5bee18b6 --- /dev/null +++ b/buildtools/autotools/addexistingfilesdlg.h @@ -0,0 +1,77 @@ +/*************************************************************************** + ------------------- + begin : Frag' mich was leichteres + copyright : (C) 2002 by Victor Rder + email : 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. * + * * + ***************************************************************************/ + +/** Here resides the Import-existing-files-dialog of the Automake Manager **/ +/** (a KDevelop build tool part) **/ + +#ifndef ADDEXISTINGFILESDLG_H +#define ADDEXISTINGFILESDLG_H + +#include +#include + +#include "addexistingdlgbase.h" +#include "fileselectorwidget.h" + +#include "misc.h" + +class KImportIconView; +class FileSelectorWidget; +class AutoProjectWidget; +class AutoProjectPart; +class SubprojectItem; +class TargetItem; +class KFileItem; + +class AddExistingFilesDialog : public AddExistingDlgBase +{ + Q_OBJECT + +public: + AddExistingFilesDialog( AutoProjectPart* part, AutoProjectWidget *widget, + SubprojectItem* spitem, TargetItem* titem, QWidget* parent = 0, + const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~AddExistingFilesDialog(); + +private: + FileSelectorWidget* sourceSelector; + KImportIconView* importView; + + AutoProjectPart* m_part; + AutoProjectWidget* m_widget; + + TargetItem* m_titem; + SubprojectItem* m_spitem; + + KFileItemList m_importList; + +protected: + // virtual void resizeEvent ( QResizeEvent* ev ); + void init(); + void importItems (); + +protected slots: + void slotAddSelected(); + void slotAddAll(); + void slotRemoveAll(); + void slotRemoveSelected(); + void slotDropped ( QDropEvent* ev ); + + void slotOk(); +}; + +#endif // ADDEXISTINGFILESDLG_H +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/addfiledlg.cpp b/buildtools/autotools/addfiledlg.cpp new file mode 100644 index 00000000..46529086 --- /dev/null +++ b/buildtools/autotools/addfiledlg.cpp @@ -0,0 +1,135 @@ +/*************************************************************************** + * Copyright (C) 2001-2002 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "addfiledlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "autolistviewitems.h" + +#include "filetemplate.h" +#include "misc.h" +#include "urlutil.h" +#include "autoprojectpart.h" +#include "autoprojectwidget.h" + +#include "kdevpartcontroller.h" + +AddFileDialog::AddFileDialog(AutoProjectPart *part, AutoProjectWidget *widget, + SubprojectItem *spitem, TargetItem *item, + QWidget *parent, const char *name) + : AddFileDlgBase(parent, name, true) +{ + connect ( createButton, SIGNAL ( clicked() ), this, SLOT ( accept() ) ); + connect ( cancelButton, SIGNAL ( clicked() ), this, SLOT ( reject() ) ); + + directoryLabel->setText ( spitem->path ); + if ( item->name.isEmpty() ) + targetLabel->setText ( i18n ( "%1 in %2" ).arg ( item->primary ).arg ( item->prefix ) ); + else + targetLabel->setText ( item->name ); + + setIcon ( SmallIcon ( "filenew.png" ) ); + + m_part = part; + m_widget = widget; + subProject = spitem; + target = item; +} + + +AddFileDialog::~AddFileDialog() +{} + + +void AddFileDialog::accept() +{ + QString name = fileEdit->text(); + if (name.find('/') != -1) { + KMessageBox::sorry(this, i18n("Please enter the file name without '/' and so on.")); + return; + } + + QListViewItem *child = target->firstChild(); + while (child) { + FileItem *item = static_cast(child); + if (name == item->name) { + KMessageBox::sorry(this, i18n("This file is already in the target.")); + return; + } + child = child->nextSibling(); + } + + if (templateCheckBox->isChecked()) { + QString srcdir = m_part->projectDirectory(); + QString destdir = subProject->path; + QString destpath = destdir + "/" + name; + if (QFileInfo(destpath).exists()) { + KMessageBox::sorry(this, i18n("A file with this name already exists.

Please use the \"Add existing file\" dialog.")); + return; + } + if( !FileTemplate::copy(m_part, QFileInfo(name).extension(), destpath) ) + kdDebug(9020) << "cannot create file " << destpath << endl; + } else { + // create an empty file + QString srcdir = m_part->projectDirectory(); + QString destdir = subProject->path; + QString destpath = destdir + "/" + name; + + if (QFileInfo(destpath).exists()) { + KMessageBox::sorry(this, i18n("A file with this name already exists.

Please use the \"Add existing file\" dialog.")); + return; + } + + QFile f( destpath ); + if( f.open(IO_WriteOnly) ) + f.close(); + } + + FileItem *fitem = m_widget->createFileItem(name, subProject); + target->sources.append(fitem); + target->insertItem(fitem); + + 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; + subProject->variables[varname] += (" " + name); + + QMap replaceMap; + replaceMap.insert(varname, subProject->variables[varname]); + + AutoProjectTool::addToMakefileam(subProject->path + "/Makefile.am", replaceMap); + + m_widget->emitAddedFile( subProject->path.mid ( m_part->project()->projectDirectory().length() + 1 ) + "/" + name ); + m_part->partController()->editDocument ( KURL ( subProject->path + "/" + name ) ); + + QDialog::accept(); +} + +#include "addfiledlg.moc" diff --git a/buildtools/autotools/addfiledlg.h b/buildtools/autotools/addfiledlg.h new file mode 100644 index 00000000..328e3593 --- /dev/null +++ b/buildtools/autotools/addfiledlg.h @@ -0,0 +1,47 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _ADDFILEDLG_H_ +#define _ADDFILEDLG_H_ + +#include + +#include "addfiledlgbase.h" + +class QCheckBox; +class QLineEdit; +class AutoProjectPart; +class AutoProjectWidget; +class SubprojectItem; +class TargetItem; + + +class AddFileDialog : public AddFileDlgBase +{ + Q_OBJECT + +public: + AddFileDialog( AutoProjectPart *part, AutoProjectWidget *widget, + SubprojectItem *spitem, TargetItem *item, + QWidget *parent = 0, const char *name = 0 ); + ~AddFileDialog(); + +protected: + virtual void accept(); + +private: + AutoProjectPart *m_part; + AutoProjectWidget *m_widget; + SubprojectItem *subProject; + TargetItem *target; +}; + +#endif diff --git a/buildtools/autotools/addfiledlgbase.ui b/buildtools/autotools/addfiledlgbase.ui new file mode 100644 index 00000000..dc8e38b2 --- /dev/null +++ b/buildtools/autotools/addfiledlgbase.ui @@ -0,0 +1,289 @@ + +AddFileDlgBase + + + AddFileDlgBase + + + + 0 + 0 + 521 + 217 + + + + + 5 + 5 + 0 + 0 + + + + + 32767 + 32767 + + + + + 0 + 0 + + + + Add New Created File to Target + + + + unnamed + + + + targetBox + + + Box + + + Sunken + + + Subproject Information + + + + unnamed + + + + targetLayout + + + + unnamed + + + 0 + + + + directoryLabel + + + [TARGET DIRECTORY] + + + + + targetLabel + + + [TARGET NAME] + + + + + directoryStaticLabel + + + + 0 + 5 + 0 + 0 + + + + + + + + Directory: + + + + + targetStaticLabel + + + + 0 + 5 + 0 + 0 + + + + + + + + Target: + + + + + + + + + fileGroupBox + + + File Information + + + + unnamed + + + + fileEdit + + + + 5 + 5 + 0 + 0 + + + + + 0 + 0 + + + + + + templateCheckBox + + + + 1 + 0 + 0 + 0 + + + + &Use file template + + + true + + + + + fileStaticLabel + + + + 0 + 5 + 0 + 0 + + + + + 0 + 0 + + + + + + + + New file &name (with extension): + + + fileEdit + + + + + + + Spacer2 + + + Vertical + + + Expanding + + + + 20 + 16 + + + + + + buttonLayout + + + + unnamed + + + 0 + + + + buttonSpacer + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + createButton + + + &OK + + + true + + + + + cancelButton + + + &Cancel + + + + + + + + ksqueezedtextlabel.h + klineedit.h + kdialog.h + + + + + ksqueezedtextlabel.h + klineedit.h + + diff --git a/buildtools/autotools/addicondlg.cpp b/buildtools/autotools/addicondlg.cpp new file mode 100644 index 00000000..251601f7 --- /dev/null +++ b/buildtools/autotools/addicondlg.cpp @@ -0,0 +1,115 @@ +/*************************************************************************** + * Copyright (C) 2002 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "addicondlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include // fix me! + +#include "autolistviewitems.h" + +#include "autoprojectpart.h" +#include "autoprojectwidget.h" + + +const char *type_map[] = { + "app", "action", "device", "filesys", "mime" +}; + + +const char *size_map[] = { + "hi16", "hi22", "hi32", "hi48", "hi64", "hi128" +}; + + +AddIconDialog::AddIconDialog(AutoProjectPart *part, AutoProjectWidget *widget, + SubprojectItem *spitem, TargetItem *titem, + QWidget *parent, const char *name) + : AddIconDialogBase(parent, name, true) +{ + type_combo->insertItem(i18n("Application")); + type_combo->insertItem(i18n("Action")); + type_combo->insertItem(i18n("Device")); + type_combo->insertItem(i18n("File System")); + type_combo->insertItem(i18n("MIME Type")); + + size_combo->insertItem("16"); + size_combo->insertItem("22"); + size_combo->insertItem("32"); + size_combo->insertItem("48"); + size_combo->insertItem("64"); + size_combo->insertItem("128"); + + somethingChanged(); + + setIcon ( SmallIcon ( "iconadd_kdevelop" ) ); + + m_part = part; + m_widget = widget; + m_subProject = spitem; + m_target = titem; +} + + +AddIconDialog::~AddIconDialog() +{} + + +void AddIconDialog::somethingChanged() +{ + QString size = size_map[size_combo->currentItem()]; + QString type = type_map[type_combo->currentItem()]; + QString name = name_edit->text(); + + filename_edit->setText(size + "-" + type + "-" + name + ".png"); +} + + +void AddIconDialog::accept() +{ + QString name = filename_edit->text(); + + QString destdir = m_subProject->subdir; + QString destpath = destdir + "/" + name; + + QString size = size_combo->currentText(); + QString unknown = KIconTheme::defaultThemeName()+ "/" + size + "x" + size + "/mimetypes/unknown.png"; + + QString templateFileName = locate("icon", unknown); + kdDebug(9020) << "Unknown: " << unknown << ", template: " << templateFileName << endl; + + if (!templateFileName.isEmpty()) { + KProcess proc; + proc << "cp"; + proc << templateFileName; + proc << destpath; + proc.start(KProcess::DontCare); + } + + FileItem *fitem = m_widget->createFileItem(name, m_subProject); + m_target->sources.append(fitem); + m_target->insertItem(fitem); + + m_part->startMakeCommand(destdir, QString::fromLatin1("force-reedit")); + + m_widget->emitAddedFile(destpath); + + QDialog::accept(); +} + +#include "addicondlg.moc" diff --git a/buildtools/autotools/addicondlg.h b/buildtools/autotools/addicondlg.h new file mode 100644 index 00000000..64fac0a5 --- /dev/null +++ b/buildtools/autotools/addicondlg.h @@ -0,0 +1,44 @@ +/*************************************************************************** +* Copyright (C) 2002 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _ADDICONDLG_H_ +#define _ADDICONDLG_H_ + +#include "addicondlgbase.h" + +class AutoProjectPart; +class AutoProjectWidget; +class SubprojectItem; +class TargetItem; + + +class AddIconDialog : public AddIconDialogBase +{ + Q_OBJECT + +public: + AddIconDialog( AutoProjectPart *part, AutoProjectWidget *widget, + SubprojectItem *spitem, TargetItem *titem, + QWidget *parent = 0, const char *name = 0 ); + ~AddIconDialog(); + + +private: + virtual void somethingChanged(); + virtual void accept(); + + AutoProjectPart *m_part; + AutoProjectWidget *m_widget; + SubprojectItem *m_subProject; + TargetItem *m_target; +}; + +#endif diff --git a/buildtools/autotools/addicondlgbase.ui b/buildtools/autotools/addicondlgbase.ui new file mode 100644 index 00000000..7fec5097 --- /dev/null +++ b/buildtools/autotools/addicondlgbase.ui @@ -0,0 +1,273 @@ + +AddIconDialogBase + + + add_icon_dialog + + + + 0 + 0 + 301 + 218 + + + + Add New Icon + + + false + + + + unnamed + + + + + type_label + + + + + + + &Type: + + + AlignVCenter|AlignRight + + + type_combo + + + + + size_label + + + + + + + &Size: + + + AlignVCenter|AlignRight + + + size_combo + + + + + size_combo + + + + + filename_label + + + + + + + File name: + + + AlignVCenter|AlignRight + + + filename_edit + + + + + name_label + + + + + + + &Name: + + + AlignVCenter|AlignRight + + + name_edit + + + + + Line1 + + + HLine + + + Sunken + + + Horizontal + + + + + Layout1 + + + + unnamed + + + 0 + + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + okbutton + + + &OK + + + true + + + true + + + + + cancelbutton + + + &Cancel + + + true + + + + + + + name_edit + + + unknown + + + + + type_combo + + + + + filename_edit + + + + 5 + 0 + 0 + 0 + + + + StyledPanel + + + Sunken + + + + + Spacer22 + + + Vertical + + + Fixed + + + + 20 + 20 + + + + + + + + okbutton + clicked() + add_icon_dialog + accept() + + + cancelbutton + clicked() + add_icon_dialog + reject() + + + name_edit + textChanged(const QString&) + add_icon_dialog + somethingChanged() + + + type_combo + activated(int) + add_icon_dialog + somethingChanged() + + + size_combo + activated(int) + add_icon_dialog + somethingChanged() + + + + type_combo + size_combo + name_edit + okbutton + cancelbutton + + + somethingChanged() + + + kdialog.h + + + + + + diff --git a/buildtools/autotools/addprefixdlg.cpp b/buildtools/autotools/addprefixdlg.cpp new file mode 100644 index 00000000..d1557114 --- /dev/null +++ b/buildtools/autotools/addprefixdlg.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + * Copyright (C) 2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "addprefixdlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +AddPrefixDialog::AddPrefixDialog( const QString& nameEdit, const QString& pathEdit, + QWidget *parent, const char *name) + : QDialog(parent, name, true) +{ + setCaption(i18n("Add Prefix")); + + QLabel *name_label = new QLabel(i18n("&Name:"), this); + name_edit = new KLineEdit(nameEdit, this); + name_edit->setFocus(); + name_label->setBuddy(name_edit); + connect( name_edit, SIGNAL( textChanged ( const QString & ) ), SLOT( slotPrefixChanged() ) ); + + QLabel *path_label = new QLabel(i18n("&Path:"), this); + path_edit = new KLineEdit(pathEdit, this); + path_label->setBuddy(path_edit); + QFontMetrics fm(path_edit->fontMetrics()); + path_edit->setMinimumWidth(fm.width('X')*35); + connect( path_edit, SIGNAL( textChanged ( const QString & ) ), SLOT( slotPrefixChanged() ) ); + + QVBoxLayout *layout = new QVBoxLayout(this, 10); + + QGridLayout *grid = new QGridLayout(2, 2); + layout->addLayout(grid); + grid->addWidget(name_label, 0, 0); + grid->addWidget(name_edit, 0, 1); + grid->addWidget(path_label, 1, 0); + grid->addWidget(path_edit, 1, 1); + + QFrame *frame = new QFrame(this); + frame->setFrameStyle(QFrame::HLine | QFrame::Sunken); + layout->addWidget(frame, 0); + + KButtonBox *buttonbox = new KButtonBox(this); + buttonbox->addStretch(); + m_pOk = buttonbox->addButton(KStdGuiItem::ok()); + QPushButton *cancel = buttonbox->addButton(KStdGuiItem::cancel()); + m_pOk->setDefault(true); + connect( m_pOk, SIGNAL(clicked()), this, SLOT(accept()) ); + connect( cancel, SIGNAL(clicked()), this, SLOT(reject()) ); + buttonbox->layout(); + layout->addWidget(buttonbox, 0); + slotPrefixChanged(); +} + + +AddPrefixDialog::~AddPrefixDialog() +{} + +void AddPrefixDialog::slotPrefixChanged() +{ + m_pOk->setEnabled( !name_edit->text().isEmpty() && !path_edit->text().isEmpty() ); +} + +#include "addprefixdlg.moc" diff --git a/buildtools/autotools/addprefixdlg.h b/buildtools/autotools/addprefixdlg.h new file mode 100644 index 00000000..a20bc63a --- /dev/null +++ b/buildtools/autotools/addprefixdlg.h @@ -0,0 +1,45 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _ADDPREFIXDLG_H_ +#define _ADDPREFIXDLG_H_ + +#include +#include +class QPushButton; + +class AddPrefixDialog : public QDialog +{ + Q_OBJECT + +public: + AddPrefixDialog( const QString& nameEdit = "", const QString& pathEdit = "", + QWidget *parent = 0, const char *name = 0 ); + ~AddPrefixDialog(); + + QString name() const + { + return name_edit->text(); + } + QString path() const + { + return path_edit->text(); + } +private slots: + void slotPrefixChanged(); + +private: + KLineEdit *name_edit; + KLineEdit *path_edit; + QPushButton *m_pOk; +}; + +#endif diff --git a/buildtools/autotools/addservicedlg.cpp b/buildtools/autotools/addservicedlg.cpp new file mode 100644 index 00000000..2dc76e5e --- /dev/null +++ b/buildtools/autotools/addservicedlg.cpp @@ -0,0 +1,233 @@ +/*************************************************************************** + * Copyright (C) 2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "addservicedlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "autolistviewitems.h" + +#include "misc.h" +#include "autoprojectwidget.h" +#include "autoprojectpart.h" + + +AddServiceDialog::AddServiceDialog(AutoProjectWidget *widget, SubprojectItem *spitem, + QWidget *parent, const char *name) + : AddServiceDialogBase(parent, name, true) +{ + filename_edit->setText(".desktop"); + filename_edit->home(false); + filename_edit->setFocus(); + chosentypes_listview->header()->hide(); + availtypes_listview->header()->hide(); + + m_widget = widget; + subProject = spitem; + + // Fill the combo box with library names in the directory + QPtrListIterator tit(spitem->targets); + for (; tit.current(); ++tit) { + if ((*tit)->primary == "LTLIBRARIES") + library_combo->insertItem(QString((*tit)->name)); + } + + // Fill the list of available service types + KServiceType::List l = KServiceType::allServiceTypes(); + KServiceType::List::Iterator it; + for (it = l.begin(); it != l.end(); ++it) + if (!(*it)->isType(KST_KMimeType)) + new QListViewItem(availtypes_listview, (*it)->name()); + + setIcon ( SmallIcon ( "servicenew_kdevelop.png" ) ); +} + + +AddServiceDialog::~AddServiceDialog() +{} + + +void AddServiceDialog::updateProperties() +{ + QStringList props; + + QListViewItem *item = static_cast(chosentypes_listview->firstChild()); + while (item) { + KServiceType::Ptr type = KServiceType::serviceType(item->text(0)); + if (type) { + QStringList stprops = type->propertyDefNames(); + QStringList::ConstIterator stit; + for (stit = stprops.begin(); stit != stprops.end(); ++stit) + if (props.find(*stit) == props.end() && (*stit) != "Name" && (*stit) != "Comment" + && (*stit) != "Icon") + props.append(*stit); + } + item = item->nextSibling(); + } + + properties_listview->clear(); + QStringList::ConstIterator it; + for (it = props.begin(); it != props.end(); ++it) + new QListViewItem(properties_listview, *it); +} + + +void AddServiceDialog::iconClicked() +{ + KIconLoader *loader = AutoProjectFactory::instance()->iconLoader(); + QString name = KIconDialog::getIcon(KIcon::Desktop); + if (!name.isNull()) { + iconName = name; + icon_button->setPixmap(loader->loadIcon(name, KIcon::Desktop)); + } +} + + +void AddServiceDialog::addTypeClicked() +{ + QListViewItem *selitem = availtypes_listview->selectedItem(); + if (!selitem) + return; + + QListViewItem *olditem = chosentypes_listview->firstChild(); + while (olditem) { + if (selitem->text(0) == olditem->text(0)) + return; + olditem = olditem->nextSibling(); + } + new QListViewItem(chosentypes_listview, selitem->text(0)); + + updateProperties(); +} + + +void AddServiceDialog::removeTypeClicked() +{ + delete chosentypes_listview->currentItem(); + + updateProperties(); +} + + +void AddServiceDialog::propertyExecuted(QListViewItem *item) +{ + if (!item) + return; + + QString prop = item->text(0); + QString value = item->text(1); + bool ok; + value = KInputDialog::getText(i18n("Enter Value"), i18n("Property %1:").arg(prop), value, &ok, this); + if (!ok) + return; + + item->setText(1, value); +} + + +void AddServiceDialog::accept() +{ + // Create list of service types + QStringList serviceTypes; + QListViewItem *item = chosentypes_listview->firstChild(); + while (item) { + serviceTypes.append(item->text(0)); + item = item->nextSibling(); + } + + // Some plausibility tests + QString fileName = filename_edit->text(); + if (fileName.isEmpty() || fileName == ".desktop") { + KMessageBox::sorry(this, i18n("You have to enter a file name.")); + filename_edit->setFocus(); + return; + } + + QString name = name_edit->text(); + if (name.isEmpty()) { + KMessageBox::sorry(this, i18n("You have to enter a service name.")); + name_edit->setFocus(); + return; + } + + QFile f(subProject->path + "/" + fileName); + if (f.exists()) { + KMessageBox::sorry(this, i18n("A file with this name exists already.")); + filename_edit->setFocus(); + return; + } + if (!f.open(IO_WriteOnly)) { + KMessageBox::sorry(this, i18n("Could not open file for writing.")); + return; + } + + QTextStream stream(&f); + stream << "[Desktop Entry]" << endl; + stream << "Type=Service" << endl; + stream << "Name=" << name << endl; + stream << "Comment=" << comment_edit->text() << endl; + if (!iconName.isNull()) + stream << "Icon=" << iconName << endl; + stream << "ServiceTypes=" << serviceTypes.join(",") << endl; + item = properties_listview->firstChild(); + while (item) { + stream << item->text(0) << "=" << item->text(1) << endl; + item = item->nextSibling(); + } + f.close(); + + // Find a prefix that points to the services directory. + // If there is none, use kde_services + QMap::ConstIterator it; + for (it = subProject->prefixes.begin(); it != subProject->prefixes.end(); ++it) + if (it.data() == "$(kde_servicesdir)") + break; + QString prefix = (it == subProject->prefixes.end())? QString("kde_services") : it.key(); + QString varname = prefix + "_DATA"; + + // Look if a list view item for this prefix exists already. + // Create a new one otherwise + TargetItem *titem = 0; + for (uint i=0; i < subProject->targets.count(); ++i) { + TargetItem *tmptitem = subProject->targets.at(i); + if ("DATA" == tmptitem->primary && prefix == tmptitem->prefix) { + titem = tmptitem; + break; + } + } + if (!titem) { + titem = m_widget->createTargetItem("", prefix, "DATA", false); + subProject->targets.append(titem); + } + // Add this file to the target + FileItem *fitem = m_widget->createFileItem(fileName, subProject); + titem->sources.append(fitem); + + subProject->variables[varname] += (" " + fileName); + QMap replaceMap; + replaceMap.insert(varname, subProject->variables[varname]); + AutoProjectTool::addToMakefileam(subProject->path + "/Makefile.am", replaceMap); + + QDialog::accept(); +} + +#include "addservicedlg.moc" diff --git a/buildtools/autotools/addservicedlg.h b/buildtools/autotools/addservicedlg.h new file mode 100644 index 00000000..c8b694a5 --- /dev/null +++ b/buildtools/autotools/addservicedlg.h @@ -0,0 +1,46 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _ADDSERVICEDLG_H_ +#define _ADDSERVICEDLG_H_ + +#include "addservicedlgbase.h" + +class AutoProjectWidget; +class SubprojectItem; +class TargetItem; + + +class AddServiceDialog : public AddServiceDialogBase +{ + Q_OBJECT + +public: + AddServiceDialog( AutoProjectWidget *widget, SubprojectItem *spitem, + QWidget *parent = 0, const char *name = 0 ); + ~AddServiceDialog(); + +protected: + virtual void iconClicked(); + virtual void addTypeClicked(); + virtual void removeTypeClicked(); + virtual void propertyExecuted( QListViewItem *item ); + virtual void accept(); + +private: + void updateProperties(); + + AutoProjectWidget *m_widget; + SubprojectItem *subProject; + QString iconName; +}; + +#endif diff --git a/buildtools/autotools/addservicedlgbase.ui b/buildtools/autotools/addservicedlgbase.ui new file mode 100644 index 00000000..050f8066 --- /dev/null +++ b/buildtools/autotools/addservicedlgbase.ui @@ -0,0 +1,544 @@ + +AddServiceDialogBase + + + add_service_dialog + + + + 0 + 0 + 602 + 422 + + + + Add New Service + + + false + + + + unnamed + + + + + GroupBox1 + + + &Service File + + + + unnamed + + + + + filename_edit + + + + + + + + icon_label + + + + + + + &Icon: + + + AlignVCenter|AlignRight + + + icon_button + + + + + Layout2 + + + + unnamed + + + 0 + + + + + icon_button + + + + 24 + 24 + + + + + + + false + + + + + Spacer1 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + comment_edit + + + + + name_edit + + + + + library_combo + + + true + + + + + library_label + + + + + + + &Library: + + + AlignVCenter|AlignRight + + + library_combo + + + + + filename_label + + + + + + + &File name: + + + AlignVCenter|AlignRight + + + filename_edit + + + + + name_label + + + + + + + &Name: + + + AlignVCenter|AlignRight + + + name_edit + + + + + comment_label + + + + + + + Co&mment: + + + AlignVCenter|AlignRight + + + comment_edit + + + + + + + GroupBox2 + + + Service &Types + + + + unnamed + + + + + Layout5 + + + + unnamed + + + 0 + + + + + + + + + true + + + true + + + + chosentypes_listview + + + + 7 + 7 + 0 + 0 + + + + LastColumn + + + + + Layout3 + + + + unnamed + + + 0 + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + add_button + + + <- + + + + + remove_button + + + -> + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + + + true + + + true + + + + availtypes_listview + + + + 7 + 7 + 0 + 0 + + + + LastColumn + + + + + + + + Property + + + true + + + true + + + + + Value + + + true + + + true + + + + properties_listview + + + + 7 + 5 + 0 + 0 + + + + true + + + AllColumns + + + + + properties_label + + + + 5 + 5 + 0 + 0 + + + + + + + + &Properties: + + + AlignTop|AlignRight + + + properties_listview + + + + + + + Layout1 + + + + unnamed + + + 0 + + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + okbutton + + + &OK + + + true + + + true + + + + + cancelbutton + + + &Cancel + + + true + + + + + + + + + okbutton + clicked() + add_service_dialog + accept() + + + cancelbutton + clicked() + add_service_dialog + reject() + + + remove_button + clicked() + add_service_dialog + removeTypeClicked() + + + properties_listview + doubleClicked(QListViewItem*) + add_service_dialog + propertyExecuted(QListViewItem*) + + + properties_listview + returnPressed(QListViewItem*) + add_service_dialog + propertyExecuted(QListViewItem*) + + + icon_button + clicked() + add_service_dialog + iconClicked() + + + add_button + clicked() + add_service_dialog + addTypeClicked() + + + + filename_edit + library_combo + name_edit + icon_button + comment_edit + chosentypes_listview + add_button + remove_button + availtypes_listview + properties_listview + okbutton + cancelbutton + + + iconClicked() + addTypeClicked() + propertyExecuted(QListViewItem*) + removeTypeClicked() + + + kdialog.h + + + + diff --git a/buildtools/autotools/addsubprojectdlg.cpp b/buildtools/autotools/addsubprojectdlg.cpp new file mode 100644 index 00000000..8011886b --- /dev/null +++ b/buildtools/autotools/addsubprojectdlg.cpp @@ -0,0 +1,198 @@ +/*************************************************************************** + * Copyright (C) 2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "addsubprojectdlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "autolistviewitems.h" + +#include "kdevmakefrontend.h" +#include "misc.h" +#include "autoprojectpart.h" +#include "autosubprojectview.h" + + +AddSubprojectDialog::AddSubprojectDialog(AutoProjectPart *part, AutoSubprojectView *view, + SubprojectItem *item, QWidget *parent, const char *name) + : AddSubprojectDlgBase(parent, name, true) +{ + setIcon(SmallIcon("folder_new.png")); + + connect( createButton, SIGNAL(clicked()), this, SLOT(accept()) ); + connect( cancelButton, SIGNAL(clicked()), this, SLOT(reject()) ); + + m_subProject = item; + m_subprojectView = view; + m_part = part; +} + + +AddSubprojectDialog::~AddSubprojectDialog() +{} + + +void AddSubprojectDialog::accept() +{ + QString name = spEdit->text().stripWhiteSpace(); + + if (name.isEmpty()) { + KMessageBox::sorry(this, i18n("You have to give the subproject a name.")); + return; + } + + QListViewItem *childItem = m_subProject->firstChild(); + while (childItem) { + if (name == static_cast(childItem)->subdir) { + KMessageBox::sorry(this, i18n("A subproject with this name already exists.")); + return; + } + childItem = childItem->nextSibling(); + } + + +#if 0 + // check for config.status + if( !QFileInfo(m_part->projectDirectory(), "config.status").exists() ){ + KMessageBox::sorry(this, i18n("There is no config.status in the project root directory. Run 'Configure' first")); + QDialog::accept(); + return; + } +#endif + + QDir dir( m_subProject->path ); + QFileInfo file( dir, name ); + + if( file.exists() && !file.isDir() ) { + KMessageBox::sorry(this, i18n("A file named %1 already exists.").arg(name)); + QDialog::accept(); + return; + } else if( file.isDir() ) { + if( KMessageBox::warningContinueCancel(this, + i18n("A subdirectory %1 already exists. " + "Do you wish to add it as a subproject?").arg(name)) + == KMessageBox::Cancel ){ + QDialog::accept(); + return; + } + } else if (!dir.mkdir(name)) { + KMessageBox::sorry(this, i18n("Could not create subdirectory %1.").arg(name)); + QDialog::accept(); + return; + } + + if(!dir.cd(name)) { + KMessageBox::sorry(this, i18n("Could not access the subdirectory %1.").arg(name)); + QDialog::accept(); + return; + } + + // Adjust SUBDIRS variable in containing Makefile.am + if (m_subProject->variables["SUBDIRS"].find("$(TOPSUBDIRS)") != -1) + { + QFile subdirsfile( m_subProject->path + "/subdirs" ); + if ( subdirsfile.open( IO_WriteOnly | IO_Append ) ) + { + QTextStream subdirsstream( &subdirsfile ); + subdirsstream << name << endl; + subdirsfile.close(); + } + } + else if (m_subProject->variables["SUBDIRS"].find("$(AUTODIRS)") != -1) + { + } + else + { + m_subProject->variables["SUBDIRS"] += (" " + name); + QMap replaceMap; + replaceMap.insert("SUBDIRS", m_subProject->variables["SUBDIRS"]); + AutoProjectTool::addToMakefileam(m_subProject->path + "/Makefile.am", replaceMap); + } + + // Create new item in tree view + SubprojectItem *newitem = new SubprojectItem(m_subProject, name); + newitem->subdir = name; + newitem->path = m_subProject->path + "/" + name; + newitem->variables["INCLUDES"] = m_subProject->variables["INCLUDES"]; + newitem->setOpen(true); + + // Move to the bottom of the list + QListViewItem *lastItem = m_subProject->firstChild(); + while (lastItem->nextSibling()) + lastItem = lastItem->nextSibling(); + if (lastItem != newitem) + newitem->moveItem(lastItem); + + // Create a Makefile in the new subdirectory + + QFile f( dir.filePath("Makefile.am") ); + if (f.exists()) { + m_subprojectView->parse( newitem ); + } else { + if (!f.open(IO_WriteOnly)) { + KMessageBox::sorry(this, i18n("Could not create Makefile.am in subdirectory %1.").arg(name)); + return; + } + QTextStream stream(&f); + stream << "INCLUDES = " << newitem->variables["INCLUDES"] << endl << "METASOURCES = AUTO" << endl; + f.close(); + } + + + + // if !isKDE: add the new sub-proj to configure.in + if ( !m_part->isKDE() ) { + QString projroot = m_part->projectDirectory() + "/"; + QString subdirectory = dir.path(); + QString relpath = subdirectory.replace(0, projroot.length(),""); + + QString configureFile = m_part->getAutoConfFile(projroot); + + QStringList list = AutoProjectTool::configureinLoadMakefiles(configureFile); + if ( !list.isEmpty() ) + { + list.push_back( relpath + "/Makefile" ); + AutoProjectTool::configureinSaveMakefiles(configureFile, list); + } + } + +#if 0 + QString relmakefile = (m_subProject->path + "/" + name + "/Makefile").mid(m_part->projectDirectory().length()+1); + kdDebug(9020) << "Relative makefile path: " << relmakefile << endl; + + QString cmdline = "cd "; + cmdline += KProcess::quote(m_part->projectDirectory()); + cmdline += " && automake "; + cmdline += KProcess::quote(relmakefile); + cmdline += " && CONFIG_HEADERS=config.h CONFIG_FILES="; + cmdline += KProcess::quote(relmakefile); + cmdline += " ./config.status"; + + m_part->makeFrontend()->queueCommand( m_part->projectDirectory(), cmdline ); + m_part->makeFrontend()->queueCommand( m_part->projectDirectory(), m_part->configureCommand() ); +#endif + + m_part->needMakefileCvs(); + + QDialog::accept(); +} + +#include "addsubprojectdlg.moc" diff --git a/buildtools/autotools/addsubprojectdlg.h b/buildtools/autotools/addsubprojectdlg.h new file mode 100644 index 00000000..eabfc0e1 --- /dev/null +++ b/buildtools/autotools/addsubprojectdlg.h @@ -0,0 +1,44 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _ADDSUBPROJECTDLG_H_ +#define _ADDSUBPROJECTDLG_H_ + +#include +#include + +#include "addsubprojectdlgbase.h" + +class AutoProjectPart; +class AutoSubprojectView; +class SubprojectItem; + + +class AddSubprojectDialog : public AddSubprojectDlgBase +{ + Q_OBJECT + +public: + AddSubprojectDialog( AutoProjectPart *part, AutoSubprojectView *widget, + SubprojectItem *item, QWidget *parent = 0, const char *name = 0 ); + ~AddSubprojectDialog(); + +private: + virtual void accept(); + + KLineEdit *name_edit; + + SubprojectItem *m_subProject; + AutoSubprojectView *m_subprojectView; + AutoProjectPart *m_part; +}; + +#endif diff --git a/buildtools/autotools/addsubprojectdlgbase.ui b/buildtools/autotools/addsubprojectdlgbase.ui new file mode 100644 index 00000000..b4c762b1 --- /dev/null +++ b/buildtools/autotools/addsubprojectdlgbase.ui @@ -0,0 +1,198 @@ + +AddSubprojectDlgBase + + + AddSubprojectDlgBase + + + + 0 + 0 + 445 + 126 + + + + + 5 + 5 + 0 + 0 + + + + + 32767 + 32767 + + + + + 0 + 0 + + + + Add New Subproject + + + + unnamed + + + + fileGroupBox + + + Subproject + + + + unnamed + + + + Layout3 + + + + unnamed + + + 0 + + + + spStaticLabel + + + + 0 + 5 + 0 + 0 + + + + + 0 + 0 + + + + + + + + Subproject &name: + + + spEdit + + + + + spEdit + + + + 5 + 5 + 0 + 0 + + + + + 0 + 0 + + + + + + + + + + Spacer2 + + + Vertical + + + Expanding + + + + 20 + 16 + + + + + + buttonLayout + + + + unnamed + + + 0 + + + + buttonSpacer + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + createButton + + + &OK + + + true + + + + + cancelButton + + + &Cancel + + + + + + + + spEdit + createButton + cancelButton + + + klineedit.h + kdialog.h + + + + + klineedit.h + + diff --git a/buildtools/autotools/addtargetdlg.cpp b/buildtools/autotools/addtargetdlg.cpp new file mode 100644 index 00000000..b01b5b82 --- /dev/null +++ b/buildtools/autotools/addtargetdlg.cpp @@ -0,0 +1,226 @@ +/*************************************************************************** + * Copyright (C) 2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "addtargetdlg.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "autolistviewitems.h" + +#include "misc.h" +#include "autodetailsview.h" +#include "autoprojectwidget.h" + + +AddTargetDialog::AddTargetDialog(AutoProjectWidget *widget, SubprojectItem *item, + QWidget *parent, const char *name) + : AddTargetDialogBase(parent, name, true) +{ + m_subproject = item; + m_widget = widget; +// m_detailsView = view; + + primary_combo->setFocus(); + primary_combo->insertItem(i18n("Program")); + primary_combo->insertItem(i18n("Library")); + primary_combo->insertItem(i18n("Libtool Library")); + primary_combo->insertItem(i18n("Script")); + primary_combo->insertItem(i18n("Header")); + primary_combo->insertItem(i18n("Data File")); + primary_combo->insertItem(i18n("Java")); + + primaryChanged(); // updates prefix combo + + if (widget->kdeMode()) + ldflagsother_edit->setText("$(all_libraries)"); + + connect( filename_edit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotFileNameChanged (const QString&) ) ); + + setIcon ( SmallIcon ( "targetnew_kdevelop.png" ) ); + + canonicalLabel->setText ( QString::null ); +} + + +AddTargetDialog::~AddTargetDialog() +{} + + +void AddTargetDialog::primaryChanged() +{ + QStringList list; + switch (primary_combo->currentItem()) { + case 0: // Program + list.append("bin"); + list.append("sbin"); + list.append("libexec"); + list.append("pkglib"); + list.append("noinst"); + break; + case 1: // Library + case 2: // Libtool library + list.append("lib"); + list.append("pkglib"); + list.append("noinst"); + if (m_widget->kdeMode()) + list.append("kde_module"); + break; + case 3: // Script + list.append("bin"); + list.append("sbin"); + list.append("libexec"); + list.append("pkgdata"); + list.append("noinst"); + break; + case 4: // Header + list.append("include"); + list.append("oldinclude"); + list.append("pkginclude"); + list.append("noinst"); + break; + case 5: // Data + list.append("bin"); + list.append("sbin"); + list.append("noinst"); + break; + case 6: // Java + list.append("java"); + list.append("noinst"); + break; + } + + prefix_combo->clear(); + + prefix_combo->insertStringList(list); + QStringList prefixes; + QMap::ConstIterator it; + for (it = m_subproject->prefixes.begin(); it != m_subproject->prefixes.end(); ++it) + prefix_combo->insertItem(it.key()); + + // Only enable ldflags stuff for libtool libraries + bool lt = primary_combo->currentItem() == 2; + bool prog = primary_combo->currentItem() == 0; + allstatic_box->setEnabled(lt); + avoidversion_box->setEnabled(lt); + module_box->setEnabled(lt); + noundefined_box->setEnabled(lt); + ldflagsother_edit->setEnabled(lt || prog); +} + + +void AddTargetDialog::accept() +{ + QString name = filename_edit->text().stripWhiteSpace(); + QString prefix = prefix_combo->currentText(); + + QString primary; + switch (primary_combo->currentItem()) { + case 0: primary = "PROGRAMS"; break; + case 1: primary = "LIBRARIES"; break; + case 2: primary = "LTLIBRARIES"; break; + case 3: primary = "SCRIPTS"; break; + case 4: primary = "HEADERS"; break; + case 5: primary = "DATA"; break; + case 6: primary = "JAVA"; break; + default: ; + } + + if (name.isEmpty()) { + KMessageBox::sorry(this, i18n("You have to give the target a name")); + return; + } + +#if 0 + if (primary == "LIBRARIES" && !name.startsWith("lib")) { + KMessageBox::sorry(this, i18n("Libraries must have a lib prefix.")); + return; + } + + if (primary == "LTLIBRARIES" && !name.startsWith("lib")) { + KMessageBox::sorry(this, i18n("Libtool libraries must have a lib prefix.")); + return; + } + + if (primary == "LTLIBRARIES" && name.right(3) != ".la") { + KMessageBox::sorry(this, i18n("Libtool libraries must have a .la suffix.")); + return; + } + +#endif + + if( primary.endsWith("LIBRARIES") && !name.startsWith("lib") && !module_box->isChecked() ) + name.prepend( QString::fromLatin1("lib") ); + + if( primary == "LTLIBRARIES" && !name.endsWith(".la") ) + name.append( QString::fromLatin1(".la") ); + + if ( primary == "LIBRARIES" && !name.endsWith(".a") ) + name.append ( QString::fromLatin1(".a") ); + + QPtrListIterator it(m_subproject->targets); + for (; it.current(); ++it) + if (name == (*it)->name) { + KMessageBox::sorry(this, i18n("A target with this name already exists.")); + return; + } + + QStringList flagslist; + if (primary == "LTLIBRARIES") { + if (allstatic_box->isChecked()) + flagslist.append("-all-static"); + if (avoidversion_box->isChecked()) + flagslist.append("-avoid-version"); + if (module_box->isChecked()) + flagslist.append("-module"); + if (noundefined_box->isChecked()) + flagslist.append("-no-undefined"); + } + flagslist.append(ldflagsother_edit->text()); + QString ldflags = flagslist.join( " " ); + + TargetItem *titem = m_widget->createTargetItem(name, prefix, primary, false); + // m_detailsView->insertItem ( titem ); + m_subproject->targets.append(titem); + + QString canonname = AutoProjectTool::canonicalize(name); + + QMap replaceMap; + + if( primary == "PROGRAMS" || primary == "LIBRARIES" || primary == "LTLIBRARIES" || primary == "DATA" ){ + QString varname = prefix + "_" + primary; + m_subproject->variables[varname] += (" " + name); + replaceMap.insert(varname, m_subproject->variables[varname]); + if ( primary != "DATA" ){ + replaceMap.insert(canonname + "_SOURCES", ""); + } + } + if (primary == "LTLIBRARIES" || primary == "PROGRAMS") + replaceMap.insert(canonname + "_LDFLAGS", ldflags); + + AutoProjectTool::addToMakefileam(m_subproject->path + "/Makefile.am", replaceMap); + + QDialog::accept(); +} + +void AddTargetDialog::slotFileNameChanged ( const QString& text ) +{ + canonicalLabel->setText ( AutoProjectTool::canonicalize ( text ) ); +} + +#include "addtargetdlg.moc" diff --git a/buildtools/autotools/addtargetdlg.h b/buildtools/autotools/addtargetdlg.h new file mode 100644 index 00000000..98708531 --- /dev/null +++ b/buildtools/autotools/addtargetdlg.h @@ -0,0 +1,43 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _ADDTARGETDLG_H_ +#define _ADDTARGETDLG_H_ + +#include "addtargetdlgbase.h" + +class AutoDetailsView; +class AutoProjectWidget; +class SubprojectItem; + + +class AddTargetDialog : public AddTargetDialogBase +{ + Q_OBJECT + +public: + AddTargetDialog( AutoProjectWidget *widget, SubprojectItem *item, + QWidget *parent = 0, const char *name = 0 ); + ~AddTargetDialog(); + +protected slots: + virtual void slotFileNameChanged ( const QString& ); + +private: + virtual void primaryChanged(); + virtual void accept(); + + SubprojectItem *m_subproject; + AutoProjectWidget *m_widget; + AutoDetailsView* m_detailsView; +}; + +#endif diff --git a/buildtools/autotools/addtargetdlgbase.ui b/buildtools/autotools/addtargetdlgbase.ui new file mode 100644 index 00000000..25687563 --- /dev/null +++ b/buildtools/autotools/addtargetdlgbase.ui @@ -0,0 +1,348 @@ + +AddTargetDialogBase + + + add_target_dialog + + + + 0 + 0 + 585 + 356 + + + + Add New Target + + + false + + + + unnamed + + + + groupBox2 + + + &Target + + + + unnamed + + + + primary_label + + + + + + + &Primary: + + + AlignVCenter|AlignRight + + + primary_combo + + + + + primary_combo + + + + + prefix_label + + + + + + + Pre&fix: + + + AlignVCenter|AlignRight + + + prefix_combo + + + + + prefix_combo + + + + + filename_label + + + + + + + File &name: + + + AlignVCenter|AlignRight + + + filename_edit + + + + + filename_edit + + + + + Spacer21 + + + Horizontal + + + Expanding + + + + 246 + 20 + + + + + + canonicalLabel + + + [CANONICALIZED NAME] + + + + + textLabel1 + + + + 1 + + + + + + + image0 + + + + + + + Spacer22 + + + Vertical + + + Fixed + + + + 20 + 20 + + + + + + ldflags_group + + + Linker Flags (&LDFLAGS) + + + + unnamed + + + + allstatic_box + + + Do not link against shared libraries (-all-static) + + + + + avoidversion_box + + + Do not assign version numbers to libraries (-avoid-version) + + + + + module_box + + + Create a library that can be dynamically loaded (-module) + + + + + noundefined_box + + + Library does not depend on external symbols (-no-undefined) + + + + + Layout11_2 + + + + unnamed + + + 0 + + + + ldflagsother_label + + + + + + + Ot&her: + + + ldflagsother_edit + + + + + ldflagsother_edit + + + + + + + + + Layout1 + + + + unnamed + + + 0 + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + okbutton + + + &OK + + + true + + + true + + + + + cancelbutton + + + &Cancel + + + true + + + + + + + + + 789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141ac02ba68c4d4c199b98323631656c62cad8c494891423ce0ee2dc4c6418208bd55a7301009c7f45ef + + + + + okbutton + clicked() + add_target_dialog + accept() + + + cancelbutton + clicked() + add_target_dialog + reject() + + + primary_combo + activated(int) + add_target_dialog + primaryChanged() + + + + primary_combo + prefix_combo + filename_edit + allstatic_box + avoidversion_box + module_box + noundefined_box + ldflagsother_edit + okbutton + cancelbutton + + + kdialog.h + + + primaryChanged() + + + + + ksqueezedtextlabel.h + + diff --git a/buildtools/autotools/addtranslationdlg.cpp b/buildtools/autotools/addtranslationdlg.cpp new file mode 100644 index 00000000..993dee7d --- /dev/null +++ b/buildtools/autotools/addtranslationdlg.cpp @@ -0,0 +1,109 @@ +/*************************************************************************** + * Copyright (C) 2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "addtranslationdlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "misc.h" +#include "autoprojectpart.h" + + +AddTranslationDialog::AddTranslationDialog(AutoProjectPart *part, QWidget *parent, const char *name) + : QDialog(parent, name, true) +{ + setCaption(i18n("Add Translation")); + + m_part = part; + + QHBox *hbox = new QHBox(this); + (void) new QLabel(i18n("Language:"), hbox); + lang_combo = new QComboBox(hbox); + + QVBoxLayout *layout = new QVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint()); + layout->addWidget(hbox); + + QFrame *frame = new QFrame(this); + frame->setFrameStyle(QFrame::HLine | QFrame::Sunken); + layout->addWidget(frame, 0); + + KButtonBox *buttonbox = new KButtonBox(this); + buttonbox->addStretch(); + QPushButton *ok_button = buttonbox->addButton(KStdGuiItem::ok()); + QPushButton *cancel_button = buttonbox->addButton(KStdGuiItem::cancel()); + ok_button->setDefault(true); + connect( ok_button, SIGNAL(clicked()), this, SLOT(accept()) ); + connect( cancel_button, SIGNAL(clicked()), this, SLOT(reject()) ); + buttonbox->layout(); + layout->addWidget(buttonbox, 0); + + QStringList rawlist, list; + rawlist << "af" << "ar" << "bg" << "bo" << "br" << "bs" << "ca" << "cs" << "cy" << "da" + << "de" << "el" << "en_GB" << "eo" << "es" << "et" << "eu" << "fi" << "fr"; + rawlist << "ga" << "gl" << "gu" << "he" << "hi" << "hu" << "id" << "is" << "it" << "ja" + << "km" << "ko" << "lt" << "lv" << "mi" << "mk" << "mr" << "nl" << "no" << "no_NY"; + rawlist << "oc" << "pl" << "pt" << "pt_BR" << "ro" << "ru" << "sk" << "sl" << "sr" << "sv" + << "ta" << "th" << "tr" << "uk" << "wa" << "zh_CN.GB2312" << "zh_TW.Big5"; + + // Remove already added languages + QStringList::ConstIterator it; + for (it = rawlist.begin(); it != rawlist.end(); ++it) { + QFileInfo fi(m_part->projectDirectory() + "/po/" + (*it) + ".po"); + if (!fi.exists()) + list.append(*it); + } + + if (list.isEmpty()) { + KMessageBox::information(this, i18n("Your sourcecode is already translated to all supported languages.")); + ok_button->setEnabled(false); + } + lang_combo->insertStringList(list); +} + + +AddTranslationDialog::~AddTranslationDialog() +{} + + +void AddTranslationDialog::accept() +{ + QString dir = m_part->projectDirectory() + "/po"; + QString fileName = dir + "/" + lang_combo->currentText() + ".po"; + + QFile f(fileName); + if (f.exists()) { + KMessageBox::information(this, i18n("A translation file for the language %1 exists already.")); + return; + } + f.open(IO_WriteOnly); + f.close(); + + dir = m_part->buildDirectory() + "/po"; + m_part->startMakeCommand(dir, QString::fromLatin1("force-reedit")); + + QDialog::accept(); +} + +#include "addtranslationdlg.moc" diff --git a/buildtools/autotools/addtranslationdlg.h b/buildtools/autotools/addtranslationdlg.h new file mode 100644 index 00000000..cd14ddf2 --- /dev/null +++ b/buildtools/autotools/addtranslationdlg.h @@ -0,0 +1,36 @@ +/*************************************************************************** +* Copyright (C) 1999 by Sandy Meier * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _ADDTRANSLATIONDLG_H_ +#define _ADDTRANSLATIONDLG_H_ + +#include + +class QComboBox; +class AutoProjectPart; + + +class AddTranslationDialog : public QDialog +{ + Q_OBJECT + +public: + AddTranslationDialog( AutoProjectPart *part, QWidget *parent = 0, const char *name = 0 ); + ~AddTranslationDialog(); + +private: + virtual void accept(); + + QComboBox *lang_combo; + AutoProjectPart *m_part; +}; + +#endif diff --git a/buildtools/autotools/autodetailsview.cpp b/buildtools/autotools/autodetailsview.cpp new file mode 100644 index 00000000..26255fd3 --- /dev/null +++ b/buildtools/autotools/autodetailsview.cpp @@ -0,0 +1,728 @@ +/* + KDevelop Autotools Support + Copyright (c) 2002 by Victor Roeder + Copyright (c) 2005 by Matt Rogers + + *************************************************************************** + * * + * 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 "autodetailsview.h" + +/** Qt */ +#include +#include +#include +#include +#include + + /** KDE Libs */ +#include +#include +#include +#include +#include +#include +#include + +/** KDevelop */ +#include "kdevappfrontend.h" +#include "kdevcore.h" +#include "kdevmainwindow.h" +#include "kdevpartcontroller.h" +#include "kdevcreatefile.h" +#include "kdevlanguagesupport.h" +#include "kdevmakefrontend.h" +#include "urlutil.h" + +#include "domutil.h" + +#include "targetoptionsdlg.h" +#include "addfiledlg.h" +#include "addicondlg.h" +#include "addexistingfilesdlg.h" +#include "removefiledlg.h" +#include "removetargetdlg.h" + +#include "autolistviewitems.h" +#include "autotoolsaction.h" +#include "autoprojectpart.h" +#include "autoprojectwidget.h" + +#include "subclassesdlg.h" + +AutoDetailsView::AutoDetailsView(AutoProjectWidget* widget, AutoProjectPart* part, QWidget *parent, const char *name) + : AutoProjectViewBase(parent, name) +{ + m_widget = widget; + m_part = part; + + initActions(); + QDomDocument dom = *(m_part->projectDom()); + m_subclasslist = DomUtil::readPairListEntry(dom, "/kdevautoproject/subclassing", + "subclass","sourcefile", "uifile"); + + m_listView->setAllColumnsShowFocus( true ); + m_listView->setRootIsDecorated( true ); + m_listView->setResizeMode( QListView::LastColumn ); + m_listView->addColumn( QString::null ); + m_listView->header()->hide(); + targetOptionsAction->setEnabled( false ); + addNewFileAction->setEnabled( false ); + addExistingFileAction->setEnabled( false ); + buildTargetAction->setEnabled( false ); + executeTargetAction->setEnabled( false ); + removeDetailAction->setEnabled(false); + connect( m_listView, SIGNAL( selectionChanged( QListViewItem* ) ), + this, SLOT( slotSelectionChanged( QListViewItem* ) ) ); + connect( m_listView, SIGNAL( selectionChanged() ), + this, SLOT( slotSelectionChanged( ) ) ); +} + + +AutoDetailsView::~AutoDetailsView() +{ +} + +/** + * If nothing selected, disable all the icons. + */ +void AutoDetailsView::slotSelectionChanged( ){ + + if ( m_listView->selectedItems().isEmpty()){ + targetOptionsAction->setEnabled( false ); + addNewFileAction->setEnabled( false ); + addExistingFileAction->setEnabled( false ); + buildTargetAction->setEnabled( false ); + executeTargetAction->setEnabled( false ); + removeDetailAction->setEnabled(false); + } +} + +/** + * Change the enabled icons depending on what is selected. + * This is never called if nothing is selected.. + * @param item + */ +void AutoDetailsView::slotSelectionChanged( QListViewItem* item ) +{ + bool isTarget = false; + bool isRegularTarget = false; + bool isFile = false; + bool isProgram = false; + + if ( item ) + { + // We assume here that ALL items in the detail list view + // are ProjectItem's + ProjectItem * pvitem = static_cast( item ); + TargetItem* titem = 0; + + if ( pvitem->type() == ProjectItem::File ) + { + titem = static_cast ( pvitem->parent() ); + + QString primary = titem->primary; + if ( primary == "PROGRAMS" || primary == "LIBRARIES" || + primary == "LTLIBRARIES" || primary == "JAVA" ) + { + isRegularTarget = true; // not a data group + isFile = true; + } + } + else + { + titem = static_cast ( pvitem ); + isTarget = true; + } + + QString primary = titem->primary; + if ( primary == "PROGRAMS" || primary == "LIBRARIES" || + primary == "LTLIBRARIES" || primary == "JAVA" ) + { + isRegularTarget = true; // not a data group + } + + if ( primary == "PROGRAMS" ) + isProgram = true; + } + + targetOptionsAction->setEnabled( isRegularTarget && !isFile ); + addNewFileAction->setEnabled( isTarget ); + addExistingFileAction->setEnabled( isTarget ); + removeDetailAction->setEnabled ( true ); + + if ( isRegularTarget && isFile || isRegularTarget ) + { + buildTargetAction->setEnabled ( true ); + if( isProgram ) + executeTargetAction->setEnabled ( true ); + } + else + { + buildTargetAction->setEnabled ( false ); + executeTargetAction->setEnabled ( false ); + } + emit selectionChanged( item ); +} + +void AutoDetailsView::initActions() +{ + KActionCollection * actions = new KActionCollection( this ); + + targetOptionsAction = new AutoToolsAction( i18n( "Options..." ), "configure", 0, + this, SLOT( slotTargetOptions() ), actions, + "target options" ); + targetOptionsAction->setWhatsThis(i18n("Options

Target options dialog that " + "provides settings for linker flags and lists " + "of dependencies and external libraries that " + "are used when compiling the target.")); + targetOptionsAction->plug( m_optionsButton ); + targetOptionsAction->setEnabled( false ); + + QToolTip::add( m_button1, tr2i18n( "Create New File..." ) ); + addNewFileAction = new AutoToolsAction( i18n( "Create New File..." ), "filenew", 0, + this, SLOT( slotAddNewFile() ), actions, + "add new file" ); + addNewFileAction->setWhatsThis(i18n("Create new file

Creates a new file and " + "adds it to a currently selected target.")); + addNewFileAction->plug( m_button1 ); + addNewFileAction->setEnabled( false ); + + QToolTip::add( m_button2, tr2i18n( "Add Existing Files..." ) ); + addExistingFileAction = new AutoToolsAction( i18n( "Add Existing Files..." ), "fileimport", 0, + this, SLOT( slotAddExistingFile() ), actions, + "add existing file" ); + addExistingFileAction->setWhatsThis(i18n("Add existing files

Adds existing " + "file to a currently selected target. Header " + "files will not be included in SOURCES list " + "of a target. They will be added to " + "noinst_HEADERS instead.")); + addExistingFileAction->plug( m_button2 ); + addExistingFileAction->setEnabled( false ); + + addIconAction = new KAction( i18n( "Add Icon..." ), "iconadd_kdevelop", 0, + this, SLOT( slotAddIcon() ), actions, "add icon" ); + addIconAction->setWhatsThis(i18n("Add icon

Adds an icon to a KDEICON target.")); + + QToolTip::add( m_button4, tr2i18n( "Build Target")); + buildTargetAction = new AutoToolsAction( i18n( "Build Target..." ), "launch", 0, + this, SLOT( slotBuildTarget() ), actions, + "build target" ); + buildTargetAction->setWhatsThis(i18n("Build target

Constructs a series of " + "make commands to build the selected target. " + "Also builds dependent targets.")); + buildTargetAction->plug( m_button4 ); + buildTargetAction->setEnabled( false ); + + QToolTip::add( m_button5, tr2i18n( "Execute Target...")); + executeTargetAction = new AutoToolsAction( i18n( "Execute Target..." ), "exec", 0, + this, SLOT( slotExecuteTarget() ), actions, + "execute target" ); + executeTargetAction->setWhatsThis(i18n("Execute target

Executes the target " + "and tries to build in case it is not built.")); + executeTargetAction->plug( m_button5 ); + executeTargetAction->setEnabled( false ); + + setActiveTargetAction = new KAction( i18n( "Make Target Active" ), "", 0, + this, SLOT( slotSetActiveTarget() ), actions, + "set active target" ); + setActiveTargetAction->setWhatsThis(i18n("Make target active

Marks the " + "currently selected target as 'active'. New " + "files and classes by default go to an active " + "target. " + "Using the Build Active Target menu " + "command builds it.")); + + QToolTip::add( m_button3, tr2i18n( "Remove")); + removeDetailAction = new AutoToolsAction( i18n( "Remove" ), "editdelete", 0, this, + SLOT( slotRemoveDetail() ), actions, + "remove detail" ); + removeDetailAction->setWhatsThis(i18n("Remove

Shows a list of targets " + "dependent on the selected target or file and " + "asks for removal. Also asks if the target or " + "file should be removed from disk.")); + removeDetailAction->plug( m_button3 ); + removeDetailAction->setEnabled( false ); + + connect( m_listView, SIGNAL( executed( QListViewItem* ) ), + this, SLOT( slotDetailsExecuted( QListViewItem* ) ) ); + connect( m_listView, SIGNAL( returnPressed( QListViewItem* ) ), + this, SLOT( slotDetailsExecuted( QListViewItem* ) ) ); + connect( m_listView, SIGNAL( contextMenu( KListView*, QListViewItem*, const QPoint& ) ), + this, SLOT( slotDetailsContextMenu( KListView*, QListViewItem*, const QPoint& ) ) ); +} + +QString AutoDetailsView::getUiFileLink(const QString& relpath, const QString& filename) +{ + DomUtil::PairList::iterator it; + + for (it=m_subclasslist.begin(); it != m_subclasslist.end(); ++it) + { + if ((*it).first == QString("/")+relpath+filename) + return (*it).second; + } + + return QString::null; +} + +void AutoDetailsView::slotTargetOptions() +{ + kdDebug( 9020 ) << "AutoDetailsView::slotTargetOptions()" << endl; + TargetItem *titem = dynamic_cast ( m_listView->selectedItem() ); + + if ( !titem ) + return; + + TargetOptionsDialog dlg( m_widget, titem, this, "target options dialog" ); + + dlg.setCaption ( i18n ( "Target Options for '%1'" ).arg ( titem->name ) ); + + dlg.exec(); +} + + +void AutoDetailsView::slotAddNewFile() +{ + TargetItem * titem = dynamic_cast ( m_listView->selectedItem() ); + if ( !titem ) + return; + + KDevCreateFile * createFileSupport = m_part->extension("KDevelop/CreateFile"); + if (createFileSupport) + { + KDevCreateFile::CreatedFile crFile = + createFileSupport->createNewFile(QString::null, + m_widget->selectedSubproject()->path); +/* if (crFile.status == KDevCreateFile::CreatedFile::STATUS_OK) + { + FileItem *fitem = m_widget->createFileItem(crFile.filename, m_widget->selectedSubproject()); + titem->sources.append(fitem); + titem->insertItem(fitem); + emit selectionChanged( titem ); // update list view + }*/ + } else { + AddFileDialog dlg( m_part, m_widget, m_widget->selectedSubproject(), titem, + this, "add file dialog" ); + QString caption; + if ( titem->name.isEmpty() ) + caption = i18n ( "%1 in %2" ).arg ( titem->primary ).arg ( titem->prefix ); + else + caption = titem->name; + + dlg.setCaption ( i18n ( "Add New File to '%1'" ).arg ( caption ) ); + + if ( dlg.exec() ) + emit selectionChanged( titem ); // update list view + } +} + + +void AutoDetailsView::slotAddExistingFile() +{ + TargetItem * titem = dynamic_cast ( m_listView->selectedItem() ); + if ( !titem ) + return; + + AddExistingFilesDialog dlg( m_part, m_widget, m_widget->selectedSubproject(), titem, + this, "add existing files" ); + QString caption; + if ( titem->name.isEmpty() ) + caption = i18n ( "%1 in %2" ).arg ( titem->primary ).arg ( titem->prefix ); + else + caption = titem->name; + + dlg.setCaption( i18n( "Add Existing Files to '%1'" ).arg ( caption ) ); + + dlg.exec(); +} + + +void AutoDetailsView::slotAddIcon() +{ + TargetItem * titem = dynamic_cast ( m_listView->selectedItem() ); + if ( !titem ) + return ; + + AddIconDialog dlg( m_part, m_widget, m_widget->selectedSubproject(), titem, + this, "add icon" ); + dlg.exec(); +} + + +void AutoDetailsView::slotBuildTarget() +{ + ProjectItem * pvitem = dynamic_cast( m_listView->selectedItem() ); + if ( !pvitem ) + return; + + TargetItem* titem = 0; + + if ( pvitem->type() == ProjectItem::File ) + titem = static_cast ( pvitem->parent() ); + else + titem = static_cast ( m_listView->selectedItem() ); + + QString relpath = URLUtil::getRelativePath( m_part->topsourceDirectory(), m_part->projectDirectory() ) + "/" + m_widget->selectedSubproject()->relativePath(); + + m_part->buildTarget(relpath, titem); +} + +void AutoDetailsView::slotExecuteTarget() +{ + ProjectItem * pvitem = dynamic_cast( m_listView->selectedItem() ); + if ( !pvitem ) + return; + + TargetItem* titem = 0; + + if ( pvitem->type() == ProjectItem::File ) + titem = static_cast ( pvitem->parent() ); + else + titem = static_cast ( m_listView->selectedItem() ); + + QString relpath = URLUtil::getRelativePath( m_part->topsourceDirectory(), m_part->projectDirectory() ) + "/" + m_part->activeDirectory(); + m_part->executeTarget(QDir( DomUtil::readEntry( *m_part->projectDom(), "/kdevautoproject/run/cwd/"+titem->name )), titem); +} + +void AutoDetailsView::slotRemoveDetail() +{ + ProjectItem * pvitem = dynamic_cast( m_listView->selectedItem() ); + + if ( pvitem && ( pvitem->type() == ProjectItem::File ) ) + { + FileItem * fitem = static_cast ( m_listView->selectedItem() ); + if(fitem && fitem->is_subst) + { + fitem->changeMakefileEntry(""); + return; + } + + QListViewItem* sibling = fitem->nextSibling(); + + if ( !fitem ) + return; + + TargetItem *titem = static_cast( fitem->parent() ); + + RemoveFileDialog dlg( m_widget, m_part, m_widget->selectedSubproject(), + titem, fitem->text( 0 ), this, "remove file dialog" ); + + QString caption; + if ( titem->name.isEmpty() ) + caption = i18n ( "%1 in %2" ).arg ( titem->primary ).arg ( titem->prefix ); + else + caption = titem->name; + + dlg.setCaption ( i18n ( "Remove File From '%1'" ).arg ( caption ) ); + + if ( dlg.exec() ) + { + emit selectionChanged( titem ); + + if ( sibling) + { + m_listView->setSelected ( sibling, true ); + m_listView->ensureItemVisible ( sibling ); + } + } + + return; + } + + if ( pvitem && ( pvitem->type() == ProjectItem::Target ) ) + { + TargetItem* titem = static_cast ( m_listView->selectedItem() ); + QListViewItem* sibling = titem->nextSibling(); + + if ( !titem ) return; + + bool isactive = ( titem == m_widget->activeTarget() ); + RemoveTargetDialog dlg ( m_widget, m_part, m_widget->selectedSubproject(), + titem, this, "remove target dialog" ); + + dlg.setCaption ( i18n ( "Remove Target From '%1'" ).arg ( m_widget->selectedSubproject()->subdir ) ); + + if ( dlg.exec() ) + { + //details->takeItem ( titem ); + + m_widget->slotOverviewSelectionChanged ( m_widget->selectedSubproject() ); + + if( isactive ) + m_widget->setActiveTarget(""); + if ( sibling) + { + m_listView->setSelected ( sibling, true ); + m_listView->ensureItemVisible ( sibling ); + } + } + + return; + } +} + + +void AutoDetailsView::slotDetailsContextMenu( KListView *, QListViewItem *item, const QPoint &p ) +{ + if ( !item ) + return; + + ProjectItem *pvitem = dynamic_cast( item ); + if ( !pvitem ) + { + kdDebug(9020) << k_funcinfo << "Cast to type of ProjectItem* failed." + << "Details context menu will be empty!"; + return; + } + + if ( pvitem->type() == ProjectItem::Target ) + { + + TargetItem * titem = dynamic_cast( pvitem ); + if ( !titem ) + { + kdDebug(9020) << k_funcinfo << "Unable to populate target item menu" + << " due to failed cast. " << endl; + return; + } + + QString caption; + if ( titem->name.isEmpty() ) + caption = i18n ( "%1 in %2" ).arg ( titem->primary ).arg ( titem->prefix ); + else + caption = titem->name; + + KPopupMenu popup( i18n( "Target: %1" ).arg( caption ), this ); + + if ( titem->primary == "PROGRAMS" || titem->primary == "LIBRARIES" + || titem->primary == "LTLIBRARIES" || titem->primary == "JAVA" ) + { + targetOptionsAction->plug( &popup ); + popup.insertSeparator(); + addNewFileAction->plug( &popup ); + addExistingFileAction->plug( &popup ); + popup.insertSeparator(); + removeDetailAction->plug( &popup ); + popup.insertSeparator(); + setActiveTargetAction->plug( &popup ); + popup.insertSeparator(); + buildTargetAction->plug( &popup ); + if( titem->primary == "PROGRAMS") + executeTargetAction->plug( &popup ); + } + else if ( titem->primary == "KDEDOCS" ) + { + addNewFileAction->plug( &popup ); + addExistingFileAction->plug( &popup ); + popup.insertSeparator(); + removeDetailAction->plug( &popup ); + popup.insertSeparator(); + buildTargetAction->plug( &popup ); + } + else if ( titem->primary == "KDEICON" ) + { + addIconAction->plug( &popup ); + popup.insertSeparator(); + removeDetailAction->plug( &popup ); + } + else + { + addNewFileAction->plug( &popup ); + addExistingFileAction->plug( &popup ); + popup.insertSeparator(); + removeDetailAction->plug( &popup ); + } + + popup.exec( p ); + + } + else if ( pvitem->type() == ProjectItem::File ) + { + + FileItem * fitem = dynamic_cast( pvitem ); + if ( !fitem ) + { + kdDebug(9020) << k_funcinfo << "Unable to populate file item menu" + << " due to failed cast. " << endl; + return; + } + + KPopupMenu popup( i18n( "File: %1" ).arg( fitem->name ), this ); + + removeDetailAction->plug( &popup ); + KURL::List urls; + urls.append(m_widget->selectedSubproject()->path + "/" + fitem->name); + FileContext context(urls); + + int idSubclassWidget = popup.insertItem(SmallIconSet("qmake_subclass"), + i18n("Subclassing Wizard...") ); + popup.setWhatsThis(idSubclassWidget, i18n("Subclass widget

Launches " + "Subclassing wizard. " + "It allows to create a subclass from the " + "class defined in .ui file. " + "There is also possibility to implement " + "slots and functions defined in the base " + "class.")); + int idUISubclasses = popup.insertItem(SmallIconSet("qmake_subclass"), + i18n("List of Subclasses...")); + popup.setWhatsThis(idUISubclasses, i18n("List of subclasses

Shows " + "subclasses list editor. " + "There is possibility to add or remove " + "subclasses from the list.")); + int idUpdateWidgetclass = popup.insertItem(SmallIconSet("qmake_subclass"), + i18n("Edit ui-Subclass...")); + popup.setWhatsThis(idUpdateWidgetclass, i18n("Edit ui-subclass

Launches " + "Subclassing wizard and prompts " + "to implement missing in childclass " + "slots and functions.")); + int idViewUIH = popup.insertItem(SmallIconSet("qmake_ui_h"), + i18n("Open ui.h File")); + popup.setWhatsThis(idViewUIH, i18n("Open ui.h file

Opens .ui.h file " + "associated with the selected .ui.")); + + if (!fitem->name.contains(QRegExp("ui$")) || fitem->is_subst == true) + { + popup.removeItem(idUISubclasses); + popup.removeItem(idViewUIH); + popup.removeItem(idSubclassWidget); + } + + if (fitem->uiFileLink.isEmpty()) + popup.removeItem(idUpdateWidgetclass); + + if(fitem->is_subst == false) + m_part->core()->fillContextMenu( &popup, &context ); + + int r = popup.exec( p ); + + if(r == idViewUIH) + { + m_part->partController()->editDocument(KURL(m_widget->selectedSubproject()->path + + "/" + QString(fitem->name + ".h"))); + } + else if (r == idSubclassWidget) + { + QStringList newFileNames; + newFileNames = m_part->languageSupport()->subclassWidget(m_widget->selectedSubproject()->path + "/" + fitem->name); + if (!newFileNames.empty()) + { + QDomDocument &dom = *(m_part->projectDom()); + for (uint i=0; iprojectDirectory().length()); + QString uifile_relpath = QString(m_widget->selectedSubproject()->path + "/" + fitem->name).remove(0,m_part->projectDirectory().length()); + DomUtil::PairList list = DomUtil::readPairListEntry(dom,"/kdevautoproject/subclassing", + "subclass","sourcefile", "uifile"); + + list << DomUtil::Pair(srcfile_relpath,uifile_relpath); + DomUtil::writePairListEntry(dom, "/kdevautoproject/subclassing", + "subclass", "sourcefile", "uifile", list); + newFileNames[i] = newFileNames[i].replace(QRegExp(m_part->projectDirectory()+"/"),""); + } + m_subclasslist = DomUtil::readPairListEntry(dom,"/kdevautoproject/subclassing", + "subclass","sourcefile", "uifile"); + m_part->addFiles(newFileNames); + } + } + else if (r == idUpdateWidgetclass) + { + QString noext = m_widget->selectedSubproject()->path + "/" + fitem->name; + + if (noext.findRev('.')>-1) + noext = noext.left(noext.findRev('.')); + + QStringList dummy; + QString uifile = fitem->uiFileLink; + + if (uifile.findRev('/')>-1) + { + QStringList uisplit = QStringList::split('/',uifile); + uifile=uisplit[uisplit.count()-1]; + } + + m_part->languageSupport()->updateWidget(m_widget->selectedSubproject()->path + + "/" + uifile, noext); + } + else if (r == idUISubclasses) + { + QDomDocument &dom = *(m_part->projectDom()); + DomUtil::PairList list = DomUtil::readPairListEntry(dom,"/kdevautoproject/subclassing", + "subclass","sourcefile", "uifile"); + SubclassesDlg *sbdlg = new SubclassesDlg( QString(m_widget->selectedSubproject()->path + "/" +fitem->name).remove(0,m_part->projectDirectory().length()), + list, m_part->projectDirectory()); + + if (sbdlg->exec()) + { + QDomElement el = DomUtil::elementByPath( dom, "/kdevautoproject"); + QDomElement el2 = DomUtil::elementByPath( dom, "/kdevautoproject/subclassing"); + if ( (!el.isNull()) && (!el2.isNull()) ) + { + el.removeChild(el2); + } + + DomUtil::writePairListEntry(dom, "/kdevautoproject/subclassing", "subclass", + "sourcefile", "uifile", list); + + m_subclasslist = DomUtil::readPairListEntry(dom,"/kdevautoproject/subclassing", + "subclass","sourcefile", "uifile"); + } + } + } +} + + +void AutoDetailsView::slotDetailsExecuted( QListViewItem *item ) +{ + if ( !item ) + return ; + + ProjectItem *pvitem = static_cast( item ); + if ( pvitem->type() != ProjectItem::File ) + return ; + + if ( !m_widget->selectedSubproject() ) + return; + + QString dirName = m_widget->selectedSubproject()->path; + FileItem *fitem = static_cast( item ); + if(fitem->is_subst) + { + fitem->changeSubstitution(); + return; + } + + m_part->partController()->editDocument( KURL( dirName + "/" + fitem->name ) ); +} + +void AutoDetailsView::slotSetActiveTarget() +{ + TargetItem * titem = static_cast( m_listView->selectedItem() ); + if ( !titem ) return ; + + SubprojectItem * subpitem = m_widget->selectedSubproject(); + if ( !subpitem ) return; + + QString targetPath = subpitem->path + "/" + titem->name; + targetPath = targetPath.mid( m_part->projectDirectory().length() + 1 ); + kdDebug( 9020 ) << "Setting active " << targetPath << endl; + m_widget->setActiveTarget( targetPath ); + QDomDocument &dom = *m_part->projectDom(); + DomUtil::writeEntry( dom, "/kdevautoproject/general/activetarget", targetPath ); +} + +void AutoDetailsView::focusOutEvent(QFocusEvent */*e*/) +{ + m_widget->setLastFocusedView(AutoProjectWidget::DetailsView); +} + +#include "autodetailsview.moc" + +//kate: indent-mode csands; tab-width 4; space-indent off; diff --git a/buildtools/autotools/autodetailsview.h b/buildtools/autotools/autodetailsview.h new file mode 100644 index 00000000..ee67558d --- /dev/null +++ b/buildtools/autotools/autodetailsview.h @@ -0,0 +1,88 @@ +/* + KDevelop Autotools Support + Copyright (c) 2002 by Victor Roeder + Copyright (c) 2005 by Matt Rogers + +*************************************************************************** +* * +* 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. * +* * +*************************************************************************** +*/ + +#ifndef AUTODETAILSVIEW_H +#define AUTODETAILSVIEW_H + +#include "autoprojectviewbase.h" + +#include "domutil.h" +#include "autolistviewitems.h" + +class KAction; + +class AutoProjectPart; +class AutoProjectWidget; +class AutoToolsAction; + +class AutoDetailsView : protected AutoProjectViewBase +{ + friend class RemoveFileDialog; + friend class FileItem; + Q_OBJECT + +public: + AutoDetailsView( AutoProjectWidget* widget, AutoProjectPart* part, QWidget *parent, const char *name ); + virtual ~AutoDetailsView(); + + QString getUiFileLink( const QString &path, const QString& filename ); + KListView* listView() + { + return m_listView; + } + +public slots: + void slotSelectionChanged( QListViewItem* item ); + void slotSelectionChanged(); + +signals: + void selectionChanged( QListViewItem* ); + +protected: + void initActions (); + virtual void focusOutEvent( QFocusEvent *e ); + +private slots: + void slotDetailsExecuted( QListViewItem *item ); + void slotDetailsContextMenu( KListView *, QListViewItem *item, const QPoint &p ); + + void slotTargetOptions (); + void slotAddNewFile(); + void slotAddExistingFile(); + void slotAddIcon(); + void slotBuildTarget(); + void slotExecuteTarget(); + void slotRemoveDetail(); + void slotSetActiveTarget(); + +private: + AutoProjectWidget* m_widget; + AutoProjectPart* m_part; + + DomUtil::PairList m_subclasslist; + + AutoToolsAction* targetOptionsAction; + AutoToolsAction* addNewFileAction; + AutoToolsAction* addExistingFileAction; + KAction* addIconAction; + AutoToolsAction* buildTargetAction; + AutoToolsAction* executeTargetAction; + KAction* setActiveTargetAction; + AutoToolsAction* removeDetailAction; + +}; + +#endif +// kate: indent-mode csands; tab-width 4; 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 +#include +#include + +#include +#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(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(parent()); + + QMap 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(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); + } + } +} diff --git a/buildtools/autotools/autolistviewitems.h b/buildtools/autotools/autolistviewitems.h new file mode 100644 index 00000000..0dece2a2 --- /dev/null +++ b/buildtools/autotools/autolistviewitems.h @@ -0,0 +1,143 @@ +/*************************************************************************** +* 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. * +* * +***************************************************************************/ + +#ifndef AUTOLISTVIEWITEMS_H +#define AUTOLISTVIEWITEMS_H + +#include + +#include + +class TargetItem; +class FileItem; +class AutoProjectPart; + +/** +* Base class for all items appearing in ProjectOverview and ProjectDetails. +*/ +class ProjectItem : public QListViewItem +{ +public: + enum Type { Subproject, Target, File }; + + ProjectItem( Type type, QListView *parent, const QString &text ); + ProjectItem( Type type, ProjectItem *parent, const QString &text ); + + void paintCell( QPainter *p, const QColorGroup &cg, + int column, int width, int alignment ); + void setBold( bool b ) + { + bld = b; + } + bool isBold() const + { + return bld; + } + Type type() + { + return typ; + } + +private: + Type typ; + bool bld; + +}; + + +/** +* Stores the content of one Makefile.am +*/ +class SubprojectItem : public ProjectItem +{ +public: + SubprojectItem( QListView *parent, const QString &text ); + SubprojectItem( SubprojectItem *parent, const QString &text ); + + /** name of the directory */ + QString subdir; + /** absolute path */ + QString path; + /** mapping from prefix to path */ + QMap prefixes; + /** mapping from variable name to value */ + QMap variables; + /** list of targets */ + QPtrList targets; + + QString relativePath(); + +private: + void init(); +}; + + +/** +* Stores one target +* For e.g. the line +* bin_LTLIBRARIES = foo.la +* generates a target with name 'foo.la', primary LTLIBRARIES and prefix 'bin' +* In order to make things not too simple ;-) headers and data are handled +* a bit different from programs, libraries and scripts: All headers for a +* certain prefix (analogously for data) are put in _one_ TargetItem object, +* and the names of the files are put in the sources variable. This avoids +* cluttering the list view with lots of header items. +*/ +class TargetItem : public ProjectItem +{ +public: + //enum TargetKind { Program, Library, DataGroup, IconGroup, DocGroup }; + + TargetItem( QListView *lv, bool group, const QString &text ); + + // Target kind - not used currently + //TargetKind kind; + //! Name of target, e.g. foo + QString name; + //! One of PROGRAMS, LIBRARIES, LTLIBRARIES, SCRIPTS, HEADERS, DATA, JAVA + //! In addition to these automake primaries, we use KDEICON and KDEDOCS + //! for am_edit magic + QString primary; + //! May be bin, pkglib, noinst, check, sbin, pkgdata, java... + QString prefix; + //! Content of foo_SOURCES (or java_JAVA) assignment + QPtrList sources; + //! Content of foo_LDFLAGS assignment + QString ldflags; + //! Content of foo_LDADD assignment + QString ldadd; + //! Content of foo_LIBADD assignment + QString libadd; + //! Content of foo_DEPENDENCIES assignment + QString dependencies; +}; + + +// Not sure if this complexity is really necessary... +class FileItem : public ProjectItem +{ + +public: + FileItem( QListView *lv, const QString &text, bool set_is_subst = false ); + void changeSubstitution(); + void changeMakefileEntry( const QString& ); + + QString name; + QString uiFileLink; + const bool is_subst; +}; + +#endif +// kate: indent-mode csands; tab-width 4; + diff --git a/buildtools/autotools/autoprojectpart.cpp b/buildtools/autotools/autoprojectpart.cpp new file mode 100644 index 00000000..ea0b6896 --- /dev/null +++ b/buildtools/autotools/autoprojectpart.cpp @@ -0,0 +1,1474 @@ +/*************************************************************************** + * Copyright (C) 2001-2002 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * Copyright (C) 2002 by Victor Roeder * + * 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 + +#include "autoprojectpart.h" +#include "autolistviewitems.h" +#include "configureoptionswidget.h" +#include "addtranslationdlg.h" +#include "addicondlg.h" +#include "autoprojectwidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define CONFIGURE_OPTIONS 1 +#define RUN_OPTIONS 2 +#define MAKE_OPTIONS 3 + +static const KDevPluginInfo data("kdevautoproject"); + +K_EXPORT_COMPONENT_FACTORY( libkdevautoproject, AutoProjectFactory( data ) ) + +AutoProjectPart::AutoProjectPart(QObject *parent, const char *name, const QStringList &args) + : KDevBuildTool(&data, parent, name ? name : "AutoProjectPart") + , m_lastCompilationFailed(false) +{ + setInstance(AutoProjectFactory::instance()); + + setXMLFile("kdevautoproject.rc"); + + m_executeAfterBuild = false; + m_isKDE = (args[0] == "kde"); + m_needMakefileCvs = false; + + m_widget = new AutoProjectWidget(this, m_isKDE); + m_widget->setIcon(SmallIcon( info()->icon() )); + m_widget->setCaption(i18n("Automake Manager")); + QWhatsThis::add(m_widget, i18n("Automake manager

" + "The project tree consists of two parts. The 'overview' " + "in the upper half shows the subprojects, each one having a " + "Makefile.am. The 'details' view in the lower half shows the " + "targets and files for the subproject selected in the overview.")); + + mainWindow()->embedSelectViewRight(m_widget, i18n("Automake Manager"), i18n("Automake manager")); + KAction *action; + + action = new KAction( i18n("Add Translation..."), 0, + this, SLOT(slotAddTranslation()), + actionCollection(), "project_addtranslation" ); + action->setToolTip(i18n("Add translation")); + action->setWhatsThis(i18n("Add translation

Creates .po file for the selected language.")); + action->setGroup("autotools"); + + + if (!m_isKDE) + action->setEnabled(false); + + action = new KAction( i18n("&Build Project"), "make_kdevelop", Key_F8, + this, SLOT(slotBuild()), + actionCollection(), "build_build" ); + action->setToolTip(i18n("Build project")); + action->setWhatsThis(i18n("Build project

Runs make from the project directory.
" + "Environment variables and make arguments can be specified " + "in the project settings dialog, Make Options tab.")); + action->setGroup("autotools"); + + action = new KAction( i18n("Build &Active Target"), "make_kdevelop", Key_F7, + this, SLOT(slotBuildActiveTarget()), + actionCollection(), "build_buildactivetarget" ); + action->setToolTip(i18n("Build active target")); + action->setWhatsThis(i18n("Build active target

Constructs a series of make commands to build an active target. " + "Also builds dependent targets.
" + "Environment variables and make arguments can be specified " + "in the project settings dialog, Make Options tab.")); + action->setGroup("autotools"); + + action = new KAction( i18n("Compile &File"), "make_kdevelop", + this, SLOT(slotCompileFile()), + actionCollection(), "build_compilefile" ); + action->setToolTip(i18n("Compile file")); + action->setWhatsThis(i18n("Compile file

Runs make filename.o command from the directory where 'filename' is the name of currently opened file.
" + "Environment variables and make arguments can be specified " + "in the project settings dialog, Make Options tab.")); + action->setGroup("autotools"); + + action = new KAction( i18n("Run Configure"), 0, + this, SLOT(slotConfigure()), + actionCollection(), "build_configure" ); + action->setToolTip(i18n("Run configure")); + action->setWhatsThis(i18n("Run configure

Executes configure with flags, arguments " + "and environment variables specified in the project settings dialog, " + "Configure Options tab.")); + action->setGroup("autotools"); + + action = new KAction( i18n("Run automake && friends"), 0, + this, SLOT(slotMakefilecvs()), + actionCollection(), "build_makefilecvs" ); + action->setToolTip(i18n("Run automake && friends")); + action->setWhatsThis(i18n("Run automake && friends

Executes
make -f Makefile.cvs
./configure
commands from the project directory.")); + action->setGroup("autotools"); + + action = new KAction( i18n("Install"), 0, + this, SLOT(slotInstall()), + actionCollection(), "build_install" ); + action->setToolTip(i18n("Install")); + action->setWhatsThis(i18n("Install

Runs make install command from the project directory.
" + "Environment variables and make arguments can be specified " + "in the project settings dialog, Make Options tab.")); + action->setGroup("autotools"); + + action = new KAction( i18n("Install (as root user)"), 0, + this, SLOT(slotInstallWithKdesu()), + actionCollection(), "build_install_kdesu" ); + action->setToolTip(i18n("Install as root user")); + action->setWhatsThis(i18n("Install

Runs make install command from the project directory with root privileges.
" + "It is executed via kdesu command.
" + "Environment variables and make arguments can be specified " + "in the project settings dialog, Make Options tab.")); + action->setGroup("autotools"); + + action = new KAction( i18n("&Clean Project"), 0, + this, SLOT(slotClean()), + actionCollection(), "build_clean" ); + action->setToolTip(i18n("Clean project")); + action->setWhatsThis(i18n("Clean project

Runs make clean command from the project directory.
" + "Environment variables and make arguments can be specified " + "in the project settings dialog, Make Options tab.")); + action->setGroup("autotools"); + + action = new KAction( i18n("&Distclean"), 0, + this, SLOT(slotDistClean()), + actionCollection(), "build_distclean" ); + action->setToolTip(i18n("Distclean")); + action->setWhatsThis(i18n("Distclean

Runs make distclean command from the project directory.
" + "Environment variables and make arguments can be specified " + "in the project settings dialog, Make Options tab.")); + action->setGroup("autotools"); + + action = new KAction( i18n("Make Messages && Merge"), 0, + this, SLOT(slotMakeMessages()), + actionCollection(), "build_messages" ); + action->setToolTip(i18n("Make messages && merge")); + action->setWhatsThis(i18n("Make messages && merge

Runs make package-messages command from the project directory.
" + "Environment variables and make arguments can be specified " + "in the project settings dialog, Make Options tab.")); + action->setGroup("autotools"); + + if (!m_isKDE) + action->setEnabled(false); + + buildConfigAction = new KSelectAction( i18n("Build Configuration"), 0, + actionCollection(), "project_configuration" ); + buildConfigAction->setToolTip(i18n("Build configuration menu")); + buildConfigAction->setWhatsThis(i18n("Build configuration menu

Allows to switch between project build configurations.
" + "Build configuration is a set of build and top source directory settings, " + "configure flags and arguments, compiler flags, etc.
" + "Modify build configurations in project settings dialog, Configure Options tab.")); + buildConfigAction->setGroup("autotools"); + + QDomDocument &dom = *projectDom(); + if (!DomUtil::readBoolEntry(dom, "/kdevautoproject/run/disable_default")) { + //ok we handle the execute in this kpart + action = new KAction( i18n("Execute Program"), "exec", SHIFT+Key_F9, + this, SLOT(slotExecute()), + actionCollection(), "build_execute" ); + action->setToolTip(i18n("Execute program")); + action->setWhatsThis(i18n("Execute program

Executes the currently active target or the main program specified in project settings, Run Options tab.")); + action->setGroup("autotools"); + } + + connect( buildConfigAction, SIGNAL(activated(const QString&)), + this, SLOT(slotBuildConfigChanged(const QString&)) ); + connect( buildConfigAction->popupMenu(), SIGNAL(aboutToShow()), + this, SLOT(slotBuildConfigAboutToShow()) ); + +// connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)), this, SLOT(projectConfigWidget(KDialogBase*)) ); + + _configProxy = new ConfigWidgetProxy( core() ); + _configProxy->createProjectConfigPage( i18n("Configure Options"), CONFIGURE_OPTIONS, info()->icon() ); + _configProxy->createProjectConfigPage( i18n("Run Options"), RUN_OPTIONS, info()->icon() ); + _configProxy->createProjectConfigPage( i18n("Make Options"), MAKE_OPTIONS, info()->icon() ); + connect( _configProxy, SIGNAL(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )), + this, SLOT(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )) ); + + + connect( makeFrontend(), SIGNAL(commandFinished(const QString&)), + this, SLOT(slotCommandFinished(const QString&)) ); + connect( makeFrontend(), SIGNAL(commandFailed(const QString&)), + this, SLOT(slotCommandFailed(const QString&)) ); + + setWantautotools(); + + +} + + +AutoProjectPart::~AutoProjectPart() +{ + if (m_widget) + { + mainWindow()->removeView(m_widget); + } + delete m_widget; + delete _configProxy; +} + + +void AutoProjectPart::insertConfigWidget( const KDialogBase* dlg, QWidget * page, unsigned int pagenumber ) +{ + switch ( pagenumber ) + { + case CONFIGURE_OPTIONS: + { + ConfigureOptionsWidget *w2 = new ConfigureOptionsWidget(this, page ); + connect( dlg, SIGNAL(okClicked()), w2, SLOT(accept()) ); + } + break; + + case RUN_OPTIONS: + { + QDomDocument &dom = *projectDom(); + if (!DomUtil::readBoolEntry(dom, "/kdevautoproject/run/disable_default")) + { + //ok we handle the execute in this kpart + RunOptionsWidget *w3 = new RunOptionsWidget(*projectDom(), "/kdevautoproject", buildDirectory(), page ); + connect( dlg, SIGNAL(okClicked()), w3, SLOT(accept()) ); + } + } + break; + + case MAKE_OPTIONS: + { + MakeOptionsWidget *w4 = new MakeOptionsWidget(*projectDom(), "/kdevautoproject", page ); + connect( dlg, SIGNAL(okClicked()), w4, SLOT(accept()) ); + } + break; + } +} + +void AutoProjectPart::openProject(const QString &dirName, const QString &projectName) +{ + m_projectName = projectName; + m_projectPath =dirName; + + m_widget->openProject(dirName); + + QDomDocument &dom = *projectDom(); + QString activeTarget = DomUtil::readEntry(dom, "/kdevautoproject/general/activetarget"); + kdDebug(9020) << k_funcinfo << "activeTarget " << activeTarget << endl; + if (!activeTarget.isEmpty()) + m_widget->setActiveTarget(activeTarget); + else + { + KMessageBox::information( m_widget, i18n("No active target specified, running the application will\n" + "not work until you make a target active in the Automake Manager\n" + "on the right side or use the Main Program options under\n" + "Project -> Project Options -> Run Options"), i18n("No active target specified"), "kdevelop_open_project_no_active_target"); + } + + KDevProject::openProject( dirName, projectName ); +} + + +void AutoProjectPart::closeProject() +{ + m_widget->closeProject(); +} + + +QString AutoProjectPart::projectDirectory() const +{ + return m_projectPath; +} + + +QString AutoProjectPart::projectName() const +{ + return m_projectName; +} + + +/** Retuns a PairList with the run environment variables */ +DomUtil::PairList AutoProjectPart::runEnvironmentVars() const +{ + return DomUtil::readPairListEntry(*projectDom(), "/kdevautoproject/run/envvars", "envvar", "name", "value"); +} + + +/** Retuns the currently selected run directory + * If no main Program was selected in the Run Options dialog + * use the currently active target instead to calculate it. + * The returned string can be: + * if /kdevautoproject/run/directoryradio == executable + * The directory where the executable is + * if /kdevautoproject/run/directoryradio == build + * The directory where the executable is relative to build directory + * if /kdevautoproject/run/directoryradio == custom + * The custom directory absolute path + */ +QString AutoProjectPart::runDirectory() const +{ + + QDomDocument &dom = *projectDom(); + + QString cwd; + if( DomUtil::readBoolEntry(dom, "/kdevautoproject/run/useglobalprogram", false) || !m_widget->activeTarget() ) + { + cwd = defaultRunDirectory("kdevautoproject"); + }else + { + cwd = DomUtil::readEntry( dom, "/kdevautoproject/run/cwd/"+m_widget->activeTarget()->name ); + } + if( cwd.isEmpty() ) + cwd = buildDirectory() +"/"+ URLUtil::getRelativePath( topsourceDirectory(), projectDirectory() ) +"/"+m_widget->activeDirectory(); + + return cwd; +} + + +/** Retuns the currently selected main program + * If no main Program was selected in the Run Options dialog + * use the currently active target instead. + * The returned string can be: + * if /kdevautoproject/run/directoryradio == executable + * The executable name + * if /kdevautoproject/run/directoryradio == build + * The path to executable relative to build directory + * if /kdevautoproject/run/directoryradio == custom or relative == false + * The absolute path to executable + */ + +QString AutoProjectPart::mainProgram() const +{ + QDomDocument * dom = projectDom(); + + if ( !dom ) return QString(); + + if( DomUtil::readBoolEntry(*dom, "/kdevautoproject/run/useglobalprogram", false) ) + { + QString DomMainProgram = DomUtil::readEntry(*dom, "/kdevautoproject/run/mainprogram"); + + if ( DomMainProgram.isEmpty() ) return QString(); + + if ( DomMainProgram.startsWith("/") ) // assume absolute path + { + return DomMainProgram; + } + else // assume builddir relative path + { + QString relprojectpath = URLUtil::getRelativePath( topsourceDirectory(), projectDirectory() ); + if( !relprojectpath.isEmpty() ) + relprojectpath = "/" + relprojectpath; + return buildDirectory() + relprojectpath + "/" + DomMainProgram; + } + + } + else // If no Main Program was specified, return the active target + { + TargetItem* titem = m_widget->activeTarget(); + + if ( !titem ) { + KMessageBox::error( m_widget, i18n("There is no active target.\n" + "Unable to determine the main program."), i18n("No active target found") ); + kdDebug ( 9020 ) << k_funcinfo << "Error! : There's no active target! -> Unable to determine the main program in AutoProjectPart::mainProgram()" << endl; + return QString::null; + } + + if ( titem->primary != "PROGRAMS" ) { + KMessageBox::error( m_widget, i18n("Active target \"%1\" is not binary ( %2 ).\n" + "Unable to determine the main program. If you want this\n" + "to be the active target, set a main program under\n" + "Project -> Project Options -> Run Options").arg(titem->name).arg(titem->primary), i18n("Active target is not a library") ); + kdDebug ( 9020 ) << k_funcinfo << "Error! : Active target isn't binary (" << titem->primary << ") ! -> Unable to determine the main program in AutoProjectPart::mainProgram()" << endl; + return QString::null; + } + + QString relprojectpath = URLUtil::getRelativePath( topsourceDirectory(), projectDirectory() ); + if( !relprojectpath.isEmpty() ) + relprojectpath = "/" + relprojectpath; + return buildDirectory() + relprojectpath + "/" + activeDirectory() + "/" + titem->name; + } +} + + +/** Retuns a QString with the debug command line arguments */ +QString AutoProjectPart::debugArguments() const +{ + QDomDocument &dom = *projectDom(); + + if( DomUtil::readBoolEntry(dom, "/kdevautoproject/run/useglobalprogram", false) || !m_widget->activeTarget() ) + { + return DomUtil::readEntry(dom, "/kdevautoproject/run/globaldebugarguments"); + }else + { + return DomUtil::readEntry(dom, "/kdevautoproject/run/debugarguments/" + m_widget->activeTarget()->name); + } +} + + +/** Retuns a QString with the run command line arguments */ +QString AutoProjectPart::runArguments() const +{ + QDomDocument &dom = *projectDom(); + + if( DomUtil::readBoolEntry(dom, "/kdevautoproject/run/useglobalprogram", false) || !m_widget->activeTarget() ) + { + return DomUtil::readEntry(dom, "/kdevautoproject/run/programargs"); + }else + { + return DomUtil::readEntry(dom, "/kdevautoproject/run/runarguments/" + m_widget->activeTarget()->name); + } +} + + +QString AutoProjectPart::activeDirectory() const +{ + return m_widget->activeDirectory(); +} + + +QStringList AutoProjectPart::allFiles() const +{ + return m_widget->allFiles(); +} + + +void AutoProjectPart::setWantautotools() +{ + QDomDocument &dom = *projectDom(); + QDomElement el = DomUtil::elementByPath(dom, "/kdevautoproject/make"); + if ( el.namedItem("envvars").isNull() ) { + DomUtil::PairList list; + list << DomUtil::Pair("WANT_AUTOCONF_2_5", "1"); + list << DomUtil::Pair("WANT_AUTOMAKE_1_6", "1"); + DomUtil::writePairListEntry(dom, "/kdevautoproject/make/envvars", "envvar", "name", "value", list); + } +} + + +QString AutoProjectPart::makeEnvironment() const +{ + // Get the make environment variables pairs into the environstr string + // in the form of: "ENV_VARIABLE=ENV_VALUE" + // Note that we quote the variable value due to the possibility of + // embedded spaces + DomUtil::PairList envvars = + DomUtil::readPairListEntry(*projectDom(), "/kdevautoproject/make/envvars", "envvar", "name", "value"); + + QString environstr; + DomUtil::PairList::ConstIterator it; + for (it = envvars.begin(); it != envvars.end(); ++it) + { + environstr += (*it).first; + environstr += "="; + environstr += EnvVarTools::quote((*it).second); + environstr += " "; + } + + KConfigGroup grp( kapp->config(), "MakeOutputView" ); + if( grp.readBoolEntry( "ForceCLocale", true ) ) + environstr += "LC_MESSAGES="+EnvVarTools::quote("C")+" "+"LC_CTYPE="+EnvVarTools::quote("C")+" "; + + return environstr; +} + + +void AutoProjectPart::addFile(const QString &fileName) +{ + QStringList fileList; + fileList.append ( fileName ); + + this->addFiles ( fileList ); +} + +void AutoProjectPart::addFiles ( const QStringList& fileList ) +{ + QString directory, name; + QStringList::ConstIterator it; + bool messageBoxShown = false; + + for ( it = fileList.begin(); it != fileList.end(); ++it ) + { + int pos = ( *it ).findRev('/'); + if (pos != -1) + { + directory = ( *it ).left(pos); + name = ( *it ).mid(pos+1); + } + else + { + directory = ""; + name = ( *it ); + } + + if (directory != m_widget->activeDirectory() || + directory.isEmpty()) + { + if ( !messageBoxShown ) + { + KMessageBox::information(m_widget, i18n("The directory you selected is not the active directory.\n" + "You should 'activate' the target you're currently working on in Automake Manager.\n" + "Just right-click a target and choose 'Make Target Active'."), + i18n ( "No Active Target Found" ), "No automake manager active target warning" ); + messageBoxShown = true; + } + } + } + + m_widget->addFiles(fileList); +} + +void AutoProjectPart::removeFile(const QString &fileName) +{ + QStringList fileList; + fileList.append ( fileName ); + + this->removeFiles ( fileList ); +} + +void AutoProjectPart::removeFiles ( const QStringList& fileList ) +{ + /// \FIXME m_widget->removeFiles does nothing! + m_widget->removeFiles ( fileList ); + + emit removedFilesFromProject ( fileList ); +} + +QStringList AutoProjectPart::allBuildConfigs() const +{ + QDomDocument &dom = *projectDom(); + + QStringList allConfigs; + allConfigs.append("default"); + + QDomNode node = dom.documentElement().namedItem("kdevautoproject").namedItem("configurations"); + QDomElement childEl = node.firstChild().toElement(); + while (!childEl.isNull()) + { + QString config = childEl.tagName(); + kdDebug(9020) << k_funcinfo << "Found config " << config << endl; + if (config != "default") + allConfigs.append(config); + childEl = childEl.nextSibling().toElement(); + } + + return allConfigs; +} + + +QString AutoProjectPart::currentBuildConfig() const +{ + QDomDocument &dom = *projectDom(); + + QString config = DomUtil::readEntry(dom, "/kdevautoproject/general/useconfiguration"); + if (config.isEmpty() || !allBuildConfigs().contains(config)) + config = "default"; + + return config; +} + + +QString AutoProjectPart::buildDirectory() const +{ + QString prefix = "/kdevautoproject/configurations/" + currentBuildConfig() + "/"; + + QString builddir = DomUtil::readEntry(*projectDom(), prefix + "builddir"); + if (builddir.isEmpty()) + return topsourceDirectory(); + else if (builddir.startsWith("/")) + return builddir; + else + return projectDirectory() + "/" + builddir; +} + +QString AutoProjectPart::topsourceDirectory() const +{ + QString prefix = "/kdevautoproject/configurations/" + currentBuildConfig() + "/"; + + QString topsourcedir = DomUtil::readEntry(*projectDom(), prefix + "topsourcedir"); + if (topsourcedir.isEmpty()) + return projectDirectory(); + else if (topsourcedir.startsWith("/")) + return topsourcedir; + else + return projectDirectory() + "/" + topsourcedir; +} + +QString AutoProjectPart::constructMakeCommandLine(const QString &dir, const QString &target) const +{ + + QString preCommand; + QFileInfo fi1(); + kdDebug(9020) << k_funcinfo << "Looking for Makefile in " << dir << endl; + if ( !QFile::exists(dir + "/GNUmakefile") && !QFile::exists(dir + "/makefile") + && ! QFile::exists(dir + "/Makefile") ) + { + if (!QFile::exists(buildDirectory() + "/configure")) + { + int r = KMessageBox::questionYesNo(m_widget, i18n("%1\nThere is no Makefile in this directory\n" + "and no configure script for this project.\n" + "Run automake & friends and configure first?").arg(buildDirectory()), QString::null, i18n("Run Them"), i18n("Do Not Run")); + if (r == KMessageBox::No) + return QString::null; + preCommand = makefileCvsCommand(); + if (preCommand.isNull()) + return QString::null; + preCommand += " && "; + preCommand += configureCommand() + " && "; + } + else + { + int r = KMessageBox::questionYesNo(m_widget, i18n("%1\nThere is no Makefile in this directory. Run 'configure' first?").arg(dir), QString::null, i18n("Run configure"), i18n("Do Not Run")); + if (r == KMessageBox::No) + return QString::null; + preCommand = configureCommand() + " && "; + } + } + QDomDocument &dom = *projectDom(); + + QString cmdline = DomUtil::readEntry(dom, "/kdevautoproject/make/makebin"); + int prio = DomUtil::readIntEntry(dom, "/kdevautoproject/make/prio"); + QString nice; + kdDebug(9020) << k_funcinfo << "nice = " << prio<< endl; + if (prio != 0) + { + nice = QString("nice -n%1 ").arg(prio); + } + + if (cmdline.isEmpty()) + cmdline = MAKE_COMMAND; + if (!DomUtil::readBoolEntry(dom, "/kdevautoproject/make/abortonerror")) + cmdline += " -k"; + bool runmultiple = DomUtil::readBoolEntry(dom, "/kdevautoproject/make/runmultiplejobs"); + int jobs = DomUtil::readIntEntry(dom, "/kdevautoproject/make/numberofjobs"); + if (runmultiple && jobs != 0) + { + cmdline += " -j"; + cmdline += QString::number(jobs); + } + if (DomUtil::readBoolEntry(dom, "/kdevautoproject/make/dontact")) + cmdline += " -n"; + + cmdline += " "; + cmdline += target; + cmdline.prepend(nice); + cmdline.prepend(makeEnvironment()); + + QString dircmd = "cd "; + dircmd += KProcess::quote(dir); + dircmd += " && "; + + return preCommand + dircmd + cmdline; +} + + +void AutoProjectPart::startMakeCommand(const QString &dir, const QString &target, bool withKdesu) +{ + if (partController()->saveAllFiles()==false) + return; //user cancelled + kdDebug(9020) << "startMakeCommand:" << dir << ": "<< target << endl; + m_buildCommand = constructMakeCommandLine(dir, target); + + if (withKdesu) + m_buildCommand = "kdesu -t -c '" + m_buildCommand + "'"; + + if (!m_buildCommand.isNull()) + makeFrontend()->queueCommand(dir, m_buildCommand); +} + + +/** Adds the make command for the libraries that the target depends on + * to the make frontend queue (this is a recursive function) */ +bool AutoProjectPart::queueInternalLibDependenciesBuild(TargetItem* titem, QStringList& alreadyScheduledDeps) +{ + + QString addstr = (titem->primary == "PROGRAMS")? titem->ldadd : titem->libadd; + QStringList l2 = QStringList::split(QRegExp("[ \t]"), addstr); // list of dependencies + QString tdir; // temp target directory + QString tname; // temp target name + QString tcmd; // temp command line + QStringList::Iterator l2it; + for (l2it = l2.begin(); l2it != l2.end(); ++l2it) + { + QString dependency = *l2it; + if (dependency.startsWith("$(top_builddir)/")) + { + // These are the internal libraries + dependency.remove("$(top_builddir)/"); + + if( !alreadyScheduledDeps.contains(*l2it) ) + { + alreadyScheduledDeps << *l2it; + tdir = buildDirectory(); + if (!tdir.endsWith("/") && !tdir.isEmpty()) + tdir += "/"; + int pos = dependency.findRev('/'); + if (pos == -1) + { + tname = dependency; + } + else + { + tdir += dependency.left(pos+1); + tname = dependency.mid(pos+1); + } + kdDebug(9020) << "Scheduling : <" << tdir << "> target <" << tname << ">" << endl; + // Recursively queue the dependencies for building + SubprojectItem *spi = m_widget->subprojectItemForPath( dependency.left(pos) ); + if (spi) + { + QPtrList< TargetItem > tl = spi->targets; + // Cycle through the list of targets to find the one we're looking for + TargetItem *ti = tl.first(); + do + { + if (ti->name == tname) + { + // found it: queue it and stop looking + if( !queueInternalLibDependenciesBuild(ti, alreadyScheduledDeps) ) + return false; + break; + } + ti = tl.next(); + } + while (ti); + } + + kdDebug(9020) << "queueInternalLibDependenciesBuild:" << tdir << ": "<< tname << endl; + tcmd = constructMakeCommandLine(tdir, tname); + if (!tcmd.isNull()) + { + makeFrontend()->queueCommand( tdir, tcmd); + } + }else + { + //Message box about circular deps. + tdir = buildDirectory(); + if (!tdir.endsWith("/") && !tdir.isEmpty()) + tdir += "/"; + int pos = dependency.findRev('/'); + if (pos == -1) + { + tname = dependency; + } + else + { + tdir += dependency.left(pos+1); + tname = dependency.mid(pos+1); + } + KMessageBox::error( 0, i18n("Found a circular dependency in the project, between this target and %1.\nCannot build this project until this is resolved.").arg(tname), i18n("Circular Dependency found") ); + return false; + } + } + } + return true; +} + + +void AutoProjectPart::slotBuild() +{ + //m_lastCompilationFailed = false; + + if( m_needMakefileCvs ) + { + slotMakefilecvs(); + slotConfigure(); + m_needMakefileCvs = false; + } + + startMakeCommand(buildDirectory(), QString::fromLatin1("")); +} + + +void AutoProjectPart::buildTarget(QString relpath, TargetItem* titem) +{ + + if ( !titem ) + return; + + //m_lastCompilationFailed = false; + + // Calculate the complete name of the target and store it in name + QString name = titem->name; + if ( titem->primary == "KDEDOCS" ) + name = "index.cache.bz2"; + + // Calculate the full path of the target and store it in path + QString path = buildDirectory(); + if (!path.endsWith("/") && !path.isEmpty()) + path += "/"; + if (relpath.at(0) == '/') + path += relpath.mid(1); + else + path += relpath; + + // Save all files once + partController()->saveAllFiles(); + + // Add the make command for the libraries that the target depends on to the make frontend queue + // if this recursive behavour is un-wanted comment the next line + QStringList deps; + if( !queueInternalLibDependenciesBuild(titem, deps) ) + return; + + // Calculate the "make" command line for the target + //QString relpath = dir.path().mid( projectDirectory().length() ); + m_runProg=buildDirectory() + "/" + relpath+"/"+name; + kdDebug(9020) << "buildTarget:" << buildDirectory()<< endl; + kdDebug(9020) << "buildTarget:" << relpath << " " << path << ": "<< name << " : " << m_runProg << endl; + QString tcmd = constructMakeCommandLine( path, name ); + + // Call make + if (!tcmd.isNull()) + { + m_buildCommand = tcmd; + makeFrontend()->queueCommand( path, tcmd); + } +} + + +void AutoProjectPart::slotBuildActiveTarget() +{ + // Get a pointer to the active target + TargetItem* titem = m_widget->activeTarget(); + + if ( !titem ) + return; + + // build it + buildTarget( URLUtil::getRelativePath( topsourceDirectory(), projectDirectory() ) + "/" + activeDirectory(), titem); +} + + +void AutoProjectPart::slotCompileFile() +{ + KParts::ReadWritePart *part = dynamic_cast(partController()->activePart()); + if (!part || !part->url().isLocalFile()) + return; + + QString fileName = part->url().path(); + QFileInfo fi(fileName); + QString sourceDir = fi.dirPath(); + QString baseName = fi.baseName(true); + kdDebug(9020) << "Compiling " << fileName + << " in dir " << sourceDir + << " with baseName " << baseName << endl; + + QString projectDir = projectDirectory(); + if (!sourceDir.startsWith(projectDir)) { + KMessageBox::sorry(m_widget, i18n("Can only compile files in directories which belong to the project.")); + return; + } + + QString buildDir = buildDirectory() + sourceDir.mid(projectDir.length()); + QString target = baseName + ".lo"; + kdDebug(9020) << "builddir " << buildDir << ", target " << target << endl; + + startMakeCommand(buildDir, target); +} + +QString AutoProjectPart::configureCommand() const +{ + QDomDocument &dom = *projectDom(); + QString prefix = "/kdevautoproject/configurations/" + currentBuildConfig() + "/"; + + QString cmdline = "\"" + topsourceDirectory(); + cmdline += "/configure\""; + QString cc = DomUtil::readEntry(dom, prefix + "ccompilerbinary"); + if (!cc.isEmpty()) + cmdline.prepend(QString("CC=%1 ").arg(cc)); + QString cflags = DomUtil::readEntry(dom, prefix + "cflags"); + if (!cflags.isEmpty()) + cmdline.prepend(QString("CFLAGS=\"%1\" ").arg(cflags)); + QString cxx = DomUtil::readEntry(dom, prefix + "cxxcompilerbinary"); + if (!cxx.isEmpty()) + cmdline.prepend(QString("CXX=%1 ").arg(cxx)); + QString cxxflags = DomUtil::readEntry(dom, prefix + "cxxflags"); + if (!cxxflags.isEmpty()) + cmdline.prepend(QString("CXXFLAGS=\"%1\" ").arg(cxxflags)); + QString f77 = DomUtil::readEntry(dom, prefix + "f77compilerbinary"); + if (!f77.isEmpty()) + cmdline.prepend(QString("F77=%1 ").arg(f77)); + QString fflags = DomUtil::readEntry(dom, prefix + "f77flags"); + if (!fflags.isEmpty()) + cmdline.prepend(QString("FFLAGS=\"%1\" ").arg(fflags)); + QString cppflags = DomUtil::readEntry(dom, prefix + "cppflags"); + if (!cppflags.isEmpty()) + cmdline.prepend(QString("CPPFLAGS=\"%1\" ").arg(cppflags)); + QString ldflags = DomUtil::readEntry(dom, prefix + "ldflags"); + if (!ldflags.isEmpty()) + cmdline.prepend(QString("LDFLAGS=\"%1\" ").arg(ldflags)); + + QString configargs = DomUtil::readEntry(dom, prefix + "configargs"); + if (!configargs.isEmpty()) { + cmdline += " "; + cmdline += configargs; + } + + DomUtil::PairList envvars = + DomUtil::readPairListEntry(*projectDom(), prefix + "envvars", "envvar", "name", "value"); + + QString environstr; + DomUtil::PairList::ConstIterator it; + for (it = envvars.begin(); it != envvars.end(); ++it) { + environstr += (*it).first; + environstr += "="; + environstr += EnvVarTools::quote((*it).second); + environstr += " "; + } + cmdline.prepend(environstr); + + QString builddir = buildDirectory(); + QString dircmd; + + // if the build directory doesn't exist, add it's creation to the configureCommand + if ( !QFile::exists(builddir)) { + dircmd = "mkdir "; + dircmd += KProcess::quote(builddir); + dircmd += " && "; + } + + // add "cd into the build directory" to the configureCommand + dircmd += "cd "; + dircmd += KProcess::quote(builddir); + dircmd += " && "; + + return dircmd + cmdline; +} + +void AutoProjectPart::slotConfigure() +{ + QString cmdline = configureCommand(); + if (cmdline.isNull()) + return; + + makeFrontend()->queueCommand(buildDirectory(), cmdline); +} + +QString AutoProjectPart::makefileCvsCommand() const +{ + kdDebug(9020) << "makefileCvsCommand: runDirectory :" << runDirectory() << ":" <queueCommand(projectDirectory(), cmdline); +} + + +void AutoProjectPart::slotInstall() +{ + startMakeCommand(buildDirectory(), QString::fromLatin1("install")); +} + + +void AutoProjectPart::slotInstallWithKdesu() +{ + // First issue "make" to build the entire project with the current user + // This way we make sure all files are up to date before we do the "make install" + slotBuild(); + + // After that issue "make install" with the root user + startMakeCommand(buildDirectory(), QString::fromLatin1("install"), true); +} + + +void AutoProjectPart::slotClean() +{ + startMakeCommand(buildDirectory(), QString::fromLatin1("clean")); +} + + +void AutoProjectPart::slotDistClean() +{ + startMakeCommand(buildDirectory(), QString::fromLatin1("distclean")); +} + + +void AutoProjectPart::slotMakeMessages() +{ + startMakeCommand(buildDirectory(), QString::fromLatin1("package-messages")); +} + + +/** Checks if the currently selected main program or, + * if no main Program was selected in the Run Options dialog, + * the currently active target is up-to-date and builds it if necessary. + * In the end checks if the program is already running and if not calls the + * slotExecute2() function to execute it or asks the user what to do. + */ +void AutoProjectPart::slotExecute() +{ + partController()->saveAllFiles(); + QDomDocument &dom = *projectDom(); + + m_runProg=m_runProg.isEmpty()?mainProgram():m_runProg; + + bool _auto = false; + if( DomUtil::readBoolEntry(dom, "/kdevautoproject/run/autocompile", true) && isDirty() ){ + m_executeAfterBuild = true; + if ( DomUtil::readBoolEntry(dom, "/kdevautoproject/run/useglobalprogram", false) ){ + // A Main Program was specified, build all targets because we don't know which is it + kdDebug(9020) << "slotExecute: before slotBuild" << endl; + slotBuild(); + + } + else{ + // If no Main Program was specified, build the active target + kdDebug(9020) << "slotExecute: before slotBuildActiveTarget" << endl; + slotBuildActiveTarget(); + } + _auto = true; + } + + if( DomUtil::readBoolEntry(dom, "/kdevautoproject/run/autoinstall", false) && isDirty() ){ + m_executeAfterBuild = true; + // Use kdesu?? + if( DomUtil::readBoolEntry(dom, "/kdevautoproject/run/autokdesu", false) ){ + //slotInstallWithKdesu assumes that it hasn't just been build... + kdDebug(9020) << "slotExecute: before startMakeCommand" << endl; + _auto ? slotInstallWithKdesu() : startMakeCommand(buildDirectory(), QString::fromLatin1("install"), true); + } + else{ + kdDebug(9020) << "slotExecute: before slotInstall" << endl; + slotInstall(); + } + _auto = true; + } + + if ( _auto ){ + m_runProg.truncate(0); + return; + } + + if (appFrontend()->isRunning()) { + if (KMessageBox::questionYesNo(m_widget, i18n("Your application is currently running. Do you want to restart it?"), i18n("Application Already Running"), i18n("&Restart Application"), i18n("Do &Nothing")) == KMessageBox::No) + return; + connect(appFrontend(), SIGNAL(processExited()), SLOT(slotExecute2())); + appFrontend()->stopApplication(); + return; + } + kdDebug(9020) << "slotExecute: before slotExecute2" << endl; + slotExecute2(); +} + +void AutoProjectPart::executeTarget(const QDir& dir, const TargetItem* titem) +{ + m_executeAfterBuild=true; + partController()->saveAllFiles(); + + bool is_dirty = false; + QDateTime t = QFileInfo(dir , titem->name ).lastModified(); + QPtrListIterator it( titem->sources ); + for( ; it.current() ; ++it ) + { + if( t < QFileInfo(dir , (*it)->name).lastModified()) + is_dirty = true; + } + + if( DomUtil::readBoolEntry(*projectDom(), "/kdevautoproject/run/autocompile", true) && is_dirty ) + { + connect( makeFrontend(), SIGNAL(commandFinished(const QString&)), this, SLOT(slotExecuteTargetAfterBuild(const QString&)) ); + connect( makeFrontend(), SIGNAL(commandFailed(const QString&)), this, SLOT(slotNotExecuteTargetAfterBuildFailed(const QString&)) ); + + m_runProg=titem->name; + m_executeTargetAfterBuild.first = dir; + m_executeTargetAfterBuild.second = const_cast(titem); + + QString relpath = "/" + URLUtil::getRelativePath( topsourceDirectory(), projectDirectory() ) + "/" + m_widget->selectedSubproject()->subdir; + kdDebug(9020) << "executeTarget: before buildTarget " << relpath << endl; + buildTarget(relpath, const_cast(titem)); + return; + } + + + bool inTerminal = DomUtil::readBoolEntry(*projectDom(), "/kdevautoproject/run/terminal"); + + QString program = environString(); + + if ( !titem ) { + KMessageBox::error( m_widget, i18n("There is no active target.\n" + "Unable to determine the main program"), i18n("No active target found") ); + kdDebug ( 9020 ) << k_funcinfo << "Error! : There's no active target! -> Unable to determine the main program in AutoProjectPart::mainProgram()" << endl; + program += titem->name; + }else if ( titem->primary != "PROGRAMS" ) { + KMessageBox::error( m_widget, i18n("Active target \"%1\" is not binary ( %2 ).\n" + "Unable to determine the main program. If you want this\n" + "to be the active target, set a main program under\n" + "Project -> Project Options -> Run Options").arg(titem->name).arg(titem->primary), i18n("Active target is not a library") ); + kdDebug ( 9020 ) << k_funcinfo << "Error! : Active target isn't binary (" << titem->primary << ") ! -> Unable to determine the main program in AutoProjectPart::mainProgram()" << endl; + program += titem->name; + }else + program += buildDirectory() + "/" + URLUtil::getRelativePath( topsourceDirectory(), projectDirectory() ) + "/" + m_widget->selectedSubproject()->relativePath()+ "/" + titem->name; + + QString args = DomUtil::readEntry(*projectDom(), "/kdevautoproject/run/runarguments/" + titem->name); + + program += " " + args; + kdDebug(9020) << "executeTarget:cmd=" << dir.path() << " " << program << endl; + appFrontend()->startAppCommand(dir.path(), program ,inTerminal); + m_executeAfterBuild=false; + +} + +void AutoProjectPart::slotExecuteTargetAfterBuild(const QString& command) +{ + kdDebug(9020) << "slotExecuteTargetAfterBuild " << command << endl; + if ( m_executeAfterBuild && constructMakeCommandLine(m_executeTargetAfterBuild.first.path(), m_executeTargetAfterBuild.second->name) == command ) + { + disconnect( makeFrontend(), SIGNAL(commandFinished(const QString&)), this, SLOT(slotExecuteAfterTargetBuild()) ); + disconnect( makeFrontend(), SIGNAL(commandFailed(const QString&)), this, SLOT(slotExecuteAfterTargetBuildFailed()) ); + kdDebug(9020) << "slotExecuteTargetAfterBuild " << endl; + executeTarget(m_executeTargetAfterBuild.first, m_executeTargetAfterBuild.second); + } + +} + +void AutoProjectPart::slotNotExecuteTargetAfterBuildFailed(const QString& command) +{ + kdDebug(9020) << "executeTargetAfterBuildFailed" << endl; + if ( constructMakeCommandLine(m_executeTargetAfterBuild.first.path(), m_executeTargetAfterBuild.second->name) == command ) + { + m_executeAfterBuild=false; + disconnect( makeFrontend(), SIGNAL(commandFinished(const QString&)), this, SLOT(slotExecuteTargetAfterBuild()) ); + disconnect( makeFrontend(), SIGNAL(commandFailed(const QString&)), this, SLOT(slotNotExecuteTargetAfterBuildFailed()) ); + } +} + + +/* Get the run environment variables pairs into the environstr string + * in the form of: "ENV_VARIABLE=ENV_VALUE" + * Note that we quote the variable value due to the possibility of + * embedded spaces. */ +QString AutoProjectPart::environString() const +{ + DomUtil::PairList envvars = runEnvironmentVars(); + QString environstr; + DomUtil::PairList::ConstIterator it; + for (it = envvars.begin(); it != envvars.end(); ++it) { + environstr += (*it).first; + environstr += "="; + environstr += EnvVarTools::quote((*it).second); + environstr += " "; + } + return environstr; +} + +/** Executes the currently selected main program. + * If no main Program was selected in the Run Options dialog + * the currently active target is executed instead. + */ +void AutoProjectPart::slotExecute2() +{ + disconnect(appFrontend(), SIGNAL(processExited()), this, SLOT(slotExecute2())); + + if (m_runProg.isEmpty()){ + // Do not execute non executable targets + return; + } + + QString program = environString(); + // Adds the ./ that is necessary to execute the program in bash shells + if (!m_runProg.startsWith("/")){ + program += "./"; + } + program += m_runProg; + program += " " + runArguments(); + + bool inTerminal = DomUtil::readBoolEntry(*projectDom(), "/kdevautoproject/run/terminal"); + + kdDebug(9020) << "slotExecute2: runDirectory: <" << runDirectory() << ">" <" <" <" <" <startAppCommand(runDirectory(), program, inTerminal); + m_executeAfterBuild=false; + m_runProg.truncate(0); +} + + +void AutoProjectPart::slotAddTranslation() +{ + AddTranslationDialog dlg(this, m_widget); + dlg.exec(); +} + + +void AutoProjectPart::slotBuildConfigChanged(const QString &config) +{ + DomUtil::writeEntry(*projectDom(), "/kdevautoproject/general/useconfiguration", config); + kdDebug(9020) << "Changed used configuration to " << config << endl; +} + + +void AutoProjectPart::slotBuildConfigAboutToShow() +{ + QStringList l = allBuildConfigs(); + buildConfigAction->setItems(l); + buildConfigAction->setCurrentItem(l.findIndex(currentBuildConfig())); +} + +void AutoProjectPart::restorePartialProjectSession ( const QDomElement* el ) +{ + m_widget->restoreSession ( el ); +} + +void AutoProjectPart::savePartialProjectSession ( QDomElement* el ) +{ + QDomDocument domDoc = el->ownerDocument(); + + KMessageBox::information ( 0, "Hallo, Welt!" ); + + kdDebug ( 9020 ) << k_funcinfo << "1" << endl; + + if ( domDoc.isNull() ) + { + kdDebug ( 9020 ) << k_funcinfo << "2" << endl; + return; + } + + kdDebug ( 9020 ) << k_funcinfo << "3" << endl; + + m_widget->saveSession ( el ); +} + +void AutoProjectPart::slotCommandFinished( const QString& command ) +{ + kdDebug(9020) << k_funcinfo << endl; + + if( m_buildCommand != command ) + return; + + m_buildCommand = QString::null; + + m_timestamp.clear(); + QStringList fileList = allFiles(); + QStringList::Iterator it = fileList.begin(); + while( it != fileList.end() ){ + QString fileName = *it; + ++it; + + m_timestamp[ fileName ] = QFileInfo( projectDirectory(), fileName ).lastModified(); + } + + emit projectCompiled(); + + // reset the "last compilation has failed" flag + m_lastCompilationFailed = false; + + if( m_executeAfterBuild ){ + slotExecute(); + } +} + +void AutoProjectPart::slotCommandFailed( const QString& /*command*/ ) +{ + kdDebug(9020) << "slotCommandFinished " << k_funcinfo << endl; + + m_lastCompilationFailed = true; + m_executeAfterBuild=false; +} + +bool AutoProjectPart::isDirty() +{ + if (m_lastCompilationFailed) return true; + + QStringList fileList = allFiles(); + QStringList::Iterator it = fileList.begin(); + while( it != fileList.end() ){ + QString fileName = *it; + ++it; + + QMap::Iterator it = m_timestamp.find( fileName ); + QDateTime t = QFileInfo( projectDirectory(), fileName ).lastModified(); + if( it == m_timestamp.end() || *it != t ){ + return true; + } + } + + return false; +} + +void AutoProjectPart::needMakefileCvs( ) +{ + m_needMakefileCvs = true; +} + +bool AutoProjectPart::isKDE() const +{ + return m_isKDE; +} + +KDevProject::Options AutoProjectPart::options() const +{ + return UsesAutotoolsBuildSystem; +} + +QStringList recursiveATFind( const QString &currDir, const QString &baseDir ) +{ + kdDebug(9020) << "Dir " << currDir << endl; + QStringList fileList; + + if( !currDir.contains( "/..") && !currDir.contains("/.") ) + { + QDir dir(currDir); + QStringList dirList = dir.entryList(QDir::Dirs ); + QStringList::Iterator idx = dirList.begin(); + for( ; idx != dirList.end(); ++idx ) + { + fileList += recursiveATFind( currDir + "/" + (*idx),baseDir ); + } + QStringList newFiles = dir.entryList("*.am *.in"); + idx = newFiles.begin(); + for( ; idx != newFiles.end(); ++idx ) + { + QString file = currDir + "/" + (*idx); + fileList.append( file.remove( baseDir ) ); + } + } + + + return fileList; +} + +/*! + \fn AutoProjectPart::distFiles() const + */ +QStringList AutoProjectPart::distFiles() const +{ + QStringList sourceList = allFiles(); + // Scan current source directory for any .pro files. + QString projectDir = projectDirectory(); + QDir dir(projectDir); + QDir admin(projectDir +"/admin"); + QStringList files = dir.entryList( "Makefile.cvs Makefile.am configure* INSTALL README NEWS TODO ChangeLog COPYING AUTHORS stamp-h.in acinclude.m4 config.h.in Makefile.in install-sh config.sub config.guess mkinstalldirs missing ltmain.sh depcomp"); + QStringList adminFiles = admin.entryList(QDir::Files); + QStringList::Iterator idx = adminFiles.begin(); + for( ; idx != adminFiles.end(); ++idx) + { + files.append( "admin/" + (*idx) ); + } + QStringList srcDirs = dir.entryList(QDir::Dirs); + idx = srcDirs.begin(); + for(; idx != srcDirs.end(); ++idx) + { + sourceList += recursiveATFind( projectDirectory() + "/" + (*idx), projectDirectory()); + } + return sourceList + files; +} + +void AutoProjectPart::startSimpleMakeCommand( const QString & dir, const QString & command, bool withKdesu ) +{ + if (partController()->saveAllFiles()==false) + return; //user cancelled + + // m_buildCommand = constructMakeCommandLine(dir, target); + + QString cmdline = command; + cmdline.prepend(makeEnvironment()); + + QString dircmd = "cd "; + dircmd += KProcess::quote(dir); + dircmd += " && "; + + m_buildCommand = dircmd + cmdline; + + if (withKdesu) + m_buildCommand = "kdesu -t -c '" + m_buildCommand + "'"; + + if (!m_buildCommand.isNull()) + makeFrontend()->queueCommand(dir, m_buildCommand); +} + +QString AutoProjectPart::getAutoConfFile(const QString& dir){ + + QFile inFile(dir + "/configure.in"); + QFile acFile(dir + "/configure.ac"); + if ( inFile.exists()){ + return inFile.name(); + }else if (acFile.exists()){ + return acFile.name(); + } + return acFile.name();; +} + +#include "autoprojectpart.moc" + +// kate: space-indent on; indent-width 4; diff --git a/buildtools/autotools/autoprojectpart.h b/buildtools/autotools/autoprojectpart.h new file mode 100644 index 00000000..d0862cc3 --- /dev/null +++ b/buildtools/autotools/autoprojectpart.h @@ -0,0 +1,153 @@ +/*************************************************************************** +* Copyright (C) 2001-2002 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* Copyright (C) 2002 by Victor R�er * +* 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. * +* * +***************************************************************************/ + +#ifndef _AUTOPROJECTPART_H_ +#define _AUTOPROJECTPART_H_ + +#include +#include +#include +#include +#include +#include +#include "kdevbuildtool.h" + +class QDomElement; +class QStringList; +class KDialogBase; +class AutoProjectWidget; +class KSelectAction; +class TargetItem; +class ConfigWidgetProxy; + +class AutoProjectPart : public KDevBuildTool +{ + Q_OBJECT + +public: + AutoProjectPart( QObject *parent, const char *name, const QStringList &args ); + virtual ~AutoProjectPart(); + + /** + * Implementation of the KDevProject interface. + */ + virtual QString projectDirectory() const; + virtual QString projectName() const; + virtual DomUtil::PairList runEnvironmentVars() const; + virtual QString runDirectory() const; + virtual QString mainProgram() const; + virtual QString debugArguments() const; + virtual QString runArguments() const; + virtual QString environString() const; + virtual QString activeDirectory() const; + virtual QStringList allFiles() const; + virtual void addFile( const QString &fileName ); + virtual void addFiles ( const QStringList& fileList ); + virtual void removeFile( const QString &fileName ); + virtual void removeFiles ( const QStringList& fileList ); + virtual QString buildDirectory() const; + virtual Options options() const; + + /** + * Implementation of the KDevPlugin interface. + */ + virtual void restorePartialProjectSession ( const QDomElement* el ); + virtual void savePartialProjectSession ( QDomElement* el ); + + /** + * automake specific methods. + */ + QStringList allBuildConfigs() const; + QString currentBuildConfig() const; + QString topsourceDirectory() const; + void startMakeCommand( const QString &dir, const QString &target, bool withKdesu = false ); + void startSimpleMakeCommand( const QString &dir, const QString &command, bool withKdesu = false ); + void buildTarget( QString relpath, TargetItem* titem ); + void executeTarget( const QDir& dir, const TargetItem* titem ); + + void needMakefileCvs(); + bool isDirty(); + bool isKDE() const; + QStringList distFiles() const; + QString getAutoConfFile(const QString& dir); + +protected: + /** + * Reimplemented from KDevProject. These methods are only + * for use by the application core. + */ + virtual void openProject( const QString &dirName, const QString &projectName ); + virtual void closeProject(); + +private slots: + // void projectConfigWidget(KDialogBase *dlg); + void slotAddTranslation(); + void slotBuild(); + void slotBuildActiveTarget(); + void slotCompileFile(); + void slotClean(); + void slotDistClean(); + void slotInstall(); + void slotInstallWithKdesu(); + void slotMakefilecvs(); + void slotMakeMessages(); + void slotConfigure(); + void slotExecute(); + void slotExecute2(); + void slotExecuteTargetAfterBuild( const QString& command ); + void slotNotExecuteTargetAfterBuildFailed( const QString& command ); + void slotBuildConfigChanged( const QString &config ); + void slotBuildConfigAboutToShow(); + void slotCommandFinished( const QString& command ); + void slotCommandFailed( const QString& command ); + //void slotImportExisting(); + void insertConfigWidget( const KDialogBase* dlg, QWidget * page, unsigned int ); + + +private: + QGuardedPtr m_widget; + QString m_projectName; + QString m_projectPath; + KSelectAction *buildConfigAction; + + QString makeEnvironment() const; + void setWantautotools(); + QString makefileCvsCommand() const; + QString configureCommand() const; + + QMap m_timestamp; + bool m_executeAfterBuild; + QString m_buildCommand; + bool m_needMakefileCvs; + bool m_lastCompilationFailed; + bool m_isKDE; + QPair m_executeTargetAfterBuild; + QString m_runProg; + + ConfigWidgetProxy * _configProxy; + + // Enble AutoProjectWidget to emit our signals + friend class AutoProjectWidget; + friend class AddSubprojectDialog; + friend class FileItem; + + // For make commands queuing + QString constructMakeCommandLine( const QString &dir, const QString &target ) const; + bool queueInternalLibDependenciesBuild( TargetItem* titem, QStringList& list ); +}; + +typedef KDevGenericFactory AutoProjectFactory; + +#endif +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/autoprojectviewbase.ui b/buildtools/autotools/autoprojectviewbase.ui new file mode 100644 index 00000000..ad5142ba --- /dev/null +++ b/buildtools/autotools/autoprojectviewbase.ui @@ -0,0 +1,123 @@ + +AutoProjectViewBase + + + AutoProjectViewBase + + + + 0 + 0 + 245 + 334 + + + + + unnamed + + + 4 + + + + layout3 + + + + unnamed + + + 2 + + + + m_button1 + + + + + + + + m_button2 + + + + + + + + m_button3 + + + + + + + + m_button4 + + + + + + + + m_button5 + + + + + + + + spacer1 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + m_optionsButton + + + + + + Options + + + + + + + m_listView + + + true + + + LastColumn + + + false + + + + + + + klistview.h + + diff --git a/buildtools/autotools/autoprojectwidget.cpp b/buildtools/autotools/autoprojectwidget.cpp new file mode 100644 index 00000000..c3248504 --- /dev/null +++ b/buildtools/autotools/autoprojectwidget.cpp @@ -0,0 +1,748 @@ +/* + KDevelop Autotools Support + Copyright (c) 2001-2002 by Bernd Gehrmann + Copyright (c) 2002 by Victor Roeder + Copyright (c) 2005 by Matt Rogers + + *************************************************************************** + * * + * 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 "autoprojectwidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kdevcore.h" +#include "domutil.h" +#include "misc.h" +#include "choosetargetdialog.h" + +#include "autolistviewitems.h" + +#include "autoprojectpart.h" +#include "autosubprojectview.h" +#include "autodetailsview.h" +#include "urlutil.h" +#include "makefilehandler.h" + +static QString nicePrimary( const QString &primary ) +{ + if ( primary == "PROGRAMS" ) + return i18n( "Program" ); + else if ( primary == "LIBRARIES" ) + return i18n( "Library" ); + else if ( primary == "LTLIBRARIES" ) + return i18n( "Libtool Library" ); + else if ( primary == "SCRIPTS" ) + return i18n( "Script" ); + else if ( primary == "HEADERS" ) + return i18n( "Header" ); + else if ( primary == "DATA" ) + return i18n( "Data" ); + else if ( primary == "JAVA" ) + return i18n( "Java" ); + else + return QString::null; +} + + +AutoProjectWidget::AutoProjectWidget( AutoProjectPart *part, bool kde ) + : QVBox( 0, "auto project widget" ) +{ + m_part = part; + m_kdeMode = kde; + m_activeSubproject = 0; + m_activeTarget = 0; + m_shownSubproject = 0; + m_choosenTarget = 0; + m_makefileHandler = new MakefileHandler(); + + QSplitter *splitter = new QSplitter(Vertical, this); + + initOverview ( splitter ); + initDetailview ( splitter ); + + initActions (); +} + + +AutoProjectWidget::~AutoProjectWidget() +{ + delete m_makefileHandler; +} + +void AutoProjectWidget::initOverview ( QWidget* parent ) +{ + m_subprojectView = new AutoSubprojectView( this, m_part, parent, "project overview widget" ); +} + +void AutoProjectWidget::initDetailview ( QWidget* parent ) +{ + m_detailView = new AutoDetailsView( this, m_part, parent, "project details widget" ); +} + +void AutoProjectWidget::initActions() +{ + connect( m_subprojectView, SIGNAL( selectionChanged( QListViewItem* ) ), + this, SLOT( slotOverviewSelectionChanged( QListViewItem* ) ) ); +} + +AutoSubprojectView* AutoProjectWidget::getSubprojectView () +{ + return m_subprojectView; +} + +AutoDetailsView* AutoProjectWidget::getDetailsView () +{ + return m_detailView; +} + +void AutoProjectWidget::openProject( const QString &dirName ) +{ + m_subprojectView->loadMakefileams ( dirName ); + MakefileHandler mfh; + mfh.parse( m_part->projectDirectory(), true ); + +} + + +void AutoProjectWidget::closeProject() +{ + m_shownSubproject = 0; + m_subprojectView->listView()->clear(); + m_detailView->listView()->clear(); +} + +SubprojectItem* AutoProjectWidget::activeSubproject () +{ + return m_activeSubproject; +} + +TargetItem* AutoProjectWidget::activeTarget () +{ + return m_activeTarget; +} + +QStringList AutoProjectWidget::allSubprojects() +{ + int prefixlen = m_part->projectDirectory().length() + 1; + QStringList res; + + QListViewItemIterator it( m_subprojectView->listView() ); + for ( ; it.current(); ++it ) + { + // Skip root subproject + // if ( it.current() == m_subprojectView->firstChild() ) + // continue; + QString path = static_cast( it.current() ) ->path; + res.append( path.mid( prefixlen ) ); + } + + return res; +} + +QPtrList AutoProjectWidget::allSubprojectItems() +{ + QPtrList res; + + QListViewItemIterator it ( m_subprojectView->listView() ); + + for ( ; it.current(); ++it ) + { + // Skip root subproject + // if ( it.current() == m_subprojectView->firstChild() ) + // continue; + + SubprojectItem* spitem = static_cast ( it.current() ); + res.append ( spitem ); + } + + return res; +} + +SubprojectItem* AutoProjectWidget::subprojectItemForPath(const QString & path, bool pathIsAbsolute) +{ + kdDebug(9020) << "Looking for path " << path << endl; + + int prefixLen = m_part->projectDirectory().length() + 1; + QListViewItemIterator it( m_subprojectView->listView() ); + for(; it.current(); ++it) + { + SubprojectItem* spitem = static_cast(it.current() ); + QString relpath = (spitem->path).mid(prefixLen); + kdDebug(9020) << " ... checking -" << spitem->path << "-" << endl; + kdDebug(9020) << " ... (tailored: -" << relpath << "- against -" << (pathIsAbsolute ? path.mid(prefixLen) : path) << "- )" << endl; + if ( relpath == (pathIsAbsolute ? path.mid(prefixLen) : path)) + { + kdDebug(9020) << "Found it!" << endl; + return spitem; + } + } + kdDebug(9020) << "Not found" << endl; + return NULL; +} + +QString AutoProjectWidget::pathForTarget(const TargetItem *titem) const +{ + + if (!titem) + return QString::null; + + kdDebug(9020) << "Looking for target " << titem->name << endl; + int prefixLen = m_part->projectDirectory().length() + 1; + QListViewItemIterator it( m_subprojectView->listView() ); + for(; it.current(); ++it) + { + SubprojectItem* spitem = static_cast(it.current() ); + kdDebug(9020) << "Checking: " << spitem->path << endl; + if (spitem->targets.containsRef(titem)) + { + kdDebug(9020) << "Found it!" << endl; + QString relpath = (spitem->path).mid(prefixLen); + return relpath; + } + } + kdDebug(9020) << "Not found" << endl; + return QString::null; +} + +QStringList AutoProjectWidget::allLibraries() +{ + int prefixlen = m_part->projectDirectory().length() + 1; + QStringList res; + + QListViewItemIterator it( m_subprojectView->listView() ); + for ( ; it.current(); ++it ) + { + SubprojectItem *spitem = static_cast( it.current() ); + QString path = spitem->path; + QPtrListIterator tit( spitem->targets ); + for ( ; tit.current(); ++tit ) + { + QString primary = ( *tit ) ->primary; + if ( primary == "LIBRARIES" || primary == "LTLIBRARIES" ) + { + QString fullname = path + "/" + ( *tit ) ->name; + res.append( fullname.mid( prefixlen ) ); + } + } + } + + return res; +} + + +QStringList AutoProjectWidget::allFiles() +{ + QPtrStack s; + QMap dict; + + for ( QListViewItem * item = m_subprojectView->listView()->firstChild(); item; + item = item->nextSibling() ? item->nextSibling() : s.pop() ) + { + if ( item->firstChild() ) + s.push( item->firstChild() ); + + SubprojectItem *spitem = static_cast( item ); + // use URLUtil so paths in root project dir are worked out correctly + QString relPath = URLUtil::relativePath(m_part->projectDirectory(), spitem->path, URLUtil::SLASH_SUFFIX); + QPtrListIterator tit( spitem->targets ); + for ( ; tit.current(); ++tit ) + { + QPtrListIterator fit( tit.current() ->sources ); + for ( ; fit.current(); ++fit ) + { + + if((*fit)->is_subst) + continue; + + QFileInfo fileInfo( (*fit)->name ); + if( fileInfo.extension() == "ui" ) + { + dict.insert( relPath + fileInfo.baseName() + ".h", true ); + dict.insert( relPath + fileInfo.baseName() + ".cpp", true ); + } + + dict.insert( relPath + ( *fit ) ->name, true ); + } + } + } + + // Files may be in multiple targets, so we have to remove + // duplicates + QStringList res; + QMap::Iterator it = dict.begin(); + while( it != dict.end() ){ + res << it.key(); + ++it; + } + + return res; +} + + +QString AutoProjectWidget::subprojectDirectory() +{ + if ( !selectedSubproject() ) + return QString::null; + + return selectedSubproject()->path; +} + + +void AutoProjectWidget::setActiveTarget( const QString &targetPath ) +{ + int prefixlen = m_part->projectDirectory().length() + 1; + QString olddir = m_part->activeDirectory(); + m_activeSubproject = 0; + m_activeTarget = 0; + + QListViewItemIterator it( m_subprojectView->listView() ); + for ( ; it.current(); ++it ) + { + SubprojectItem *spitem = static_cast( it.current() ); + QString path = spitem->path; + QPtrListIterator tit( spitem->targets ); + for ( ; tit.current(); ++tit ) + { + QString primary = ( *tit ) ->primary; + if ( primary != "PROGRAMS" && primary != "LIBRARIES" + && primary != "LTLIBRARIES" && primary != "JAVA" ) + continue; + + QString currentTargetPath = ( path + "/" + ( *tit ) ->name ).mid( prefixlen ); + + bool hasTarget = ( targetPath == currentTargetPath ); + ( *tit )->setBold( hasTarget ); + if ( hasTarget ) + { + spitem->setBold( true ); + m_activeSubproject = spitem; + m_activeTarget = ( *tit ); + m_subprojectView->listView()->setSelected( m_activeSubproject, true ); + m_subprojectView->listView()->ensureItemVisible ( m_activeSubproject ); + m_subprojectView->listView()->viewport()->update(); + m_detailView->listView()->setSelected ( m_activeTarget, true ); + m_detailView->listView()->ensureItemVisible ( m_activeTarget ); + m_detailView->listView()->viewport()->update(); + } + else + { + // to avoid a setBold ( false ) if there's another target in the current Subproject (i.e. spitem) ... + spitem->setBold ( ( m_activeSubproject == spitem ) ); + m_detailView->listView()->viewport()->update(); + } + } + } + if( olddir != m_part->activeDirectory() ) + { + emit m_part->activeDirectoryChanged( olddir, m_part->activeDirectory() ); + } + + if ( m_activeSubproject == 0 && m_activeTarget == 0 ) + { + m_subprojectView->listView()->setSelected ( m_subprojectView->listView()->firstChild(), true ); + m_subprojectView->listView()->ensureItemVisible ( m_subprojectView->listView()->firstChild() ); + m_subprojectView->listView()->viewport()->update(); + } +} + + +QString AutoProjectWidget::activeDirectory() +{ + if ( m_activeSubproject ) + return m_activeSubproject->path.mid( m_part->projectDirectory().length() + 1 ); + else + { +/* if ( selectedSubproject() ) + return selectedSubproject()->path; + else*/ + return QString::null; + } +} + + +void AutoProjectWidget::addFiles( const QStringList &list ) +{ + QDomDocument &dom = *m_part->projectDom(); + QStringList fileList = list; + + if ( DomUtil::readBoolEntry( dom, "/kdevautoproject/general/useactivetarget" ) ) + { + QStringList::iterator it; + + QString fileName; + + for ( it = fileList.begin(); it != fileList.end(); ++it ) + { + int pos = ( *it ).findRev('/'); + if (pos != -1) + fileName = ( *it ).mid(pos+1); + else + fileName = ( *it ); + + //FileItem * fitem = createFileItem( fileName,m_activeSubproject ); + //m_activeTarget->sources.append( fitem ); + //m_activeTarget->insertItem( fitem ); + + /// @todo Merge with code in addfiledlg.cpp + // Check wether a selected subproject+target exists and matches this file + // If so use that as target. + if( m_detailView->listView()->selectedItem() && m_subprojectView->listView()->selectedItem() ) + { + TargetItem *titem = dynamic_cast ( m_detailView->listView()->selectedItem() ); + SubprojectItem * subitem = dynamic_cast ( m_subprojectView->listView()->selectedItem() ); + QString relativeDir = URLUtil::directory(*it); + SubprojectItem* spitem = subprojectItemForPath(relativeDir); + + if( titem && subitem && subitem == spitem ) + { + addToTarget(fileName, subitem, titem); + }else + { + addToTarget(fileName, m_activeSubproject, m_activeTarget); + } + }else + { + addToTarget(fileName, m_activeSubproject, m_activeTarget); + } + +// QString canontargetname = AutoProjectTool::canonicalize( m_activeTarget->name ); +// QString varname = canontargetname + "_SOURCES"; +// m_activeSubproject->variables[ varname ] += ( " " + fileName ); +// +// QMap replaceMap; +// replaceMap.insert( varname, m_activeSubproject->variables[ varname ] ); +// +// AutoProjectTool::addToMakefileam( m_activeSubproject->path + "/Makefile.am", replaceMap ); + } + + emitAddedFiles ( list ); + } + else + { + QStringList doManually, doneAutomatically; + // First check wether the detail view has a selected target and the subproject + // view selected subproject matches the path of the new file. Then + // we can assume the user used the right-click option on the target + for( QStringList::iterator it = fileList.begin(); it != fileList.end(); ++it) + { + bool autoAdded = false; + if( m_detailView->listView()->selectedItem() && m_subprojectView->listView()->selectedItem() ) + { + TargetItem *titem = dynamic_cast ( m_detailView->listView()->selectedItem() ); + SubprojectItem * subitem = dynamic_cast ( m_subprojectView->listView()->selectedItem() ); + QString relativeDir = URLUtil::directory(*it); + SubprojectItem* spitem = subprojectItemForPath(relativeDir); + if( titem && subitem && subitem == spitem ) + { + addToTarget(URLUtil::filename(*it), subitem, titem); + autoAdded = true; + doneAutomatically << *it; + } + } + if(!autoAdded) doManually << *it; + } + + // See if we can figure out the target for each file without asking the user + // I think it's a valid assumption that if a directory contains only one target + // the file can be added to that target (Julian Rockey linux at jrockey.com) + QStringList temp = doManually; + doManually.clear(); + for(QStringList::iterator it = temp.begin();it!=temp.end();++it) + { + bool autoAdded = false; + QString relativeDir = URLUtil::directory(*it); + SubprojectItem* spitem = subprojectItemForPath(relativeDir); + if (spitem) + { + QPtrList titemList = spitem->targets; + if (titemList.count()==1) { + addToTarget( URLUtil::filename(*it), spitem, titemList.first() ); + doneAutomatically.append(*it); + autoAdded = true; + } + } + + // add to manual list if this file wasn't auto-added + if (!autoAdded) doManually.append(*it); + } + if (doneAutomatically.count()>0) emitAddedFiles(doneAutomatically); + + // raise dialog for any files that weren't added automatically + if (doManually.count()>0) { + ChooseTargetDialog chooseTargetDlg ( this, m_part, doManually, this, "choose target dialog" ); + + //chooseTargetDlg = new ChooseTargetDialog ( this, this, "choose target dialog" ); + + if ( chooseTargetDlg.exec() && chooseTargetDlg.alwaysUseActiveTarget() ) + DomUtil::writeBoolEntry( dom, "/kdevautoproject/general/useactivetarget", true ); + } + } +} + +void AutoProjectWidget::addToTarget(const QString & fileName, SubprojectItem* spitem, TargetItem* titem) +{ + QString varname; + /// \FIXME a quick hack to prevent adding header files to _SOURCES and display them in noinst_HEADERS + if (AutoProjectPrivate::isHeader(fileName) && + ( titem->primary == "PROGRAMS" || titem->primary == "LIBRARIES" || titem->primary == "LTLIBRARIES" ) ) + { + kdDebug ( 9020 ) << "Ignoring header file and adding it to noinst_HEADERS: " << fileName << endl; + TargetItem* noinst_HEADERS_item = getSubprojectView()->findNoinstHeaders(spitem); + FileItem *fitem = createFileItem( fileName, spitem ); + noinst_HEADERS_item->sources.append( fitem ); + noinst_HEADERS_item->insertItem( fitem ); + varname = "noinst_HEADERS"; + } + else + { + FileItem * fitem = createFileItem( fileName, spitem ); + titem->sources.append( fitem ); + titem->insertItem( fitem ); + + QString canontargetname = AutoProjectTool::canonicalize( titem->name ); + varname = canontargetname + "_SOURCES"; + } + spitem->variables[ varname ] += ( " " + fileName ); + + QMap replaceMap; + replaceMap.insert( varname, spitem->variables[ varname ] ); + + AutoProjectTool::addToMakefileam( spitem->path + "/Makefile.am", replaceMap ); + + m_detailView->slotSelectionChanged( spitem ); +} + +void AutoProjectWidget::removeFiles( const QStringList &list ) +{ + Q_UNUSED( list ) +} + +void AutoProjectWidget::slotOverviewSelectionChanged( QListViewItem *item ) +{ + if ( !item ) + return; + + // Delete the items from the details view first. + if ( m_shownSubproject ) + { + // Remove all TargetItems and all of their children from the view + kdDebug ( 9020 ) << "m_shownSubproject (before takeItem()): " << m_shownSubproject->subdir << endl; + + QListViewItem* i = m_detailView->listView()->firstChild(); + while( i ) + { + QListViewItem* o = i; + i = i->nextSibling(); + m_detailView->listView()->takeItem(o); + } + } + + // We assume here that ALL items in the over list view + // are SubprojectItem's + m_shownSubproject = dynamic_cast( item ); + if ( !m_shownSubproject) return; + kdDebug ( 9020 ) << "m_shownSubproject (after takeItem()): " << selectedSubproject()->subdir << endl; + + // Insert all TargetItems and all of their children into the view + QPtrListIterator it2( selectedSubproject()->targets ); + for ( ; it2.current(); ++it2 ) + { + kdDebug ( 9020 ) << "insertItem in detail " << ( *it2 )->name << endl; + m_detailView->listView()->insertItem( *it2 ); + QPtrListIterator it3( ( *it2 ) ->sources ); + for ( ; it3.current(); ++it3 ) + ( *it2 )->insertItem( *it3 ); + QString primary = ( *it2 ) ->primary; + if ( primary == "PROGRAMS" || primary == "LIBRARIES" || + primary == "LTLIBRARIES" || primary == "JAVA" ) + ( *it2 ) ->setOpen( true ); + } +} + +TargetItem *AutoProjectWidget::selectedTarget() +{ + ProjectItem * pvitem = static_cast( m_detailView->listView()->selectedItem() ); + if ( !pvitem || ( pvitem->type() != ProjectItem::Target ) ) + return 0; + + return static_cast( pvitem ); +} + + +FileItem *AutoProjectWidget::selectedFile() +{ + ProjectItem * pvitem = static_cast( m_detailView->listView()->selectedItem() ); + if ( !pvitem || ( pvitem->type() != ProjectItem::File ) ) + return 0; + + return static_cast( pvitem ); +} + +SubprojectItem* AutoProjectWidget::selectedSubproject() +{ + ProjectItem * pvitem = static_cast ( m_subprojectView->listView()->selectedItem() ); + + if ( !pvitem || ( pvitem->type() != ProjectItem::Subproject ) ) + return 0; + + return static_cast ( pvitem ); +} + +TargetItem *AutoProjectWidget::createTargetItem( const QString &name, + const QString &prefix, const QString &primary, + bool take ) +{ + bool docgroup = ( primary == "KDEDOCS" ); + bool icongroup = ( primary == "KDEICON" ); + bool group = !(docgroup || icongroup); + + QString text; + if ( docgroup ) + text = i18n( "Documentation data" ); + else if ( icongroup ) + text = i18n( "KDE Icon data" ).arg( prefix ); + else + text = i18n( "%1 (%2 in %3)" ).arg( name ).arg( nicePrimary( primary ) ).arg( prefix ); + + // Workaround because of QListView not being able to create + // items without actually inserting them + TargetItem *titem = new TargetItem( m_detailView->listView(), group, text ); + titem->name = name; + titem->prefix = prefix; + titem->primary = primary; + if( take ) + m_detailView->listView()->takeItem( titem ); + + return titem; +} + + +FileItem *AutoProjectWidget::createFileItem( const QString &name, SubprojectItem *subproject ) +{ + bool is_subst; + if(name.find("$(") == 0 || name.find("${") == 0) + is_subst = true; + else + is_subst = false; + + FileItem * fitem = new FileItem( m_subprojectView->listView(), name, is_subst ); + fitem->uiFileLink = m_detailView->getUiFileLink(subproject->relativePath()+"/", name ); + m_subprojectView->listView()->takeItem( fitem ); + fitem->name = name; + + return fitem; +} + + +void AutoProjectWidget::emitAddedFiles( const QStringList &fileList ) +{ + emit m_part->addedFilesToProject( fileList ); +} + +void AutoProjectWidget::emitAddedFile( const QString &name ) +{ + QStringList fileList; + fileList.append ( name ); + emit m_part->addedFilesToProject( fileList ); +} + +void AutoProjectWidget::emitRemovedFiles( const QStringList &fileList ) +{ + emit m_part->removedFilesFromProject( fileList ); +} + +void AutoProjectWidget::emitRemovedFile( const QString &name ) +{ + QStringList fileList; + fileList.append ( name ); + emit m_part->removedFilesFromProject( fileList ); +} + +void AutoProjectWidget::restoreSession ( const QDomElement* el ) +{ + Q_UNUSED( el ); +} + +void AutoProjectWidget::saveSession ( QDomElement* el ) +{ + if ( m_activeTarget && m_activeSubproject ) + { + QDomDocument domDoc = el->ownerDocument(); + + QString activeTargetPath = m_activeSubproject->path.mid ( m_part->project()->projectDirectory().length() + 1 ); + activeTargetPath = activeTargetPath + "/" + m_activeTarget->name; + + QDomElement generalEl = domDoc.createElement("general"); + + kdDebug ( 9020 ) << k_funcinfo << "Saving session data of AutoProjectWidget: " << activeTargetPath << endl; + + generalEl.setAttribute("activetarget", activeTargetPath); + el->appendChild(generalEl); + } +} + +void AutoProjectWidget::setActiveSubproject( SubprojectItem * spitem ) +{ + QString olddir = m_part->activeDirectory(); + m_activeSubproject = spitem; + emit m_part->activeDirectoryChanged( olddir, m_part->activeDirectory() ); +} + +void AutoProjectWidget::focusInEvent( QFocusEvent */*e*/ ) +{ + switch (m_lastFocusedView) + { + case DetailsView: + m_detailView->listView()->setFocus(); + break; + case SubprojectView: + default: + m_subprojectView->listView()->setFocus(); + } +} + +void AutoProjectWidget::setLastFocusedView( AutoProjectView view ) +{ + m_lastFocusedView = view; +} + +#include "autoprojectwidget.moc" + +MakefileHandler* AutoProjectWidget::makefileHandler() +{ + return m_makefileHandler; +} +//kate: indent-mode csands; tab-width 4; space-indent off; + diff --git a/buildtools/autotools/autoprojectwidget.h b/buildtools/autotools/autoprojectwidget.h new file mode 100644 index 00000000..0f4a8b13 --- /dev/null +++ b/buildtools/autotools/autoprojectwidget.h @@ -0,0 +1,229 @@ +/* + KDevelop Autotools Support + Copyright (c) 2001-2002 by Bernd Gehrmann + Copyright (c) 2002 by Victor Roeder + Copyright (c) 2005 by Matt Rogers + +*************************************************************************** +* * +* 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. * +* * +*************************************************************************** +*/ + +#ifndef _AUTOPROJECTWIDGET_H_ +#define _AUTOPROJECTWIDGET_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "domutil.h" +#include "makefilehandler.h" + +class AutoProjectPart; +class AutoSubprojectView; +class AutoDetailsView; +class SubprojectItem; +class TargetItem; +class FileItem; +class KAction; +class QDomElement; +class QToolButton; +class QStringList; +class QFocusEvent; +class KListViewItem; +class QListViewItem; +class MakefileHandler; + +class AutoProjectWidget : public QVBox +{ + Q_OBJECT + friend class RemoveFileDialog; + friend class TargetOptionsDialog; // to access projectDom() via m_part->projectDom() +public: + AutoProjectWidget( AutoProjectPart *part, bool kde ); + ~AutoProjectWidget(); + + void openProject( const QString &dirName ); + void closeProject(); + + /** + * A list of the (relative) names of all subprojects (== subdirectories) + */ + QStringList allSubprojects(); + /** + * A list of all Subproject items in the overview KListView + */ + QPtrList allSubprojectItems(); + /** + * A list of the (relative) names of all libraries + */ + QStringList allLibraries(); + /** + * A list of all files that belong to the project + **/ + QStringList allFiles(); + /** + * The top level directory of the project. + **/ + QString projectDirectory() const; + /** + * The directory of the currently shown subproject. + */ + QString subprojectDirectory(); + /** + * Are we in KDE mode? + */ + bool kdeMode() const + { + return m_kdeMode; + } + + /** + * Sets the given target active. The argument is given + * relative to the project directory. + */ + void setActiveTarget( const QString &targetPath ); + /** + * Returns the active target as path relative to + * the project directory. + */ + QString activeDirectory(); + + /** + * Adds a file to the active target. + * If the file does not contain a "/" character, it is added + * to the active target. + * If it does contain "/" character(s), ... @todo .. add to appropriate target + */ + void addFiles( const QStringList &list ); + /** + * Removes the file fileName from the directory directory. + * (not implemented currently) + */ + void removeFiles( const QStringList &list ); + + /** + * Returns the currently selected target. Returns 0 if + * no target is selected. + */ + TargetItem *selectedTarget(); + + /** + * Returns the currently selected file. Returns 0 if + * no file is selected. + */ + FileItem *selectedFile(); + + /** + * Returns the currently selected subproject (directory with Makefile.am). Returns 0 if + * no subproject is selected. + */ + SubprojectItem* selectedSubproject(); + + /** + * Creates a TargetItem instance without a parent item. + */ + TargetItem *createTargetItem( const QString &name, + const QString &prefix, const QString &primary, + bool take = true ); + /** + * Creates a FileItem instance without a parent item. + */ + FileItem *createFileItem( const QString &name, SubprojectItem *subproject ); + + /** + * Returns the Subproject that contains the Active Target. The Active Target is a special target + * to which e.g. all files are added to. + */ + SubprojectItem* activeSubproject (); + void setActiveSubproject( SubprojectItem* spitem ); + + /** + * Returns the Active Target. The Active Target is a special target + * to which e.g. all files are added to. + */ + TargetItem* activeTarget(); + + /** + * Returns the sub project item, if any, for a given path. The path supplied can be either + * absolute, or relative to the project directory. If no subproject item is found for the + * path, null is returned. + */ + SubprojectItem* subprojectItemForPath( const QString & path, bool pathIsAbsolute = false ); + + /** + * Returns the projectdir-relative path for a target item + */ + QString pathForTarget( const TargetItem *item ) const; + + /** + * Adds file fileName to target titem in subproject spitem + */ + void addToTarget( const QString & fileName, SubprojectItem* spitem, TargetItem* titem ); + + /** + * Restores the last settings of the AutoProjectWidget + */ + void restoreSession ( const QDomElement* el ); + + /** + * Saves the latest changes of the AutoProjectWidget to the session file. + */ + void saveSession ( QDomElement* el ); + + AutoSubprojectView* getSubprojectView (); + AutoDetailsView* getDetailsView (); + + + void emitAddedFile ( const QString& name ); + void emitAddedFiles( const QStringList &fileList ); + void emitRemovedFile ( const QString& name ); + void emitRemovedFiles( const QStringList &fileList ); + + void parse( SubprojectItem *item ); + + enum AutoProjectView { SubprojectView, DetailsView }; + void setLastFocusedView( AutoProjectView view ); + + MakefileHandler* makefileHandler(); + +public slots: + void slotOverviewSelectionChanged( QListViewItem *item ); + +protected: + void initOverview ( QWidget* parent ); + void initDetailview ( QWidget* parent ); + void initActions (); + + virtual void focusInEvent( QFocusEvent *e ); + +private: + + AutoSubprojectView* m_subprojectView; + AutoDetailsView* m_detailView; + + bool m_kdeMode; + AutoProjectPart *m_part; + SubprojectItem *m_activeSubproject; + TargetItem *m_activeTarget; + TargetItem *m_choosenTarget; + SubprojectItem *m_shownSubproject; + + AutoProjectView m_lastFocusedView; + + MakefileHandler *m_makefileHandler; +}; + +#endif +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/autosubprojectview.cpp b/buildtools/autotools/autosubprojectview.cpp new file mode 100644 index 00000000..efa3a358 --- /dev/null +++ b/buildtools/autotools/autosubprojectview.cpp @@ -0,0 +1,1137 @@ +/* + KDevelop Autotools Support + Copyright (c) 2002 by Victor Roeder + Copyright (c) 2005 by Matt Rogers + + *************************************************************************** + * * + * 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. * + * * + *************************************************************************** +*/ + +/** Qt */ +#include +#include +#include +#include +#include + +/** KDE Libs */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** KDevelop */ +#include +#include +#include +#include +#include + +/** AutoProject */ +#include "subprojectoptionsdlg.h" +#include "addsubprojectdlg.h" +#include "addtargetdlg.h" +#include "addservicedlg.h" +#include "addapplicationdlg.h" +#include "addexistingdirectoriesdlg.h" +#include "autolistviewitems.h" +#include "autoprojectwidget.h" +#include "autoprojectpart.h" +#include "autosubprojectview.h" +#include "autotoolsaction.h" +#include "removesubprojectdialog.h" +#include "managecustomcommand.h" + +namespace AutoProjectPrivate +{ + +bool isHeader( const QString& fileName ) +{ + return QStringList::split( ";", "h;H;hh;hxx;hpp;tcc;h++" ).contains( QFileInfo(fileName).extension(false) ); +} + +static QString cleanWhitespace( const QString &str ) +{ + QString res; + + QStringList l = QStringList::split( QRegExp( "[ \t]" ), str ); + QStringList::ConstIterator it; + for ( it = l.begin(); it != l.end(); ++it ) + { + res += *it; + res += " "; + } + + return res.left( res.length() - 1 ); +} + +static void removeDir( const QString& dirName ) +{ + QDir d( dirName ); + const QFileInfoList* fileList = d.entryInfoList(); + if( !fileList ) + return; + + QFileInfoListIterator it( *fileList ); + while( it.current() ){ + const QFileInfo* fileInfo = it.current(); + ++it; + + if( fileInfo->fileName() == "." || fileInfo->fileName() == ".." ) + continue; + + if( fileInfo->isDir() && !fileInfo->isSymLink() ) + removeDir( fileInfo->absFilePath() ); + + kdDebug(9020) << "remove " << fileInfo->absFilePath() << endl; + d.remove( fileInfo->fileName(), false ); + } + + kdDebug(9020) << "remove dir " << dirName << endl; + d.rmdir( d.absPath(), true ); +} + +} + + +AutoSubprojectView::AutoSubprojectView(AutoProjectWidget* widget, AutoProjectPart* part, QWidget *parent, const char *name) +: AutoProjectViewBase(parent, name) +{ + + m_widget = widget; + m_part = part; + + m_listView->setSorting(-1); + m_listView->header()->hide(); + m_listView->addColumn( QString::null ); + + connect( m_listView, SIGNAL( selectionChanged( QListViewItem* ) ), + this, SLOT( slotSelectionChanged( QListViewItem* ) ) ); + + initActions(); +} + + +AutoSubprojectView::~AutoSubprojectView() +{ +} + +void AutoSubprojectView::slotSelectionChanged( QListViewItem* item ) +{ + if ( m_listView->selectedItems().count() <= 0 ) + { + subProjectOptionsAction->setEnabled( false ); + addSubprojectAction->setEnabled( false ); + addTargetAction->setEnabled( false ); + addServiceAction->setEnabled( false ); + addApplicationAction->setEnabled( false ); + buildSubprojectAction->setEnabled( false ); + } + else + { + subProjectOptionsAction->setEnabled( true ); + addSubprojectAction->setEnabled( true ); + addTargetAction->setEnabled( true ); + addServiceAction->setEnabled( true ); + addApplicationAction->setEnabled( true ); + buildSubprojectAction->setEnabled( true ); + } + + emit selectionChanged( item ); +} + +void AutoSubprojectView::loadMakefileams ( const QString& dir ) +{ + SubprojectItem * item = new SubprojectItem( m_listView, m_part->projectName() ); + item->setPixmap ( 0, SmallIcon ( "kdevelop" ) ); + item->subdir = "/"; + item->path = dir; + parse( item ); + item->setOpen( true ); + + //setSelected( item, true ); + + expandCollapseFirst( m_listView->firstChild(), false ); +} + + +void AutoSubprojectView::initActions() +{ + KActionCollection * actions = new KActionCollection( this ); + + subProjectOptionsAction = new AutoToolsAction( i18n( "Options..." ), "configure", 0, + this, SLOT( slotSubprojectOptions() ), actions, "subproject options" ); + subProjectOptionsAction->setWhatsThis(i18n("Options

Shows subproject options dialog " + "that provides settings for compiler, include paths, " + "prefixes and build order.")); + subProjectOptionsAction->plug( m_optionsButton ); + + QToolTip::add( m_button1, tr2i18n( "Add new subproject...")); + addSubprojectAction = new AutoToolsAction( i18n( "Add new subproject..." ), "folder_new", 0, + this, SLOT( slotAddSubproject() ), actions, "add subproject" ); + addSubprojectAction->setWhatsThis(i18n("Add new subproject

Creates a new " + "subproject in currently selected subproject.")); + addSubprojectAction->plug( m_button1 ); + + removeSubprojectAction = new KAction( i18n( "Remove Subproject..." ), "remove_subdir", 0, + this, SLOT( slotRemoveSubproject() ), actions, "remove subproject" ); + removeSubprojectAction->setWhatsThis(i18n("Remove subproject

Removes the subproject. Asks if the " + "subproject should be also removed from disk. Only subprojects " + "which do not hold other subprojects can be removed.")); + addExistingSubprojectAction = new KAction( i18n( "Add Existing Subprojects..." ), "fileimport", 0, + this, SLOT( slotAddExistingSubproject() ), actions, "add existing subproject" ); + addExistingSubprojectAction->setWhatsThis(i18n("Add existing subprojects

Imports existing " + "subprojects containing Makefile.am.")); + + QToolTip::add( m_button2, tr2i18n( "Add Target...")); + addTargetAction = new AutoToolsAction( i18n( "Add Target..." ), "targetnew_kdevelop", 0, + this, SLOT( slotAddTarget() ), actions, "add target" ); + addTargetAction->setWhatsThis(i18n( "Add target

Adds a new target to " + "the currently selected subproject. Target can be a " + "binary program, library, script, also a collection of " + "data or header files.")); + addTargetAction->plug( m_button2 ); + + QToolTip::add( m_button3, tr2i18n( "Add Service...")); + addServiceAction = new AutoToolsAction( i18n( "Add Service..." ), "servicenew_kdevelop", 0, this, + SLOT( slotAddService() ), actions, "add service" ); + addServiceAction->setWhatsThis(i18n("Add service

Creates a .desktop file describing the service.")); + addServiceAction->plug( m_button3 ); + + QToolTip::add( m_button4, tr2i18n( "Add Application...")); + addApplicationAction = new AutoToolsAction( i18n( "Add Application..." ), "window_new", 0, this, + SLOT( slotAddApplication() ), actions, "add application" ); + addApplicationAction->setWhatsThis(i18n("Add application

Creates an application .desktop file.")); + addApplicationAction->plug( m_button4 ); + + QToolTip::add( m_button5, tr2i18n( "Build")); + buildSubprojectAction = new AutoToolsAction( i18n( "Build" ), "launch", 0, this, + SLOT( slotBuildSubproject() ), actions, "build subproject" ); + buildSubprojectAction->setWhatsThis(i18n("Build

Runs make from the directory of " + "the selected subproject.
Environment variables and " + "make arguments can be specified in the project settings " + "dialog, Make Options tab.")); + buildSubprojectAction->plug( m_button5 ); + + forceReeditSubprojectAction = new KAction( i18n( "Force Reedit" ), 0, 0, this, + SLOT( slotForceReeditSubproject() ), actions, "force-reedit subproject" ); + forceReeditSubprojectAction->setWhatsThis(i18n("Force Reedit

Runs make force-reedit " + "from the directory of the selected subproject.
This " + "recreates makefile (tip: and solves most of .moc related " + "problems)
Environment variables and make arguments can " + "be specified in the project settings dialog, " + "Make Options tab.")); + + if (!m_part->isKDE()) + forceReeditSubprojectAction->setEnabled(false); + + cleanSubprojectAction = new KAction( i18n( "Clean" ), 0, 0, this, + SLOT( slotCleanSubproject() ), actions, "clean subproject" ); + cleanSubprojectAction->setWhatsThis(i18n("Clean

Runs make clean from the directory of " + "the selected subproject.
Environment variables and make " + "arguments can be specified in the project settings dialog, " + "Make Options tab.")); + + installSubprojectAction = new KAction( i18n( "Install" ), 0, 0, this, + SLOT( slotInstallSubproject() ), actions, "install subproject" ); + installSubprojectAction->setWhatsThis(i18n("Install

Runs make install from the directory " + "of the selected subproject.
Environment variables and " + "make arguments can be specified in the project settings " + "dialog, Make Options tab.")); + installSuSubprojectAction = new KAction( i18n( "Install (as root user)" ), 0, 0, + this, SLOT( slotInstallSuSubproject() ), actions, "install subproject as root" ); + installSuSubprojectAction->setWhatsThis(i18n("Install as root user

Runs make install " + "command from the directory of the selected subproject " + "with root privileges.
It is executed via kdesu " + "command.
Environment variables and make arguments " + "can be specified in the project settings dialog, " + "Make Options tab.")); + + expandAction = new KAction( i18n( "Expand Subtree" ), 0, 0, this, + SLOT(slotExpandTree()), actions, "expandAction" ); + collapseAction = new KAction( i18n( "Collapse Subtree" ), 0, 0, this, + SLOT(slotCollapseTree()), actions, "collapseAction" ); + + otherAction = new KAction( i18n( "Manage Custom Commands..." ), 0, 0, this, + SLOT( slotManageBuildCommands() ), actions, "manage custom commands" ); + otherAction->setWhatsThis(i18n("Manage custom commands

Allows to create, edit and " + "delete custom build commands which appears in the subproject " + "context menu.
")); + + connect( m_listView, SIGNAL( contextMenu( KListView*, QListViewItem*, const QPoint& ) ), + this, SLOT( slotContextMenu( KListView*, QListViewItem*, const QPoint& ) ) ); +} + +void AutoSubprojectView::slotContextMenu( KListView *, QListViewItem *item, const QPoint &p ) +{ + if ( !item ) + return ; + + KPopupMenu popup( i18n( "Subproject: %1" ).arg( item->text( 0 ) ), this ); + + subProjectOptionsAction->plug( &popup ); + popup.insertSeparator(); + addSubprojectAction->plug( &popup ); + addTargetAction->plug( &popup ); + addServiceAction->plug( &popup ); + addApplicationAction->plug( &popup ); + popup.insertSeparator(); + addExistingSubprojectAction->plug( &popup ); + popup.insertSeparator(); + removeSubprojectAction->plug( &popup ); + popup.insertSeparator(); + buildSubprojectAction->plug( &popup ); + popup.insertSeparator(); + forceReeditSubprojectAction->plug( &popup ); + cleanSubprojectAction->plug( &popup ); + popup.insertSeparator(); + installSubprojectAction->plug( &popup ); + installSuSubprojectAction->plug( &popup ); + popup.insertSeparator(); + collapseAction->plug( &popup ); + expandAction->plug( &popup ); + + KConfig *config = m_part->instance()->config(); + bool separate = true; + QMap customBuildCommands = config->entryMap("CustomCommands"); + for (QMap::const_iterator it = customBuildCommands.constBegin(); + it != customBuildCommands.constEnd(); ++it) + { + if (separate) + { + popup.insertSeparator(); + separate = false; + } + int id = popup.insertItem(it.key(), this, SLOT(slotCustomBuildCommand(int))); + m_commandList.append(it.data()); + popup.setItemParameter(id, m_commandList.findIndex(it.data())); + } + + popup.insertSeparator(); + otherAction->plug( &popup ); + + KURL::List urls; + urls.append(m_widget->selectedSubproject()->path); + FileContext context(urls); + m_part->core()->fillContextMenu( &popup, &context ); + + popup.exec( p ); +} + +void AutoSubprojectView::slotSubprojectOptions() +{ + kdDebug( 9020 ) << "AutoSubprojectView::slotSubprojectOptions()" << endl; + + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + SubprojectOptionsDialog dlg( m_part, m_widget, spitem, this, "subproject options dialog" ); + dlg.exec(); +} + + +void AutoSubprojectView::slotAddSubproject() +{ + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + AddSubprojectDialog dlg( m_part, this, spitem, this, "add subproject dialog" ); + + dlg.setCaption ( i18n ( "Add New Subproject to '%1'" ).arg ( spitem->subdir ) ); + dlg.exec(); +} + + +void AutoSubprojectView::slotAddExistingSubproject() +{ + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + AddExistingDirectoriesDialog dlg ( m_part, m_widget, spitem, this, "add existing subprojects" ); + + dlg.setCaption ( i18n ( "Add Existing Subproject to '%1'" ).arg ( spitem->subdir ) ); + dlg.targetLabel->setText(""); + dlg.directoryLabel->setText(spitem->path); + + if ( dlg.exec() ) + emit selectionChanged ( spitem ); +} + +void AutoSubprojectView::slotAddTarget() +{ + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + AddTargetDialog dlg( m_widget, spitem, this, "add target dialog" ); + + dlg.setCaption ( i18n ( "Add New Target to '%1'" ).arg ( spitem->subdir ) ); + + // Update the details view if a target was added + if ( dlg.exec() ) + emit selectionChanged( spitem ); +} + + +void AutoSubprojectView::slotAddService() +{ + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + AddServiceDialog dlg( m_widget, spitem, this, "add service dialog" ); + + dlg.setCaption ( i18n ( "Add New Service to '%1'" ).arg ( spitem->subdir ) ); + + // Update the details view if a service was added + if ( dlg.exec() ) + emit selectionChanged( spitem ); +} + + +void AutoSubprojectView::slotAddApplication() +{ + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + AddApplicationDialog dlg( m_widget, spitem, this, "add application dialog" ); + + dlg.setCaption ( i18n ( "Add New Application to '%1'" ).arg ( spitem->subdir ) ); + + // Update the details view if an application was added + if ( dlg.exec() ) + emit selectionChanged( spitem ); +} + + +void AutoSubprojectView::slotBuildSubproject() +{ + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + QString relpath = "/" + URLUtil::getRelativePath( m_part->topsourceDirectory(), m_part->projectDirectory() ) + "/" + spitem->path.mid( m_part->projectDirectory().length() ); + + m_part->startMakeCommand( m_part->buildDirectory() + relpath, QString::fromLatin1( "" ) ); +} + +void AutoSubprojectView::slotRemoveSubproject() +{ + kdDebug(9020) << "AutoSubprojectView::slotRemoveSubproject()" << endl; + + SubprojectItem* spitem = static_cast( m_listView->selectedItem() ); + if( !spitem ) + return; + + SubprojectItem* parent = static_cast( spitem->parent() ); + if( !parent || !parent->listView() || spitem->childCount() != 0 ){ + KMessageBox::error( 0, i18n("This item cannot be removed"), i18n("Automake Manager") ); + return; + } + + QStringList list = QStringList::split( QRegExp("[ \t]"), parent->variables["SUBDIRS"] ); + QStringList::Iterator it = list.find( spitem->subdir ); + QString subdirToRemove = spitem->subdir; + bool topsubdirs = true; + if ((parent->variables["SUBDIRS"].find("$(TOPSUBDIRS)") == -1) + && (parent->variables["SUBDIRS"].find("$(AUTODIRS)") == -1)) + { + topsubdirs = false; + if( it == list.end() ){ + KMessageBox::sorry(this, i18n("There is no subproject %1 in SUBDIRS").arg(spitem->subdir)); + return; + } + } + + RemoveSubprojectDialog dlg(i18n("Remove Subproject %1").arg(spitem->text(0)), + i18n("Do you really want to remove subproject %1 with all targets and files?").arg(spitem->text(0))); + if( dlg.exec() ){ + + bool removeSources = dlg.removeFromDisk(); + + if (!topsubdirs) + { + list.remove( it ); + parent->variables[ "SUBDIRS" ] = list.join( " " ); + } + + parent->listView()->setSelected( parent, true ); + kapp->processEvents( 500 ); + + + if( removeSources ){ + kdDebug(9020) << "remove dir " << spitem->path << endl; + AutoProjectPrivate::removeDir( spitem->path ); + } + + if( m_widget->activeSubproject() == spitem ){ + m_widget->setActiveSubproject( 0 ); + } + + // Adjust AC_OUTPUT in configure.in + if ( !m_part->isKDE() ) { + + QString projroot = m_part->projectDirectory() + "/"; + QString subdirectory = spitem->path; + QString relpath = subdirectory.replace(0, projroot.length(),""); + + QString configureFile = m_part->getAutoConfFile(projroot); + + QStringList list = AutoProjectTool::configureinLoadMakefiles(configureFile); + + QStringList::iterator it; + + for ( it = list.begin(); it != list.end(); it++ ) { + QString current = (QString) (*it); + QRegExp path_regex(relpath); + if ( path_regex.search(current) >= 0) { + list.remove(it); + break; + } + } + AutoProjectTool::configureinSaveMakefiles(configureFile, list); + + } + + // remove all targets + spitem->targets.setAutoDelete( true ); + spitem->targets.clear(); + delete( spitem ); + spitem = 0; + + // Adjust SUBDIRS variable in containing Makefile.am + + if (parent->variables["SUBDIRS"].find("$(TOPSUBDIRS)") != -1) + { + QFile subdirsfile( parent->path + "/subdirs" ); + QStringList topdirs; + if ( subdirsfile.open( IO_ReadOnly ) ) + { + QTextStream subdirsstream( &subdirsfile ); + while (!subdirsstream.atEnd()) + topdirs.append(subdirsstream.readLine()); + subdirsfile.close(); + } + topdirs.remove(subdirToRemove); + if ( subdirsfile.open( IO_WriteOnly | IO_Truncate ) ) + { + QTextStream subdirsstream( &subdirsfile ); + for (QStringList::const_iterator it = topdirs.begin(); it != topdirs.end(); ++it) + subdirsstream << *it << endl; + subdirsfile.close(); + } + } + + QMap replaceMap; + replaceMap.insert( "SUBDIRS", subdirToRemove ); + AutoProjectTool::removeFromMakefileam( parent->path + "/Makefile.am", replaceMap ); + + QString relmakefile = ( parent->path + "/Makefile" ).mid( m_part->projectDirectory().length()+1 ); + kdDebug(9020) << "Relative makefile path: " << relmakefile << endl; + + // check for config.status + if( !QFileInfo(m_part->buildDirectory(), "config.status").exists() ){ + return; + } + + QString cmdline = "cd "; + cmdline += KProcess::quote(m_part->projectDirectory()); + cmdline += " && automake "; + cmdline += KProcess::quote(relmakefile); + cmdline += " && cd "; + cmdline += KProcess::quote(m_part->buildDirectory()); + cmdline += " && CONFIG_HEADERS=config.h CONFIG_FILES="; + cmdline += KProcess::quote(relmakefile); + cmdline += " ./config.status"; + m_part->makeFrontend()->queueCommand( m_part->projectDirectory(), cmdline ); + } +} + + +void AutoSubprojectView::parsePrimary( SubprojectItem *item, + const QString &lhs, const QString &rhs ) +{ + // Parse line foo_bar = bla bla + + int pos = lhs.findRev( '_' ); + QString prefix = lhs.left( pos ); + QString primary = lhs.right( lhs.length() - pos - 1 ); + // kdDebug(9020) << "Prefix:" << prefix << ",Primary:" << primary << endl; + + +#if 0 + + QStrList prefixes; + prefixes.append( "bin" ); + prefixes.append( "pkglib" ); + prefixes.append( "pkgdata" ); + prefixes.append( "noinst" ); + prefixes.append( "check" ); + prefixes.append( "sbin" ); + QStrList primaries; + primaries.append( "PROGRAMS" ); + primaries.append( "LIBRARIES" ); + primaries.append( "LTLIBRARIES" ); + primaries.append( "SCRIPTS" ); + primaries.append( "HEADERS" ); + primaries.append( "DATA" ); +#endif + + // Not all combinations prefix/primary are possible, so this + // could also be checked... not trivial because the list of + // possible prefixes can be extended dynamically (see below) + if ( primary == "PROGRAMS" || primary == "LIBRARIES" || primary == "LTLIBRARIES" ) + { + QStringList l = QStringList::split( QRegExp( "[ \t\n]" ), rhs ); + QStringList::Iterator it1; + for ( it1 = l.begin(); it1 != l.end(); ++it1 ) + { + TargetItem *titem = m_widget->createTargetItem( *it1, prefix, primary ); + item->targets.append( titem ); + + QString canonname = AutoProjectTool::canonicalize( *it1 ); + titem->ldflags = AutoProjectPrivate::cleanWhitespace( item->variables[ canonname + "_LDFLAGS" ] ); + titem->ldadd = AutoProjectPrivate::cleanWhitespace( item->variables[ canonname + "_LDADD" ] ); + titem->libadd = AutoProjectPrivate::cleanWhitespace( item->variables[ canonname + "_LIBADD" ] ); + titem->dependencies = AutoProjectPrivate::cleanWhitespace( item->variables[ canonname + "_DEPENDENCIES" ] ); + + QString sources = item->variables[ canonname + "_SOURCES" ]; + QStringList sourceList = QStringList::split( QRegExp( "[ \t\n]" ), sources ); + QMap dict; + QStringList::Iterator it = sourceList.begin(); + while( it != sourceList.end() ){ + dict.insert( *it, true ); + ++it; + } + + QMap::Iterator dictIt = dict.begin(); + while( dictIt != dict.end() ){ + QString fname = dictIt.key(); + ++dictIt; + + FileItem *fitem = m_widget->createFileItem( fname, item ); + titem->sources.append( fitem ); + + if( AutoProjectPrivate::isHeader(fname) ) + headers += fname; + } + } + } + else if ( primary == "SCRIPTS" || primary == "HEADERS" || primary == "DATA" ) + { + // See if we have already such a group + for ( uint i = 0; i < item->targets.count(); ++i ) + { + TargetItem *titem = item->targets.at( i ); + if ( primary == titem->primary && prefix == titem->prefix ) + { + item->targets.remove( i ); + break; + } + } + // Create a new one + TargetItem *titem = m_widget->createTargetItem( "", prefix, primary ); + item->targets.append( titem ); + + QStringList l = QStringList::split( QRegExp( "[ \t]" ), rhs ); + QStringList::Iterator it3; + for ( it3 = l.begin(); it3 != l.end(); ++it3 ) + { + QString fname = *it3; + FileItem *fitem = m_widget->createFileItem( fname, item ); + titem->sources.append( fitem ); + + if( AutoProjectPrivate::isHeader(fname) ) + headers += fname; + + } + } + else if ( primary == "JAVA" ) + { + QStringList l = QStringList::split( QRegExp( "[ \t\n]" ), rhs ); + QStringList::Iterator it1; + TargetItem *titem = m_widget->createTargetItem( "", prefix, primary ); + item->targets.append( titem ); + + for ( it1 = l.begin(); it1 != l.end(); ++it1 ) + { + FileItem *fitem = m_widget->createFileItem( *it1, item ); + titem->sources.append( fitem ); + } + } +} + + +void AutoSubprojectView::parseKDEDOCS( SubprojectItem *item, + const QString & /*lhs*/, const QString & /*rhs*/ ) +{ + // Handle the line KDE_ICON = + // (actually, no parsing is involved here) + + QString prefix = "kde_docs"; + QString primary = "KDEDOCS"; + + TargetItem *titem = m_widget->createTargetItem( "", prefix, primary ); + item->targets.append( titem ); + + QDir d( item->path ); + QStringList l = d.entryList( QDir::Files ); + + QRegExp re( "Makefile.*|\\..*|.*~|index.cache.bz2" ); + + QStringList::ConstIterator it; + for ( it = l.begin(); it != l.end(); ++it ) + { + if ( !re.exactMatch( *it ) ) + { + QString fname = *it; + FileItem * fitem = m_widget->createFileItem( fname, item ); + titem->sources.append( fitem ); + } + } +} + + +void AutoSubprojectView::parseKDEICON( SubprojectItem *item, + const QString &lhs, const QString &rhs ) +{ + // Parse a line foo_ICON = bla bla + + int pos = lhs.find( "_ICON" ); + QString prefix = lhs.left( pos ); + if ( prefix == "KDE" ) + prefix = "kde_icon"; + + QString primary = "KDEICON"; + + TargetItem *titem = m_widget->createTargetItem( "", prefix, primary ); + item->targets.append( titem ); + + QDir d( item->path ); + QStringList l = d.entryList( QDir::Files ); + + QString regexp; + + if ( rhs == "AUTO" ) + { + regexp = ".*\\.(png|mng|xpm)"; + } + else + { + QStringList appNames = QStringList::split( QRegExp( "[ \t\n]" ), rhs ); + regexp = ".*(-" + appNames.join( "|-" ) + ")\\.(png|mng|xpm)"; + } + + QRegExp re( regexp ); + + QStringList::ConstIterator it; + for ( it = l.begin(); it != l.end(); ++it ) + { + if ( re.exactMatch( *it ) ) + { + FileItem * fitem = m_widget->createFileItem( *it, item ); + titem->sources.append( fitem ); + } + } +} + + +void AutoSubprojectView::parsePrefix( SubprojectItem *item, + const QString &lhs, const QString &rhs ) +{ + // Parse a line foodir = bla bla + QString name = lhs.left( lhs.length() - 3 ); + QString dir = rhs; + item->prefixes.insert( name, dir ); +} + + +void AutoSubprojectView::parseSUBDIRS( SubprojectItem *item, + const QString & /*lhs*/, const QString &rhs ) +{ + // Parse a line SUBDIRS = bla bla + QString subdirs = rhs; + kdDebug( 9020 ) << "subdirs are " << subdirs << endl; + + // Take care of KDE hacks: + // TOPSUBDIRS is an alias for all directories + // listed in the subdirs file + if ( subdirs.find( "$(TOPSUBDIRS)" ) != -1 ) + { + QStringList dirs; + QFile subdirsfile( item->path + "/subdirs" ); + if( subdirsfile.exists() ) + { + if ( subdirsfile.open( IO_ReadOnly ) ) + { + QTextStream subdirsstream( &subdirsfile ); + while ( !subdirsstream.atEnd() ) + dirs.append( subdirsstream.readLine() ); + subdirsfile.close(); + } + } else + { + QDir d( item->path ); + QStringList l = d.entryList( QDir::Dirs ); + for( QStringList::const_iterator it = l.begin(); it != l.end(); ++it ) + { + if( (*it) != "CVS" && (*it) != "admin" && (*it) != ".svn" && (*it) != "." && (*it) != ".." ) + { + QDir subdir = d; + subdir.cd( *it, false ); + if( subdir.exists( "Makefile.am" ) ) + dirs.append( *it ); + } + } + + } + subdirs.replace( QRegExp( "\\$\\(TOPSUBDIRS\\)" ), dirs.join( " " ) ); + } + + // AUTODIRS is an alias for all subdirectories + if ( subdirs.find( "$(AUTODIRS)" ) != -1 ) + { + QDir d( item->path ); + QStringList dirs = d.entryList( QDir::Dirs ); + dirs.remove( "." ); + dirs.remove( ".." ); + dirs.remove( "CVS" ); + subdirs.replace( QRegExp( "\\$\\(AUTODIRS\\)" ), dirs.join( " " ) ); + } + + // If there are any variables in the subdirs line then search + // the Makefile(.am?) for its definition. Unfortunately, it may be + // defined outside this file in which case those dirs won't be added. + QRegExp varre( "\\$\\(\\s*(.*)\\s*\\)" ); + varre.setMinimal( true ); + while ( varre.search( subdirs ) != -1 ) + { + QString varname = varre.cap( 1 ); + QString varvalue; + + // Search the whole Makefile(.am?) + // Note that if the variable isn't found it just disappears + // (Perhaps we should add it back in this case?) + QMap::ConstIterator varit = item->variables.find( varname ); + if ( varit != item->variables.end() ) + { + kdDebug( 9020 ) << "Found Makefile var " << varname << ", adding dirs <" << varit.data() << ">" << endl; + varvalue = varit.data(); + } + else + { + kdDebug( 9020 ) << "Not found Makefile var " << varname << endl; + } + subdirs.replace( QRegExp( "\\$\\(\\s*" + varname + "\\s*\\)" ), varvalue ); + } + + //search for AC_SUBST variables and try to replace them with variables + //that have been already defined e.g. in a "kdevelop hint" + varre = QRegExp( "\\@(.*)\\@" ); + varre.setMinimal( true ); + while ( varre.search( subdirs ) != -1 ) + { + QString varname = varre.cap( 1 ); + QString varvalue; + + // Search the whole Makefile(.am?) + // Note that if the variable isn't found it just disappears + // (Perhaps we should add it back in this case?) + QMap::ConstIterator varit = item->variables.find( varname ); + if ( varit != item->variables.end() ) + { + kdDebug( 9020 ) << "Found Makefile var " << varname << ", adding dirs <" << varit.data() << ">" << endl; + varvalue = varit.data(); + } + else + { + kdDebug( 9020 ) << "Not found Makefile var " << varname << endl; + } + subdirs.replace( QRegExp( "\\@" + varname + "\\@" ), varvalue ); + } + + QStringList l = QStringList::split( QRegExp( "[ \t]" ), subdirs ); + l.sort(); + QStringList::Iterator it; + for ( it = l.begin(); it != l.end(); ++it ) + { + if ( *it == "." ) + continue; + SubprojectItem *newitem = new SubprojectItem( item, ( *it ) ); + newitem->subdir = ( *it ); + newitem->path = item->path + "/" + ( *it ); + parse( newitem ); + // Experience tells me this :-) + bool open = true; + if ( newitem->subdir == "doc" ) + open = false; + if ( newitem->subdir == "po" ) + open = false; + if ( newitem->subdir == "pics" ) + open = false; + if ( newitem && static_cast( newitem->parent() ) + ->subdir == "doc" ) + open = false; + if ( newitem && static_cast + ( newitem->parent() ) ->subdir == "po" ) + open = false; + if ( newitem && static_cast + ( newitem->parent() ) ->subdir == "pics" ) + open = false; + newitem->setOpen( open ); + + // Move to the bottom of the list + QListViewItem *lastItem = item->firstChild(); + while ( lastItem->nextSibling() + ) + lastItem = lastItem->nextSibling(); + if ( lastItem != newitem ) + newitem->moveItem( lastItem ); + } +} + +void AutoSubprojectView::parse( SubprojectItem *item ) +{ + headers.clear(); + AutoProjectTool::parseMakefileam( item->path + "/Makefile.am", &item->variables ); + + QMap::ConstIterator it; + for ( it = item->variables.begin(); it != item->variables.end(); ++it ) + { + QString lhs = it.key(); + QString rhs = it.data(); + if ( lhs == "KDE_DOCS" ) + parseKDEDOCS( item, lhs, rhs ); + else if ( lhs.right( 5 ) == "_ICON" ) + parseKDEICON( item, lhs, rhs ); + else if ( lhs.find( '_' ) > 0 ) + parsePrimary( item, lhs, rhs ); + else if ( lhs.right( 3 ) == "dir" ) + parsePrefix( item, lhs, rhs ); + else if ( lhs == "SUBDIRS" ) + parseSUBDIRS( item, lhs, rhs ); + } + + /// @todo only if in a c++ project + TargetItem* noinst_HEADERS_item = findNoinstHeaders(item); + + QDir dir( item->path ); + QStringList headersList = QStringList::split( QRegExp("[ \t]"), item->variables[ "noinst_HEADERS" ] ); + + headersList += dir.entryList( "*.h;*.H;*.hh;*.hxx;*.hpp;*.tcc", QDir::Files ); + headersList.sort(); + headersList = QStringList::split(QRegExp("[ \t]"), headersList.join( " " )); + + QStringList::Iterator fileIt = headersList.begin(); + while( fileIt != headersList.end() ){ + QString fname = *fileIt; + ++fileIt; + + if( AutoProjectPrivate::isHeader(fname) && !headers.contains(fname) ){ + FileItem *fitem = m_widget->createFileItem( fname, item ); + noinst_HEADERS_item->sources.append( fitem ); + } + } +} + +void AutoSubprojectView::slotForceReeditSubproject( ) +{ + SubprojectItem* spitem = dynamic_cast ( m_listView->selectedItem() ); + if ( !spitem ) return; + + QString relpath = "/" + URLUtil::getRelativePath( m_part->topsourceDirectory(), m_part->projectDirectory() ) + "/" + spitem->path.mid( m_part->projectDirectory().length() ); + + m_part->startMakeCommand( m_part->buildDirectory() + relpath, "force-reedit" ); +} + +void AutoSubprojectView::slotInstallSubproject( ) +{ + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + QString relpath = "/" + URLUtil::getRelativePath( m_part->topsourceDirectory(), m_part->projectDirectory() ) + "/" + spitem->path.mid( m_part->projectDirectory().length() ); + + m_part->startMakeCommand( m_part->buildDirectory() + relpath, "install" ); +} + +void AutoSubprojectView::slotInstallSuSubproject( ) +{ + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + QString relpath = "/" + URLUtil::getRelativePath( m_part->topsourceDirectory(), m_part->projectDirectory() ) + "/" + spitem->path.mid( m_part->projectDirectory().length() ); + + m_part->startMakeCommand( m_part->buildDirectory() + relpath, "install", true ); +} + +TargetItem * AutoSubprojectView::findNoinstHeaders( SubprojectItem *item ) +{ + TargetItem* noinst_HEADERS_item = 0; + QPtrListIterator itemIt( item->targets ); + while( itemIt.current() ){ + TargetItem* titem = itemIt.current(); + ++itemIt; + + if( titem->prefix == "noinst" && titem->primary == "HEADERS" ){ + noinst_HEADERS_item = titem; + break; + } + } + + if( !noinst_HEADERS_item ){ + noinst_HEADERS_item = m_widget->createTargetItem( "", "noinst", "HEADERS" ); + item->targets.append( noinst_HEADERS_item ); + } + + return noinst_HEADERS_item; +} + +void AutoSubprojectView::slotCleanSubproject( ) +{ + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + QString relpath = "/" + URLUtil::getRelativePath( m_part->topsourceDirectory(), m_part->projectDirectory() ) + "/" + spitem->path.mid( m_part->projectDirectory().length() ); + + m_part->startMakeCommand( m_part->buildDirectory() + relpath, "clean" ); +} + +void AutoSubprojectView::focusOutEvent( QFocusEvent */* e*/ ) +{ + m_widget->setLastFocusedView(AutoProjectWidget::SubprojectView); +} + +void AutoSubprojectView::slotManageBuildCommands( ) +{ + KConfig *config = m_part->instance()->config(); + //menu item name <-> command + QMap customBuildCommands = config->entryMap("CustomCommands"); + + KDialogBase dlg(KDialogBase::Plain, i18n("Manage Custom Commands"), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok); + dlg.plainPage()->setMargin(0); + (new QVBoxLayout(dlg.plainPage(), 0, 0))->setAutoAdd(true); + + ManageCustomCommand *widget = new ManageCustomCommand(dlg.plainPage()); + + for (QMap::const_iterator it = customBuildCommands.constBegin(); + it != customBuildCommands.constEnd(); ++it) + { + widget->commandsTable->insertRows(widget->commandsTable->numRows()); + widget->setRowProperties(widget->commandsTable->numRows()-1); + widget->commandsTable->setText(widget->commandsTable->numRows() - 1, 0, it.key()); + widget->commandsTable->setText(widget->commandsTable->numRows() - 1, 1, + it.data().section(":::", 0, 0)); + static_cast(widget->commandsTable-> + item(widget->commandsTable->numRows() - 1, 2))-> + setCurrentItem(it.data().section(":::", 1, 1).toInt()); + } + + widget->commandsTable->setFocus(); + if (dlg.exec() == QDialog::Accepted) + { + config->deleteGroup("CustomCommands"); + config->setGroup("CustomCommands"); + for (int i = 0; i < widget->commandsTable->numRows(); ++i) + { + config->writeEntry(widget->commandsTable->text(i, 0), + widget->commandsTable->text(i, 1)+":::"+ + QString("%1").arg(static_cast(widget-> + commandsTable->item(i, 2))->currentItem())); + } + config->sync(); + } + +} + +void AutoSubprojectView::slotCustomBuildCommand(int val) +{ + QString cmd = m_commandList[val].section(":::", 0, 0); + int type = m_commandList[val].section(":::", 1, 1).toInt(); + + SubprojectItem* spitem = dynamic_cast( m_listView->selectedItem() ); + if ( !spitem ) return; + + QString relpath = "/" + URLUtil::getRelativePath( m_part->topsourceDirectory(), m_part->projectDirectory() ) + "/" + spitem->path.mid( m_part->projectDirectory().length() ); + switch (type) + { + case 0: //make target + m_part->startMakeCommand( m_part->buildDirectory() + relpath, cmd ); + break; + case 1: //make target as root + m_part->startMakeCommand( m_part->buildDirectory() + relpath, cmd, true ); + break; + case 2: //make command + m_part->startSimpleMakeCommand( m_part->buildDirectory() + relpath, cmd ); + break; + case 3: //make command as root + m_part->startSimpleMakeCommand( m_part->buildDirectory() + relpath, cmd, true ); + break; + case 4: //command + m_part->appFrontend()->startAppCommand(m_part->buildDirectory() + relpath, + cmd, false); + break; + case 5: //command as root + m_part->appFrontend()->startAppCommand(m_part->buildDirectory() + relpath, + "kdesu -t -c ' cd " + + KProcess::quote(m_part->buildDirectory() + relpath) + " && " + + cmd + "'", false); + break; + } +} + +void AutoSubprojectView::slotExpandTree() +{ + expandCollapseFirst( m_listView->currentItem(), true ); +} + +void AutoSubprojectView::slotCollapseTree() +{ + expandCollapseFirst( m_listView->currentItem(), false ); +} + +void AutoSubprojectView::expandCollapseFirst( QListViewItem * item, bool expand ) +{ + if ( !item ) return; + + if ( item == m_listView->firstChild() ) // special case for root node + { + item = item->firstChild(); + while ( item ) + { + expandCollapse( item, expand ); + item = item->nextSibling(); + } + } + else + { + expandCollapse( item, expand ); + } +} + +void AutoSubprojectView::expandCollapse( QListViewItem * item, bool expand ) +{ + if ( !item ) return; + + item->setOpen( expand ); + + item = item->firstChild(); + while ( item ) + { + expandCollapse( item, expand ); + item = item->nextSibling(); + } +} + +#include "autosubprojectview.moc" + +// kate: indent-mode csands; tab-width 4; space-indent off; diff --git a/buildtools/autotools/autosubprojectview.h b/buildtools/autotools/autosubprojectview.h new file mode 100644 index 00000000..e49caddd --- /dev/null +++ b/buildtools/autotools/autosubprojectview.h @@ -0,0 +1,130 @@ +/* + KDevelop Autotools Support + Copyright (c) 2002 by Victor Roeder + Copyright (c) 2005 by Matt Rogers + +*************************************************************************** +* * +* 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. * +* * +*************************************************************************** +*/ + +#ifndef AUTOSUBPROJECTVIEW_H +#define AUTOSUBPROJECTVIEW_H + +#include +#include "autoprojectviewbase.h" + + +class KAction; +class AutoToolsAction; +class AutoProjectWidget; +class AutoProjectPart; +class TargetItem; +class SubprojectItem; +class KListViewItem; +class KListView; + +namespace AutoProjectPrivate +{ + bool isHeader( const QString& fileName ); +} + + +//with protected inheritance gcc 3.2.3 complains in autoprojectwidget.cpp, line 116 +//that it cannot access the base class QObject (for the connect() call), +//so in order to be able to compile this file I made the inheritance public again, Alex +class AutoSubprojectView : public AutoProjectViewBase +{ + Q_OBJECT + +public: + AutoSubprojectView( AutoProjectWidget* widget, AutoProjectPart* part, QWidget *parent, const char *name ); + virtual ~AutoSubprojectView(); + +public: + void loadMakefileams ( const QString& dir ); + + void parse( SubprojectItem *item ); + KListView* listView() const + { + return m_listView; + } + + TargetItem *findNoinstHeaders( SubprojectItem *item ); + +signals: + void selectionChanged( QListViewItem* ); + +protected: + void initActions (); + + void parseKDEDOCS( SubprojectItem *item, + const QString &lhs, const QString &rhs ); + void parseKDEICON( SubprojectItem *item, + const QString &lhs, const QString &rhs ); + void parsePrimary( SubprojectItem *item, + const QString &lhs, const QString &rhs ); + void parsePrefix( SubprojectItem *item, + const QString &lhs, const QString &rhs ); + void parseSUBDIRS( SubprojectItem *item, + const QString &lhs, const QString &rhs ); + virtual void focusOutEvent( QFocusEvent *e ); + void expandCollapse( QListViewItem * item, bool expand ); + void expandCollapseFirst( QListViewItem * item, bool expand ); + +private: + AutoProjectWidget* m_widget; + AutoProjectPart* m_part; + QStringList headers; + + bool m_kdeMode; + + AutoToolsAction* addApplicationAction; + AutoToolsAction* subProjectOptionsAction; + AutoToolsAction* addSubprojectAction; + KAction* addExistingSubprojectAction; + AutoToolsAction* addTargetAction; + AutoToolsAction* addServiceAction; + AutoToolsAction* buildSubprojectAction; + KAction* removeSubprojectAction; + KAction* cleanSubprojectAction; + KAction* forceReeditSubprojectAction; + KAction* installSubprojectAction; + KAction* installSuSubprojectAction; + KAction* otherAction; + KAction* expandAction; + KAction* collapseAction; + + QStringList m_commandList; + QValueList m_commandTypeList; + +private slots: + void slotContextMenu( KListView *, QListViewItem *item, const QPoint &p ); + //void slotSubprojectExecuted(QListViewItem* item); + void slotSelectionChanged( QListViewItem* item ); + void slotAddApplication(); + void slotSubprojectOptions(); + void slotAddSubproject(); + void slotAddExistingSubproject(); + void slotAddTarget(); + void slotAddService(); + void slotBuildSubproject(); + void slotRemoveSubproject(); + void slotForceReeditSubproject(); + void slotInstallSubproject(); + void slotInstallSuSubproject(); + void slotCleanSubproject(); + void slotManageBuildCommands(); + void slotCustomBuildCommand( int ); + void slotExpandTree(); + void slotCollapseTree(); +}; + +#endif + +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/autotoolsaction.cpp b/buildtools/autotools/autotoolsaction.cpp new file mode 100644 index 00000000..63b38762 --- /dev/null +++ b/buildtools/autotools/autotoolsaction.cpp @@ -0,0 +1,156 @@ +/* + KDevelop Autotools Support + Copyright (c) 2005 by Matt Rogers + + *************************************************************************** + * * + * 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 "autotoolsaction.h" + +#include +#include +#include +#include +#include +#include + +AutoToolsAction::~AutoToolsAction() +{ +} + +AutoToolsAction::AutoToolsAction( const QString& text, const KShortcut& cut, + const QObject* receiver, const char* slot, + KActionCollection* parent, const char* name ) +: KAction( text, cut, receiver, slot, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( const QString& text, const QIconSet& pix, const KShortcut& cut, + const QObject* receiver, const char* slot, + KActionCollection* parent, const char* name ) +: KAction( text, pix, cut, receiver, slot, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( const QString& text, const QString& pix, const KShortcut& cut, + const QObject* receiver, const char* slot, + KActionCollection* parent, const char* name ) +: KAction( text, pix, cut, receiver, slot, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( const KGuiItem& item, const KShortcut & cut, + const QObject* receiver, const char* slot, + KActionCollection* parent, const char* name ) +: KAction( item, cut, receiver, slot, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( const QString& text, const KShortcut& cut, + QObject* parent, const char* name ) +: KAction( text, cut, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( const QString& text, const KShortcut& cut, + const QObject* receiver, const char* slot, + QObject* parent, const char* name ) +: KAction( text, cut, receiver, slot, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( const QString& text, const QIconSet& pix, + const KShortcut& cut, QObject* parent, const char* name ) +: KAction( text, pix, cut, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( const QString& text, const QString& pix, + const KShortcut& cut, QObject* parent, const char* name ) +: KAction( text, pix, cut, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( const QString& text, const QIconSet& pix, + const KShortcut& cut, const QObject* receiver, + const char* slot, QObject* parent, const char * name ) +: KAction( text, pix, cut, receiver, slot, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( const QString& text, const QString& pix, + const KShortcut & cut, const QObject* receiver, + const char* slot, QObject* parent, const char * name ) +: KAction( text, pix, cut, receiver, slot, parent, name ) +{ +} + +AutoToolsAction::AutoToolsAction( QObject * parent, const char * name ) +: KAction( parent, name ) +{ +} + +int AutoToolsAction::plug( QWidget* w, int index ) +{ + if ( !w ) { + kdWarning(129) << "KAction::plug called with 0 argument\n"; + return -1; + } + + // Check if action is permitted + if (kapp && !kapp->authorizeKAction(name())) + return -1; + + if ( ::qt_cast( w ) ) + { + QToolButton* tb = static_cast( w ); + connect( tb, SIGNAL( clicked() ), this, SLOT( activate() ) ); + int id = getToolButtonID(); + + if ( !icon().isEmpty() ) + tb->setPixmap( SmallIcon( icon() ) ); + else + tb->setText( text() ); + + if ( !isEnabled() ) + tb->setEnabled( false ); + + if ( !whatsThis().isEmpty() ) + { + QWhatsThis::remove( tb ); + QWhatsThis::add( tb, whatsThisWithIcon() ); + } + + if ( !toolTip().isEmpty() ) + { + QToolTip::remove( tb ); + QToolTip::add( tb, toolTip() ); + } + + addContainer( tb, id ); + + return containerCount() - 1; + } + + return KAction::plug( w, index ); +} + +void AutoToolsAction::updateEnabled( int i ) +{ + QWidget* w = container( i ); + + if ( ::qt_cast( w ) ) + static_cast( w )->setEnabled( isEnabled() ); + else + KAction::updateEnabled( i ) ; +} + + + +//kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/autotoolsaction.h b/buildtools/autotools/autotoolsaction.h new file mode 100644 index 00000000..97c8e79e --- /dev/null +++ b/buildtools/autotools/autotoolsaction.h @@ -0,0 +1,70 @@ +/* + KDevelop Autotools Support + Copyright (c) 2005 by Matt Rogers + +*************************************************************************** +* * +* 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. * +* * +*************************************************************************** +*/ +#ifndef AUTOTOOLSACTION_H +#define AUTOTOOLSACTION_H + +#include +#include + +class QObject; +class KActionCollection; + +/** + * A KAction derivative that will work with the QToolButtons used in + * the Automake Manager + * @author Matt Rogers + */ +class AutoToolsAction : public KAction +{ +public: + virtual ~AutoToolsAction(); + + AutoToolsAction( const QString& text, const KShortcut& cut, + const QObject* receiver, const char* slot, + KActionCollection* parent, const char* name ); + + AutoToolsAction( const QString& text, const QIconSet& pix, const KShortcut& cut, + const QObject* receiver, const char* slot, + KActionCollection* parent, const char* name ); + + AutoToolsAction( const QString& text, const QString& pix, const KShortcut& cut, + const QObject* receiver, const char* slot, + KActionCollection* parent, const char* name ); + + AutoToolsAction( const KGuiItem& item, const KShortcut& cut, + const QObject* receiver, const char* slot, + KActionCollection* parent, const char* name ); + + AutoToolsAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 ); + AutoToolsAction( const QString& text, const KShortcut& cut, + const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); + AutoToolsAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), + QObject* parent = 0, const char* name = 0 ); + AutoToolsAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), + QObject* parent = 0, const char* name = 0 ); + AutoToolsAction( const QString& text, const QIconSet& pix, const KShortcut& cut, + const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); + AutoToolsAction( const QString& text, const QString& pix, const KShortcut& cut, + const QObject* receiver, const char* slot, QObject* parent, + const char* name = 0 ); + AutoToolsAction( QObject* parent = 0, const char* name = 0 ); + + virtual int plug( QWidget *widget, int index = -1 ); + + virtual void updateEnabled( int i ); +}; + +#endif + +//kate: indent-mode csands; tab-width 4; auto-insert-doxygen on; diff --git a/buildtools/autotools/choosetargetdialog.cpp b/buildtools/autotools/choosetargetdialog.cpp new file mode 100644 index 00000000..b35c5c75 --- /dev/null +++ b/buildtools/autotools/choosetargetdialog.cpp @@ -0,0 +1,348 @@ +/*************************************************************************** + ------------------- + begin : 29.11.2002 + copyright : (C) 2002 by Victor Rder + email : 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 "choosetargetdialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "choosetargetdlgbase.h" +#include "autodetailsview.h" +#include "autolistviewitems.h" +#include "autosubprojectview.h" +#include "misc.h" +#include "autoprojectwidget.h" +#include "autoprojectpart.h" + +#include "kdevpartcontroller.h" + +class ChooseTargetDialog::Private +{ +public: + AutoProjectWidget* widget; + AutoProjectPart* part; + QStringList fileList; + QPtrList subprojectList; + SubprojectItem* chosenSubproject; + TargetItem* chosenTarget; + ChooseTargetDlgBase* baseUI; +}; + +ChooseTargetDialog::ChooseTargetDialog ( AutoProjectWidget* widget, AutoProjectPart* part, + QStringList fileList, QWidget* parent, const char* name ) +: KDialogBase( parent, name, false, i18n("Automake Manager - Choose Target"), + Ok | Cancel, KDialogBase::Ok, true /* seperator */ ) + +{ + Q_UNUSED( parent ); + Q_UNUSED( name ); + d = new ChooseTargetDialog::Private; + d->widget = widget; + d->part = part; + d->fileList = fileList; + d->subprojectList = widget->allSubprojectItems(); + d->baseUI = new ChooseTargetDlgBase( this, "base ui" ); + setMainWidget( d->baseUI ); + + d->baseUI->subprojectComboBox->setAutoCompletion( true ); + d->baseUI->targetComboBox->setAutoCompletion( true ); + d->baseUI->newFileList->header()->hide(); + d->baseUI->newFileList->addColumn( QString::null ); + d->baseUI->newFileList->setSorting(-1); + + setIcon ( SmallIcon ( "target_kdevelop" ) ); + + + QPtrListIterator sit(d->subprojectList); + for ( ; (*sit); ++sit ) + { + QPtrList targetList = (*sit)->targets; + QPtrListIterator targetIt(targetList); + + // Only insert Subproject which have a "regular" target + for ( ; (*targetIt); ++targetIt ) + { + QString titemPrimary = (*targetIt)->primary; + if ( titemPrimary == "PROGRAMS" || titemPrimary == "LIBRARIES" || + titemPrimary == "LTLIBRARIES" || titemPrimary == "JAVA" ) + { + d->baseUI->subprojectComboBox->insertItem ( SmallIcon ( "folder" ), (*sit)->subdir ); + } + } + } + + if ( d->widget->activeTarget() && d->widget->activeSubproject() ) + { + d->chosenTarget = d->widget->activeTarget(); + //kdDebug ( 9020 ) << "1) Chosen target is " << d->chosenTarget->name << endl; + d->chosenSubproject = widget->activeSubproject(); + d->baseUI->chosenTargetLabel->setText( ( widget->activeSubproject()->path + "/" + + d->widget->activeTarget()->name + "" ) + .mid( d->part->projectDirectory().length() + 1 ) ); + d->baseUI->subprojectComboBox->setEnabled( false ); + d->baseUI->targetComboBox->setEnabled( false ); + + d->baseUI->subprojectComboBox->setCurrentItem( widget->activeSubproject()->subdir ); + slotSubprojectChanged( widget->activeSubproject()->subdir ); + } + else + { + d->baseUI->activeTargetRadioButton->toggle(); + d->baseUI->activeTargetRadioButton->setEnabled ( false ); + d->baseUI->neverAskAgainCheckbox->setEnabled ( false ); + + slotSubprojectChanged ( d->baseUI->subprojectComboBox->text(0) ); + } + + QStringList::iterator it; + QString fileName; + + for ( it = fileList.begin(); it != fileList.end(); ++it ) + { + int pos = ( *it ).findRev('/'); + if (pos != -1) + fileName = ( *it ).mid(pos+1); + else + fileName = ( *it ); + + + d->baseUI->newFileList->insertItem( new QListViewItem( d->baseUI->newFileList, fileName ) ); + } + + connect ( d->baseUI->subprojectComboBox, SIGNAL ( activated ( const QString& ) ), + this, SLOT( slotSubprojectChanged ( const QString& ) ) ); + connect ( d->baseUI->targetComboBox, SIGNAL ( activated ( const QString& ) ), + this, SLOT( slotTargetChanged ( const QString& ) ) ); +} + + +ChooseTargetDialog::~ChooseTargetDialog() +{ +} + +void ChooseTargetDialog::slotSubprojectChanged ( const QString& name ) +{ + d->chosenTarget = 0; + SubprojectItem* spitem = d->subprojectList.first(); + + for ( ; spitem; spitem = d->subprojectList.next() ) + { + if ( spitem->subdir == name ) + { + QPtrList targetList = spitem->targets; + TargetItem* titem = targetList.first(); + + d->baseUI->targetComboBox->clear(); + +/* choosenSubprojectLabel->setText ( ( spitem->path + "" + ->name + "" ).mid ( d->widget->projectDirectory().length() + 1 ) );*/ + + d->chosenSubproject = spitem; + + for ( ; titem; titem = targetList.next() ) + { + if ( titem->primary == "PROGRAMS" || titem->primary == "LIBRARIES" || + titem->primary == "LTLIBRARIES" || titem->primary == "JAVA" ) + { + d->baseUI->targetComboBox->insertItem ( SmallIcon ( "target_kdevelop" ), titem->name ); + + //d->baseUI->targetComboBox->addToHistory ( titem->name ); + + // if the Active Target is in the currently selected Subproject + if ( d->widget->activeTarget() && + titem->name == d->widget->activeTarget()->name ) + { + d->baseUI->targetComboBox->setCurrentItem( titem->name ); + d->baseUI->chosenTargetLabel->setText( ( spitem->path + "/" + titem->name + "" ).mid( d->part->projectDirectory().length() + 1 ) ); + d->chosenTarget = titem; + //kdDebug ( 9020 ) << "2) Chosen target is " << d->chosenTarget->name << endl; + } + else + { + //d->baseUI->targetComboBox->setCurrentItem ( 0 ); + if ( !d->chosenTarget ) + { + d->baseUI->chosenTargetLabel->setText( ( spitem->path + "/" + titem->name + "") + .mid( d->part->projectDirectory().length() + 1 ) ); + //choosenSubprojectLabel->setText ( ( spitem->path + "" + titem->name + "" ).mid ( d->widget->projectDirectory().length() + 1 ) ); + + d->chosenTarget = titem; + } + //kdDebug ( 9020 ) << "2a) Chosen target is " << d->chosenTarget->name << endl; + } + } + } + + break; + } + } +} + +void ChooseTargetDialog::slotTargetChanged( const QString& name ) +{ + d->baseUI->chosenTargetLabel->setText( ( d->chosenSubproject->path + "/" + name + "" ) + .mid( d->part->projectDirectory().length() + 1 ) ); + + QPtrList targetList = d->chosenSubproject->targets; + TargetItem* titem = targetList.first(); + + for ( ; titem; titem = targetList.next() ) + { + if ( titem->name == name ) + { + d->chosenTarget = titem; + //kdDebug ( 9020 ) << "4) Chosen target is " << d->chosenTarget->name << endl; + + break; + } + } +} + +void ChooseTargetDialog::slotOk() +{ + if ( d->baseUI->activeTargetRadioButton->isChecked() ) + { + d->chosenTarget = d->widget->activeTarget(); + d->chosenSubproject = d->widget->activeSubproject(); + } + if ( !d->chosenSubproject || !d->chosenTarget ) + return; + + //kdDebug ( 9020 ) << "3) Chosen target is " << d->chosenTarget->name << endl; + + QStringList newFileList; + QStringList::iterator it; + QString directory, fileName; + + for ( it = d->fileList.begin(); it != d->fileList.end(); ++it ) + { + bool found = false; + + int pos = ( *it ).findRev('/'); + if (pos != -1) + { + directory = ( *it ).left(pos); + fileName = ( *it ).mid(pos+1); + } + else + { + fileName = ( *it ); + } + + FileItem * fitem = d->chosenTarget->sources.first(); + for ( ; fitem; fitem = d->chosenTarget->sources.next() ) + { + if ( fitem->name == fileName ) + { + KMessageBox::error ( this, i18n ( "The file %1 already exists in the chosen target.\nThe file will be created but will not be added to the target.\n" + "Rename the file and select 'Add Existing Files' from the Automake Manager." ).arg ( fitem->name ), + i18n ( "Error While Adding Files" ) ); + found = true; + } + } + + if ( !found ) + { + /// \FIXME a quick hack to prevent adding header files to _SOURCES + /// and display them in noinst_HEADERS + if (AutoProjectPrivate::isHeader(fileName) && + ( d->chosenTarget->primary == "PROGRAMS" || d->chosenTarget->primary == "LIBRARIES" || d->chosenTarget->primary == "LTLIBRARIES" ) ) + { + kdDebug ( 9020 ) << "Ignoring header file and adding it to noinst_HEADERS: " << fileName << endl; + TargetItem* noinst_HEADERS_item = d->widget->getSubprojectView()->findNoinstHeaders(d->chosenSubproject); + FileItem *fitem = d->widget->createFileItem( fileName, d->chosenSubproject ); + noinst_HEADERS_item->sources.append( fitem ); + noinst_HEADERS_item->insertItem( fitem ); + + QString varname = "noinst_HEADERS"; + d->chosenSubproject->variables[ varname ] += ( " " + fileName ); + + QMap replaceMap; + replaceMap.insert( varname, d->chosenSubproject->variables[ varname ] ); + + AutoProjectTool::addToMakefileam( d->chosenSubproject->path + "/Makefile.am", replaceMap ); + } + else + { + fitem = d->widget->createFileItem( fileName,d->chosenSubproject ); + d->chosenTarget->sources.append( fitem ); + d->chosenTarget->insertItem( fitem ); + + QString canontargetname = AutoProjectTool::canonicalize( d->chosenTarget->name ); + QString varname = canontargetname + "_SOURCES"; + d->chosenSubproject->variables[ varname ] += ( " " + fileName ); + + QMap replaceMap; + replaceMap.insert( varname, d->chosenSubproject->variables[ varname ] ); + + AutoProjectTool::addToMakefileam( d->chosenSubproject->path + "/Makefile.am", replaceMap ); + } + newFileList.append ( d->chosenSubproject->path.mid ( d->part->projectDirectory().length() + 1 ) + "/" + fileName ); + } + + if ( directory.isEmpty() || directory != d->chosenSubproject->subdir ) + { + KShellProcess proc("/bin/sh"); + + proc << "mv"; + proc << KShellProcess::quote( d->part->projectDirectory() + "/" + directory + "/" + fileName ); + proc << KShellProcess::quote( d->chosenSubproject->path + "/" + fileName ); + proc.start(KProcess::DontCare); + } + + // why open the files?! +// d->part->partController()->editDocument ( KURL ( d->chosenSubproject->path + "/" + fileName ) ); + + found = false; + } + + d->widget->emitAddedFiles( newFileList ); + KDialogBase::slotOk(); +} + +TargetItem* ChooseTargetDialog::chosenTarget() +{ + return d->chosenTarget; +} + +SubprojectItem* ChooseTargetDialog::chosenSubproject() +{ + return d->chosenSubproject; +} + +bool ChooseTargetDialog::alwaysUseActiveTarget() const +{ + return d->baseUI->neverAskAgainCheckbox->isChecked(); +} + + +#include "choosetargetdialog.moc" +//kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/choosetargetdialog.h b/buildtools/autotools/choosetargetdialog.h new file mode 100644 index 00000000..44825ce5 --- /dev/null +++ b/buildtools/autotools/choosetargetdialog.h @@ -0,0 +1,57 @@ +/*************************************************************************** + ------------------- + begin : 29.11.2002 + copyright : (C) 2002 by Victor Rder + email : 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. * + * * + ***************************************************************************/ + +#ifndef _CHOOSETARGETDIALOG_H_ +#define _CHOOSETARGETDIALOG_H_ + +#include + +class AutoProjectWidget; +class AutoProjectPart; +class SubprojectItem; +class TargetItem; +class QStringList; +class QWidget; + +class ChooseTargetDialog : public KDialogBase +{ +Q_OBJECT +public: + ChooseTargetDialog( AutoProjectWidget* widget, AutoProjectPart* part, + QStringList fileList, QWidget* parent = 0, + const char* name = 0 ); + ~ChooseTargetDialog(); + +public: + TargetItem* chosenTarget(); + SubprojectItem* chosenSubproject(); + + bool alwaysUseActiveTarget() const; + +public slots: + void slotSubprojectChanged ( const QString& ); + void slotTargetChanged ( const QString& ); + +protected: + virtual void slotOk(); + +private: + class Private; + ChooseTargetDialog::Private* d; +}; + +#endif +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/choosetargetdlgbase.ui b/buildtools/autotools/choosetargetdlgbase.ui new file mode 100644 index 00000000..3581e595 --- /dev/null +++ b/buildtools/autotools/choosetargetdlgbase.ui @@ -0,0 +1,222 @@ + +ChooseTargetDlgBase + + + ChooseTargetDlgBase + + + + 0 + 0 + 444 + 306 + + + + + 444 + 306 + + + + Automake Manager - Choose Target + + + + unnamed + + + + buttonGroup1 + + + NoFrame + + + Plain + + + 1 + + + + + + false + + + + unnamed + + + 0 + + + + activeTargetRadioButton + + + Add new files to m&y active target + + + true + + + + + chooseTargetRadioButton + + + Choose &another target + + + + + + + chosenTargetGroupBox + + + false + + + Choose &Target + + + + unnamed + + + + subprojectComboBox + + + false + + + + + targetComboBox + + + true + + + + + targetStaticLabel + + + + + + + Target: + + + + + chosenTargetLabel + + + + 7 + 5 + 0 + 0 + + + + [TARGET] + + + + + + + groupBox1 + + + &New Files + + + + unnamed + + + + newFileList + + + true + + + + + cancelNoticeLabel + + + <qt><b>Note:</b> If you cancel, your files will be created but will <b>not</b> be added to the project.</qt> + + + AlignVCenter + + + + + + + neverAskAgainCheckbox + + + Do &not ask me again and use always my active target + + + + + + + activeTargetRadioButton + toggled(bool) + chosenTargetGroupBox + setDisabled(bool) + + + activeTargetRadioButton + toggled(bool) + subprojectComboBox + setDisabled(bool) + + + activeTargetRadioButton + toggled(bool) + targetComboBox + setDisabled(bool) + + + + activeTargetRadioButton + chooseTargetRadioButton + subprojectComboBox + targetComboBox + newFileList + neverAskAgainCheckbox + + + kdialog.h + + + slotActiveTargetToggled(bool) + slotChooseTargetToggled(bool) + slotSubprojectChanged(const QString&) + slotTargetChanged(const QString&) + + + + kcombobox.h + klineedit.h + kcombobox.h + klineedit.h + klistview.h + + diff --git a/buildtools/autotools/configureoptionswidget.cpp b/buildtools/autotools/configureoptionswidget.cpp new file mode 100644 index 00000000..7e2db214 --- /dev/null +++ b/buildtools/autotools/configureoptionswidget.cpp @@ -0,0 +1,431 @@ +/*************************************************************************** + * Copyright (C) 2001-2002 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "configureoptionswidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kdevcompileroptions.h" +#include "autoprojectpart.h" +#include "environmentvariableswidget.h" + + +class ServiceComboBox +{ +public: + static void insertStringList(QComboBox *combo, const QValueList &list, + QStringList *names, QStringList *execs) + { + QValueList::ConstIterator it; + for (it = list.begin(); it != list.end(); ++it) { + combo->insertItem((*it)->comment()); + (*names) << (*it)->desktopEntryName(); + (*execs) << (*it)->exec(); + kdDebug(9020) << "insertStringList item " << (*it)->name() << "," << (*it)->exec() << endl; + } + } + static QString currentText(QComboBox *combo, const QStringList &names) + { + if (combo->currentItem() == -1) + return QString::null; + return names[combo->currentItem()]; + } + static void setCurrentText(QComboBox *combo, const QString &str, const QStringList &names) + { + QStringList::ConstIterator it; + int i = 0; + for (it = names.begin(); it != names.end(); ++it) { + if (*it == str) { + combo->setCurrentItem(i); + break; + } + ++i; + } + } +}; + + +ConfigureOptionsWidget::ConfigureOptionsWidget(AutoProjectPart *part, QWidget *parent, const char *name) + : ConfigureOptionsWidgetBase(parent, name) +{ + config_combo->setValidator(new QRegExpValidator(QRegExp("^\\D.*"), this)); + + m_part = part; + env_groupBox->setColumnLayout( 1, Qt::Vertical ); + QDomDocument &dom = *part->projectDom(); + m_environmentVariablesWidget = new EnvironmentVariablesWidget(dom, "/kdevautoproject/general/envvars", env_groupBox); + + coffers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'C'"); + cxxoffers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'C++'"); + f77offers = KTrader::self()->query("KDevelop/CompilerOptions", "[X-KDevelop-Language] == 'Fortran'"); + + ServiceComboBox::insertStringList(cservice_combo, coffers, &cservice_names, &cservice_execs); + ServiceComboBox::insertStringList(cxxservice_combo, cxxoffers, &cxxservice_names, &cxxservice_execs); + ServiceComboBox::insertStringList(f77service_combo, f77offers, &f77service_names, &f77service_execs); + + if (coffers.isEmpty()) + cflags_button->setEnabled(false); + if (cxxoffers.isEmpty()) + cxxflags_button->setEnabled(false); + if (f77offers.isEmpty()) + f77flags_button->setEnabled(false); + + allConfigs = part->allBuildConfigs(); + config_combo->insertStringList(allConfigs); + + dirty = false; + currentConfig = QString::null; + configChanged(part->currentBuildConfig()); + + fixLayout(); +} + + +ConfigureOptionsWidget::~ConfigureOptionsWidget() +{} + + +void ConfigureOptionsWidget::fixLayout() +{ + int w1 = ccompiler_label->sizeHint().width(); + int w2 = cbinary_label->sizeHint().width(); + int w3 = cflags_label->sizeHint().width(); + int w4 = cxxcompiler_label->sizeHint().width(); + int w5 = cxxbinary_label->sizeHint().width(); + int w6 = cxxflags_label->sizeHint().width(); + int w7 = f77compiler_label->sizeHint().width(); + int w8 = f77binary_label->sizeHint().width(); + int w9 = f77flags_label->sizeHint().width(); + + int w = QMAX(w1, QMAX(w2, w3)); + w = QMAX(w, QMAX(w4, w5)); + w = QMAX(w, QMAX(w6, w7)); + w = QMAX(w, QMAX(w8, w9)); + + ccompiler_label->setMinimumWidth(w); + cxxcompiler_label->setMinimumWidth(w); + f77compiler_label->setMinimumWidth(w); +} + + +void ConfigureOptionsWidget::readSettings(const QString &config) +{ + QDomDocument dom = *m_part->projectDom(); + QString prefix = "/kdevautoproject/configurations/" + config + "/"; + kdDebug(9020) << "Reading config from " << prefix << endl; + + configargs_edit->setText(DomUtil::readEntry(dom, prefix + "configargs")); + QString builddir = DomUtil::readEntry(dom, prefix + "builddir"); + if (builddir.isEmpty() && config != "default") + builddir = config; + builddir_edit->setText(builddir); + + topsourcedir_edit->setText(DomUtil::readEntry(dom, prefix + "topsourcedir")); + + cppflags_edit->setText(DomUtil::readEntry(dom, prefix + "cppflags")); + ldflags_edit->setText(DomUtil::readEntry(dom, prefix + "ldflags")); + + QString ccompiler = DomUtil::readEntry(dom, prefix + "ccompiler"); + QString cxxcompiler = DomUtil::readEntry(dom, prefix + "cxxcompiler"); + QString f77compiler = DomUtil::readEntry(dom, prefix + "f77compiler"); + + if (ccompiler.isEmpty()) { + kdDebug(9020) << "No c compiler set" << endl; + QValueList::ConstIterator it; + for (it = coffers.begin(); it != coffers.end(); ++it) { + if ((*it)->property("X-KDevelop-Default").toBool()) { + kdDebug(9020) << "Found default " << (*it)->name() << endl; + ccompiler = (*it)->name(); + break; + } + } + } + if (cxxcompiler.isEmpty()) { + kdDebug(9020) << "No cxx compiler set" << endl; + QValueList::ConstIterator it; + for (it = cxxoffers.begin(); it != cxxoffers.end(); ++it) { + if ((*it)->property("X-KDevelop-Default").toBool()) { + kdDebug(9020) << "Found default " << (*it)->name() << endl; + cxxcompiler = (*it)->name(); + break; + } + } + } + if (f77compiler.isEmpty()) { + kdDebug(9020) << "No c compiler set" << endl; + QValueList::ConstIterator it; + for (it = f77offers.begin(); it != f77offers.end(); ++it) { + if ((*it)->property("X-KDevelop-Default").toBool()) { + kdDebug(9020) << "Found default " << (*it)->name() << endl; + f77compiler = (*it)->name(); + break; + } + } + } + + ServiceComboBox::setCurrentText(cservice_combo, ccompiler, cservice_names); + ServiceComboBox::setCurrentText(cxxservice_combo, cxxcompiler, cxxservice_names); + ServiceComboBox::setCurrentText(f77service_combo, f77compiler, f77service_names); + + cbinary_edit->setText(DomUtil::readEntry(dom, prefix + "ccompilerbinary")); + cxxbinary_edit->setText(DomUtil::readEntry(dom, prefix + "cxxcompilerbinary")); + f77binary_edit->setText(DomUtil::readEntry(dom, prefix + "f77compilerbinary")); + + cflags_edit->setText(DomUtil::readEntry(dom, prefix + "cflags")); + cxxflags_edit->setText(DomUtil::readEntry(dom, prefix + "cxxflags")); + f77flags_edit->setText(DomUtil::readEntry(dom, prefix + "f77flags")); + + m_environmentVariablesWidget->readEnvironment(dom, prefix + "envvars"); +} + + +void ConfigureOptionsWidget::saveSettings(const QString &config) +{ + m_environmentVariablesWidget->accept(); + QDomDocument dom = *m_part->projectDom(); + QString prefix = "/kdevautoproject/configurations/" + config + "/"; + kdDebug(9020) << "Saving config under " << prefix << endl; + + DomUtil::writeEntry(dom, prefix + "configargs", configargs_edit->text()); + DomUtil::writeEntry(dom, prefix + "builddir", builddir_edit->text()); + DomUtil::writeEntry(dom, prefix + "topsourcedir", topsourcedir_edit->text()); + + DomUtil::writeEntry(dom, prefix + "cppflags", cppflags_edit->text()); + DomUtil::writeEntry(dom, prefix + "ldflags", ldflags_edit->text()); + + QFileInfo fi(m_part->buildDirectory()); + QDir dir(fi.dir()); + dir.mkdir(fi.fileName()); + + DomUtil::writeEntry(dom, prefix + "ccompiler", + ServiceComboBox::currentText(cservice_combo, cservice_names)); + DomUtil::writeEntry(dom, prefix + "cxxcompiler", + ServiceComboBox::currentText(cxxservice_combo, cxxservice_names)); + DomUtil::writeEntry(dom, prefix + "f77compiler", + ServiceComboBox::currentText(f77service_combo, f77service_names)); + + DomUtil::writeEntry(dom, prefix + "ccompilerbinary", cbinary_edit->text()); + DomUtil::writeEntry(dom, prefix + "cxxcompilerbinary", cxxbinary_edit->text()); + DomUtil::writeEntry(dom, prefix + "f77compilerbinary", f77binary_edit->text()); + + DomUtil::writeEntry(dom, prefix + "cflags", cflags_edit->text()); + DomUtil::writeEntry(dom, prefix + "cxxflags", cxxflags_edit->text()); + DomUtil::writeEntry(dom, prefix + "f77flags", f77flags_edit->text()); + + if (KMessageBox::questionYesNo(this, i18n("Re-run configure for %1 now?").arg(config), QString::null, i18n("Rerun"), i18n("Do Not Run")) == KMessageBox::Yes) + QTimer::singleShot(0, m_part, SLOT(slotConfigure())); + +} + + +void ConfigureOptionsWidget::setDirty() +{ + kdDebug(9020) << "config dirty" << endl; + dirty = true; +} + + +void ConfigureOptionsWidget::builddirClicked() +{ + QString dir = builddir_edit->text(); + dir = KFileDialog::getExistingDirectory(dir, this); + if (!dir.isNull()) + builddir_edit->setText(dir); +} + +void ConfigureOptionsWidget::topsourcedirClicked() +{ + QString dir = topsourcedir_edit->text(); + dir = KFileDialog::getExistingDirectory(dir, this); + if (!dir.isNull()) + topsourcedir_edit->setText(dir); +} + +void ConfigureOptionsWidget::configComboTextChanged(const QString &config) +{ + bool canAdd = !allConfigs.contains(config) && !config.contains("/") && !config.isEmpty(); + bool canRemove = allConfigs.contains(config) && config != "default"; + addconfig_button->setEnabled(canAdd); + removeconfig_button->setEnabled(canRemove); +} + + +void ConfigureOptionsWidget::configChanged(const QString &config) +{ + if (config == currentConfig || !allConfigs.contains(config)) + return; + + if (!currentConfig.isNull() && dirty) + saveSettings(currentConfig); + + currentConfig = config; + readSettings(config); + dirty = false; + + config_combo->blockSignals(true); + config_combo->setEditText(config); + config_combo->blockSignals(false); +} + + +void ConfigureOptionsWidget::configAdded() +{ + QString config = config_combo->currentText(); + + allConfigs.append(config); + + config_combo->clear(); + config_combo->insertStringList(allConfigs); + configChanged(config); + setDirty(); // force saving +} + + +void ConfigureOptionsWidget::configRemoved() +{ + QString config = config_combo->currentText(); + + QDomDocument dom = *m_part->projectDom(); + QDomNode node = dom.documentElement().namedItem("kdevautoproject").namedItem("configurations"); + node.removeChild(node.namedItem(config)); + allConfigs.remove(config); + + config_combo->clear(); + config_combo->insertStringList(allConfigs); + + currentConfig = QString::null; + configChanged("default"); +} + + +void ConfigureOptionsWidget::cserviceChanged() +{ + QString exec = ServiceComboBox::currentText(cservice_combo, cservice_execs); + cbinary_edit->setText(exec); + kdDebug(9020) << "exec: " << exec << endl; +} + + +void ConfigureOptionsWidget::cxxserviceChanged() +{ + QString exec = ServiceComboBox::currentText(cxxservice_combo, cxxservice_execs); + cxxbinary_edit->setText(exec); +} + + +void ConfigureOptionsWidget::f77serviceChanged() +{ + QString exec = ServiceComboBox::currentText(f77service_combo, f77service_execs); + f77binary_edit->setText(exec); + kdDebug(9020) << "exec: " << exec << endl; +} + + +void ConfigureOptionsWidget::cflagsClicked() +{ + QString name = ServiceComboBox::currentText(cservice_combo, cservice_names); + KDevCompilerOptions *plugin = createCompilerOptions(name); + + if (plugin) { + QString flags = plugin->exec(this, cflags_edit->text()); + cflags_edit->setText(flags); + delete plugin; + } +} + + +void ConfigureOptionsWidget::cxxflagsClicked() +{ + QString name = ServiceComboBox::currentText(cxxservice_combo, cxxservice_names); + KDevCompilerOptions *plugin = createCompilerOptions(name); + + if (plugin) { + QString flags = plugin->exec(this, cxxflags_edit->text()); + cxxflags_edit->setText(flags); + delete plugin; + } +} + + +void ConfigureOptionsWidget::f77flagsClicked() +{ + QString name = ServiceComboBox::currentText(f77service_combo, f77service_names); + KDevCompilerOptions *plugin = createCompilerOptions(name); + + if (plugin) { + QString flags = plugin->exec(this, f77flags_edit->text()); + f77flags_edit->setText(flags); + delete plugin; + } +} + + +KDevCompilerOptions *ConfigureOptionsWidget::createCompilerOptions(const QString &name) +{ + KService::Ptr service = KService::serviceByDesktopName(name); + if (!service) { + kdDebug(9020) << "Can't find service " << name; + return 0; + } + + KLibFactory *factory = KLibLoader::self()->factory(QFile::encodeName(service->library())); + if (!factory) { + QString errorMessage = KLibLoader::self()->lastErrorMessage(); + KMessageBox::error(0, i18n("There was an error loading the module %1.\n" + "The diagnostics is:\n%2").arg(service->name()).arg(errorMessage)); + exit(1); + } + + QStringList args; + QVariant prop = service->property("X-KDevelop-Args"); + if (prop.isValid()) + args = QStringList::split(" ", prop.toString()); + + QObject *obj = factory->create(this, service->name().latin1(), + "KDevCompilerOptions", args); + + if (!obj->inherits("KDevCompilerOptions")) { + kdDebug(9020) << "Component does not inherit KDevCompilerOptions" << endl; + return 0; + } + KDevCompilerOptions *dlg = (KDevCompilerOptions*) obj; + + return dlg; +} + + +void ConfigureOptionsWidget::accept() +{ + DomUtil::writeEntry(*m_part->projectDom(), "/kdevautoproject/general/useconfiguration", currentConfig); + m_environmentVariablesWidget->accept(); + if (dirty) + { + saveSettings(currentConfig); + } +} + +#include "configureoptionswidget.moc" diff --git a/buildtools/autotools/configureoptionswidget.h b/buildtools/autotools/configureoptionswidget.h new file mode 100644 index 00000000..a973ce7d --- /dev/null +++ b/buildtools/autotools/configureoptionswidget.h @@ -0,0 +1,69 @@ +/*************************************************************************** +* Copyright (C) 2001-2002 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _CONFIGUREOPTIONSWIDGET_H_ +#define _CONFIGUREOPTIONSWIDGET_H_ + +#include "configureoptionswidgetbase.h" + +#include +#include "domutil.h" + + +class KDevCompilerOptions; +class AutoProjectPart; +class EnvironmentVariablesWidget; + +class ConfigureOptionsWidget : public ConfigureOptionsWidgetBase +{ + Q_OBJECT + +public: + ConfigureOptionsWidget( AutoProjectPart *part, QWidget *parent = 0, const char *name = 0 ); + ~ConfigureOptionsWidget(); + +public slots: + void accept(); + +private: + virtual void builddirClicked(); + virtual void topsourcedirClicked(); + virtual void setDirty(); + virtual void configChanged( const QString &config ); + virtual void configComboTextChanged( const QString &config ); + virtual void configAdded(); + virtual void configRemoved(); + virtual void cflagsClicked(); + virtual void cxxflagsClicked(); + virtual void f77flagsClicked(); + virtual void cserviceChanged(); + virtual void cxxserviceChanged(); + virtual void f77serviceChanged(); + + void fixLayout(); + void readSettings( const QString &config ); + void saveSettings( const QString &config ); + + KDevCompilerOptions *createCompilerOptions( const QString &lang ); + KTrader::OfferList coffers, cxxoffers, f77offers; + QStringList cservice_names, cservice_execs; + QStringList cxxservice_names, cxxservice_execs; + QStringList f77service_names, f77service_execs; + QStringList allConfigs; + QString currentConfig; + bool dirty; + + AutoProjectPart *m_part; + EnvironmentVariablesWidget* m_environmentVariablesWidget; +}; + +#endif +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/configureoptionswidgetbase.ui b/buildtools/autotools/configureoptionswidgetbase.ui new file mode 100644 index 00000000..0eb47ac7 --- /dev/null +++ b/buildtools/autotools/configureoptionswidgetbase.ui @@ -0,0 +1,1040 @@ + +ConfigureOptionsWidgetBase + + + configure_options_widget + + + + 0 + 0 + 628 + 607 + + + + Configure Options + + + + unnamed + + + 0 + + + + Layout1 + + + + unnamed + + + + config_label + + + + 1 + 5 + 0 + 0 + + + + &Configuration: + + + config_combo + + + + + config_combo + + + + 3 + 0 + 0 + 0 + + + + true + + + Different build profiles + + + profiles + + + + + Spacer17_2 + + + Horizontal + + + Fixed + + + + 20 + 8 + + + + + + addconfig_button + + + &Add + + + false + + + + + removeconfig_button + + + &Remove + + + false + + + + + Spacer18_2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + + + tabwidget + + + + general_tab + + + &General + + + + unnamed + + + + configargs_edit + + + Options to pass to configure, e.g. --prefix=<install dir> + + + Options to pass to configure, e.g. --prefix=<install dir> + + + + + builddir_label + + + &Build directory (must be different for every different configuration): + + + builddir_edit + + + + + Spacer23 + + + Horizontal + + + Fixed + + + + 20 + 20 + + + + + + topsourcedir_label + + + Top source &directory: + + + topsourcedir_edit + + + + + builddir_edit + + + The build process will place the object +files and binary in this directory. + +If the name does not have a leading / +then it is relative to the project directory. +(in the General page) + +The build process also checks here for +a Makefile and a configure script. + +If you have imported a project and you were +building in the project directory, you +probably want this to be blank. + + + The build process will place the object +files and binary in this directory. + +If the name does not have a leading / +then it is relative to the project directory. +(in the General page) + +The build process also checks here for +a Makefile and a configure script. + +If you have imported a project and you were +building in the project directory, you +probably want this to be blank. + + + + + builddir_button + + + + 30 + 0 + + + + + 30 + 32767 + + + + ... + + + + + Spacer24 + + + Horizontal + + + Fixed + + + + 20 + 20 + + + + + + topsourcedir_button + + + + 30 + 0 + + + + + 30 + 32767 + + + + ... + + + + + topsourcedir_edit + + + Where to start looking for the src files. +If the name does not have a leading / +then it is relative to the project directory. +(in the General page) + + + Where to start looking for the src files. +If the name does not have a leading / +then it is relative to the project directory. +(in the General page) + + + + + spacer17 + + + Horizontal + + + Fixed + + + + 20 + 20 + + + + + + ldflags_label + + + Li&nker flags (LDFLAGS): + + + ldflags_edit + + + Linker flags, e.g. -L<lib dir> if you have libraries in a +nonstandard directory <lib dir> + + + + + spacer17_2_2 + + + Horizontal + + + Fixed + + + + 20 + 20 + + + + + + ldflags_edit + + + Linker flags, e.g. -L<lib dir> if you have libraries in a +nonstandard directory <lib dir> + + + Linker flags, e.g. -L<lib dir> if you have libraries in a +nonstandard directory <lib dir> + + + + + cppflags_edit + + + C/C++ preprocessor flags, e.g. -I<include dir> if you have +headers in a nonstandard directory <include dir> + + + C/C++ preprocessor flags, e.g. -I<include dir> if you have +headers in a nonstandard directory <include dir> + + + + + spacer17_2 + + + Horizontal + + + Fixed + + + + 20 + 20 + + + + + + cppflags_label + + + C/C++ &preprocessor flags (CPPFLAGS): + + + cppflags_edit + + + C/C++ preprocessor flags, e.g. -I<include dir> if you have +headers in a nonstandard directory <include dir> + + + + + configargs_label + + + Configure argu&ments: + + + configargs_edit + + + + + env_groupBox + + + + 5 + 3 + 0 + 0 + + + + Environment &Variables + + + + unnamed + + + + + + + + c_tab + + + C + + + + unnamed + + + + ccompiler_label + + + C com&piler: + + + cservice_combo + + + + + cservice_combo + + + + + Spacer11 + + + Vertical + + + Fixed + + + + 20 + 20 + + + + + + cflags_label + + + Compiler f&lags (CFLAGS): + + + cflags_edit + + + + + cflags_edit + + + + + cflags_button + + + + 0 + 0 + 0 + 0 + + + + + 30 + 32767 + + + + ... + + + + + Spacer10 + + + Vertical + + + Expanding + + + + 20 + 168 + + + + + + cbinary_label + + + Compiler co&mmand (CC): + + + cbinary_edit + + + + + cbinary_edit + + + + + Spacer12 + + + Vertical + + + Fixed + + + + 20 + 20 + + + + + + + + cxx_tab + + + C++ + + + + unnamed + + + + cxxcompiler_label + + + C++ com&piler: + + + cxxservice_combo + + + + + cxxservice_combo + + + + + Spacer13 + + + Vertical + + + Fixed + + + + 20 + 20 + + + + + + cxxbinary_label + + + Compiler co&mmand (CXX): + + + cxxbinary_edit + + + + + cxxbinary_edit + + + + + Spacer13_2 + + + Vertical + + + Fixed + + + + 20 + 20 + + + + + + cxxflags_label + + + Compiler flags (C&XXFLAGS): + + + cxxflags_edit + + + + + cxxflags_edit + + + + + cxxflags_button + + + + 0 + 0 + 0 + 0 + + + + + 30 + 32767 + + + + ... + + + + + Spacer16 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + fortran_tab + + + F&ortran + + + + unnamed + + + + f77compiler_label + + + Fortra&n compiler: + + + f77service_combo + + + + + f77service_combo + + + + + Spacer16_2 + + + Vertical + + + Fixed + + + + 20 + 20 + + + + + + f77binary_label + + + Compiler co&mmand (F77): + + + f77binary_edit + + + + + f77binary_edit + + + + + Spacer17 + + + Vertical + + + Fixed + + + + 20 + 20 + + + + + + f77flags_label + + + Compiler f&lags (FFLAGS): + + + f77flags_edit + + + + + f77flags_edit + + + + + f77flags_button + + + + 0 + 0 + 0 + 0 + + + + + 30 + 32767 + + + + ... + + + + + Spacer18 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + + cflags_button + clicked() + configure_options_widget + cflagsClicked() + + + f77flags_button + clicked() + configure_options_widget + f77flagsClicked() + + + cservice_combo + activated(int) + configure_options_widget + cserviceChanged() + + + f77service_combo + activated(int) + configure_options_widget + f77serviceChanged() + + + cxxflags_button + clicked() + configure_options_widget + cxxflagsClicked() + + + cxxservice_combo + activated(int) + configure_options_widget + cxxserviceChanged() + + + addconfig_button + clicked() + configure_options_widget + configAdded() + + + removeconfig_button + clicked() + configure_options_widget + configRemoved() + + + config_combo + activated(const QString&) + configure_options_widget + configChanged(const QString&) + + + config_combo + textChanged(const QString&) + configure_options_widget + configComboTextChanged(const QString&) + + + builddir_button + clicked() + configure_options_widget + builddirClicked() + + + configargs_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + builddir_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + cbinary_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + cflags_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + cxxbinary_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + cxxflags_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + f77binary_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + f77flags_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + topsourcedir_button + clicked() + configure_options_widget + topsourcedirClicked() + + + topsourcedir_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + cppflags_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + ldflags_edit + textChanged(const QString&) + configure_options_widget + setDirty() + + + + configargs_edit + builddir_edit + builddir_button + topsourcedir_edit + topsourcedir_button + cppflags_edit + ldflags_edit + tabwidget + config_combo + addconfig_button + removeconfig_button + cservice_combo + cbinary_edit + cflags_edit + cflags_button + cxxservice_combo + cxxbinary_edit + cxxflags_edit + cxxflags_button + f77service_combo + f77binary_edit + f77flags_edit + f77flags_button + + + kdialog.h + + + builddirClicked() + cflagsClicked() + configAdded() + configChanged(const QString&) + configComboTextChanged(const QString&) + configRemoved() + cserviceChanged() + cxxflagsClicked() + cxxserviceChanged() + f77flagsClicked() + f77serviceChanged() + setDirty() + topsourcedirClicked() + + + + + klineedit.h + + diff --git a/buildtools/autotools/fileselectorwidget.cpp b/buildtools/autotools/fileselectorwidget.cpp new file mode 100644 index 00000000..65b87bf7 --- /dev/null +++ b/buildtools/autotools/fileselectorwidget.cpp @@ -0,0 +1,243 @@ +/**************************************************************************** + * Copyright (C) 2001 by Hugo Varotto * + * hugo@varotto-usa.com * + * * + * Based on Kate's fileselector widget by * + * Matt Newell * + * (C) 2001 by Matt Newell * + * newellm@proaxis.com * + * * + * 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "fileselectorwidget.h" +#include +#include +#include +#include +#include +#include + +#include "autoprojectwidget.h" +#include "autoprojectpart.h" +#include "kdevlanguagesupport.h" + +#include "kfilednddetailview.h" +#include "kfiledndiconview.h" + +KDnDDirOperator::KDnDDirOperator ( const KURL &urlName, QWidget* parent, const char* name ) : KDirOperator ( urlName, parent, name ) +{ + +} + +KFileView* KDnDDirOperator::createView( QWidget* parent, KFile::FileView view ) +{ + KFileView* new_view = 0L; + + if( (view & KFile::Detail) == KFile::Detail ) { + new_view = new KFileDnDDetailView( parent, "detail view"); + } + else if ((view & KFile::Simple) == KFile::Simple ) { + new_view = new KFileDnDIconView( parent, "simple view"); + new_view->setViewName( i18n("Short View") ); + } + + return new_view; +} + + +FileSelectorWidget::FileSelectorWidget(AutoProjectPart* part, KFile::Mode mode, QWidget* parent, const char* name ) : QWidget(parent, name) +{ + m_part = part; + + // widgets and layout + QVBoxLayout* lo = new QVBoxLayout(this); + + QHBox *hlow = new QHBox (this); + lo->addWidget(hlow); + + home = new QPushButton( hlow ); + home->setPixmap(SmallIcon("gohome")); + QToolTip::add(home, i18n("Home directory")); + up = new QPushButton( /*i18n("&Up"),*/ hlow ); + up->setPixmap(SmallIcon("up")); + QToolTip::add(up, i18n("Up one level")); + back = new QPushButton( /*i18n("&Back"),*/ hlow ); + back->setPixmap(SmallIcon("back")); + QToolTip::add(back, i18n("Previous directory")); + forward = new QPushButton( /*i18n("&Next"),*/ hlow ); + forward->setPixmap(SmallIcon("forward")); + QToolTip::add(forward, i18n("Next directory")); + + // HACK + QWidget* spacer = new QWidget(hlow); + hlow->setStretchFactor(spacer, 1); + hlow->setMaximumHeight(up->height()); + + cmbPath = new KURLComboBox( KURLComboBox::Directories, true, this, "path combo" ); + cmbPath->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed )); + KURLCompletion* cmpl = new KURLCompletion(); + cmbPath->setCompletionObject( cmpl ); + lo->addWidget(cmbPath); + + dir = new KDnDDirOperator(KURL(), this, "operator"); + dir->setView(KFile::Simple); + dir->setMode(mode); + + lo->addWidget(dir); + lo->setStretchFactor(dir, 2); + + QHBox* filterBox = new QHBox(this); + filterIcon = new QLabel(filterBox); + filterIcon->setPixmap( BarIcon("filter") ); + filter = new KHistoryCombo(filterBox, "filter"); + filter->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed )); + filterBox->setStretchFactor(filter, 2); + lo->addWidget(filterBox); + + // slots and signals + connect( filter, SIGNAL( textChanged(const QString&) ), SLOT( slotFilterChanged(const QString&) ) ); + connect( filter, SIGNAL( activated(const QString&) ), SLOT( slotFilterChanged(const QString&) ) ); + connect( filter, SIGNAL( returnPressed(const QString&) ), SLOT( filterReturnPressed(const QString&) ) ); + + connect( home, SIGNAL( clicked() ), dir, SLOT( home() ) ); + connect( up, SIGNAL( clicked() ), dir, SLOT( cdUp() ) ); + connect( back, SIGNAL( clicked() ), dir, SLOT( back() ) ); + connect( forward, SIGNAL( clicked() ), dir, SLOT( forward() ) ); + + connect( cmbPath, SIGNAL( urlActivated( const KURL& )), this, SLOT( cmbPathActivated( const KURL& ) )); + //connect( cmbPath, SIGNAL( returnPressed( const QString& )), this, SLOT( cmbPathReturnPressed( const QString& ) )); + connect( dir, SIGNAL(urlEntered(const KURL&)), this, SLOT(dirUrlEntered(const KURL&)) ); + + connect( dir, SIGNAL(finishedLoading()), this, SLOT(dirFinishedLoading()) ); + +// dirUrlEntered( dir->url() ); + + QStringList list; + + /* read the file patterns from the project DOM */ + QDomElement docEl = m_part->projectDom()->documentElement(); + QDomElement fileviewEl = docEl.namedItem("kdevfileview").toElement(); + QDomElement groupsEl = fileviewEl.namedItem("groups").toElement(); + QDomElement groupEl = groupsEl.firstChild().toElement(); + + while ( !groupEl.isNull() ) + { + if (groupEl.tagName() == "group") + { + list << groupEl.attribute("pattern").replace ( QRegExp ( ";" ), " " ) + " (" + groupEl.attribute("name") + ")"; + } + groupEl = groupEl.nextSibling().toElement(); + } + + filter->setHistoryItems ( list ); + +} + + +FileSelectorWidget::~FileSelectorWidget() +{ +} + +void FileSelectorWidget::dragEnterEvent ( QDragEnterEvent* /*ev*/ ) +{ +} + +void FileSelectorWidget::dropEvent ( QDropEvent* /*ev*/ ) +{ + kdDebug ( 9020 ) << "Dropped" << endl; + + QString path = "Something was dropped in the Destination directory file-selector"; + + emit dropped ( path ); + +} + +void FileSelectorWidget::filterReturnPressed ( const QString& nf ) +{ + // KURL u ( m_part->project()->projectDirectory() ); + setDir ( nf ); +} + +void FileSelectorWidget::slotFilterChanged( const QString & nf ) +{ + dir->setNameFilter( nf ); + dir->updateDir(); +} + +void FileSelectorWidget::cmbPathActivated( const KURL& u ) +{ + dir->setURL( u, true ); +} + +void FileSelectorWidget::cmbPathReturnPressed( const QString& u ) +{ + dir->setFocus(); + dir->setURL( KURL(u), true ); +} + + +void FileSelectorWidget::dirUrlEntered( const KURL& u ) +{ + cmbPath->removeURL( u ); + QStringList urls = cmbPath->urls(); + urls.prepend( u.url() ); + while ( urls.count() >= (uint)cmbPath->maxItems() ) + urls.remove( urls.last() ); + cmbPath->setURLs( urls ); +} + + +void FileSelectorWidget::dirFinishedLoading() +{ + // HACK - enable the nav buttons + // have to wait for diroperator... + up->setEnabled( dir->actionCollection()->action( "up" )->isEnabled() ); + back->setEnabled( dir->actionCollection()->action( "back" )->isEnabled() ); + forward->setEnabled( dir->actionCollection()->action( "forward" )->isEnabled() ); + home->setEnabled( dir->actionCollection()->action( "home" )->isEnabled() ); +} + + +void FileSelectorWidget::focusInEvent(QFocusEvent*) +{ + dir->setFocus(); +} + +void FileSelectorWidget::setDir( KURL u ) +{ + dir->setURL(u, true); +} + +void FileSelectorWidget::setDir(const QString& path) +{ + KURL u ( path ); + dir->setURL ( u, true ); +} + + +#include "fileselectorwidget.moc" + diff --git a/buildtools/autotools/fileselectorwidget.h b/buildtools/autotools/fileselectorwidget.h new file mode 100644 index 00000000..7a981194 --- /dev/null +++ b/buildtools/autotools/fileselectorwidget.h @@ -0,0 +1,96 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _FILESELECTORWIDGET_H_ +#define _FILESELECTORWIDGET_H_ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +class AutoProjectPart; +class SubprojectItem; +class KFile; + +class KDnDDirOperator : public KDirOperator +{ + Q_OBJECT + +public: + KDnDDirOperator ( const KURL& urlName = KURL(), QWidget *parent = 0, const char* name = 0 ); + +protected: + virtual KFileView* createView( QWidget* parent, KFile::FileView view ); +}; + +class FileSelectorWidget : public QWidget +{ + Q_OBJECT + +public: + FileSelectorWidget( AutoProjectPart* part, KFile::Mode, QWidget* parent = 0, const char* name = 0 ); + ~FileSelectorWidget(); + + KDnDDirOperator * dirOperator() + { + return dir; + } + +public slots: + void slotFilterChanged( const QString& ); + void setDir( KURL ); + void setDir( const QString& ); + +private slots: + void cmbPathActivated( const KURL& u ); + void cmbPathReturnPressed( const QString& u ); + void dirUrlEntered( const KURL& u ); + void dirFinishedLoading(); + void filterReturnPressed( const QString& nf ); + +protected: + void focusInEvent( QFocusEvent* ); + void dragEnterEvent ( QDragEnterEvent* ev ); + void dropEvent ( QDropEvent* ev ); + +private: + KURLComboBox *cmbPath; + KHistoryCombo * filter; + QLabel* filterIcon; + KDnDDirOperator * dir; + QPushButton *home, *up, *back, *forward; + AutoProjectPart* m_part; + +signals: + void dropped ( const QString& ); + +}; + +#endif +// kate: indent-mode csands; tab-width 4; + diff --git a/buildtools/autotools/kdevautoproject.desktop b/buildtools/autotools/kdevautoproject.desktop new file mode 100644 index 00000000..bc366556 --- /dev/null +++ b/buildtools/autotools/kdevautoproject.desktop @@ -0,0 +1,97 @@ +[Desktop Entry] +Type=Service +Exec=blubb +Comment=Automake Project +Comment[br]=Raktres Automake +Comment[ca]=Projecte Automake +Comment[da]=Automake-projekt +Comment[de]=Automake-Projekt für KDevelop +Comment[el]=Έργο Automake +Comment[es]=Proyecto de Automake +Comment[et]=Automake'i project +Comment[eu]=Automake proiektua +Comment[fa]=پروژۀ Automake +Comment[fr]=Projet avec Automake +Comment[ga]=Comhad tionscadail Automake +Comment[gl]=Proxecto Automake +Comment[hi]=ऑटोमेक परियोजना +Comment[hu]=Automake-projekt +Comment[is]=Automake verkefni +Comment[it]=Progetto per automake +Comment[ja]=Automake プロジェクト +Comment[ms]=Projek Automake +Comment[nds]=Automake-Projekt +Comment[ne]=स्वत: निर्माण परियोजना +Comment[nl]=Automake-project +Comment[pa]=ਆਟੋਮੈਕ ਪ੍ਰੋਜੈਕਟ +Comment[pl]=Projekt: Automake +Comment[pt]=Projecto Automake +Comment[pt_BR]=Projeto Automake +Comment[ru]=Проект Automake +Comment[sk]=Automake projekt +Comment[sl]=Projekt automake +Comment[sr]=Automake пројекат +Comment[sr@Latn]=Automake projekat +Comment[sv]=Automake-projekt +Comment[ta]=ஆட்டோமேக் பிராஜக்ட் +Comment[tg]=Лоиҳаи Automake +Comment[tr]=Automake Projesi +Comment[uz]=Automake loyihasi +Comment[uz@cyrillic]=Automake лойиҳаси +Comment[zh_CN]=Automake 工程 +Comment[zh_TW]=Automake 專案 +Name=KDevAutoProject +Name[da]=KDevelop Automake-projekt +Name[de]=Automake-Projekt (KDevelop) +Name[hi]=के-डेव-ऑटो-परियोजना +Name[nds]=Automake-Projekt (KDevelop) +Name[ne]=केडीई विकास स्वत: परियोजना +Name[pl]=KDevProjektAuto +Name[pt_BR]=KDevAutoProjeto +Name[sk]=KDevAutoProjekt +Name[sv]=KDevelop autoprojekt +Name[ta]=கெடெவ்ஆட்டோ பிராஜக்ட் +Name[tg]=Лоиҳаи KDevAuto +Name[zh_TW]=KDevelop Automake 專案 +GenericName=Automake Project +GenericName[br]=Raktres Automake +GenericName[ca]=Projecte Automake +GenericName[da]=Automake-projekt +GenericName[de]=Automake-Projekt +GenericName[el]=Έργο Automake +GenericName[es]=Proyecto de Automake +GenericName[et]=Automake'i projekt +GenericName[eu]=Automake proiektua +GenericName[fa]=پروژۀ Automake +GenericName[fr]=Projet avec Automake +GenericName[ga]=Comhad tionscadail Automake +GenericName[gl]=Proxecto Automake +GenericName[hi]=ऑटोमेक परियोजना +GenericName[hu]=Automake-projekt +GenericName[it]=Progetto Automake +GenericName[ja]=Automake プロジェクト +GenericName[ms]=Projek Automake +GenericName[nds]=Automake-Projekt +GenericName[ne]=स्वत: निर्माण परियोजना +GenericName[nl]=Automake-project +GenericName[pl]=Projekt: Automake +GenericName[pt]=Projecto de Automake +GenericName[pt_BR]=Projeto Automake +GenericName[ru]=Проект Automake +GenericName[sk]=Automake projekt +GenericName[sl]=Projekt automake +GenericName[sr]=Automake пројекат +GenericName[sr@Latn]=Automake projekat +GenericName[sv]=Automake-projekt +GenericName[ta]=ஆட்டோமேக் பிராஜக்ட் +GenericName[tg]=Лоиҳаи Automake +GenericName[tr]=Automake Projesi +GenericName[uz]=Automake loyihasi +GenericName[uz@cyrillic]=Automake лойиҳаси +GenericName[zh_CN]=Automake 工程 +GenericName[zh_TW]=Automake 專案 +ServiceTypes=KDevelop/Project +Icon=make +X-KDE-Library=libkdevautoproject +X-KDevelop-Version=5 +X-KDevelop-Args= diff --git a/buildtools/autotools/kdevautoproject.rc b/buildtools/autotools/kdevautoproject.rc new file mode 100644 index 00000000..89571c11 --- /dev/null +++ b/buildtools/autotools/kdevautoproject.rc @@ -0,0 +1,30 @@ + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/buildtools/autotools/kdevkdeautoproject.desktop b/buildtools/autotools/kdevkdeautoproject.desktop new file mode 100644 index 00000000..235f3071 --- /dev/null +++ b/buildtools/autotools/kdevkdeautoproject.desktop @@ -0,0 +1,92 @@ +[Desktop Entry] +Type=Service +Exec=blubb +Comment=KDE Automake Project +Comment[br]=Raktres KDE Automake +Comment[ca]=Projecte Automake per al KDE +Comment[da]=KDE Automake-projekt +Comment[de]=KDE-Automake-Projekt für KDevelop +Comment[el]=Έργο KDE Automake +Comment[es]=Proyecto de Automake de KDE +Comment[et]=KDE automake'i projekt +Comment[eu]=KDE automake proiektua +Comment[fa]=پروژۀ KDE Automake +Comment[fr]=Projet Automake pour KDE +Comment[ga]=Tionscadal Automake KDE +Comment[gl]=Proxecto Automake de KDE +Comment[hi]=केडीई ऑटोमेक परियोजना +Comment[hu]=KDE Automake-projekt +Comment[is]=KDE Automake verkefni +Comment[it]=Progetto KDE per automake +Comment[ja]=KDE Automake プロジェクト +Comment[ms]=Projek Automake KDE +Comment[nds]=Automake-Projekt vun KDE +Comment[ne]=केडीई स्वत: निर्माण परियोजना +Comment[nl]=KDE Automake-project +Comment[pt]=Projecto Automake do KDE +Comment[pt_BR]=Projeto Automake do KDE +Comment[ru]=Проект KDE Automake +Comment[sk]=KDE Automake projekt +Comment[sl]=Projekt KDE Automake +Comment[sr]=KDE-ов Automake пројекат +Comment[sr@Latn]=KDE-ov Automake projekat +Comment[sv]=KDE Automake-projekt +Comment[ta]=KDE ஆட்டோமேக் பிராஜக்ட் +Comment[tg]=Лоиҳаи KDE Automake +Comment[tr]=KDE Automake Projesi +Comment[zh_CN]=KDE Automake 工程 +Comment[zh_TW]=KDE Automake 專案 +Name=KDevKDEAutoProject +Name[da]=KDevelop KDE Automake-projekt +Name[de]=KDE-Automake-Projekt (KDevelop) +Name[hi]=के-डेव-केडीई-ऑटो-परियोजना +Name[nds]=Automake-Projekt (KDE/KDevelop) +Name[ne]=केडीई विकास केडीई स्वत: परियोजना +Name[pl]=KDevProjektKDEAuto +Name[pt_BR]=KDevKDEAutoProjeto +Name[sk]=KDevAutoProjekt +Name[sv]=KDevelop KDE-autoprojekt +Name[ta]=கெடெவ்ஆட்டோ பிராஜக்ட் +Name[tg]=Лоиҳаи худкори KDevKDEAuto +Name[zh_TW]=KDevelop KDE Automake 專案 +GenericName=KDE Automake Project +GenericName[br]=Raktres KDE Automake +GenericName[ca]=Projecte Automake per al KDE +GenericName[cs]=KDE Automake projekt +GenericName[da]=KDE Automake-projekt +GenericName[de]=KDE-Automake-Projekt +GenericName[el]=Έργο KDE Automake +GenericName[es]=Proyecto de Automake de KDE +GenericName[et]=KDE automake'i projekt +GenericName[eu]=KDE automake proiektua +GenericName[fa]=پروژۀ KDE Automake +GenericName[fr]=Projet avec Automake pour KDE +GenericName[ga]=Tionscadal Automake KDE +GenericName[gl]=Proxecto Automake de KDE +GenericName[hi]=केडीई ऑटोमेक परियोजना +GenericName[hu]=KDE Automake-projekt +GenericName[it]=Progetto KDE Automake +GenericName[ja]=KDE Automake プロジェクト +GenericName[ms]=Projek Automake KDE +GenericName[nds]=Automake-Projekt vun KDE +GenericName[ne]=केडीई स्वत: निर्माण परियोजना +GenericName[nl]=KDE Automake-project +GenericName[pl]=Projekt: KDE Automake +GenericName[pt]=Projecto KDE com Automake +GenericName[pt_BR]=Projeto Automake do KDE +GenericName[ru]=Проект KDE Automake +GenericName[sk]=KDE Automake projekt +GenericName[sl]=Projekt KDE Automake +GenericName[sr]=KDE-ов Automake пројекат +GenericName[sr@Latn]=KDE-ov Automake projekat +GenericName[sv]=KDE Automake-projekt +GenericName[ta]=KDE ஆட்டோமேக் பிராஜக்ட் +GenericName[tg]=Лоиҳаи KDE Automake +GenericName[tr]=KDE Automake Projesi +GenericName[zh_CN]=KDE Automake 工程 +GenericName[zh_TW]=KDE Automake 專案 +ServiceTypes=KDevelop/Project +Icon=make +X-KDE-Library=libkdevautoproject +X-KDevelop-Version=5 +X-KDevelop-Args=kde diff --git a/buildtools/autotools/kfilednddetailview.cpp b/buildtools/autotools/kfilednddetailview.cpp new file mode 100644 index 00000000..c75022fb --- /dev/null +++ b/buildtools/autotools/kfilednddetailview.cpp @@ -0,0 +1,212 @@ +/*************************************************************************** +* kfilednddetailview.cpp - description +* ------------------- +* begin : Wed Nov 1 2000 +* copyright : (C) 2000 by Bj�n Sahlstr� +* email : kbjorn@users.sourceforge.net +***************************************************************************/ + +/*************************************************************************** +* * +* 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. * +* * +***************************************************************************/ + +////////////////////////////////////////////////////// +// Qt specific includes +#include +#include +////////////////////////////////////////////////////// +// KDE specific includes +#include +#include +#include +////////////////////////////////////////////////////// +// Application specific includes +#include "kfilednddetailview.h" + +#ifndef AUTO_OPEN_TIME +#define AUTO_OPEN_TIME + static int autoOpenTime = 750; +#endif +//----------------------------------------------- +KFileDnDDetailView::KFileDnDDetailView(QWidget *parent, const char *name ) + : KFileDetailView(parent,name), m_autoOpenTimer( this ), + m_autoOpenTime( autoOpenTime ), m_useAutoOpenTimer( true ), + m_dropItem(0), m_dndEnabled( true ) +{ + setAutoUpdate( true ); + setDnDEnabled( true ); + useAutoOpenTimer( true ); +} +//----------------------------------------------- +KFileDnDDetailView::~KFileDnDDetailView(){ +} +//----------------------------------------------- +void KFileDnDDetailView::readConfig( KConfig* config, const QString& group ) { + KConfigGroupSaver cs( config, group ); + bool dnd = config->readBoolEntry("DragAndDrop", true ); + setDnDEnabled( dnd ); + KFileDetailView::readConfig( config, group ); +} +//----------------------------------------------- +void KFileDnDDetailView::writeConfig( KConfig* config, const QString& group ) { + KConfigGroupSaver cs( config, group ); + config->writeEntry("DragAndDrop", m_dndEnabled ); + KFileDetailView::writeConfig( config, group ); +} +//----------------------------------------------- +void KFileDnDDetailView::slotOpenFolder(){ + if( m_useAutoOpenTimer ) { + m_autoOpenTimer.stop(); + if( !m_dropItem ) + return; + } + KFileItemListIterator it( * KFileView::items() ); + for( ; it.current() ;++it ){ + if( (*it)->name() == m_dropItem->text(0) ) { + if( (*it)->isFile() ) + return; + else if( (*it)->isDir() || (*it)->isLink()) { + sig->activate( (*it) ); + return; + } + } + } +} +//----------------------------------------------- +void KFileDnDDetailView::contentsDragEnterEvent( QDragEnterEvent *e ) { + + kdDebug (9020) << "KFileDnDDetailView::contentsDragEnterEvent" << endl; + + if ( ! acceptDrag( e ) ) { + e->accept( false ); + return; + } + e->acceptAction(); + QListViewItem *i = itemAt( contentsToViewport( e->pos() ) ); + if ( i && m_useAutoOpenTimer ) { + m_dropItem = i; + m_autoOpenTimer.start( m_autoOpenTime ); + } +} +//----------------------------------------------- +void KFileDnDDetailView::contentsDragMoveEvent( QDragMoveEvent *e ) { + + kdDebug (9020) << "KFileDnDDetailView::contentsDragMoveEvent" << endl; + + if ( ! acceptDrag( e ) ) { + e->accept( false ); + return; + } + e->acceptAction(); + QListViewItem *i = itemAt( contentsToViewport( e->pos() ) ); + if( ! m_useAutoOpenTimer ) + return; + if ( i ) { + if ( i != m_dropItem ) { + m_autoOpenTimer.stop(); + m_dropItem = i; + m_autoOpenTimer.start( m_autoOpenTime ); + } + } + else + m_autoOpenTimer.stop(); +} +//----------------------------------------------- +void KFileDnDDetailView::contentsDragLeaveEvent( QDragLeaveEvent* ) { + + kdDebug (9020) << "KFileDnDDetailView::contentsDragLeaveEvent" << endl; + + if( m_useAutoOpenTimer ) { + m_autoOpenTimer.stop(); + m_dropItem = 0L; + } +} +//----------------------------------------------- +void KFileDnDDetailView::contentsDropEvent( QDropEvent* e ) { + + kdDebug (9020) << "KFileDndDetailView::contentsDropEvent" << endl; + + if( m_useAutoOpenTimer ) { + m_autoOpenTimer.stop(); + m_dropItem = 0L; + } + if( ! acceptDrag( e ) ) { + e->acceptAction( false ); + return; + } + e->acceptAction(); + // the drop was accepted so lets emit this to the outside world + KURL::List urls; + KURLDrag::decode( e, urls ); + emit dropped( e ); + emit dropped( this, e ); + emit dropped( this, urls ); +} +//----------------------------------------------- +void KFileDnDDetailView::startDrag(){ + + kdDebug (9020) << "KFileDnDDetailView::startDrag()" << endl; + + // create a list of the URL:s that we want to drag + KURL::List urls; + KFileItemListIterator it( * KFileView::selectedItems() ); + for ( ; it.current(); ++it ){ + urls.append( (*it)->url() ); + } + QPixmap pixmap; + if( urls.count() > 1 ){ + pixmap = DesktopIcon( "kmultiple", 16 ); + } + if( pixmap.isNull() ) + pixmap = currentFileItem()->pixmap( 16 ); + QPoint hotspot; + hotspot.setX( pixmap.width() / 2 ); + hotspot.setY( pixmap.height() / 2 ); + m_dragObject = KURLDrag::newDrag( urls, widget() ); + m_dragObject->setPixmap( pixmap, hotspot ); + m_dragObject->drag(); // start the drag +} +//----------------------------------------------- +QDragObject* KFileDnDDetailView::dragObject() const { + return m_dragObject; +} +//----------------------------------------------- +bool KFileDnDDetailView::acceptDrag(QDropEvent* e ) const { + return KURLDrag::canDecode( e ) && + ( e->action() == QDropEvent::Copy + || e->action() == QDropEvent::Move + || e->action() == QDropEvent::Link ); +} +//----------------------------------------------- +void KFileDnDDetailView::setAutoOpenTime( const int& time ){ + m_autoOpenTime = time; + useAutoOpenTimer(); +} +//----------------------------------------------- +void KFileDnDDetailView::useAutoOpenTimer( bool use ){ + m_useAutoOpenTimer = use; + if( use ) + connect( &m_autoOpenTimer, SIGNAL( timeout() ),this, SLOT( slotOpenFolder() ) ); + else { + disconnect( &m_autoOpenTimer, SIGNAL( timeout() ),this, SLOT( slotOpenFolder() ) ); + m_dropItem = 0L; + m_autoOpenTimer.stop(); + } +} +//----------------------------------------------- +void KFileDnDDetailView::setDnDEnabled( bool useDnD ){ + m_dndEnabled = useDnD; + setDragEnabled( useDnD ); + setDropVisualizer( useDnD ); + setAcceptDrops( useDnD ); + viewport()->setAcceptDrops( useDnD ); +} +//----------------------------------------------- +#ifndef NO_INCLUDE_MOCFILES +#include "kfilednddetailview.moc" +#endif diff --git a/buildtools/autotools/kfilednddetailview.h b/buildtools/autotools/kfilednddetailview.h new file mode 100644 index 00000000..ecb232c6 --- /dev/null +++ b/buildtools/autotools/kfilednddetailview.h @@ -0,0 +1,136 @@ +/*************************************************************************** +* kfilednddetailview.h - description +* ------------------- +* begin : Wed Nov 1 2000 +* copyright : (C) 2000 by Bjrn Sahlstrm +* email : kbjorn@users.sourceforge.net +***************************************************************************/ + +/*************************************************************************** +* * +* 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. * +* * +**************************************************************************/ + +#ifndef KFILEDNDDETAILVIEW_H +#define KFILEDNDDETAILVIEW_H + +////////////////////////////////////////////////////////////////////// +// Qt specific include files +#include +#include +////////////////////////////////////////////////////////////////////// +// KDE specific include files +#include +#include + + +/** + *This is a fileview inherited from @ref KFileDetailView. + *It adds "drag and drop" handling to the view suitable for a @ref KFileDetailView. + * No special setup is needed, just connect to the @ref dropped signals + * and the view will take care of the rest. + *@short "Drag and drop" aware @ref KFileDetailView + *@author Bjrn Sahlstrm + */ + +class KFileDnDDetailView : public KFileDetailView +{ + Q_OBJECT +public: + /** */ + KFileDnDDetailView( QWidget *parent = 0, const char *name = 0 ); + /** */ + virtual ~KFileDnDDetailView(); + /** + * Set this to true if Drag'n drop should be enabled or not, default is enabled + */ + void setDnDEnabled( bool ); + /** + * @returns wether DnD is enabled or not. + */ + bool isDnDEnabled() const + { + return m_dndEnabled; + } + /** + *Sets the auto open time, which means the time that will + *elapse before a directory is automatically opened after entered by DnD. + *Only need to call this if you want to change the predefined time that is 750 ms. + *This also calls @ref #useAutoOpenTimer so no need to call this to. + */ + void setAutoOpenTime( const int& time ); + /** + *Set this to true if you want the view to use it's auto open functionallity otherwhise set it to false. + *By default this is turned ON. + */ + void useAutoOpenTimer( bool on = true ); + /** + *@returns true if auto open functionallity is turned ON (default), otherwhise false + *@see #useAutoOpenTimer + *@see #setAutoOpenTime + */ + bool isAutoOpening() const + { + return m_useAutoOpenTimer; + } + /** */ + virtual void readConfig( KConfig*, const QString& group = QString::null ); + /** */ + virtual void writeConfig( KConfig*, const QString& group = QString::null ); +signals: // Signals + /** + * Emitted whenever an decodable item is dropped in the view. + * Note: The @ref QDropEvent contains a @ref KURLDrag object. + */ + void dropped( QDropEvent* ); + /** + * Emitted whenever an decodable item is dropped in the view + * Note: The @ref QDropEvent contains a @ref KURLDrag object. + */ + void dropped( KFileView*, QDropEvent* ); + /** + * Emitted whenever an decodable item is dropped in the view. + *@param urls contains a list of all dropped @ref KURL + */ + void dropped( KFileView*, KURL::List& urls ); +protected slots: // Protected slots + /** + * Called when the auto timer times out. Open the current folder. + */ + void slotOpenFolder(); +protected: //Protected Methods + /** */ + virtual void contentsDragEnterEvent( QDragEnterEvent *e ); + /** */ + virtual void contentsDragMoveEvent( QDragMoveEvent *e ); + /** */ + virtual void contentsDragLeaveEvent( QDragLeaveEvent *e ); + /** */ + virtual void contentsDropEvent( QDropEvent* e ); + /** + * Create dragobject encoding the current selection and starts the drag + */ + virtual void startDrag(); + /** + * @returns the dragObject + */ + virtual QDragObject* dragObject() const; + /** + * @returns true if we can decode the drag and support the action + */ + virtual bool acceptDrag( QDropEvent* event ) const; +protected: // Private attributes + QTimer m_autoOpenTimer; + int m_autoOpenTime; + bool m_useAutoOpenTimer; + QListViewItem* m_dropItem; + KURLDrag* m_dragObject; + bool m_dndEnabled; +}; + +#endif +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/kfiledndiconview.cpp b/buildtools/autotools/kfiledndiconview.cpp new file mode 100644 index 00000000..47bb32a9 --- /dev/null +++ b/buildtools/autotools/kfiledndiconview.cpp @@ -0,0 +1,194 @@ +/*************************************************************************** +* kfiledndiconview.cpp - description +* ------------------- +* begin : Wed Nov 1 2000 +* copyright : (C) 2000 by Bjrn Sahlstrm +* email : kbjorn@users.sourceforge.net +***************************************************************************/ + +/*************************************************************************** +* * +* 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. * +* * +***************************************************************************/ + +////////////////////////////////////////////////////// +// Qt specific includes +#include +#include +////////////////////////////////////////////////////// +// KDE specific includes +#include +#include +#include +////////////////////////////////////////////////////// +// Application specific includes +#include "kfiledndiconview.h" + +#ifndef AUTO_OPEN_TIME +#define AUTO_OPEN_TIME + static int autoOpenTime = 750; +#endif +//----------------------------------------------- +KFileDnDIconView::KFileDnDIconView( QWidget *parent, const char *name ) + : KFileIconView(parent,name), m_autoOpenTimer( this ), + m_autoOpenTime( autoOpenTime ), m_useAutoOpenTimer( true ), + m_dropItem(0), m_dndEnabled( true ) +{ + setDnDEnabled( true ); + setAutoUpdate( true ); + useAutoOpenTimer( true ); +} +//----------------------------------------------- +KFileDnDIconView::~KFileDnDIconView(){ +} +//----------------------------------------------- +void KFileDnDIconView::readConfig( KConfig* config, const QString& group ) { + KConfigGroupSaver cs( config, group ); + bool dnd = config->readBoolEntry("EnableDND", true ); + setDnDEnabled( dnd ); + KFileIconView::readConfig( config, group ); +} +//----------------------------------------------- +void KFileDnDIconView::writeConfig( KConfig* config, const QString& group ) { + KConfigGroupSaver cs( config, group ); + config->writeEntry("EnableDND", m_dndEnabled ); + KFileIconView::writeConfig( config, group ); +} +//----------------------------------------------- +void KFileDnDIconView::slotOpenFolder(){ + if( m_useAutoOpenTimer ) { + m_autoOpenTimer.stop(); + if( !m_dropItem ) + return; + } + KFileItemListIterator it( * KFileView::items() ); + for( ; it.current() ;++it ){ + if( (*it)->name() == m_dropItem->text() ) { + if( (*it)->isFile() ) + return; + else if( (*it)->isDir() || (*it)->isLink()) { + sig->activate( (*it) ); + return; + } + } + } +} +//----------------------------------------------- +void KFileDnDIconView::contentsDragEnterEvent( QDragEnterEvent *e ) { + if ( ! acceptDrag( e ) ) { // can we decode this ? + e->accept( false ); // No + return; + } + e->acceptAction(); // Yes + QIconViewItem *i = findItem( contentsToViewport( e->pos() ) ); + if ( i && m_useAutoOpenTimer) { // are we over an item ? + m_dropItem = i; // set new m_dropItem + m_autoOpenTimer.start( m_autoOpenTime ); // restart timer + } +} +//----------------------------------------------- +void KFileDnDIconView::contentsDragMoveEvent( QDragMoveEvent *e ) { + if ( ! acceptDrag( e ) ) { // can we decode this ? + e->accept( false ); // No + return; + } + e->acceptAction(); // Yes + QIconViewItem *i = findItem( contentsToViewport( e->pos() ) ); + if( ! m_useAutoOpenTimer ) + return; + if ( i ) { // are we over an item ? + if ( i != m_dropItem ) { // if so, is it a new one ? + m_autoOpenTimer.stop(); // stop timer + m_dropItem = i; // set new m_dropItem + m_autoOpenTimer.start( m_autoOpenTime ); // restart timer + } + } + else + m_autoOpenTimer.stop(); // stop timer +} +//----------------------------------------------- +void KFileDnDIconView::contentsDragLeaveEvent( QDragLeaveEvent* ) { + if( m_useAutoOpenTimer ) { + m_autoOpenTimer.stop(); + m_dropItem = 0L; + } +} +//----------------------------------------------- +void KFileDnDIconView::contentsDropEvent( QDropEvent* e ) { + if( m_useAutoOpenTimer ) { + m_autoOpenTimer.stop(); + m_dropItem = 0L; + } + if( ! acceptDrag( e ) ) { + e->acceptAction( false ); + return; + } + e->acceptAction(); + // the drop was accepted so lets emit this + KURL::List urls; + KURLDrag::decode( e, urls ); + emit dropped( e ); +} +//----------------------------------------------- +void KFileDnDIconView::startDrag(){ + if ( ! currentItem() ) // is there any selected items ? + return; // nope + dragObject()->dragCopy(); // start the drag +} +//----------------------------------------------- +QDragObject* KFileDnDIconView::dragObject() { + // create a list of the URL:s that we want to drag + KURL::List urls; + KFileItemListIterator it( * KFileView::selectedItems() ); + for ( ; it.current(); ++it ){ + urls.append( (*it)->url() ); + } + QPixmap pixmap; + if( urls.count() > 1 ) + pixmap = DesktopIcon( "kmultiple", iconSize() ); + if( pixmap.isNull() ) + pixmap = currentFileItem()->pixmap( iconSize() ); + QPoint hotspot; + hotspot.setX( pixmap.width() / 2 ); + hotspot.setY( pixmap.height() / 2 ); + QDragObject* myDragObject = KURLDrag::newDrag( urls, widget() ); + myDragObject->setPixmap( pixmap, hotspot ); + return myDragObject; +} +//----------------------------------------------- +void KFileDnDIconView::setAutoOpenTime( const int& time ){ + m_autoOpenTime = time; + useAutoOpenTimer(); +} +//----------------------------------------------- +void KFileDnDIconView::useAutoOpenTimer( bool use ){ + m_useAutoOpenTimer = use; + if ( use ) + connect( &m_autoOpenTimer, SIGNAL( timeout() ),this, SLOT( slotOpenFolder() ) ); + else { + disconnect( &m_autoOpenTimer, SIGNAL( timeout() ),this, SLOT( slotOpenFolder() ) ); + m_dropItem = 0L; + m_autoOpenTimer.stop(); + } +} +//----------------------------------------------- +void KFileDnDIconView::setDnDEnabled( bool useDnD ){ + m_dndEnabled = useDnD; + setAcceptDrops( useDnD ); + viewport()->setAcceptDrops( useDnD ); +} +//----------------------------------------------- +bool KFileDnDIconView::acceptDrag(QDropEvent* e ) const { + return KURLDrag::canDecode( e ) && + ( e->action() == QDropEvent::Copy + || e->action() == QDropEvent::Move + || e->action() == QDropEvent::Link ); +} +//----------------------------------------------- +#ifndef NO_INCLUDE_MOCFILES +#include "kfiledndiconview.moc" +#endif diff --git a/buildtools/autotools/kfiledndiconview.h b/buildtools/autotools/kfiledndiconview.h new file mode 100644 index 00000000..65edd91a --- /dev/null +++ b/buildtools/autotools/kfiledndiconview.h @@ -0,0 +1,128 @@ +/************************************************************************** +* kfiledndiconview.h - description +* ------------------- +* begin : Wed Nov 1 2000 +* copyright : (C) 2000 by Bjrn Sahlstrm +* email : kbjorn@users.sourceforge.net +***************************************************************************/ + +/*************************************************************************** +* * +* 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. * +* * +**************************************************************************/ + +#ifndef KFILEDNDICONVIEW_H +#define KFILEDNDICONVIEW_H + +#include +#include +#include +#include + +/** + * This is a fileview inherited from @ref KFileIconView. + * It adds "drag and drop" suitable for a @ref KFileIconView + * No special setup is needed, just connect to the @ref dropped signals + * and the view will take care of the rest. + * @short Drag and drop" aware @ref KFileIconView + * @author Bjrn Sahlstrm +*/ + +class KFileDnDIconView : public KFileIconView +{ + Q_OBJECT +public: // Public methods + + KFileDnDIconView( QWidget *parent = 0, const char *name = 0 ); + virtual ~KFileDnDIconView(); + + /** + * Set if Drag'n drop should be enabled or not, default is enabled. + */ + void setDnDEnabled( bool ); + + /** + * @returns wether DnD is enabled or not. + */ + bool isDnDEnabled() const + { + return m_dndEnabled; + } + + /** + * Sets the auto open time, which means the time that will + * elapse before a directory is automatically opened after entered by DnD. + * Only need to call this if you want to change the predefined time that is 750 ms. + * This also calls @ref #useAutoOpenTimer so no need to call this to. + */ + void setAutoOpenTime( const int& time ); + + /** + * Set this to true if you want the view to use it's auto open functionallity otherwhise set it to false. + * By default this is turned ON. + */ + void useAutoOpenTimer( bool on = true ); + + /** + * @returns true if auto open functionallity is turned ON (default), otherwhise false + * @see #useAutoOpenTimer + * @see #setAutoOpenTime + */ + bool isAutoOpening() const + { + return m_useAutoOpenTimer; + } + + virtual void readConfig( KConfig*, const QString& group = QString::null ); + virtual void writeConfig( KConfig*, const QString& group = QString::null ); +signals: + + /** + * Emitted whenever an decodable item is dropped in the view. + * Note: The @ref QDropEvent contains a @ref KURLDrag object. + */ + void dropped( QDropEvent* ); + +protected slots: + /** + * Called when the auto timer times out. Open the current folder. + */ + void slotOpenFolder(); + +protected: + virtual void contentsDragEnterEvent( QDragEnterEvent *e ); + virtual void contentsDragMoveEvent( QDragMoveEvent *e ); + virtual void contentsDragLeaveEvent( QDragLeaveEvent *e ); + virtual void contentsDropEvent( QDropEvent* e ); + + /** + * Creates a @ref QDragObject containing all urls of the selected @ref KFileItem of the view, + * @returns the @ref QDragObject + */ + virtual QDragObject* dragObject(); + + /** + *Creates the drag item and starts the drag + */ + virtual void startDrag(); + + /** + *@returns true if we can decode the drag and support the action + */ + virtual bool acceptDrag( QDropEvent* event ) const; + +protected: + + QTimer m_autoOpenTimer; + int m_autoOpenTime; + bool m_useAutoOpenTimer; + QIconViewItem* m_dropItem; + bool m_dndEnabled; +}; +#endif +// kate: indent-mode csands; tab-width 4; auto-insert-doxygen on; + diff --git a/buildtools/autotools/kimporticonview.cpp b/buildtools/autotools/kimporticonview.cpp new file mode 100644 index 00000000..9b64d3ee --- /dev/null +++ b/buildtools/autotools/kimporticonview.cpp @@ -0,0 +1,87 @@ +/*************************************************************************** + ------------------- + begin : 19.01.2003 + copyright : (C) 2002 by Victor Rder + email : 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 +#include +#include +#include + +#include +#include +#include + +#include "kimporticonview.h" + + +KImportIconView::KImportIconView(const QString& strIntro, QWidget *parent, const char *name) + : KFileDnDIconView(parent, name) +{ + m_strIntro = strIntro; + m_bDropped = false; + + setAcceptDrops ( true ); +} + + +KImportIconView::~KImportIconView() +{ +} + +void KImportIconView::drawContents ( QPainter *p, int cx, int cy, int cw, int ch ) +{ + if ( !m_bDropped) + { + QIconView::drawContents ( p, cx, cy, cw, ch ); + + p->save(); + QFont font ( p->font() ); + font.setBold ( true ); + font.setFamily ( "Helvetica [Adobe]" ); + font.setPointSize ( 10 ); + p->setFont ( font ); + p->setPen ( QPen ( KGlobalSettings::highlightColor() ) ); + + QRect rect = frameRect(); + QFontMetrics fm ( p->font() ); + rect.setLeft ( rect.left() + 30 ); + rect.setRight ( rect.right() - 30 ); + + resizeContents ( contentsWidth(), contentsHeight() ); + + // word-wrap the string + KWordWrap* wordWrap1 = KWordWrap::formatText( fm, rect, AlignHCenter | WordBreak, m_strIntro ); + KWordWrap* wordWrap2 = KWordWrap::formatText( fm, rect, AlignHCenter | WordBreak, i18n("Or just use the buttons.") ); + + QRect introRect1 = wordWrap1->boundingRect(); + QRect introRect2 = wordWrap2->boundingRect(); + + wordWrap1->drawText ( p, ( ( frameRect().right() - introRect1.right() ) / 2 ), ( ( frameRect().bottom() - introRect1.bottom() ) / 2 ) - 20, AlignHCenter | AlignVCenter ); + wordWrap2->drawText ( p, ( ( frameRect().right() - introRect2.right() ) / 2 ), ( ( frameRect().bottom() - introRect2.bottom() ) / 2 ) + introRect1.bottom(), AlignHCenter | AlignVCenter ); + + p->restore(); + } + else + { + QIconView::drawContents ( p, cx, cy, cw, ch ); + } +} + +void KImportIconView::somethingDropped ( bool dropped ) +{ + m_bDropped = dropped; +} + +#include "kimporticonview.moc" diff --git a/buildtools/autotools/kimporticonview.h b/buildtools/autotools/kimporticonview.h new file mode 100644 index 00000000..100fc33e --- /dev/null +++ b/buildtools/autotools/kimporticonview.h @@ -0,0 +1,44 @@ +/*************************************************************************** + ------------------- + begin : 19.01.2003 + copyright : (C) 2002 by Victor Rder + email : 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. * + * * + ***************************************************************************/ + +#ifndef KIMPORTICONVIEW_H +#define KIMPORTICONVIEW_H + +#include + +#include "kfiledndiconview.h" + +class KImportIconView : public KFileDnDIconView +{ + Q_OBJECT + +public: + KImportIconView( const QString& strIntro, QWidget *parent, const char *name ); + virtual ~KImportIconView(); + + void somethingDropped ( bool dropped ); + +protected: + void drawContents ( QPainter *p, int cx, int cy, int cw, int ch ); + +private: + QString m_strIntro; + bool m_bDropped; +}; + +#endif +// kate: indent-mode csands; tab-width 4; + diff --git a/buildtools/autotools/makefilehandler.cpp b/buildtools/autotools/makefilehandler.cpp new file mode 100644 index 00000000..03ad5277 --- /dev/null +++ b/buildtools/autotools/makefilehandler.cpp @@ -0,0 +1,166 @@ +/* + KDevelop Autotools Support + Copyright (c) 2005 by Matt Rogers + +*************************************************************************** +* * +* 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 +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "makefilehandler.h" + +typedef QValueList ASTList; + +class MakefileHandler::Private +{ +public: + QMap projects; + QMap folderToFileMap; +}; + +MakefileHandler::MakefileHandler() +{ + d = new MakefileHandler::Private; +} + +MakefileHandler::~MakefileHandler() +{ + delete d; +} + +void MakefileHandler::parse( const QString& folder, bool recursive ) +{ + //look for either Makefile.am.in, Makefile.am, or Makefile.in, in that order + AutoTools::ProjectAST* ast; + int ret = -1; + QString filePath = folder + "/Makefile.am.in"; + if ( QFile::exists( filePath ) ) + ret = AutoTools::Driver::parseFile( filePath, &ast ); + else + { + filePath = folder + "/Makefile.am"; + if ( QFile::exists( filePath ) ) + ret = AutoTools::Driver::parseFile( filePath, &ast ); + else + { + filePath = folder + "/Makefile.in"; + if ( QFile::exists( filePath ) ) + ret = AutoTools::Driver::parseFile( filePath, &ast ); + else + kdDebug(9020) << k_funcinfo << "no appropriate file to parse in " + << folder << endl; + } + } + + if ( ret != 0 ) + { + return; + } + + kdDebug(9020) << k_funcinfo << filePath << " was parsed correctly. Adding information" << endl; + Q_ASSERT( ast != 0 ); + d->projects[filePath] = ast; + d->folderToFileMap[folder] = filePath; + + if ( recursive && ast && ast->hasChildren() ) + { + QValueList astChildList = ast->children(); + QValueList::iterator it(astChildList.begin()), clEnd(astChildList.end()); + for ( ; it != clEnd; ++it ) + { + if ( (*it)->nodeType() == AutoTools::AST::AssignmentAST ) + { + AutoTools::AssignmentAST* assignment = static_cast( (*it) ); + if ( assignment->scopedID == "SUBDIRS" ) + { + QString list = assignment->values.join( QString::null ); + list.simplifyWhiteSpace(); + kdDebug(9020) << k_funcinfo << "subdirs is " << list << endl; + QStringList subdirList = QStringList::split( " ", list ); + QStringList::iterator vit = subdirList.begin(); + for ( ; vit != subdirList.end(); ++vit ) + { + QString realDir = ( *vit ); + if ( realDir.startsWith( "\\" ) ) + realDir.remove( 0, 1 ); + + realDir = realDir.stripWhiteSpace(); + if ( realDir != "." && realDir != ".." && !realDir.isEmpty() ) + { + if ( isVariable( realDir ) ) + { + kdDebug(9020) << k_funcinfo << "'" << realDir << "' is a variable" << endl; + realDir = resolveVariable( realDir, ast ); + } + + kdDebug(9020) << k_funcinfo << "Beginning parsing of '" << realDir << "'" << endl; + parse( folder + '/' + realDir, recursive ); + } + } + } + } + } + } +} + +AutoTools::ProjectAST* MakefileHandler::astForFolder( const QString& folderPath ) +{ + if ( d->folderToFileMap.contains( folderPath ) ) + { + QString filePath = d->folderToFileMap[folderPath]; + return d->projects[filePath]; + } + else + return 0; +} + +bool MakefileHandler::isVariable( const QString& item ) const +{ + if ( item.contains( QRegExp( "(\\$\\([a-zA-Z0-9_-]*\\)|@[a-zA-Z0-9_-]*@)" ) ) ) + return true; + else + return false; +} + +QString MakefileHandler::resolveVariable( const QString& variable, AutoTools::ProjectAST* ast ) +{ + if ( !ast ) + return variable; + + kdDebug(9020) << k_funcinfo << "attempting to resolve '" << variable << "'"<< endl; + ASTList childList = ast->children(); + ASTList::iterator it( childList.begin() ), clEnd( childList.end() ); + for ( ; it != clEnd; ++it ) + { + if ( ( *it )->nodeType() == AutoTools::AST::AssignmentAST ) + { + AutoTools::AssignmentAST* assignment = static_cast( ( *it ) ); + if ( variable.find( assignment->scopedID ) != -1 ) + { + kdDebug(9020) << k_funcinfo << "Resolving variable '" << variable << "' to '" + << assignment->values.join( QString::null ).stripWhiteSpace() << "'" << endl; + return assignment->values.join( QString::null ).stripWhiteSpace(); + } + } + } + + return variable; +} +//kate: space-indent on; indent-width 4; diff --git a/buildtools/autotools/makefilehandler.h b/buildtools/autotools/makefilehandler.h new file mode 100644 index 00000000..77045fe9 --- /dev/null +++ b/buildtools/autotools/makefilehandler.h @@ -0,0 +1,76 @@ +/* + KDevelop Autotools Support + Copyright (c) 2005 by Matt Rogers + +*************************************************************************** +* * +* 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. * +* * +*************************************************************************** +*/ +#ifndef MAKEFILEHANDLER_H +#define MAKEFILEHANDLER_H + +/** + * This class is responsible for taking the data from the Makefile.am parser + * and providing various data list view items can use in the automake manager + * widget + * @author Matt Rogers + */ +namespace AutoTools { +class ProjectAST; +} + +class MakefileHandler +{ +public: + MakefileHandler(); + ~MakefileHandler(); + + /** + * Parse a folder that has supported makefiles in it. The following files + * will be looked for in the following order: + * \li Makefile.am.in + * \li Makefile.am + * \li Makefile.in + * + * \param folder, the folder to parse + * \param recursive if true, subfolders will be parsed - defaults to true + */ + void parse( const QString& folder, bool recursive = true ); + + /** + * Get the AST for a certain path + * \param folderPath the path of the folder to get an AST for + * \return the AST that represents a particular folder + */ + AutoTools::ProjectAST* astForFolder( const QString& folderPath ); + + /** + * Check if a string is an automake variable + * \return true if it is an automake variable, false otherwise + */ + bool isVariable( const QString& item ) const; + + /** + * Find the value for the variable specified by \p variable + * \param variable The name of the variable to look for + * \param ast the AST to use to look for the variable in + * \return the value to substitute for the variable + */ + QString resolveVariable( const QString& variable, + AutoTools::ProjectAST* ast ); + + +private: + class Private; + Private* d; +}; + +#endif + +//kate: space-indent on; indent-width 4; + diff --git a/buildtools/autotools/managecustomcommand.cpp b/buildtools/autotools/managecustomcommand.cpp new file mode 100644 index 00000000..7d111965 --- /dev/null +++ b/buildtools/autotools/managecustomcommand.cpp @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2004 by Alexander Dymo * + * * + * This program 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 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 Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "managecustomcommand.h" + +#include + +#include + +ManageCustomCommand::ManageCustomCommand(QWidget *parent, const char *name) + :ManageCustomBuildCommandsBase(parent, name) +{ +} + +void ManageCustomCommand::addButton_clicked() +{ + commandsTable->setNumRows(commandsTable->numRows() + 1); + setRowProperties(commandsTable->numRows()-1); +} + +void ManageCustomCommand::removeButton_clicked() +{ + commandsTable->removeRow(commandsTable->currentRow()); +} + +void ManageCustomCommand::setRowProperties(int row) +{ + commandsTable->setItem(row, 2, + new QComboTableItem(commandsTable, QStringList::split(",", + i18n("this is a list of items in the combobox", + "Make target,Make target (as root),Make command,Make command (as root),Command,Command (as root)")))); +} + +#include "managecustomcommand.moc" diff --git a/buildtools/autotools/managecustomcommand.h b/buildtools/autotools/managecustomcommand.h new file mode 100644 index 00000000..cda5e54a --- /dev/null +++ b/buildtools/autotools/managecustomcommand.h @@ -0,0 +1,37 @@ +/*************************************************************************** +* Copyright (C) 2004 by Alexander Dymo * +* * +* This program 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 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 Library General Public * +* License along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ +#ifndef MANAGECUSTOMCOMMAND_H +#define MANAGECUSTOMCOMMAND_H + +#include "managecustomcommandsbase.h" + +class ManageCustomCommand: public ManageCustomBuildCommandsBase +{ + Q_OBJECT +public: + ManageCustomCommand( QWidget *parent = 0, const char *name = 0 ); + + void setRowProperties( int row ); +public slots: + virtual void addButton_clicked(); + virtual void removeButton_clicked(); +}; + +#endif +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/managecustomcommandsbase.ui b/buildtools/autotools/managecustomcommandsbase.ui new file mode 100644 index 00000000..43164ef5 --- /dev/null +++ b/buildtools/autotools/managecustomcommandsbase.ui @@ -0,0 +1,125 @@ + +ManageCustomBuildCommandsBase + + + ManageCustomBuildCommandsBase + + + true + + + + 0 + 0 + 435 + 218 + + + + + unnamed + + + 0 + + + + addButton + + + &Add + + + + + removeButton + + + &Remove + + + + + + Menu Text + + + + + + + + Command + + + + + + + + Command Type + + + + + + + commandsTable + + + 0 + + + 3 + + + true + + + SingleRow + + + + + spacer4 + + + Vertical + + + Expanding + + + + 20 + 40 + + + + + + + + addButton + clicked() + ManageCustomBuildCommandsBase + addButton_clicked() + + + removeButton + clicked() + ManageCustomBuildCommandsBase + removeButton_clicked() + + + + commandsTable + addButton + removeButton + + + addButton_clicked() + removeButton_clicked() + + + diff --git a/buildtools/autotools/misc.cpp b/buildtools/autotools/misc.cpp new file mode 100644 index 00000000..97c449e7 --- /dev/null +++ b/buildtools/autotools/misc.cpp @@ -0,0 +1,999 @@ +/*************************************************************************** +* Copyright (C) 2001-2002 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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 +#include +#include +#include +#include + +#include +#include +#include + +#include "misc.h" + +#include "kdevcompileroptions.h" + + +static KDevCompilerOptions *createCompilerOptions( const QString &name, QObject *parent ) +{ + KService::Ptr service = KService::serviceByDesktopName( name ); + if ( !service ) + { + kdDebug( 9020 ) << "Can't find service " << name << endl; + return 0; + } + + + KLibFactory *factory = KLibLoader::self()->factory(QFile::encodeName(service->library())); + if (!factory) { + QString errorMessage = KLibLoader::self()->lastErrorMessage(); + kdDebug(9020) << "There was an error loading the module " << service->name() << endl << + "The diagnostics is:" << endl << errorMessage << endl; + exit(1); + } + + QStringList args; + QVariant prop = service->property("X-KDevelop-Args"); + if (prop.isValid()) + args = QStringList::split(" ", prop.toString()); + + QObject *obj = factory->create(parent, service->name().latin1(), + "KDevCompilerOptions", args); + + if (!obj->inherits("KDevCompilerOptions")) { + kdDebug(9020) << "Component does not inherit KDevCompilerOptions" << endl; + return 0; + } + KDevCompilerOptions *dlg = (KDevCompilerOptions*) obj; + + return dlg; + +/* + QStringList args; + QVariant prop = service->property( "X-KDevelop-Args" ); + if ( prop.isValid() ) + args = QStringList::split( " ", prop.toString() ); + + return KParts::ComponentFactory + ::createInstanceFromService( service, parent, + service->name().latin1(), args );*/ +} + + +QString AutoProjectTool::execFlagsDialog( const QString &compiler, const QString &flags, QWidget *parent ) +{ + KDevCompilerOptions * plugin = createCompilerOptions( compiler, parent ); + + if ( plugin ) + { + QString newflags = plugin->exec( parent, flags ); + delete plugin; + return newflags; + } + return QString::null; +} + + +QString AutoProjectTool::canonicalize( const QString &str ) +{ + QString res; + for ( uint i = 0; i < str.length(); ++i ) + res += ( str[ i ].isLetterOrNumber() || str[ i ] == '@' ) ? str[ i ] : QChar( '_' ); + + kdDebug(9020) << k_funcinfo << "normalized '" << str << "' to '" << res << "'" << endl; + return res; +} + + +/** + * Read the Makefile.am and return a map of all the variables. + * Will take notice of backslash and += constructs. + * @param fileName + * @param variables + */ +void AutoProjectTool::parseMakefileam(const QString &fileName, QMap *variables) +{ + QFile f(fileName); + if (!f.open(IO_ReadOnly)) + { + return ; + } + QTextStream stream(&f); + + QRegExp re("^(#kdevelop:[ \t]*)?([A-Za-z][@A-Za-z0-9_]*)[ \t]*([:\\+]?=)[ \t]*(.*)$"); + + QString last; + bool multiLine = false; + while (!stream.atEnd()) + { + QString s = stream.readLine().stripWhiteSpace(); + if (re.exactMatch(s)) + { + QString lhs = re.cap(2); + QString rhs = re.cap(4); + if (rhs[ rhs.length() - 1 ] == '\\') + { + multiLine = true; + last = lhs; + rhs[rhs.length() - 1] = ' '; + } + + // The need for stripWhiteSpace seems to be a Qt bug. + // make our list nice and neat. + QStringList bits = QStringList::split(" ", rhs); + rhs = bits.join(" "); + if (re.cap(3) == "+=") + { + ((*variables)[lhs] += ' ') += rhs; + } + else + { + variables->insert(lhs, rhs); + } + } + else if (multiLine) + { + if (s[s.length()-1] == '\\') + { + s[s.length()-1] = ' '; + } + else + { + multiLine = false; + } + QStringList bits = QStringList::split(" ", s); + ((*variables)[last] += ' ') += bits.join(" "); + } + } + f.close(); + + QMap list; + + for (QMap::iterator iter = variables->begin();iter != variables->end();iter++) + { + QStringList items = QStringList::split(" ", iter.data()); + QMap unique; + for (uint i = 0;i < items.size();i++) + { + unique.insert(items[i], ""); + } + QString line; + for (QMap::iterator it = unique.begin();it != unique.end();it++) + { + line += it.key() + ' '; + } + if (line.length() > 1) + { + line.setLength(line.length() - 1); + } + + list.insert(iter.key(), line); + } + *variables = list; +} + +/** + * Add entries to a variable. Will just add the variables to the existing line, removing duplicates + * Will preserve += constructs and make sure that the variable only has one copy of the value across + * all += constructs + * @param fileName + * @param variables key=value string of entries to add + */ +void AutoProjectTool::addToMakefileam(const QString &fileName, QMap variables) +{ + AutoProjectTool::addRemoveMakefileam(fileName, variables, true); +} + +/** + * Set entries to a variable. Will set the variables to the existing line, removing duplicates + * Will preserve += constructs and make sure that the variable only has one copy of the value across + * all += constructs + * Adds line if it does not exist. + * @param fileName + * @param variables key=value string of entries to add + */ +void AutoProjectTool::setMakefileam ( const QString &fileName, QMap variables ) +{ + for ( QMap::Iterator it0 = variables.begin(); it0 != variables.end(); ++it0 ) + { + kdDebug ( 9020 ) << "key (set): " << it0.key() << "=" << it0.data() << endl; + } + + // input file reading + QFile fin ( fileName ); + if ( !fin.open ( IO_ReadOnly ) ) + { + return ; + } + QTextStream ins ( &fin ); + + // output file writing. + QFile fout ( fileName + "#" ); + if ( !fout.open ( IO_WriteOnly ) ) + { + fin.close(); + return ; + } + QTextStream outs ( &fout ); + + // variables + QRegExp re ( "^(#kdevelop:[ \t]*)?([A-Za-z][@A-Za-z0-9_]*)[ \t]*([:\\+]?=)[ \t]*(.*)$" ); + + bool multiLine = false; + QString lastLhs; + QMap seenLhs; + while ( !fin.atEnd() ) + { + QString s = ins.readLine(); + if ( re.exactMatch ( s ) ) + { + QString lhs = re.cap ( 2 ); + bool notFound = ( variables.find ( lhs ) == variables.end() ); + + if ( notFound ) + { + if ( seenLhs.find ( lhs ) == seenLhs.end() ) + { + // not interested in this line at all + // write it out as is.. + outs << s << endl; + } + // we have seen this variable, but since we are setting the + // whole line - we skip this as it will be a += line. + } + else + { + // we are interested in this line.. + QString rhs = re.cap ( 4 ).stripWhiteSpace(); + if ( rhs[ rhs.length() - 1 ] == '\\' ) + { + // save it for when we have the whole line.. + multiLine = true; + lastLhs = lhs; + } + else + { + // deal with it now - a single line + // we are adding our interested values to this line and writing it + // now write the line out if it is not going to be empty. + QString newLine ( lhs ); + newLine += " = "; + bool added = false; + int len = newLine.length(); + QStringList variableList = QStringList::split ( ' ', variables[lhs] ); + for ( uint count = 0; count < variableList.size(); count++ ) + { + len += variableList[count].length() + 1; + if ( len > 80 ) + { + newLine += "\\\n\t"; + len = 8; + } + newLine += variableList[count]; + newLine += ' '; + added = true; + + } + // only print it out if there was a value to add.. + if ( added ) + { + newLine.setLength ( newLine.length() - 1 ); + outs << newLine << endl; + } + seenLhs[lhs] = "done"; + variables.erase ( lhs ); + } + } + } + else if ( multiLine ) + { + s = s.stripWhiteSpace(); + // we are only here if were interested in this line.. + if ( s[s.length()-1] == '\\' ) + { + s.setLength ( s.length() - 1 ); + // still more multi line we wait for.. + } + else + { + // end of the multi line.. + multiLine = false; + } + + if ( !multiLine ) + { + // we are adding our interested values to this line and writing it + // now write the line out if it is not going to be empty. + QString newLine ( lastLhs ); + newLine += " = "; + bool added = false; + int len = newLine.length(); + QStringList variableList = QStringList::split ( ' ', variables[lastLhs] ); + for ( uint count = 0; count < variableList.size(); count++ ) + { + len += variableList[count].length() + 1; + if ( len > 80 ) + { + newLine += "\\\n\t"; + len = 8; + } + newLine += variableList[count]; + newLine += ' '; + added = true; + } + // only print it out if there was a value to add.. + if ( added ) + { + newLine.setLength ( newLine.length() - 1 ); + outs << newLine << endl; + } + seenLhs[lastLhs] = "done"; + variables.erase ( lastLhs ); + lastLhs.setLength ( 0 ); + } + } + else + { + // can write this line out.. + // not a match, not a multi line, + outs << s << endl; + } + } + + for ( QMap::Iterator it0 = variables.begin(); it0 != variables.end(); ++it0 ) + { + QString newLine ( it0.key() ); + newLine += " = "; + bool added = false; + int len = newLine.length(); + QStringList variableList = QStringList::split ( ' ', it0.data() ); + for ( uint count = 0; count < variableList.size(); count++ ) + { + len += variableList[count].length() + 1; + if ( len > 80 ) + { + newLine += "\\\n\t"; + len = 8; + } + newLine += variableList[count]; + newLine += ' '; + added = true; + + } + // only print it out if there was a value to add.. + if ( added ) + { + newLine.setLength ( newLine.length() - 1 ); + outs << newLine << endl; + } + } + + fin.close(); + fout.close(); + + QDir().rename ( fileName + "#", fileName ); +} + + +/** + * Add entries to a variable. Will just add the variables to the existing line, removing duplicates + * Will preserve += constructs and make sure that the variable only has one copy of the value across + * all += constructs + * @param fileName + * @param variables key=value string of entries to add + * @param add true= add these key,value pairs, false = remove. You can have empty values for an add - the whole line is + * removed. For adding, we will not add an empty line. + */ +void AutoProjectTool::addRemoveMakefileam(const QString &fileName, QMap variables, bool add) +{ + // input file reading + QFile fin(fileName); + if (!fin.open(IO_ReadOnly)) + { + return ; + } + QTextStream ins(&fin); + + // output file writing. + QFile fout(fileName + "#"); + if (!fout.open(IO_WriteOnly)) + { + fin.close(); + return ; + } + QTextStream outs(&fout); + + // variables + QRegExp re("^(#kdevelop:[ \t]*)?([A-Za-z][@A-Za-z0-9_]*)[ \t]*([:\\+]?=)[ \t]*(.*)$"); + + // build key=map of values to add + // map can be empty.we never add an empty key, but do remove empty keys from the file.. + QDict< QMap > interest; + for (QMap::Iterator it0 = variables.begin(); it0 != variables.end(); ++it0) + { + kdDebug(9020) << "key (" << add<<"): " << it0.key() << "="<< it0.data() << endl; + + QMap* set = new QMap(); + if (!it0.data().stripWhiteSpace().isEmpty()) + { + QStringList variableList = QStringList::split(' ', it0.data()); + + for (uint i = 0; i < variableList.count(); i++) + { + set->insert(variableList[i], true); + } + } + interest.insert(it0.key(), set); + } + + bool multiLine = false; + QString lastLhs; + QStringList lastRhs; + QMap seenLhs; + while (!fin.atEnd()) + { + QString s = ins.readLine(); + if (re.exactMatch(s)) + { + QString lhs = re.cap(2); + QMap* ourRhs = interest.find(lhs); + + if (!ourRhs) + { + // not interested in this line at all + // write it out as is.. + outs << s << endl; + } + else + { + // we are interested in this line.. + QString rhs = re.cap(4).stripWhiteSpace(); + if (rhs[ rhs.length() - 1 ] == '\\') + { + // save it for when we have the whole line.. + multiLine = true; + lastLhs = lhs; + rhs.setLength(rhs.length() - 1); + lastRhs += QStringList::split(" ", rhs); + } + else + { + // deal with it now. + + QStringList bits = QStringList::split(" ", rhs); + if (add) + { + // we are adding our interested values to this line and writing it + + // add this line to we we want to add to remove duplicates. + for (uint index = 0; index < bits.size(); index++) + { + QMap::iterator findEntry = ourRhs->find(bits[index]); + if (findEntry == ourRhs->end()) + { + // we haven't seen it, so add it, so we don't add it again later.. + ourRhs->insert(bits[index], true); + } + // else we have this value in our 'to add list' , it is either already been + // added, so we don't want to add it again, or it hasn't been added, in which + // case we will do so soon. so we can ignore this now.. + } + // now write the line out if it is not going to be empty. + QString newLine(lhs); + if (seenLhs.find(lhs) == seenLhs.end()) + { + newLine += " = "; + seenLhs[lhs] = ""; + } + else + { + newLine += " += "; + } + + int len = newLine.length(); + bool added = false; + QValueList keys = ourRhs->keys(); + for (uint count = 0; count < keys.size(); count++) + { + // if out entry is true, add it.. + if ((*ourRhs)[keys[count]]) + { + added = true; + len += keys[count].length() + 1; + if (len > 80) + { + newLine += "\\\n\t"; + len = 8; + } + newLine += keys[count]; + newLine += ' '; + // set our value so we don't add it again. + (*ourRhs)[keys[count]] = false; + } + } + // only print it out if there was a value to add.. + if (added) + { + newLine.setLength(newLine.length() - 1); + outs << newLine << endl; + } + } + else + { + // we are removing our interested values from this line + + // special case - no values, remove the line.. + if (!ourRhs->empty()) + { + // check if any of these values are down to remove. + QString newLine(lhs); + if (seenLhs.find(lhs) == seenLhs.end()) + { + newLine += " = "; + seenLhs[lhs] = ""; + } + else + { + newLine += " += "; + } + + int len = newLine.length(); + bool added = false; + for (QStringList::Iterator posIter = bits.begin(); posIter != bits.end();posIter++) + { + QMap::iterator findEntry = ourRhs->find(*posIter); + if (findEntry == ourRhs->end()) + { + // we do not want to remove it.. + added = true; + len += (*posIter).length() + 1; + if (len > 80) + { + newLine += "\\\n\t"; + len = 8; + } + newLine += (*posIter); + newLine += ' '; + } + // else we have this value in our 'to remove list', so don't add it. + } + // only print it out if there was a value on it.. + if (added) + { + newLine.setLength(newLine.length() - 1); + outs << newLine << endl; + } + } + }//if (add) + }//if ( rhs[ rhs.length() - 1 ] == '\\' ) + }//if ( found == interest.end()) + } + else if (multiLine) + { + s = s.stripWhiteSpace(); + // we are only here if were interested in this line.. + if (s[s.length()-1] == '\\') + { + s.setLength(s.length() - 1); + // still more multi line we wait for.. + } + else + { + // end of the multi line.. + multiLine = false; + } + lastRhs += QStringList::split(" ", s); + + if (!multiLine) + { + // now we have to deal with this multiLine value.. + // ourRhs will always be a value, as we only get multiLine if we're interested in it.. + QMap* ourRhs = interest.find(lastLhs); + + if (add) + { + // we are adding our interested values to this line and writing it + + // add this line to we we want to add to remove duplicates. + for (uint index = 0; index < lastRhs.size(); index++) + { + QMap::iterator findEntry = ourRhs->find(lastRhs[index]); + if (findEntry == ourRhs->end()) + { + // we haven't seen it, so add it, so we don't add it again later.. + ourRhs->insert(lastRhs[index], true); + } + // else we have this value in our 'to add list' , it is either already been + // added, so we don't want to add it again, or it hasn't been added, in which + // case we will do so soon. so we can ignore this now.. + } + // now write the line out if it is not going to be empty. + QString newLine(lastLhs); + if (seenLhs.find(lastLhs) == seenLhs.end()) + { + newLine += " = "; + seenLhs[lastLhs] = ""; + } + else + { + newLine += " += "; + } + + int len = newLine.length(); + bool added = false; + QValueList keys = ourRhs->keys(); + for (uint count = 0; count < keys.size(); count++) + { + // if out entry is true, add it.. + if ((*ourRhs)[keys[count]]) + { + added = true; + len += keys[count].length() + 1; + if (len > 80) + { + newLine += "\\\n\t"; + len = 8; + } + newLine += keys[count]; + newLine += ' '; + // set our value so we don't add it again. + (*ourRhs)[keys[count]] = false; + } + } + // only print it out if there was a value to add.. + if (added) + { + newLine.setLength(newLine.length() - 1); + outs << newLine << endl; + } + } + else + { + // we are removing our interested values from this line + // special case - no values, remove the line.. + if (!ourRhs->empty()) + { + // check if any of these values are down to remove. + QString newLine(lastLhs); + if (seenLhs.find(lastLhs) == seenLhs.end()) + { + newLine += " = "; + seenLhs[lastLhs] = ""; + } + else + { + newLine += " += "; + } + int len = newLine.length(); + bool added = false; + for (QStringList::Iterator posIter = lastRhs.begin(); posIter != lastRhs.end();posIter++) + { + QMap::iterator findEntry = ourRhs->find(*posIter); + if (findEntry == ourRhs->end()) + { + // we do not want to remove it.. + added = true; + len += (*posIter).length() + 1; + if (len > 80) + { + newLine += "\\\n\t"; + len = 8; + } + newLine += (*posIter); + newLine += ' '; + } + // else we have this value in our 'to remove list', so don't add it. + } + // only print it out if there was a value on it.. + if (added) + { + newLine.setLength(newLine.length() - 1); + outs << newLine << endl; + } + } + } + + lastLhs.setLength(0); + lastRhs.clear(); + } + } + else + { + // can write this line out.. + // not a match, not a multi line, + outs << s << endl; + } + } + + if (add) + { + QDictIterator > it(interest); + for (; it.current(); ++it) + { + QString lhs = it.currentKey(); + QMap* ourRhs = it.current(); + + QString newLine(lhs); + if (seenLhs.find(lhs) == seenLhs.end()) + { + newLine += " = "; + seenLhs[lastLhs] = ""; + } + else + { + newLine += " += "; + } + int len = newLine.length(); + bool added = false; + QValueList keys = ourRhs->keys(); + for (uint count = 0; count < keys.size(); count++) + { + if ((*ourRhs)[keys[count]]) + { + added = true; + len += keys[count].length() + 1; + if (len > 80) + { + newLine += "\\\n\t"; + len = 8; + } + newLine += keys[count]; + newLine += ' '; + // set our value so we don't add it again. + (*ourRhs)[keys[count]] = false; + } + } + // only print it out if there was a value to add.. + if (added) + { + newLine.setLength(newLine.length() - 1); + outs << newLine << endl; + } + } + } + interest.setAutoDelete(true); + interest.clear(); + + fin.close(); + fout.close(); + + QDir().rename(fileName + "#", fileName); +} + +/** + * Any items in the map will be removed from the Makefile.am + * Empty lines are removed. eg. foo_LDDADD if empty is removed. + * @param fileName full path to Makefile.am + * @param variables lines to remove items from. + */ +void AutoProjectTool::removeFromMakefileam(const QString &fileName, QMap variables) +{ + AutoProjectTool::addRemoveMakefileam(fileName, variables, false); +} + + +/** + * Open the file and parse out the AC_OUTPUT line. following backslash continue lines.. + * @param configureinpath + * @return list of all the values + */ +QStringList AutoProjectTool::configureinLoadMakefiles(QString configureinpath) +{ + QFile configurein(configureinpath); + + if (!configurein.open(IO_ReadOnly)) + { + kdDebug(9020) << k_funcinfo << " - couldn't open file: " << configureinpath << endl; + return QStringList(); + } + + QTextStream stream(&configurein); + QStringList list; + + QString ac_match("^AC_OUTPUT"); + + QRegExp ac_regex(ac_match); + bool multiLine = false; + QChar cont('\\'); + QRegExp close("\\)"); + QRegExp open("\\("); + while (!stream.eof()) + { + QString line = stream.readLine().stripWhiteSpace(); + if (multiLine) + { + if (close.search(line) >= 0) + { + line = line.replace(close.search(line), 1, ""); + list += QStringList::split(" ", line); + break; + } + else + { + if (line.endsWith(cont)) + { + line.setLength(line.length() - 1); + } + list += QStringList::split(" ", line); + } + } + else if (ac_regex.search(line) >= 0) + { + line = line.replace(ac_regex.search(line), ac_match.length() - 1, ""); + + if (open.search(line) >= 0) + { + line = line.replace(open.search(line), 1, ""); + } + + if (line.endsWith(cont)) + { + line.setLength(line.length() - 1); + multiLine = true; + } + else + { + if (close.search(line) >= 0) + { + line = line.replace(close.search(line), 1, ""); + } + } + + list = QStringList::split(" ", line); + + if (!multiLine) + { + break; + } + } + } + + configurein.close(); + + // make a new object on the heap + return list; + +} + +/** + * Write the items to the AC_OUTPUT line. This replaces the exiting line. + * @param configureinpath + * @param makefiles + */ +void AutoProjectTool::configureinSaveMakefiles(QString fileName, QStringList makefiles) +{ + // input file reading + QFile fin(fileName); + if (!fin.open(IO_ReadOnly)) + { + return ; + } + QTextStream ins(&fin); + + // output file writing. + QFile fout(fileName + "#"); + if (!fout.open(IO_WriteOnly)) + { + fin.close(); + return ; + } + QTextStream outs(&fout); + + // remove duplicates if any.. + QMap toAdd; + for (uint i = 0; i < makefiles.size();i++) + { + toAdd.insert(makefiles[i].stripWhiteSpace(), ""); + } + + QString ac_match("^AC_OUTPUT"); + QRegExp ac_regex(ac_match); + bool multiLine = false; + QChar cont('\\'); + QRegExp close("\\)"); + QRegExp open("\\("); + bool done = false; + while (!fin.atEnd()) + { + QString line = ins.readLine(); + if (done) + { + outs << line << endl; + } + else + { + if (multiLine) + { + line = line.stripWhiteSpace(); + if (close.search(line) >= 0) + { + int len = 10; + QString acline("AC_OUTPUT("); + for (QMap::iterator iter = toAdd.begin();iter != toAdd.end();iter++) + { + len += iter.key().length(); + if (len > 80) + { + acline += "\\\n\t"; + len = 8; + } + acline += iter.key(); + acline += ' '; + } + acline.setLength(acline.length() - 1); + acline = acline.append(")"); + outs << acline << endl; + done = true; + } + else + { + if (line.endsWith(cont)) + { + line.setLength(line.length() - 1); + } + } + } + else if (ac_regex.search(line) >= 0) + { + line = line.stripWhiteSpace(); + line = line.replace(ac_regex.search(line), ac_match.length() - 1, ""); + if (line.endsWith(cont)) + { + line.setLength(line.length() - 1); + multiLine = true; + } + if (open.search(line) >= 0) + { + line = line.replace(open.search(line), 1, ""); + } + if (close.search(line) >= 0) + { + line = line.replace(close.search(line), 1, ""); + } + + if (!multiLine) + { + int len = 10; + QString acline("AC_OUTPUT("); + for (QMap::iterator iter = toAdd.begin();iter != toAdd.end();iter++) + { + len += iter.key().length(); + if (len > 80) + { + acline += "\\\n\t"; + len = 8; + } + acline += iter.key(); + acline += ' '; + } + acline.setLength(acline.length() - 1); + acline = acline.append(")"); + outs << acline << endl; + done = true; + } + } + else + { + outs << line << endl; + } + } + } + + fin.close(); + fout.close(); + + QDir().rename(fileName + "#", fileName); + +} + +//kate: indent-mode csands; space-indent off; tab-width 4; diff --git a/buildtools/autotools/misc.h b/buildtools/autotools/misc.h new file mode 100644 index 00000000..9db9919e --- /dev/null +++ b/buildtools/autotools/misc.h @@ -0,0 +1,65 @@ +/*************************************************************************** +* Copyright (C) 2001-2002 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _MISC_H_ +#define _MISC_H_ + +#include +#include +#include + +/** + * Very small helper class. It has just static methods. + */ +class AutoProjectTool +{ +public: + + /** + * Loads the compiler options plugin for the given compiler, executes the dialog + * with some initial flags, and returns the new flags. + */ + static QString execFlagsDialog( const QString &compiler, const QString &flags, QWidget *parent ); + + /** + * Returns the canonicalized version of a file name, i.e. + * the file name with special characters replaced by underscores + */ + static QString canonicalize( const QString &str ); + + /** + * Parses a Makefile.am and stores its variable assignments + * in a map. + */ + static void parseMakefileam( const QString &filename, QMap *variables ); + + static void addToMakefileam( const QString &filename, QMap variables ); + static void removeFromMakefileam( const QString &filename, QMap variables ); + static void setMakefileam ( const QString &fileName, QMap variables ); + + static void addRemoveMakefileam(const QString &fileName, QMap variables, bool add); + + /** + * Parses configure.in and splits AC_OUTPUT into a QStringList + */ + static QStringList configureinLoadMakefiles( QString configureinpath ); + + /** + * Receives a QStringList and puts it into + * configure.in as arguments to AC_OUTPUT + */ + static void configureinSaveMakefiles( QString configureinpath, QStringList makefiles ); + +}; + +#endif +// kate: indent-mode csands; tab-width 4; + diff --git a/buildtools/autotools/removefiledlg.cpp b/buildtools/autotools/removefiledlg.cpp new file mode 100644 index 00000000..2c3bc37f --- /dev/null +++ b/buildtools/autotools/removefiledlg.cpp @@ -0,0 +1,182 @@ +/*************************************************************************** + * Copyright (C) 2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "removefiledlg.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "autolistviewitems.h" + +#include "misc.h" +#include "autoprojectpart.h" +#include "autoprojectwidget.h" +#include "autodetailsview.h" + +static bool fileListContains(const QPtrList &list, const QString &name) +{ + QPtrListIterator it(list); + for (; it.current(); ++it) + if ((*it)->text(0) == name) + return true; + return false; +} + + +RemoveFileDialog::RemoveFileDialog(AutoProjectWidget *widget, AutoProjectPart* part, SubprojectItem *spitem, + TargetItem *item, const QString &filename, + QWidget *parent, const char *name) + : RemoveFileDlgBase(parent, name, true) +{ + removeFromTargetsCheckBox = 0; + + QStringList targets; + + QPtrListIterator it(spitem->targets); + for (; it.current(); ++it) + if (fileListContains((*it)->sources, filename)) + targets.append((*it)->name); + + if (targets.count() > 1) + { + removeFromTargetsCheckBox = new QCheckBox( fileGroupBox, "removeFromTargetsCheckBox" ); + removeFromTargetsCheckBox->setMinimumSize( QSize( 0, 45 ) ); + fileLayout->addWidget( removeFromTargetsCheckBox ); + + QString joinedtargets = " *" + targets.join("\n *"); + removeFromTargetsCheckBox->setText ( i18n ( "The file %1 is still used by the following targets:\n%2\n" + "Remove it from all of them?").arg(filename).arg(joinedtargets) ); + setMinimumSize(QSize(size().width(), size().height() + removeFromTargetsCheckBox->size().height()*2) ); + } + + removeLabel->setText ( i18n ( "Do you really want to remove %1?" ).arg ( filename ) ); + + directoryLabel->setText ( spitem->path ); + if ( item->name.isEmpty() ) + targetLabel->setText ( i18n ( "%1 in %2" ).arg ( item->primary ).arg ( item->prefix ) ); + else + targetLabel->setText ( item->name ); + + connect ( removeButton, SIGNAL ( clicked() ), this, SLOT ( accept() ) ); + connect ( cancelButton, SIGNAL ( clicked() ), this, SLOT ( reject() ) ); + + setIcon ( SmallIcon ( "editdelete.png" ) ); + + m_widget = widget; + m_part = part; + subProject = spitem; + target = item; + fileName = filename; +} + + +RemoveFileDialog::~RemoveFileDialog() +{} + + +void RemoveFileDialog::accept() +{ + m_widget->emitRemovedFile ( subProject->path.mid ( m_part->projectDirectory().length() + 1 ) + "/" + fileName ); + + QMap replaceMap; + + if (removeFromTargetsCheckBox && removeFromTargetsCheckBox->isChecked()) { + QPtrListIterator it(subProject->targets); + for (; it.current(); ++it) { + if ((*it) != target && fileListContains((*it)->sources, fileName)) { + FileItem *fitem = static_cast((*it)->firstChild()); + while (fitem) { + FileItem *nextitem = static_cast(fitem->nextSibling()); + if (fitem->text(0) == fileName) { + QListView *lv = fitem->listView(); + lv->setSelected(fitem, false); + (*it)->sources.remove(fitem); + } + fitem = nextitem; + } + QString canontargetname = AutoProjectTool::canonicalize((*it)->name); + QString varname; + if( (*it)->primary == "PROGRAMS" || (*it)->primary == "LIBRARIES" || (*it)->primary == "LTLIBRARIES" ) + varname = canontargetname + "_SOURCES"; + else + varname = (*it)->prefix + "_" + (*it)->primary; + QStringList sources = QStringList::split(QRegExp("[ \t\n]"), subProject->variables[varname]); + sources.remove(fileName); + subProject->variables[varname] = sources.join(" "); + replaceMap.insert(varname, fileName); + } + } + } + + QString fileItemName; + FileItem *fitem = static_cast(target->firstChild()); + while (fitem) { + if (fitem->text(0) == fileName) { + QListView *lv = fitem->listView(); + lv->setSelected(fitem, false); + fileItemName = fitem->name; + target->sources.remove(fitem); + break; + } + fitem = static_cast(fitem->nextSibling()); + } + 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; + QStringList sources = QStringList::split(QRegExp("[ \t\n]"), subProject->variables[varname]); + sources.remove(fileName); + subProject->variables[varname] = sources.join(" "); + replaceMap.insert(varname, fileName); + + AutoProjectTool::removeFromMakefileam(subProject->path + "/Makefile.am", replaceMap); + +// review configuration cleanup in the project file after removing subclassing related source + QDomDocument &dom = *(m_part->projectDom()); + + QDomElement el = dom.documentElement(); + QDomNode el2 = el.namedItem("kdevautoproject"); + QDomNode el3 = el2.namedItem("subclassing"); + + QDomNode n = el3.firstChild(); + QValueList nodesToRemove; + while ( !n.isNull() ) { + QDomNamedNodeMap attr = n.attributes(); + QString fpath = subProject->path + QString("/") + fileItemName; + QString relpath = fpath.remove(0, m_part->projectDirectory().length()); + if ((attr.item(0).nodeValue() == relpath) + || (attr.item(1).nodeValue() == relpath) ) + nodesToRemove.append(n); + n = n.nextSibling(); + } + QValueList::iterator it; + for ( it = nodesToRemove.begin(); it != nodesToRemove.end(); ++it ) + el3.removeChild(*it); + + if (removeCheckBox->isChecked()) + QFile::remove(subProject->path + "/" + fileName); + + QDialog::accept(); +} + +#include "removefiledlg.moc" diff --git a/buildtools/autotools/removefiledlg.h b/buildtools/autotools/removefiledlg.h new file mode 100644 index 00000000..ab843dda --- /dev/null +++ b/buildtools/autotools/removefiledlg.h @@ -0,0 +1,51 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _REMOVEFILEDLG_H_ +#define _REMOVEFILEDLG_H_ + +#include + +#include "removefiledlgbase.h" + +class QCheckBox; +class AutoProjectWidget; +class AutoProjectPart; +class SubprojectItem; +class TargetItem; + + +class RemoveFileDialog : public RemoveFileDlgBase +{ + Q_OBJECT + +public: + RemoveFileDialog( AutoProjectWidget *widget, AutoProjectPart* part, SubprojectItem *spitem, + TargetItem *item, const QString &filename, + QWidget *parent = 0, const char *name = 0 ); + ~RemoveFileDialog(); + +protected: + virtual void accept(); + +private: + QCheckBox *removeFromTargetsCheckBox; + //QCheckBox *removefromdisk_box; + + AutoProjectWidget* m_widget; + AutoProjectPart *m_part; + SubprojectItem *subProject; + TargetItem *target; + QString fileName; +}; + +#endif +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/removefiledlgbase.ui b/buildtools/autotools/removefiledlgbase.ui new file mode 100644 index 00000000..d7b66011 --- /dev/null +++ b/buildtools/autotools/removefiledlgbase.ui @@ -0,0 +1,233 @@ + +RemoveFileDlgBase + + + RemoveFileDlgBase + + + + 0 + 0 + 447 + 284 + + + + Remove File From This Target + + + + unnamed + + + + layout4 + + + + unnamed + + + + buttonSpacer + + + Horizontal + + + Expanding + + + + 247 + 20 + + + + + + removeButton + + + &OK + + + true + + + + + cancelButton + + + &Cancel + + + + + + + fileGroupBox + + + + 0 + 0 + + + + &File Information + + + + unnamed + + + + fileLayout + + + + unnamed + + + + removeLabel + + + [REMOVE QUESTION] + + + + + removeCheckBox + + + Also &remove it from disk + + + + + noticeLabel + + + + 200 + 0 + + + + <b>Note:</b> You will not be able to undelete the file. + + + + + + + + + targetBox + + + + 5 + 0 + 0 + 0 + + + + Subproject Information + + + + unnamed + + + + targetLabel + + + + 5 + 1 + 0 + 0 + + + + [TARGET NAME] + + + + + directoryStaticLabel + + + + 0 + 1 + 0 + 0 + + + + + + + + Directory: + + + + + targetStaticLabel + + + + 0 + 1 + 0 + 0 + + + + + + + + Target: + + + + + directoryLabel + + + + 5 + 1 + 0 + 0 + + + + [DIRECTORY NAME] + + + + + + + + removeCheckBox + removeButton + cancelButton + + + ksqueezedtextlabel.h + kdialog.h + + + + diff --git a/buildtools/autotools/removetargetdlg.cpp b/buildtools/autotools/removetargetdlg.cpp new file mode 100644 index 00000000..6104e404 --- /dev/null +++ b/buildtools/autotools/removetargetdlg.cpp @@ -0,0 +1,279 @@ +/*************************************************************************** + ------------------- + begin : 21.11.2002 + copyright : (C) 2002 by Victor R�er + email : 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 "removetargetdlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "autolistviewitems.h" + +#include "misc.h" + +#include "autoprojectpart.h" +#include "autoprojectwidget.h" + + +RemoveTargetDialog::RemoveTargetDialog( AutoProjectWidget *widget, AutoProjectPart* part, SubprojectItem *spitem, + TargetItem *titem, QWidget* parent, const char* name ) + : RemoveTargetDlgBase ( parent, name, true, 0 ) +{ + removeLabel->setText ( i18n ( "Do you really want to remove %1
with all files that are attached to it
and all dependencies?" ).arg ( titem->name ) ); + directoryLabel->setText ( spitem->path ); + + if ( titem->name.isEmpty() ) + targetLabel->setText ( i18n ( "%1 in %2" ).arg ( titem->primary ).arg ( titem->prefix ) ); + else + targetLabel->setText ( titem->name ); + + connect ( removeButton, SIGNAL ( clicked() ), this, SLOT ( accept() ) ); + connect ( cancelButton, SIGNAL ( clicked() ), this, SLOT ( reject() ) ); + + setIcon ( SmallIcon ( "editdelete" ) ); + + progressBar->hide(); + + m_spitem = spitem; + m_titem = titem; + m_widget = widget; + m_part = part; + + //kdDebug ( 9020 ) << "+++++ " << titem->primary << " " << titem->prefix << " " << titem->name << endl; + + init(); +} + + +RemoveTargetDialog::~RemoveTargetDialog() +{ +} + +void RemoveTargetDialog::init() +{ + QPtrList subprojectItems = m_widget->allSubprojectItems(); + + TargetItem* titem = 0; + + for ( SubprojectItem* spitem = subprojectItems.first(); spitem; spitem = subprojectItems.next() ) + { + if ( m_titem->name.isEmpty() ) + break; + + for ( titem = spitem->targets.first(); titem; titem = spitem->targets.next() ) + { + if ( m_titem->name == titem->name ) + continue; + + if ( titem->primary == "LTLIBRARIES" || titem->primary == "PROGRAMS" + || titem->primary == "LIBRARIES" || titem->primary == "JAVA" ) + { + QString canonname = AutoProjectTool::canonicalize ( titem->name ); + + if ( spitem->variables[canonname + "_LIBADD"].contains ( m_titem->name ) > 0 || + spitem->variables[canonname + "_LDADD"].contains ( m_titem->name ) > 0 ) + { + dependencyListBox->insertItem ( SmallIcon ( "target_kdevelop" ), spitem->path + " (" + titem->name + ")" ); + + dependentSubprojects.append ( spitem ); + } + } + } + } + + if ( dependencyListBox->count() == 0 ) + dependencyListBox->insertItem ( i18n("no dependency", "") ); +} + +void RemoveTargetDialog::accept () +{ + progressBar->show(); + progressBar->setFormat ( i18n ( "Removing Target... %p%" ) ); + + qApp->processEvents(); + + QString canonname = AutoProjectTool::canonicalize ( m_titem->name ); + QString varname = m_titem->prefix + "_" + m_titem->primary; + + SubprojectItem* spitem = 0; + TargetItem* titem = 0; + + QMap removeMap; + QMap replaceMap; + + // Remove dependencies to other targets first (stored by init() in 'dependentTargets') + for ( spitem = dependentSubprojects.first(); spitem; spitem = dependentSubprojects.next() ) + { + for ( titem = spitem->targets.first(); titem; titem = spitem->targets.next() ) + { + QString curVarname; + QString curCanonname = AutoProjectTool::canonicalize ( titem->name ); + QStringList dependencies; + + if ( spitem->variables[curCanonname + "_LIBADD"].contains ( m_titem->name ) ) + curVarname = curCanonname + "_LIBADD"; + else + curVarname = curCanonname + "_LDADD"; + + dependencies = QStringList::split(QRegExp("[ \t\n]"), spitem->variables[curVarname]); + + //QStringList::Iterator it = dependencies.begin(); + + for ( uint i = 0; i < dependencies.size(); ++i ) + { + QString s = dependencies[i]; + if ( s.contains ( m_titem->name ) > 0 ) + dependencies.remove ( s ); + } + + // if we removed the last entry of "blabla_LDADD" or "blabla_LIBADD", remove the complete line + if ( dependencies.count() == 0 ) + { + removeMap.insert ( curVarname, "" ); + AutoProjectTool::removeFromMakefileam ( spitem->path + "/Makefile.am", removeMap ); + removeMap.clear(); + } + else + { + spitem->variables[curVarname] = dependencies.join ( " " ); + replaceMap.insert ( curVarname, spitem->variables[curVarname] ); + AutoProjectTool::addToMakefileam ( spitem->path + "/Makefile.am", replaceMap ); + replaceMap.clear(); + } + } + } + + // handling am_edit stuff + if ( m_titem->primary == "KDEICON" ) + removeMap.insert ( "KDE_ICON", "" ); + else if ( m_titem->primary == "KDEDOCS" ) + removeMap.insert ( "KDE_DOCS", "" ); + else + { + // if we have bin_PROGRAMS = [target to be deleted] [other target] + // delete only the [target to be deleted], not the whole line! + QStringList targets = QStringList::split(QRegExp("[ \t\n]"), m_spitem->variables[varname]); + + if ( targets.count() > 1 ) + { + targets.remove ( m_titem->name ); + m_spitem->variables[varname] = targets.join ( " " ); + replaceMap.insert ( varname, m_spitem->variables[varname] ); + AutoProjectTool::addToMakefileam ( m_spitem->path + "/Makefile.am", replaceMap ); + replaceMap.clear(); + } + else + { + removeMap.insert ( varname, m_titem->name ); + } + } + + // if we have no such line containing blabla_SOURCES, blabla_LDFLAGS, etc. + // they are ignored + removeMap.insert ( canonname + "_SOURCES", "" ); + + // remove from our internal list + m_spitem->variables.erase(canonname+"_SOURCES"); + + if ( m_titem->primary == "PROGRAMS" || m_titem->primary == "LTLIBRARIES" ) + { + removeMap.insert ( canonname + "_LDFLAGS", "" ); + removeMap.insert ( canonname + "_DEPENDENCIES", "" ); + removeMap.insert ( canonname + "_LDADD", "" ); + removeMap.insert ( canonname + "_LIBADD", "" ); + } + + AutoProjectTool::removeFromMakefileam ( m_spitem->path + "/Makefile.am", removeMap ); + + removeMap.clear(); + + // if we have another "blabla_PROGRAMS" or "blabla_LTLIBRARIES" target in the same subproject + // check if it has an empty "blabla_LIBADD"-entry + if ( m_titem->primary == "PROGRAMS" || m_titem->primary == "LTLIBRARIES" ) + { + for ( titem = m_spitem->targets.first(); titem; titem = m_spitem->targets.next() ) + { + //kdDebug (9020) << "******** " << m_spitem->subdir << endl; + if ( titem->primary == "PROGRAMS" || titem->primary == "LTLIBRARIES" ) + { + QString curCanonname = AutoProjectTool::canonicalize ( titem->name ); + + if ( m_spitem->variables[curCanonname + "_LIBADD"].isEmpty() ) + { + removeMap.insert ( curCanonname + "_LIBADD", "" ); + + //kdDebug (9020) << "Removing from " << m_spitem->subdir << " " << curCanonname << "_LIBADD" << endl; + + AutoProjectTool::removeFromMakefileam ( m_spitem->path + "/Makefile.am", removeMap ); + + removeMap.clear(); + } + } + } + } + + + progressBar->setTotalSteps ( m_titem->sources.count() ); + + QStringList fileList; + + for ( FileItem* fitem = m_titem->sources.first(); fitem; fitem = m_titem->sources.next() ) + { + if (removeCheckBox->isChecked()) + { + // before removing the files, check if they are mentioned in "noinst_HEADERS = blabla1.h blabla2.h" + QStringList noInstHeaders = QStringList::split ( QRegExp ( "[ \t\n]" ), m_spitem->variables["noinst_HEADERS"] ); + + if ( noInstHeaders.contains ( fitem->name ) ) + { + noInstHeaders.remove ( fitem->name ); + + m_spitem->variables["noinst_HEADERS"] = noInstHeaders.join ( " " ); + replaceMap.insert ( "noinst_HEADERS", m_spitem->variables["noinst_HEADERS"] ); + AutoProjectTool::addToMakefileam ( m_spitem->path + "/Makefile.am", replaceMap ); + replaceMap.clear(); + } + + QFile::remove(m_spitem->path + "/" + fitem->name); + } + + fileList.append ( m_spitem->path.mid ( m_part->projectDirectory().length() + 1 ) + "/" + fitem->name ); + + qApp->processEvents(); + + progressBar->setValue ( progressBar->value() + 1 ); + } + + m_widget->emitRemovedFiles ( fileList ); + + m_spitem->targets.remove ( m_titem ); + + + QDialog::accept(); +} diff --git a/buildtools/autotools/removetargetdlg.h b/buildtools/autotools/removetargetdlg.h new file mode 100644 index 00000000..6953d2bf --- /dev/null +++ b/buildtools/autotools/removetargetdlg.h @@ -0,0 +1,55 @@ +/*************************************************************************** + ------------------- + begin : 21.11.2002 + copyright : (C) 2002 by Victor Rder + email : 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. * + * * + ***************************************************************************/ + +#ifndef _REMOVETARGETDLG_H_ +#define _REMOVETARGETDLG_H_ + +#include "removetargetdlgbase.h" + +#include + +class AutoProjectWidget; +class AutoProjectPart; +class SubprojectItem; +class TargetItem; + +/** + * + * KDevelop Authors + **/ +class RemoveTargetDialog : public RemoveTargetDlgBase +{ + +public: + RemoveTargetDialog( AutoProjectWidget *widget, AutoProjectPart* part, SubprojectItem *spitem, + TargetItem *titem, QWidget* parent = 0, const char* name = 0 ); + ~RemoveTargetDialog(); + +private: + SubprojectItem* m_spitem; + TargetItem* m_titem; + AutoProjectWidget* m_widget; + AutoProjectPart* m_part; + + QPtrList dependentSubprojects; + +protected: + void init (); + virtual void accept(); +}; + +#endif +// kate: indent-mode csands; tab-width 4; diff --git a/buildtools/autotools/removetargetdlgbase.ui b/buildtools/autotools/removetargetdlgbase.ui new file mode 100644 index 00000000..8e3660d3 --- /dev/null +++ b/buildtools/autotools/removetargetdlgbase.ui @@ -0,0 +1,264 @@ + +RemoveTargetDlgBase + + + RemoveTargetDlgBase + + + + 0 + 0 + 472 + 477 + + + + Remove Target From [SUBPROJECT] + + + + unnamed + + + + targetBox + + + Subproject Information + + + + unnamed + + + + directoryLabel + + + + 5 + 5 + 0 + 0 + + + + [TARGET DIRECTORY] + + + + + targetLabel + + + [TARGET NAME] + + + + + directoryStaticLabel + + + + 0 + 5 + 0 + 0 + + + + + + + + Directory: + + + + + targetStaticLabel + + + + 0 + 5 + 0 + 0 + + + + + + + + Target: + + + + + + + fileGroupBox + + + + 0 + 0 + + + + + 32767 + 140 + + + + &Target Information + + + + unnamed + + + + removeLabel + + + [REMOVE QUESTION] + + + + + removeCheckBox + + + Also &remove it from disk + + + + + textLabel + + + + 200 + 0 + + + + <b>Note:</b> You will not be able to undo this operation. Please check your Makefile.am afterwards. + + + + + + + groupBox3 + + + &Dependencies to Other Subprojects + + + + unnamed + + + + dependencyListBox + + + false + + + NoSelection + + + + + + + progressBar + + + true + + + + + Spacer2 + + + Vertical + + + Fixed + + + + 20 + 16 + + + + + + buttonLayout + + + + unnamed + + + 0 + + + + buttonSpacer + + + Horizontal + + + Expanding + + + + 30 + 20 + + + + + + removeButton + + + &OK + + + true + + + + + cancelButton + + + &Cancel + + + + + + + + kdialog.h + + + + + ksqueezedtextlabel.h + klistbox.h + kprogress.h + + diff --git a/buildtools/autotools/subprojectoptionsdlg.cpp b/buildtools/autotools/subprojectoptionsdlg.cpp new file mode 100644 index 00000000..5ad6bf10 --- /dev/null +++ b/buildtools/autotools/subprojectoptionsdlg.cpp @@ -0,0 +1,404 @@ +/*************************************************************************** + * Copyright (C) 2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "subprojectoptionsdlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "domutil.h" +#include "misc.h" +#include "addprefixdlg.h" + +#include "autolistviewitems.h" + +#include "autoprojectpart.h" +#include "autoprojectwidget.h" + + +SubprojectOptionsDialog::SubprojectOptionsDialog(AutoProjectPart *part, AutoProjectWidget *widget, + SubprojectItem *item, QWidget *parent, const char *name) + : SubprojectOptionsDialogBase(parent, name, true) +{ + setCaption(i18n("Subproject Options for '%1'").arg(item->subdir)); + + subProject = item; + m_part = part; + + QFontMetrics fm(cflags_edit->fontMetrics()); + int wid = fm.width('X')*35; + cflags_edit->setMinimumWidth(wid); + cxxflags_edit->setMinimumWidth(wid); + fflags_edit->setMinimumWidth(wid); + + QDomDocument &dom = *part->projectDom(); + QString prefix = "/kdevautoproject/configurations/" + m_part->currentBuildConfig() + "/"; + + ccompiler = DomUtil::readEntry(dom, prefix + "ccompiler", "kdevgccoptions"); + cxxcompiler = DomUtil::readEntry(dom, prefix + "cxxcompiler", "kdevgppoptions"); + f77compiler = DomUtil::readEntry(dom, prefix + "f77compiler", "kdevg77options"); + + if (!KService::serviceByDesktopName(ccompiler)) + cflags_button->setEnabled(false); + if (!KService::serviceByDesktopName(cxxcompiler)) + cxxflags_button->setEnabled(false); + if (!KService::serviceByDesktopName(f77compiler)) + fflags_button->setEnabled(false); + + insideinc_listview->header()->hide(); + outsideinc_listview->header()->hide(); + buildorder_listview->header()->hide(); + + insideinc_listview->setSorting(-1); + outsideinc_listview->setSorting(-1); + prefix_listview->setSorting(-1); + buildorder_listview->setSorting(-1); + + connect( prefix_listview, SIGNAL( doubleClicked ( QListViewItem *, const QPoint &, int ) ), this, SLOT( editPrefixClicked() ) ); + + // Insert all subdirectories as possible include directories + QStringList l = widget->allSubprojects(); + QCheckListItem *lastItem = 0; + QStringList::ConstIterator it; + for (it = l.begin(); it != l.end(); ++it) { + kdDebug(9020) << "----------> subproject = " << (*it) << endl; + QString subProjectName = *it; + + if( subProjectName.isEmpty() ){ + subProjectName = QString::fromLatin1( "." ); + } + QCheckListItem *clitem = new QCheckListItem(insideinc_listview, subProjectName, QCheckListItem::CheckBox); + if (lastItem) + clitem->moveItem(lastItem); + lastItem = clitem; + } + + setIcon ( SmallIcon ( "configure" ) ); + + readConfig(); +} + + +SubprojectOptionsDialog::~SubprojectOptionsDialog() +{} + + +void SubprojectOptionsDialog::readConfig() +{ + + cflags_edit->setText(subProject->variables["AM_CFLAGS"]); + cxxflags_edit->setText(subProject->variables["AM_CXXFLAGS"]); + fflags_edit->setText(subProject->variables["AM_FFLAGS"]); + + metasources_checkbox->setChecked(subProject->variables["METASOURCES"].stripWhiteSpace() == "AUTO"); + + QString includes = subProject->variables["INCLUDES"]; + QStringList includeslist = QStringList::split(QRegExp("[ \t]"), QString(includes)); + + QListViewItem *lastItem = 0; + QStringList::Iterator it; + for (it = includeslist.begin(); it != includeslist.end(); ++it) { + QCheckListItem *clitem = static_cast(insideinc_listview->firstChild()); + while (clitem) { + if (*it == ("-I$(top_srcdir)/" + clitem->text())) { + clitem->setOn(true); + break; + } + clitem = static_cast(clitem->nextSibling()); + } + if (!clitem) { + QListViewItem *item = new QListViewItem(outsideinc_listview, *it); + if (lastItem) + item->moveItem(lastItem); + lastItem = item; + } + } + + QMap::ConstIterator it2; + for (it2 = subProject->prefixes.begin(); it2 != subProject->prefixes.end(); ++it2) + new QListViewItem(prefix_listview, it2.key(), it2.data()); + + QString subdirs = subProject->variables["SUBDIRS"]; + kdDebug(9020) << "Subdirs variable: " << subdirs << endl; + QStringList subdirslist = QStringList::split(QRegExp("[ \t]"), QString(subdirs)); + lastItem = 0; + for (it = subdirslist.begin(); it != subdirslist.end(); ++it) { + QListViewItem *item = new QListViewItem(buildorder_listview, *it); + if (lastItem) + item->moveItem(lastItem); + lastItem = item; + } +} + + +void SubprojectOptionsDialog::storeConfig() +{ + QMap replaceMap; + + QString old_cflags = subProject->variables["AM_CFLAGS"]; + QString new_cflags = cflags_edit->text(); + if (new_cflags != old_cflags) { + subProject->variables["AM_CFLAGS"] = new_cflags; + replaceMap.insert("AM_CFLAGS", new_cflags); + } + + QString old_cxxflags = subProject->variables["AM_CXXFLAGS"]; + QString new_cxxflags = cxxflags_edit->text(); + if (new_cxxflags != old_cxxflags) { + subProject->variables["AM_CXXFLAGS"] = new_cxxflags; + replaceMap.insert("AM_CXXFLAGS", new_cxxflags); + } + + QString old_fflags = subProject->variables["AM_FFLAGS"]; + QString new_fflags = fflags_edit->text(); + if (new_fflags != old_fflags) { + subProject->variables["AM_FFLAGS"] = new_fflags; + replaceMap.insert("AM_FFLAGS", new_fflags); + } + + QString old_metasources = subProject->variables["METASOURCES"]; + QString new_metasources = metasources_checkbox->isChecked() ? QString::fromLatin1("AUTO") : QString::null; + if (new_metasources != old_metasources) { + subProject->variables["METASOURCES"] = new_metasources; + replaceMap.insert("METASOURCES", new_metasources); + } + + QStringList includeslist; + QCheckListItem *clitem = static_cast(insideinc_listview->firstChild()); + while (clitem) { + if (clitem->isOn()) + includeslist.append("-I$(top_srcdir)/" + clitem->text()); + clitem = static_cast(clitem->nextSibling()); + } + clitem = static_cast(outsideinc_listview->firstChild()); + while (clitem) { + includeslist.append(clitem->text()); + clitem = static_cast(clitem->nextSibling()); + } + QString includes = includeslist.join(" "); + subProject->variables["INCLUDES"] = includes; + replaceMap.insert("INCLUDES", includes); + + subProject->prefixes.clear(); + for (QListViewItem *item = prefix_listview->firstChild(); + item; item = item->nextSibling()) { + QString key = item->text(0); + QString data = item->text(1); + subProject->prefixes[key] = data; + replaceMap.insert(key + "dir", data); + } + /// \FIXME take removed prefixes into account + + QStringList subdirslist; + for (QListViewItem *item = buildorder_listview->firstChild(); + item; item = item->nextSibling()) + subdirslist.append(item->text(0)); + QString subdirs = subdirslist.join(" "); + kdDebug() << "New subdirs variable: " << subdirs << endl; + subProject->variables["SUBDIRS"] = subdirs; + replaceMap.insert("SUBDIRS", subdirs); + + AutoProjectTool::setMakefileam(subProject->path + "/Makefile.am", replaceMap); +} + + +void SubprojectOptionsDialog::cflagsClicked() +{ + QString new_cflags = AutoProjectTool::execFlagsDialog(ccompiler, cflags_edit->text(), this); +// if (!new_cflags.isNull()) + cflags_edit->setText(new_cflags); +} + + +void SubprojectOptionsDialog::cxxFlagsClicked() +{ + QString new_cxxflags = AutoProjectTool::execFlagsDialog(cxxcompiler, cxxflags_edit->text(), this); +// if (!new_cxxflags.isNull()) + cxxflags_edit->setText(new_cxxflags); +} + + +void SubprojectOptionsDialog::fflagsClicked() +{ + QString new_fflags = AutoProjectTool::execFlagsDialog(f77compiler, fflags_edit->text(), this); +// if (!new_fflags.isNull()) + fflags_edit->setText(new_fflags); +} + + +void SubprojectOptionsDialog::insideMoveUpClicked() +{ + if (insideinc_listview->currentItem() == insideinc_listview->firstChild()) { + KNotifyClient::beep(); + return; + } + + QListViewItem *item = insideinc_listview->firstChild(); + while (item->nextSibling() != insideinc_listview->currentItem()) + item = item->nextSibling(); + item->moveItem(insideinc_listview->currentItem()); +} + + +void SubprojectOptionsDialog::insideMoveDownClicked() +{ + if (insideinc_listview->currentItem() == 0 || insideinc_listview->currentItem()->nextSibling() == 0) { + KNotifyClient::beep(); + return; + } + + insideinc_listview->currentItem()->moveItem(insideinc_listview->currentItem()->nextSibling()); +} + + +void SubprojectOptionsDialog::outsideMoveUpClicked() +{ + if (outsideinc_listview->currentItem() == outsideinc_listview->firstChild()) { + KNotifyClient::beep(); + return; + } + + QListViewItem *item = outsideinc_listview->firstChild(); + while (item->nextSibling() != outsideinc_listview->currentItem()) + item = item->nextSibling(); + item->moveItem(outsideinc_listview->currentItem()); +} + + +void SubprojectOptionsDialog::outsideMoveDownClicked() +{ + if (outsideinc_listview->currentItem() == 0 || outsideinc_listview->currentItem()->nextSibling() == 0) { + KNotifyClient::beep(); + return; + } + + outsideinc_listview->currentItem()->moveItem(outsideinc_listview->currentItem()->nextSibling()); +} + +void SubprojectOptionsDialog::outsideAddClicked() +{ + KURLRequesterDlg dialog( "", i18n( "Add Include directory: Choose directory, give -Idirectory or use a variable with -I$(FOOBAR)" ), 0, 0 ); + dialog.urlRequester() ->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly ); + dialog.urlRequester() ->setURL( QString::null ); + if ( dialog.exec() != QDialog::Accepted ) + return ; + QString file = dialog.urlRequester() ->url(); + if ( !file.isEmpty() ) + { + if ( !file.isEmpty() ) + { + if( file.startsWith("-I") ) + new QListViewItem( outsideinc_listview, file ); + else + { + new QListViewItem( outsideinc_listview, "-I"+file ); + } + } + } +} + + +void SubprojectOptionsDialog::outsideEditClicked() +{ + if ( (outsideinc_listview->childCount()==0) || (outsideinc_listview->currentItem() == 0) ) + return; + bool ok; + QString dir = KInputDialog::getText(i18n("Edit Include Directory"), i18n("Edit include directory:"), + outsideinc_listview->currentItem()-> text(0), &ok, 0); + if (ok && !dir.isEmpty()) + outsideinc_listview->currentItem()-> setText(0, dir); +} + + +void SubprojectOptionsDialog::outsideRemoveClicked() +{ + delete outsideinc_listview->currentItem(); +} + + +void SubprojectOptionsDialog::addPrefixClicked() +{ + AddPrefixDialog dlg; + if (!dlg.exec() || dlg.name().isEmpty() || dlg.path().isEmpty() ) + return; + + new QListViewItem(prefix_listview, dlg.name(), dlg.path()); +} + + +void SubprojectOptionsDialog::editPrefixClicked() +{ + QListViewItem* lvItem = prefix_listview->currentItem(); + if ( (prefix_listview->childCount()==0) || (lvItem == 0) ) + return; + AddPrefixDialog dlg(lvItem-> text(0), lvItem-> text(1)); + dlg.setCaption(i18n("Edit Prefix")); + if (!dlg.exec() || dlg.name().isEmpty() || dlg.path().isEmpty() ) + return; + lvItem-> setText(0, dlg.name()); + lvItem-> setText(1, dlg.path()); +} + +void SubprojectOptionsDialog::removePrefixClicked() +{ + delete prefix_listview->currentItem(); +} + + +void SubprojectOptionsDialog::buildorderMoveUpClicked() +{ + if (buildorder_listview->currentItem() == buildorder_listview->firstChild()) { + KNotifyClient::beep(); + return; + } + + QListViewItem *item = buildorder_listview->firstChild(); + while (item->nextSibling() != buildorder_listview->currentItem()) + item = item->nextSibling(); + item->moveItem(buildorder_listview->currentItem()); +} + + +void SubprojectOptionsDialog::buildorderMoveDownClicked() +{ + if (buildorder_listview->currentItem() == 0 || buildorder_listview->currentItem()->nextSibling() == 0) { + KNotifyClient::beep(); + return; + } + + buildorder_listview->currentItem()->moveItem(buildorder_listview->currentItem()->nextSibling()); +} + + +void SubprojectOptionsDialog::accept() +{ + storeConfig(); + QDialog::accept(); +} + +#include "subprojectoptionsdlg.moc" diff --git a/buildtools/autotools/subprojectoptionsdlg.h b/buildtools/autotools/subprojectoptionsdlg.h new file mode 100644 index 00000000..7ec1fbf0 --- /dev/null +++ b/buildtools/autotools/subprojectoptionsdlg.h @@ -0,0 +1,63 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _SUBPROJECTOPTIONSDLG_H_ +#define _SUBPROJECTOPTIONSDLG_H_ + +#include "subprojectoptionsdlgbase.h" + +class AutoProjectPart; +class AutoProjectWidget; +class SubprojectItem; + + +class SubprojectOptionsDialog : public SubprojectOptionsDialogBase +{ + Q_OBJECT + +public: + SubprojectOptionsDialog( AutoProjectPart *part, AutoProjectWidget *widget, + SubprojectItem *item, QWidget *parent = 0, const char *name = 0 ); + ~SubprojectOptionsDialog(); + +private: + virtual void cflagsClicked(); + virtual void cxxFlagsClicked(); + virtual void fflagsClicked(); + virtual void insideMoveUpClicked(); + virtual void insideMoveDownClicked(); + virtual void outsideMoveUpClicked(); + virtual void outsideMoveDownClicked(); + virtual void outsideAddClicked(); + virtual void outsideRemoveClicked(); + virtual void outsideEditClicked(); + virtual void addPrefixClicked(); + virtual void editPrefixClicked(); + virtual void removePrefixClicked(); + virtual void buildorderMoveUpClicked(); + virtual void buildorderMoveDownClicked(); + virtual void accept(); + + void readConfig(); + void storeConfig(); + + SubprojectItem *subProject; + AutoProjectWidget *m_widget; + AutoProjectPart *m_part; + + QString ccompiler; + QString cxxcompiler; + QString f77compiler; +}; + +#endif +// kate: indent-mode csands; tab-width 4; + diff --git a/buildtools/autotools/subprojectoptionsdlgbase.ui b/buildtools/autotools/subprojectoptionsdlgbase.ui new file mode 100644 index 00000000..f2723e5a --- /dev/null +++ b/buildtools/autotools/subprojectoptionsdlgbase.ui @@ -0,0 +1,989 @@ + +SubprojectOptionsDialogBase + + + sub project options widget + + + + 0 + 0 + 442 + 437 + + + + Subproject Options + + + + unnamed + + + + subprojectoptions_tabwidget + + + + tab + + + Co&mpiler + + + + unnamed + + + + cflags_label + + + + + + + Compiler flags for C compiler (CFLA&GS): + + + cflags_edit + + + + + Layout5 + + + + unnamed + + + 0 + + + + cflags_edit + + + + 7 + 0 + 0 + 0 + + + + + + cflags_button + + + + 0 + 0 + 0 + 0 + + + + + 30 + 25 + + + + ... + + + false + + + + + + + Spacer2 + + + Vertical + + + Preferred + + + + 20 + 20 + + + + + + cxxflags_label + + + + + + + Compiler flags for C++ compiler (C&XXFLAGS): + + + cxxflags_edit + + + + + Layout3 + + + + unnamed + + + 0 + + + + cxxflags_edit + + + + + cxxflags_button + + + + 1 + 0 + 0 + 0 + + + + + 30 + 25 + + + + ... + + + false + + + + + + + Spacer3 + + + Vertical + + + Preferred + + + + 20 + 20 + + + + + + fflags_label + + + + + + + Compiler flags for Fortran compiler (&FFLAGS): + + + fflags_edit + + + + + Layout4 + + + + unnamed + + + 0 + + + + fflags_edit + + + + + fflags_button + + + + 1 + 0 + 0 + 0 + + + + + 30 + 25 + + + + ... + + + false + + + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + tab + + + &Includes + + + + unnamed + + + + layout11 + + + + unnamed + + + + metasources_checkbox + + + Automatically &generate metasources + + + + + layout9 + + + + unnamed + + + + Layout9 + + + + unnamed + + + 0 + + + + Spacer2_3 + + + Vertical + + + Expanding + + + + 20 + 16 + + + + + + insidemoveup_button + + + Move &Up + + + + + insidemovedown_button + + + Move &Down + + + + + Spacer3_2 + + + Vertical + + + Expanding + + + + 20 + 16 + + + + + + + + insideinc_label + + + + + + + Directories in&side project: + + + insideinc_listview + + + + + + + + + true + + + true + + + + insideinc_listview + + + LastColumn + + + + + + + layout10 + + + + unnamed + + + + Layout10 + + + + unnamed + + + 0 + + + + Spacer1_2 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + outsideadd_button + + + &Add... + + + + + outsideedit_button + + + &Edit... + + + + + outsideremove_button + + + &Remove + + + + + outsidemoveup_button + + + Move U&p + + + + + outsidemovedown_button + + + Move Dow&n + + + + + Spacer2_2 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + TextLabel2_2 + + + + + + + Directories ou&tside project: + + + outsideinc_listview + + + + + + + + + true + + + true + + + + outsideinc_listview + + + LastColumn + + + + + + + + + + + tab + + + &Prefixes + + + + unnamed + + + + + Name + + + true + + + true + + + + + Path + + + true + + + true + + + + prefix_listview + + + true + + + AllColumns + + + + + prefixes_label + + + + + + + C&ustom prefixes: + + + prefix_listview + + + + + Layout6 + + + + unnamed + + + 0 + + + + Spacer5 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + addprefix_button + + + &Add... + + + + + editprefix_button + + + &Edit... + + + + + removeprefix_button + + + &Remove + + + + + Spacer6 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + tab + + + &Build Order + + + + unnamed + + + + Layout9_2 + + + + unnamed + + + 0 + + + + Spacer2_3_2 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + buildmoveup_button + + + Move &Up + + + + + buildmovedown_button + + + Move &Down + + + + + Spacer3_2_2 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + + + true + + + true + + + + buildorder_listview + + + LastColumn + + + + + buildorder_label + + + + + + + O&rder in which sub projects are built: + + + buildorder_listview + + + + + + + + Layout2 + + + + unnamed + + + 0 + + + + Spacer1 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + okbutton + + + &OK + + + true + + + + + cancelbutton + + + &Cancel + + + + + + + + + cflags_button + clicked() + sub project options widget + cflagsClicked() + + + cxxflags_button + clicked() + sub project options widget + cxxFlagsClicked() + + + removeprefix_button + clicked() + sub project options widget + removePrefixClicked() + + + insidemoveup_button + clicked() + sub project options widget + insideMoveUpClicked() + + + insidemovedown_button + clicked() + sub project options widget + insideMoveDownClicked() + + + outsideadd_button + clicked() + sub project options widget + outsideAddClicked() + + + outsideedit_button + clicked() + sub project options widget + outsideEditClicked() + + + outsidemovedown_button + clicked() + sub project options widget + outsideMoveDownClicked() + + + outsidemoveup_button + clicked() + sub project options widget + outsideMoveUpClicked() + + + outsideremove_button + clicked() + sub project options widget + outsideRemoveClicked() + + + okbutton + clicked() + sub project options widget + accept() + + + cancelbutton + clicked() + sub project options widget + reject() + + + fflags_button + clicked() + sub project options widget + fflagsClicked() + + + buildmovedown_button + clicked() + sub project options widget + buildorderMoveDownClicked() + + + buildmoveup_button + clicked() + sub project options widget + buildorderMoveUpClicked() + + + addprefix_button + clicked() + sub project options widget + addPrefixClicked() + + + editprefix_button + clicked() + sub project options widget + editPrefixClicked() + + + + cflags_edit + cflags_button + cxxflags_edit + cxxflags_button + fflags_edit + fflags_button + subprojectoptions_tabwidget + metasources_checkbox + insideinc_listview + insidemoveup_button + insidemovedown_button + outsideinc_listview + outsideadd_button + outsideedit_button + outsideremove_button + outsidemoveup_button + outsidemovedown_button + prefix_listview + addprefix_button + editprefix_button + removeprefix_button + buildorder_listview + buildmoveup_button + buildmovedown_button + okbutton + cancelbutton + + + kdialog.h + + + buildorderMoveDownClicked() + cflagsClicked() + cxxFlagsClicked() + fflagsClicked() + insideMoveDownClicked() + insideMoveUpClicked() + buildorderMoveUpClicked() + outsideAddClicked() + outsideEditClicked() + outsideMoveDownClicked() + outsideMoveUpClicked() + outsideRemoveClicked() + removePrefixClicked() + addPrefixClicked() + editPrefixClicked() + + + + diff --git a/buildtools/autotools/targetoptionsdlg.cpp b/buildtools/autotools/targetoptionsdlg.cpp new file mode 100644 index 00000000..c8d49c55 --- /dev/null +++ b/buildtools/autotools/targetoptionsdlg.cpp @@ -0,0 +1,357 @@ +/*************************************************************************** + * Copyright (C) 2001 by Bernd Gehrmann * + * bernd@kdevelop.org * + * * + * 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 "targetoptionsdlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "autolistviewitems.h" + +#include "misc.h" +#include "autoprojectpart.h" +#include "autoprojectwidget.h" +#include "urlutil.h" + +TargetOptionsDialog::TargetOptionsDialog(AutoProjectWidget *widget, TargetItem *item, + QWidget *parent, const char *name) + : TargetOptionsDialogBase(parent, name, true) +{ + setCaption( i18n("Target Options for '%1'").arg(item->name) ); + setIcon( SmallIcon("configure") ); + + target = item; + m_widget = widget; + + if (item->primary == "PROGRAMS") { + insidelib_label->setText(i18n("Link convenience libraries inside project (LDADD)")); + outsidelib_label->setText(i18n("Link libraries outside project (LDADD)")); + } + else + argumentBox->setEnabled( false ); +// run_arguments_edit->setEnabled(false); + + insidelib_listview->header()->hide(); + outsidelib_listview->header()->hide(); + insidelib_listview->setSorting(-1); + outsidelib_listview->setSorting(-1); + + + m_cwdEdit->completionObject()->setMode(KURLCompletion::DirCompletion); + m_cwdEdit->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly ); + + // Insert all convenience libraries as possible linked libraries + QStringList l = widget->allLibraries(); + QStringList::ConstIterator it; + QString fulltargetname = m_widget->subprojectDirectory() + "/" + item->name; + for (it = l.begin(); it != l.end(); ++it) + // Do not list the target itself (a target can not link with itself) + if ( !fulltargetname.endsWith(*it) ) + (void) new QCheckListItem(insidelib_listview, *it, QCheckListItem::CheckBox); + readConfig(); +} + + +TargetOptionsDialog::~TargetOptionsDialog() +{} + + +void TargetOptionsDialog::readConfig() +{ + QString flagsstr = target->ldflags; + flagsstr.replace(QRegExp("$(KDE_PLUGIN)"), "-avoid-version -module -no-undefined $(KDE_RPATH)"); + QStringList l1 = QStringList::split(QRegExp("[ \t]"), flagsstr); + QStringList::Iterator l1it; + + l1it = l1.find("-all-static"); + if (l1it != l1.end()) { + allstatic_box->setChecked(true); + l1.remove(l1it); + } + l1it = l1.find("-avoid-version"); + if (l1it != l1.end()) { + avoidversion_box->setChecked(true); + l1.remove(l1it); + } + l1it = l1.find("-module"); + if (l1it != l1.end()) { + module_box->setChecked(true); + l1.remove(l1it); + } + l1it = l1.find("-no-undefined"); + if (l1it != l1.end()) { + noundefined_box->setChecked(true); + l1.remove(l1it); + } + ldflagsother_edit->setText(l1.join(" ")); + dependencies_edit->setText(target->dependencies); + + QString addstr = (target->primary == "PROGRAMS")? target->ldadd : target->libadd; + QStringList l2 = QStringList::split(QRegExp("[ \t]"), addstr); + + kdDebug(9020) << "ls=: " << addstr << endl; + + bool inlistItem; + QListViewItem *lastItem = 0; + QStringList::Iterator l2it; + QCheckListItem *flitem = static_cast(insidelib_listview->firstChild()); + for (l2it = l2.begin(); l2it != l2.end(); ++l2it) { + inlistItem = false; + QCheckListItem *clitem = static_cast(insidelib_listview->firstChild()); + if (flitem) { + while (clitem) { + if (*l2it == ("$(top_builddir)/" + clitem->text())) { + clitem->setOn(true); + // move this item to the "top of the list" + if (flitem != clitem) + clitem->moveItem(flitem); + // move the "top of the list" one item down + flitem = static_cast(flitem->nextSibling()); + inlistItem = true; + break; + } + clitem = static_cast(clitem->nextSibling()); + } + } + if ( inlistItem == false ) { + QListViewItem *item = new QListViewItem(outsidelib_listview, *l2it); + if (lastItem) + item->moveItem(lastItem); + lastItem = item; + } + } + + if (target->primary == "PROGRAMS") + { + run_arguments_edit->setText(DomUtil::readEntry(*m_widget->m_part->projectDom(), "/kdevautoproject/run/runarguments/" + target->name)); + if( DomUtil::readEntry(*m_widget->m_part->projectDom(), "/kdevautoproject/run/cwd/" + target->name).isEmpty() ) + { + m_cwdEdit->setURL( m_widget->m_part->buildDirectory()+"/"+URLUtil::getRelativePath(m_widget->m_part->topsourceDirectory(), m_widget->m_part->projectDirectory())+"/"+m_widget->activeDirectory() ); + m_cwdEdit->fileDialog()->setURL( KURL::fromPathOrURL( m_widget->m_part->buildDirectory()+"/"+URLUtil::getRelativePath(m_widget->m_part->topsourceDirectory(), m_widget->m_part->projectDirectory())+"/"+m_widget->activeDirectory() ) ); + }else + { + m_cwdEdit->setURL( DomUtil::readEntry(*m_widget->m_part->projectDom(), "/kdevautoproject/run/cwd/" + target->name) ); + m_cwdEdit->fileDialog()->setURL( KURL::fromPathOrURL( DomUtil::readEntry(*m_widget->m_part->projectDom(), "/kdevautoproject/run/cwd/" + target->name) ) ); + } + debug_arguments_edit->setText(DomUtil::readEntry(*m_widget->m_part->projectDom(), "/kdevautoproject/run/debugarguments/" + target->name)); + } +} + + +void TargetOptionsDialog::storeConfig() +{ + QStringList flagslist; + if (allstatic_box->isChecked()) + flagslist.append("-all-static"); + if (avoidversion_box->isChecked()) + flagslist.append("-avoid-version"); + if (module_box->isChecked()) + flagslist.append("-module"); + if (noundefined_box->isChecked()) + flagslist.append("-no-undefined"); + flagslist.append(ldflagsother_edit->text()); + QString new_ldflags = flagslist.join(" "); + + QStringList liblist; + QCheckListItem *clitem = static_cast(insidelib_listview->firstChild()); + while (clitem) { + if( clitem->isOn() ) + liblist.append("$(top_builddir)/" + clitem->text()); + clitem = static_cast(clitem->nextSibling()); + } + clitem = static_cast(outsidelib_listview->firstChild()); + while (clitem) { + liblist.append(clitem->text()); + clitem = static_cast(clitem->nextSibling()); + } + QString new_addstr = liblist.join(" "); + + QString canonname = AutoProjectTool::canonicalize(target->name); + QMap replaceMap; + + if (target->primary == "PROGRAMS") { + QString old_ldadd = target->ldadd; + if (new_addstr != old_ldadd) { + target->ldadd = new_addstr; + replaceMap.insert(canonname + "_LDADD", new_addstr); + } + } + + if (target->primary == "LIBRARIES" || target->primary == "LTLIBRARIES") { + QString old_libadd = target->libadd; + if (new_addstr != old_libadd) { + target->libadd = new_addstr; + replaceMap.insert(canonname + "_LIBADD", new_addstr); + } + } + + QString old_ldflags = target->ldflags; + if (new_ldflags != old_ldflags) { + target->ldflags = new_ldflags; + replaceMap.insert(canonname + "_LDFLAGS", new_ldflags); + } + + QString new_dependencies = dependencies_edit->text(); + QString old_dependencies = target->dependencies; + if (new_dependencies != old_dependencies) { + target->dependencies = new_dependencies; + if (!new_dependencies.isEmpty()) + replaceMap.insert(canonname + "_DEPENDENCIES", new_dependencies); + } + + // We can safely assume that this target is in the active sub project + AutoProjectTool::setMakefileam(m_widget->subprojectDirectory() + "/Makefile.am", replaceMap); + + if (target->primary == "PROGRAMS") + { + DomUtil::writeEntry(*m_widget->m_part->projectDom(), "/kdevautoproject/run/runarguments/" + target->name, run_arguments_edit->text()); + DomUtil::writeEntry(*m_widget->m_part->projectDom(), "/kdevautoproject/run/debugarguments/" + target->name, debug_arguments_edit->text()); + DomUtil::writeEntry(*m_widget->m_part->projectDom(), "/kdevautoproject/run/cwd/" + target->name, m_cwdEdit->url()); + } +} + + +void TargetOptionsDialog::insideMoveUpClicked() +{ + if (!insidelib_listview->currentItem()) + return; + if (insidelib_listview->currentItem() == insidelib_listview->firstChild()) { + KNotifyClient::beep(); + return; + } + + QListViewItem *item = insidelib_listview->firstChild(); + while (item->nextSibling() != insidelib_listview->currentItem()) + item = item->nextSibling(); + item->moveItem(insidelib_listview->currentItem()); +} + + +void TargetOptionsDialog::insideMoveDownClicked() +{ + if (!insidelib_listview->currentItem()) + return; + + if (insidelib_listview->currentItem()->nextSibling() == 0) { + KNotifyClient::beep(); + return; + } + + insidelib_listview->currentItem()->moveItem(insidelib_listview->currentItem()->nextSibling()); +} + + +void TargetOptionsDialog::outsideMoveUpClicked() +{ + if (!outsidelib_listview->currentItem()) + return; + if (outsidelib_listview->currentItem() == outsidelib_listview->firstChild()) { + KNotifyClient::beep(); + return; + } + + QListViewItem *item = outsidelib_listview->firstChild(); + while (item->nextSibling() != outsidelib_listview->currentItem()) + item = item->nextSibling(); + item->moveItem(outsidelib_listview->currentItem()); +} + + +void TargetOptionsDialog::outsideMoveDownClicked() +{ + if (!outsidelib_listview->currentItem()) + return; + if (outsidelib_listview->currentItem()->nextSibling() == 0) { + KNotifyClient::beep(); + return; + } + + outsidelib_listview->currentItem()->moveItem(outsidelib_listview->currentItem()->nextSibling()); +} + + +void TargetOptionsDialog::outsideAddClicked() +{ + KURLRequesterDlg dialog( "", i18n( "Add Library: Choose the .a/.so file, give -l or use a variable with $(FOOBAR)" ), 0, 0 ); + dialog.urlRequester() ->setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ); + dialog.urlRequester() ->setFilter( "*.so|"+i18n("Shared Library (*.so)")+"\n*.a|"+i18n("Static Library (*.a)") ); + dialog.urlRequester() ->setURL( QString::null ); + dialog.urlRequester() ->completionObject() ->setDir( m_widget->selectedSubproject()->path ); + dialog.urlRequester() ->fileDialog() ->setURL( KURL::fromPathOrURL( m_widget->selectedSubproject()->path ) ); + if ( dialog.exec() != QDialog::Accepted ) + return ; + QString file = dialog.urlRequester() ->url(); + if ( !file.isEmpty() ) + { + if ( !file.isEmpty() ) + { + if( file.startsWith("-l") ) + new QListViewItem( outsidelib_listview, file ); + else + { + QFileInfo fi(file); + if( !fi.exists() ) + new QListViewItem( outsidelib_listview, file ); + if( fi.extension(false) == "a" ) + { + new QListViewItem( outsidelib_listview, file ); + }else if ( fi.extension(false) == "so" ) + { + QString name = fi.fileName(); + if( name.startsWith( "lib" ) ) + name = name.mid(3); + name = "-l"+name.left( name.length() - 3 ); + new QListViewItem( outsidelib_listview, name ); + } + } + } + } +} + + +void TargetOptionsDialog::outsideEditClicked() +{ + if ( (outsidelib_listview->childCount()==0) || (outsidelib_listview->currentItem() == 0) ) + return; + bool ok; + QString dir = KInputDialog::getText(i18n("Edit External Library"), i18n("Edit external library:"), + outsidelib_listview->currentItem()-> text(0), &ok, 0); + if (ok && !dir.isEmpty()) + outsidelib_listview->currentItem()-> setText(0, dir); +} + + +void TargetOptionsDialog::outsideRemoveClicked() +{ + delete outsidelib_listview->currentItem(); +} + + +void TargetOptionsDialog::accept() +{ + storeConfig(); + QDialog::accept(); +} + +#include "targetoptionsdlg.moc" +// kate: indent-mode csands; space-indent on; indent-width 4; replace-tabs on; diff --git a/buildtools/autotools/targetoptionsdlg.h b/buildtools/autotools/targetoptionsdlg.h new file mode 100644 index 00000000..c1dea20a --- /dev/null +++ b/buildtools/autotools/targetoptionsdlg.h @@ -0,0 +1,49 @@ +/*************************************************************************** +* Copyright (C) 2001 by Bernd Gehrmann * +* bernd@kdevelop.org * +* * +* 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. * +* * +***************************************************************************/ + +#ifndef _TARGETOPTIONSDLG_ +#define _TARGETOPTIONSDLG_ + +#include "targetoptionsdlgbase.h" + +class AutoProjectWidget; +class TargetItem; + + +class TargetOptionsDialog : public TargetOptionsDialogBase +{ + Q_OBJECT + +public: + TargetOptionsDialog( AutoProjectWidget *widget, TargetItem *item, + QWidget *parent = 0, const char *name = 0 ); + ~TargetOptionsDialog(); + +private: + virtual void insideMoveUpClicked(); + virtual void insideMoveDownClicked(); + virtual void outsideMoveUpClicked(); + virtual void outsideMoveDownClicked(); + virtual void outsideAddClicked(); + virtual void outsideEditClicked(); + virtual void outsideRemoveClicked(); + virtual void accept(); + + void readConfig(); + void storeConfig(); + + TargetItem *target; + AutoProjectWidget *m_widget; +}; + +#endif +// kate: indent-mode csands; tab-width 4; + diff --git a/buildtools/autotools/targetoptionsdlgbase.ui b/buildtools/autotools/targetoptionsdlgbase.ui new file mode 100644 index 00000000..07487ac2 --- /dev/null +++ b/buildtools/autotools/targetoptionsdlgbase.ui @@ -0,0 +1,726 @@ + +TargetOptionsDialogBase + + + target_options_dialog + + + + 0 + 0 + 627 + 474 + + + + Target Options + + + false + + + + unnamed + + + + tabWidget + + + + Widget5 + + + Fl&ags + + + + unnamed + + + + TextLabel1 + + + + + + + Li&nker flags (LDFLAGS): + + + allstatic_box + + + + + Layout12 + + + + unnamed + + + 0 + + + + allstatic_box + + + &Do not link against shared libraries (-all-static) + + + + + avoidversion_box + + + Do not &assign version numbers to libraries (-avoid-version) + + + + + module_box + + + Create a library that can &be dynamically loaded (-module) + + + + + noundefined_box + + + Library does not depend on external symbols (-no-&undefined) + + + + + Layout11 + + + + unnamed + + + 0 + + + + ldflagsother_label + + + + + + + O&ther: + + + ldflagsother_edit + + + + + ldflagsother_edit + + + + + + + + + Spacer1 + + + Vertical + + + Preferred + + + + 20 + 20 + + + + + + Spacer2 + + + Horizontal + + + Fixed + + + + 20 + 20 + + + + + + dependencies_edit + + + + + dependencies_label + + + + + + + E&xplicit dependencies (DEPENDENCIES): + + + dependencies_edit + + + + + Spacer3 + + + Horizontal + + + Fixed + + + + 20 + 20 + + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + Widget6 + + + Li&braries + + + + unnamed + + + + insidelib_label + + + + + + + Lin&k convenience libraries inside project (LIBADD): + + + insidelib_listview + + + + + Spacer9 + + + Vertical + + + Fixed + + + + 20 + 7 + + + + + + + + + + true + + + true + + + + outsidelib_listview + + + LastColumn + + + + + outsidelib_label + + + + + + + Link libraries ou&tside project (LIBADD): + + + outsidelib_listview + + + + + Layout9_3 + + + + unnamed + + + 0 + + + + Spacer5 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + insidemoveup_button + + + Move &Up + + + + + insidemovedown_button + + + Move &Down + + + + + Spacer6 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + + + true + + + true + + + + insidelib_listview + + + LastColumn + + + + + Layout10_4 + + + + unnamed + + + 0 + + + + Spacer7 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + outsideadd_button + + + &Add... + + + + + outsideedit_button + + + &Edit... + + + + + outsideremove_button + + + &Remove + + + + + outsidemoveup_button + + + Mo&ve Up + + + + + outsidemovedown_button + + + Move Dow&n + + + + + Spacer8 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + + + + arguments_page + + + Ar&guments + + + + unnamed + + + + argumentBox + + + Program Arguments (only valid for executable targets) + + + + unnamed + + + + run_arguments_edit + + + + + arguments_label_1 + + + + + + + &Run arguments: + + + run_arguments_edit + + + + + m_cwdEdit + + + + + textLabel1 + + + Working Directory: + + + + + arguments_label_2 + + + + + + + &Debug arguments: + + + run_arguments_edit + + + + + debug_arguments_edit + + + + + + + Spacer4_2 + + + Vertical + + + Expanding + + + + 20 + 120 + + + + + + + + + Layout1 + + + + unnamed + + + 0 + + + + Spacer10 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + okbutton + + + &OK + + + true + + + true + + + + + cancelbutton + + + &Cancel + + + true + + + + + + + + + + + okbutton + clicked() + target_options_dialog + accept() + + + cancelbutton + clicked() + target_options_dialog + reject() + + + insidemoveup_button + clicked() + target_options_dialog + insideMoveUpClicked() + + + outsidemoveup_button + clicked() + target_options_dialog + outsideMoveUpClicked() + + + outsidemovedown_button + clicked() + target_options_dialog + outsideMoveDownClicked() + + + outsideadd_button + clicked() + target_options_dialog + outsideAddClicked() + + + outsideedit_button + clicked() + target_options_dialog + outsideEditClicked() + + + outsideremove_button + clicked() + target_options_dialog + outsideRemoveClicked() + + + insidemovedown_button + clicked() + target_options_dialog + insideMoveDownClicked() + + + + allstatic_box + avoidversion_box + module_box + noundefined_box + ldflagsother_edit + dependencies_edit + tabWidget + insidelib_listview + insidemoveup_button + insidemovedown_button + outsidelib_listview + outsideadd_button + outsideedit_button + outsideremove_button + outsidemoveup_button + outsidemovedown_button + okbutton + cancelbutton + + + kdialog.h + + + insideMoveDownClicked() + insideMoveUpClicked() + outsideAddClicked() + outsideEditClicked() + outsideMoveDownClicked() + outsideMoveUpClicked() + outsideRemoveClicked() + + + + + klineedit.h + klineedit.h + klineedit.h + kurlrequester.h + klineedit.h + kpushbutton.h + klineedit.h + + -- cgit v1.2.1