summaryrefslogtreecommitdiffstats
path: root/kdpkg-install/install.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-04-03 22:53:41 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-04-03 22:53:41 +0000
commit01a3b7ad4464682c1d4319151ab7791f6f0a9dd8 (patch)
tree1e1d6d8845c1693a37ef59d9b1e64bcab7d17cf7 /kdpkg-install/install.cpp
parent36c0c6f7092be4adf056abf2a63e79dda7f02ede (diff)
downloadkdpkg-01a3b7ad4464682c1d4319151ab7791f6f0a9dd8.tar.gz
kdpkg-01a3b7ad4464682c1d4319151ab7791f6f0a9dd8.zip
Made program functional again
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdpkg@1110662 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdpkg-install/install.cpp')
-rw-r--r--kdpkg-install/install.cpp57
1 files changed, 47 insertions, 10 deletions
diff --git a/kdpkg-install/install.cpp b/kdpkg-install/install.cpp
index 2501da4..9904018 100644
--- a/kdpkg-install/install.cpp
+++ b/kdpkg-install/install.cpp
@@ -21,6 +21,7 @@
#include <kgenericfactory.h>
#include <klocale.h>
+#include <kfiledialog.h>
#include <kurlrequester.h>
#include <kaboutapplication.h>
@@ -37,13 +38,17 @@
#include <console.h>
#include <install.h>
+#include <string>
+#include <stdio.h>
+
+using namespace std;
+
install::install( const QString &url, QWidget *parent, const char *name, const QStringList &)
:InstallDialog(parent, name)
{
-
if( !url )
- path = QFileDialog::getOpenFileName( "", i18n("Debian Package (*.deb)"), this, i18n("open file dialog"), i18n("Choose a file to open") );
+ path = KFileDialog::getOpenFileName( QString::null, i18n("Debian Package (*.deb)"), this, i18n("Choose a Debian package file to open"));
else
path = url;
@@ -56,7 +61,28 @@ install::install( const QString &url, QWidget *parent, const char *name, const Q
installPushButton->hide();
nextPushButton1->hide();
+ // Get KDE prefix
+ // FIXME Is there a better way to do this???
+ string prefixcommand="kde-config --prefix";
+ FILE *pipe_prefix;
+ char prefix_result[2048];
+ int i;
+ if ((pipe_prefix = popen(prefixcommand.c_str(), "r")) == NULL)
+ {
+ m_kdePrefix = "/usr";
+ }
+ else {
+ fgets(prefix_result, 2048, pipe_prefix);
+ pclose(pipe_prefix);
+ for (i=0;i<2048;i++) {
+ if (prefix_result[i] == 0) {
+ prefix_result[i-1]=0;
+ i=2048;
+ }
+ }
+ m_kdePrefix = QString(prefix_result);
+ }
if( !checkArchitecture() )
page2x1();
@@ -116,7 +142,7 @@ void install::page1()
void install::page2x1()
{
- errorTextLabel->setText("<b>"+i18n("The architecture of the package and the system doesn't match! You will not be able to install this package!")+"</b>");
+ errorTextLabel->setText("<b>"+i18n("The architecture of this package does not match that of your system. You will not be able to install this package!")+"</b>");
nextPushButton2->hide();
widgetStack->raiseWidget(2);
@@ -133,10 +159,10 @@ void install::page2x2()
void install::page3()
{
- titleTextLabel->setText( "<b>"+i18n( "Resynchronization of the package index files.")+"</b>" );
+ titleTextLabel->setText( "<b>"+i18n( "Resynchronize Package Index")+"</b>" );
closePushButton->hide();
- QStrList run; run.append( "/usr/share/kdpkg/sh/kdpkg-sh" );
+ QStrList run; run.append( m_kdePrefix + "/share/kdpkg/sh/kdpkg-sh" );
run.append( "update" );
QWidget *consoleWidget = new console(this, run );
@@ -151,7 +177,7 @@ void install::page4()
{
installPushButton->hide();
closePushButton->hide();
- titleTextLabel->setText( "<b>"+i18n( "Installation of the new package." )+"</b>" );
+ titleTextLabel->setText( "<b>"+i18n( "Install New Package" )+"</b>" );
if( !installPkg )
@@ -159,7 +185,7 @@ void install::page4()
if( !removePkg )
removePkg = "none";
- QStrList run; run.append( "/usr/share/kdpkg/sh/kdpkg-sh" );
+ QStrList run; run.append( m_kdePrefix + "/share/kdpkg/sh/kdpkg-sh" );
run.append( "install" );
run.append( path );
run.append( installPkg );
@@ -181,6 +207,8 @@ void install::page4()
void install::showDependencies()
{
+ int start_index;
+ int stop_index;
// show packages which will be installed
@@ -214,7 +242,11 @@ void install::showDependencies()
}
}
-
+ while (missingDepends.find("(") != -1) {
+ start_index = missingDepends.find("(");
+ stop_index = missingDepends.find(")", start_index);
+ missingDepends.replace(start_index, stop_index-start_index+1, "");
+ }
this->shell->setCommand("apt-get -s install "+missingDepends);
this->shell->start(true);
QStringList installList = QStringList::split( "\n", this->shell->getBuffer().stripWhiteSpace() ).grep("Inst");
@@ -234,7 +266,7 @@ void install::showDependencies()
pkgVersion = QStringList::split( " ", installList[i] )[2].mid(1);
QListViewItem * item = new QListViewItem( dependenciesListView, 0 );
- item->setPixmap( 0, QPixmap( "/usr/share/kdpkg/icons/install.png") );
+ item->setPixmap( 0, QPixmap( m_kdePrefix + "/share/kdpkg/icons/install.png") );
item->setText( 1, name );
item->setText( 2, pkgVersion );
item->setText( 3, sysVersion );
@@ -288,6 +320,11 @@ void install::showDependencies()
QString conflicts = fields.grep( "Conflicts" )[0].mid(11);
conflicts = conflicts.replace( ",", "" );
conflicts = conflicts+" "+rconflicts;
+ while (conflicts.find("(") != -1) {
+ start_index = conflicts.find("(");
+ stop_index = conflicts.find(")", start_index);
+ conflicts.replace(start_index, stop_index-start_index+1, "");
+ }
this->shell->setCommand("apt-get -s remove "+conflicts);
this->shell->start(true);
@@ -300,7 +337,7 @@ void install::showDependencies()
QString sysVersion = QStringList::split( " [", removeList[i] )[1].replace("]", "");
QListViewItem * item = new QListViewItem( dependenciesListView, 0 );
- item->setPixmap( 0, QPixmap( "/usr/share/kdpkg/icons/remove.png") );
+ item->setPixmap( 0, QPixmap( m_kdePrefix + "/share/kdpkg/icons/remove.png") );
item->setText( 1, name );
item->setText( 3, sysVersion );