23 files changed, 544 insertions, 542 deletions
diff --git a/noncore/settings/packagemanager/entrydlg.cpp b/noncore/settings/packagemanager/entrydlg.cpp index 3b794b4..5d61342 100644 --- a/noncore/settings/packagemanager/entrydlg.cpp +++ b/noncore/settings/packagemanager/entrydlg.cpp | |||
@@ -1,107 +1,108 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2004 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "entrydlg.h" | 31 | #include "entrydlg.h" |
31 | 32 | ||
32 | #include <opie2/ofiledialog.h> | 33 | #include <opie2/ofiledialog.h> |
33 | 34 | ||
34 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
36 | 37 | ||
37 | #include <qlabel.h> | 38 | #include <qlabel.h> |
38 | #include <qlayout.h> | 39 | #include <qlayout.h> |
39 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
40 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
41 | 42 | ||
42 | EntryDlg::EntryDlg( const QString &label, QWidget* parent, const char* name, bool modal ) | 43 | EntryDlg::EntryDlg( const QString &label, QWidget* parent, const char* name, bool modal ) |
43 | : QDialog( parent, name, modal ) | 44 | : QDialog( parent, name, modal ) |
44 | { | 45 | { |
45 | QGridLayout *layout = new QGridLayout( this, 3, 2, 2, 4 ); | 46 | QGridLayout *layout = new QGridLayout( this, 3, 2, 2, 4 ); |
46 | 47 | ||
47 | QLabel *l = new QLabel( label, this ); | 48 | QLabel *l = new QLabel( label, this ); |
48 | l->setAlignment( AlignLeft | AlignTop | WordBreak ); | 49 | l->setAlignment( AlignLeft | AlignTop | WordBreak ); |
49 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); | 50 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); |
50 | 51 | ||
51 | m_entry = new QLineEdit( this ); | 52 | m_entry = new QLineEdit( this ); |
52 | layout->addWidget( m_entry, 1, 0 ); | 53 | layout->addWidget( m_entry, 1, 0 ); |
53 | connect( m_entry, SIGNAL(returnPressed()), this, SLOT(slotTryAccept()) ); | 54 | connect( m_entry, SIGNAL(returnPressed()), this, SLOT(slotTryAccept()) ); |
54 | 55 | ||
55 | QPixmap pic; | 56 | QPixmap pic; |
56 | pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 57 | pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
57 | QPushButton *btn = new QPushButton( pic, QString::null, this ); | 58 | QPushButton *btn = new QPushButton( pic, QString::null, this ); |
58 | btn->setMaximumWidth( btn->height() ); | 59 | btn->setMaximumWidth( btn->height() ); |
59 | connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) ); | 60 | connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) ); |
60 | layout->addWidget( btn, 1, 1 ); | 61 | layout->addWidget( btn, 1, 1 ); |
61 | 62 | ||
62 | layout->setRowStretch( 2, 10 ); | 63 | layout->setRowStretch( 2, 10 ); |
63 | 64 | ||
64 | resize( width(), l->height() + btn->height() + 8 ); | 65 | resize( width(), l->height() + btn->height() + 8 ); |
65 | } | 66 | } |
66 | 67 | ||
67 | void EntryDlg::setText( const QString &text ) | 68 | void EntryDlg::setText( const QString &text ) |
68 | { | 69 | { |
69 | m_entry->setText( text ); | 70 | m_entry->setText( text ); |
70 | m_entry->selectAll(); | 71 | m_entry->selectAll(); |
71 | } | 72 | } |
72 | 73 | ||
73 | QString EntryDlg::getText() | 74 | QString EntryDlg::getText() |
74 | { | 75 | { |
75 | return m_entry->text(); | 76 | return m_entry->text(); |
76 | } | 77 | } |
77 | 78 | ||
78 | QString EntryDlg::getText( const QString &caption, const QString &label, const QString &text, bool *ok, | 79 | QString EntryDlg::getText( const QString &caption, const QString &label, const QString &text, bool *ok, |
79 | QWidget *parent, const char *name ) | 80 | QWidget *parent, const char *name ) |
80 | { | 81 | { |
81 | EntryDlg *dlg = new EntryDlg( label, parent, name, true ); | 82 | EntryDlg *dlg = new EntryDlg( label, parent, name, true ); |
82 | dlg->setCaption( caption ); | 83 | dlg->setCaption( caption ); |
83 | dlg->setText( text ); | 84 | dlg->setText( text ); |
84 | 85 | ||
85 | QString result; | 86 | QString result; |
86 | 87 | ||
87 | *ok = ( QPEApplication::execDialog( dlg ) == QDialog::Accepted ); | 88 | *ok = ( QPEApplication::execDialog( dlg ) == QDialog::Accepted ); |
88 | if ( *ok ) | 89 | if ( *ok ) |
89 | result = dlg->getText(); | 90 | result = dlg->getText(); |
90 | 91 | ||
91 | delete dlg; | 92 | delete dlg; |
92 | return result; | 93 | return result; |
93 | } | 94 | } |
94 | void EntryDlg::slotTryAccept() | 95 | void EntryDlg::slotTryAccept() |
95 | { | 96 | { |
96 | if ( !m_entry->text().isEmpty() ) | 97 | if ( !m_entry->text().isEmpty() ) |
97 | accept(); | 98 | accept(); |
98 | } | 99 | } |
99 | 100 | ||
100 | void EntryDlg::slotSelectPath() | 101 | void EntryDlg::slotSelectPath() |
101 | { | 102 | { |
102 | QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_entry->text() ); | 103 | QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_entry->text() ); |
103 | if ( path.at( path.length() - 1 ) == '/' ) | 104 | if ( path.at( path.length() - 1 ) == '/' ) |
104 | path.truncate( path.length() - 1 ); | 105 | path.truncate( path.length() - 1 ); |
105 | if ( !path.isNull() ) | 106 | if ( !path.isNull() ) |
106 | m_entry->setText( path ); | 107 | m_entry->setText( path ); |
107 | } | 108 | } |
diff --git a/noncore/settings/packagemanager/entrydlg.h b/noncore/settings/packagemanager/entrydlg.h index 012589b..3f897ae 100644 --- a/noncore/settings/packagemanager/entrydlg.h +++ b/noncore/settings/packagemanager/entrydlg.h | |||
@@ -1,58 +1,59 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2004 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #ifndef ENTRYDLG_H | 31 | #ifndef ENTRYDLG_H |
31 | #define ENTRYDLG_H | 32 | #define ENTRYDLG_H |
32 | 33 | ||
33 | #include <qdialog.h> | 34 | #include <qdialog.h> |
34 | 35 | ||
35 | class QLineEdit; | 36 | class QLineEdit; |
36 | 37 | ||
37 | class EntryDlg : public QDialog | 38 | class EntryDlg : public QDialog |
38 | { | 39 | { |
39 | Q_OBJECT | 40 | Q_OBJECT |
40 | 41 | ||
41 | public: | 42 | public: |
42 | static QString getText( const QString &caption, const QString &label, const QString &text = QString::null, | 43 | static QString getText( const QString &caption, const QString &label, const QString &text = QString::null, |
43 | bool *ok = 0, QWidget *parent = 0, const char *name = 0 ); | 44 | bool *ok = 0, QWidget *parent = 0, const char *name = 0 ); |
44 | 45 | ||
45 | EntryDlg( const QString &label, QWidget* parent = 0, const char* name = 0, bool modal = true ); | 46 | EntryDlg( const QString &label, QWidget* parent = 0, const char* name = 0, bool modal = true ); |
46 | 47 | ||
47 | void setText( const QString &text ); | 48 | void setText( const QString &text ); |
48 | QString getText(); | 49 | QString getText(); |
49 | 50 | ||
50 | private slots: | 51 | private slots: |
51 | void slotTryAccept(); | 52 | void slotTryAccept(); |
52 | void slotSelectPath(); | 53 | void slotSelectPath(); |
53 | 54 | ||
54 | private: | 55 | private: |
55 | QLineEdit *m_entry; | 56 | QLineEdit *m_entry; |
56 | }; | 57 | }; |
57 | 58 | ||
58 | #endif // EntryDlg_H | 59 | #endif // EntryDlg_H |
diff --git a/noncore/settings/packagemanager/filterdlg.cpp b/noncore/settings/packagemanager/filterdlg.cpp index e69b6eb..4924972 100644 --- a/noncore/settings/packagemanager/filterdlg.cpp +++ b/noncore/settings/packagemanager/filterdlg.cpp | |||
@@ -1,194 +1,195 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "filterdlg.h" | 31 | #include "filterdlg.h" |
31 | 32 | ||
32 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
33 | 34 | ||
34 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, | 35 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, |
35 | const QString &server, const QString &destination, | 36 | const QString &server, const QString &destination, |
36 | OPackageManager::Status status, const QString &category ) | 37 | OPackageManager::Status status, const QString &category ) |
37 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) | 38 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) |
38 | { | 39 | { |
39 | setCaption( tr( "Filter packages" ) ); | 40 | setCaption( tr( "Filter packages" ) ); |
40 | 41 | ||
41 | QVBoxLayout *layout = new QVBoxLayout( this ); | 42 | QVBoxLayout *layout = new QVBoxLayout( this ); |
42 | QScrollView *sv = new QScrollView( this ); | 43 | QScrollView *sv = new QScrollView( this ); |
43 | layout->addWidget( sv, 0, 0 ); | 44 | layout->addWidget( sv, 0, 0 ); |
44 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 45 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
45 | sv->setFrameStyle( QFrame::NoFrame ); | 46 | sv->setFrameStyle( QFrame::NoFrame ); |
46 | QWidget *container = new QWidget( sv->viewport() ); | 47 | QWidget *container = new QWidget( sv->viewport() ); |
47 | sv->addChild( container ); | 48 | sv->addChild( container ); |
48 | layout = new QVBoxLayout( container, 4, 4 ); | 49 | layout = new QVBoxLayout( container, 4, 4 ); |
49 | 50 | ||
50 | // Category | 51 | // Category |
51 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); | 52 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); |
52 | QWhatsThis::add( m_categoryCB, tr( "Tap here to filter package list by application category." ) ); | 53 | QWhatsThis::add( m_categoryCB, tr( "Tap here to filter package list by application category." ) ); |
53 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); | 54 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); |
54 | m_category = new QComboBox( container ); | 55 | m_category = new QComboBox( container ); |
55 | QWhatsThis::add( m_category, tr( "Select the application category to filter by here." ) ); | 56 | QWhatsThis::add( m_category, tr( "Select the application category to filter by here." ) ); |
56 | m_category->insertStringList( pm->categories() ); | 57 | m_category->insertStringList( pm->categories() ); |
57 | initItem( m_category, m_categoryCB, category ); | 58 | initItem( m_category, m_categoryCB, category ); |
58 | layout->addWidget( m_categoryCB ); | 59 | layout->addWidget( m_categoryCB ); |
59 | layout->addWidget( m_category ); | 60 | layout->addWidget( m_category ); |
60 | 61 | ||
61 | // Package name | 62 | // Package name |
62 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); | 63 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); |
63 | QWhatsThis::add( m_nameCB, tr( "Tap here to filter package list by package name." ) ); | 64 | QWhatsThis::add( m_nameCB, tr( "Tap here to filter package list by package name." ) ); |
64 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); | 65 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); |
65 | m_name = new QLineEdit( name, container ); | 66 | m_name = new QLineEdit( name, container ); |
66 | QWhatsThis::add( m_name, tr( "Enter the package name to filter by here." ) ); | 67 | QWhatsThis::add( m_name, tr( "Enter the package name to filter by here." ) ); |
67 | if ( !name.isNull() ) | 68 | if ( !name.isNull() ) |
68 | m_nameCB->setChecked( true ); | 69 | m_nameCB->setChecked( true ); |
69 | m_name->setEnabled( !name.isNull() ); | 70 | m_name->setEnabled( !name.isNull() ); |
70 | layout->addWidget( m_nameCB ); | 71 | layout->addWidget( m_nameCB ); |
71 | layout->addWidget( m_name ); | 72 | layout->addWidget( m_name ); |
72 | 73 | ||
73 | // Status | 74 | // Status |
74 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); | 75 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); |
75 | QWhatsThis::add( m_statusCB, tr( "Tap here to filter package list by the package status." ) ); | 76 | QWhatsThis::add( m_statusCB, tr( "Tap here to filter package list by the package status." ) ); |
76 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); | 77 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); |
77 | m_status = new QComboBox( container ); | 78 | m_status = new QComboBox( container ); |
78 | QWhatsThis::add( m_status, tr( "Select the package status to filter by here." ) ); | 79 | QWhatsThis::add( m_status, tr( "Select the package status to filter by here." ) ); |
79 | connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) ); | 80 | connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) ); |
80 | QString currStatus; | 81 | QString currStatus; |
81 | switch ( status ) | 82 | switch ( status ) |
82 | { | 83 | { |
83 | case OPackageManager::All : currStatus = tr( "All" ); | 84 | case OPackageManager::All : currStatus = tr( "All" ); |
84 | break; | 85 | break; |
85 | case OPackageManager::Installed : currStatus = tr( "Installed" ); | 86 | case OPackageManager::Installed : currStatus = tr( "Installed" ); |
86 | break; | 87 | break; |
87 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); | 88 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); |
88 | break; | 89 | break; |
89 | case OPackageManager::Updated : currStatus = tr( "Updated" ); | 90 | case OPackageManager::Updated : currStatus = tr( "Updated" ); |
90 | break; | 91 | break; |
91 | default : currStatus = QString::null; | 92 | default : currStatus = QString::null; |
92 | }; | 93 | }; |
93 | m_status->insertItem( tr( "All" ) ); | 94 | m_status->insertItem( tr( "All" ) ); |
94 | m_status->insertItem( tr( "Installed" ) ); | 95 | m_status->insertItem( tr( "Installed" ) ); |
95 | m_status->insertItem( tr( "Not installed" ) ); | 96 | m_status->insertItem( tr( "Not installed" ) ); |
96 | m_status->insertItem( tr( "Updated" ) ); | 97 | m_status->insertItem( tr( "Updated" ) ); |
97 | initItem( m_status, m_statusCB, currStatus ); | 98 | initItem( m_status, m_statusCB, currStatus ); |
98 | layout->addWidget( m_statusCB ); | 99 | layout->addWidget( m_statusCB ); |
99 | layout->addWidget( m_status ); | 100 | layout->addWidget( m_status ); |
100 | 101 | ||
101 | // Server | 102 | // Server |
102 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); | 103 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); |
103 | QWhatsThis::add( m_serverCB, tr( "Tap here to filter package list by source server." ) ); | 104 | QWhatsThis::add( m_serverCB, tr( "Tap here to filter package list by source server." ) ); |
104 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); | 105 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); |
105 | m_server = new QComboBox( container ); | 106 | m_server = new QComboBox( container ); |
106 | QWhatsThis::add( m_server, tr( "Select the source server to filter by here." ) ); | 107 | QWhatsThis::add( m_server, tr( "Select the source server to filter by here." ) ); |
107 | m_server->insertStringList( pm->servers() ); | 108 | m_server->insertStringList( pm->servers() ); |
108 | initItem( m_server, m_serverCB, server ); | 109 | initItem( m_server, m_serverCB, server ); |
109 | layout->addWidget( m_serverCB ); | 110 | layout->addWidget( m_serverCB ); |
110 | layout->addWidget( m_server ); | 111 | layout->addWidget( m_server ); |
111 | 112 | ||
112 | // Destination | 113 | // Destination |
113 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); | 114 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); |
114 | QWhatsThis::add( m_destCB, tr( "Tap here to filter package list by destination where the package is installed to on this device." ) ); | 115 | QWhatsThis::add( m_destCB, tr( "Tap here to filter package list by destination where the package is installed to on this device." ) ); |
115 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); | 116 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); |
116 | m_destination = new QComboBox( container ); | 117 | m_destination = new QComboBox( container ); |
117 | QWhatsThis::add( m_destination, tr( "Select the destination location to filter by here." ) ); | 118 | QWhatsThis::add( m_destination, tr( "Select the destination location to filter by here." ) ); |
118 | m_destination->insertStringList( pm->destinations() ); | 119 | m_destination->insertStringList( pm->destinations() ); |
119 | initItem( m_destination, m_destCB, destination ); | 120 | initItem( m_destination, m_destCB, destination ); |
120 | layout->addWidget( m_destCB ); | 121 | layout->addWidget( m_destCB ); |
121 | layout->addWidget( m_destination ); | 122 | layout->addWidget( m_destination ); |
122 | } | 123 | } |
123 | 124 | ||
124 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) | 125 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) |
125 | { | 126 | { |
126 | if ( !selection.isNull() ) | 127 | if ( !selection.isNull() ) |
127 | { | 128 | { |
128 | checkBox->setChecked( true ); | 129 | checkBox->setChecked( true ); |
129 | 130 | ||
130 | for ( int i = 0; i < comboBox->count(); i++ ) | 131 | for ( int i = 0; i < comboBox->count(); i++ ) |
131 | { | 132 | { |
132 | if ( comboBox->text( i ) == selection ) | 133 | if ( comboBox->text( i ) == selection ) |
133 | { | 134 | { |
134 | comboBox->setCurrentItem( i ); | 135 | comboBox->setCurrentItem( i ); |
135 | return; | 136 | return; |
136 | } | 137 | } |
137 | } | 138 | } |
138 | } | 139 | } |
139 | comboBox->setEnabled( !selection.isNull() ); | 140 | comboBox->setEnabled( !selection.isNull() ); |
140 | } | 141 | } |
141 | 142 | ||
142 | void FilterDlg::slotNameSelected( bool selected ) | 143 | void FilterDlg::slotNameSelected( bool selected ) |
143 | { | 144 | { |
144 | m_name->setEnabled( selected ); | 145 | m_name->setEnabled( selected ); |
145 | m_name->setFocus(); | 146 | m_name->setFocus(); |
146 | } | 147 | } |
147 | 148 | ||
148 | void FilterDlg::slotServerSelected( bool selected ) | 149 | void FilterDlg::slotServerSelected( bool selected ) |
149 | { | 150 | { |
150 | m_server->setEnabled( selected ); | 151 | m_server->setEnabled( selected ); |
151 | m_server->setFocus(); | 152 | m_server->setFocus(); |
152 | } | 153 | } |
153 | 154 | ||
154 | void FilterDlg::slotDestSelected( bool selected ) | 155 | void FilterDlg::slotDestSelected( bool selected ) |
155 | { | 156 | { |
156 | m_destination->setEnabled( selected ); | 157 | m_destination->setEnabled( selected ); |
157 | m_destination->setFocus(); | 158 | m_destination->setFocus(); |
158 | } | 159 | } |
159 | 160 | ||
160 | void FilterDlg::slotStatusSelected( bool selected ) | 161 | void FilterDlg::slotStatusSelected( bool selected ) |
161 | { | 162 | { |
162 | m_status->setEnabled( selected ); | 163 | m_status->setEnabled( selected ); |
163 | m_status->setFocus(); | 164 | m_status->setFocus(); |
164 | 165 | ||
165 | if ( !selected && !m_destCB->isEnabled() ) | 166 | if ( !selected && !m_destCB->isEnabled() ) |
166 | { | 167 | { |
167 | // If status check box has been deselected and destination option was previously deselected | 168 | // If status check box has been deselected and destination option was previously deselected |
168 | // (because status == "Not installed"), re-enable destination option | 169 | // (because status == "Not installed"), re-enable destination option |
169 | m_destCB->setEnabled( true ); | 170 | m_destCB->setEnabled( true ); |
170 | m_destination->setEnabled( true ); | 171 | m_destination->setEnabled( true ); |
171 | } | 172 | } |
172 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) | 173 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) |
173 | { | 174 | { |
174 | // If status check box has been selected and status == "Not installed", disable destination option | 175 | // If status check box has been selected and status == "Not installed", disable destination option |
175 | m_destCB->setEnabled( false ); | 176 | m_destCB->setEnabled( false ); |
176 | m_destCB->setChecked( false ); | 177 | m_destCB->setChecked( false ); |
177 | m_destination->setEnabled( false ); | 178 | m_destination->setEnabled( false ); |
178 | } | 179 | } |
179 | } | 180 | } |
180 | 181 | ||
181 | void FilterDlg::slotStatusChanged( const QString &category ) | 182 | void FilterDlg::slotStatusChanged( const QString &category ) |
182 | { | 183 | { |
183 | bool notInstalled = ( category == tr( "Not installed" ) ); | 184 | bool notInstalled = ( category == tr( "Not installed" ) ); |
184 | m_destCB->setEnabled( !notInstalled ); | 185 | m_destCB->setEnabled( !notInstalled ); |
185 | m_destination->setEnabled( !notInstalled ); | 186 | m_destination->setEnabled( !notInstalled ); |
186 | if ( notInstalled ) | 187 | if ( notInstalled ) |
187 | m_destCB->setChecked( false ); | 188 | m_destCB->setChecked( false ); |
188 | } | 189 | } |
189 | 190 | ||
190 | void FilterDlg::slotCategorySelected( bool selected ) | 191 | void FilterDlg::slotCategorySelected( bool selected ) |
191 | { | 192 | { |
192 | m_category->setEnabled( selected ); | 193 | m_category->setEnabled( selected ); |
193 | m_category->setFocus(); | 194 | m_category->setFocus(); |
194 | } | 195 | } |
diff --git a/noncore/settings/packagemanager/filterdlg.h b/noncore/settings/packagemanager/filterdlg.h index bd89b42..6f39464 100644 --- a/noncore/settings/packagemanager/filterdlg.h +++ b/noncore/settings/packagemanager/filterdlg.h | |||
@@ -1,101 +1,102 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #ifndef FILTERDLG_H | 31 | #ifndef FILTERDLG_H |
31 | #define FILTERDLG_H | 32 | #define FILTERDLG_H |
32 | 33 | ||
33 | #include "opackagemanager.h" | 34 | #include "opackagemanager.h" |
34 | 35 | ||
35 | #include <qcheckbox.h> | 36 | #include <qcheckbox.h> |
36 | #include <qdialog.h> | 37 | #include <qdialog.h> |
37 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
38 | #include <qlayout.h> | 39 | #include <qlayout.h> |
39 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
40 | #include <qscrollview.h> | 41 | #include <qscrollview.h> |
41 | 42 | ||
42 | class FilterDlg : public QDialog | 43 | class FilterDlg : public QDialog |
43 | { | 44 | { |
44 | Q_OBJECT | 45 | Q_OBJECT |
45 | 46 | ||
46 | public: | 47 | public: |
47 | FilterDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &name = 0x0, | 48 | FilterDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &name = 0x0, |
48 | const QString &server = 0x0, const QString &destination = 0x0, | 49 | const QString &server = 0x0, const QString &destination = 0x0, |
49 | OPackageManager::Status status = OPackageManager::All, | 50 | OPackageManager::Status status = OPackageManager::All, |
50 | const QString &category = 0x0 ); | 51 | const QString &category = 0x0 ); |
51 | 52 | ||
52 | QString name() | 53 | QString name() |
53 | { return m_nameCB->isChecked() ? m_name->text() : QString::null; }; | 54 | { return m_nameCB->isChecked() ? m_name->text() : QString::null; }; |
54 | QString server() | 55 | QString server() |
55 | { return m_serverCB->isChecked() ? m_server->currentText() : QString::null; }; | 56 | { return m_serverCB->isChecked() ? m_server->currentText() : QString::null; }; |
56 | QString destination() | 57 | QString destination() |
57 | { return m_destCB->isChecked() ? m_destination->currentText() : QString::null; }; | 58 | { return m_destCB->isChecked() ? m_destination->currentText() : QString::null; }; |
58 | OPackageManager::Status status() | 59 | OPackageManager::Status status() |
59 | { | 60 | { |
60 | if ( m_statusCB->isChecked() ) | 61 | if ( m_statusCB->isChecked() ) |
61 | { | 62 | { |
62 | if ( m_status->currentText() == tr( "All" ) ) | 63 | if ( m_status->currentText() == tr( "All" ) ) |
63 | return OPackageManager::All; | 64 | return OPackageManager::All; |
64 | else if ( m_status->currentText() == tr( "Installed" ) ) | 65 | else if ( m_status->currentText() == tr( "Installed" ) ) |
65 | return OPackageManager::Installed; | 66 | return OPackageManager::Installed; |
66 | else if ( m_status->currentText() == tr( "Not installed" ) ) | 67 | else if ( m_status->currentText() == tr( "Not installed" ) ) |
67 | return OPackageManager::NotInstalled; | 68 | return OPackageManager::NotInstalled; |
68 | else if ( m_status->currentText() == tr( "Updated" ) ) | 69 | else if ( m_status->currentText() == tr( "Updated" ) ) |
69 | return OPackageManager::Updated; | 70 | return OPackageManager::Updated; |
70 | } | 71 | } |
71 | 72 | ||
72 | return OPackageManager::NotDefined; | 73 | return OPackageManager::NotDefined; |
73 | }; | 74 | }; |
74 | QString category() | 75 | QString category() |
75 | { return m_categoryCB->isChecked() ? m_category->currentText() : QString::null; }; | 76 | { return m_categoryCB->isChecked() ? m_category->currentText() : QString::null; }; |
76 | 77 | ||
77 | private: | 78 | private: |
78 | QCheckBox *m_nameCB; | 79 | QCheckBox *m_nameCB; |
79 | QCheckBox *m_serverCB; | 80 | QCheckBox *m_serverCB; |
80 | QCheckBox *m_destCB; | 81 | QCheckBox *m_destCB; |
81 | QCheckBox *m_statusCB; | 82 | QCheckBox *m_statusCB; |
82 | QCheckBox *m_categoryCB; | 83 | QCheckBox *m_categoryCB; |
83 | 84 | ||
84 | QLineEdit *m_name; | 85 | QLineEdit *m_name; |
85 | QComboBox *m_server; | 86 | QComboBox *m_server; |
86 | QComboBox *m_destination; | 87 | QComboBox *m_destination; |
87 | QComboBox *m_status; | 88 | QComboBox *m_status; |
88 | QComboBox *m_category; | 89 | QComboBox *m_category; |
89 | 90 | ||
90 | void initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ); | 91 | void initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ); |
91 | 92 | ||
92 | private slots: | 93 | private slots: |
93 | void slotNameSelected( bool ); | 94 | void slotNameSelected( bool ); |
94 | void slotServerSelected( bool ); | 95 | void slotServerSelected( bool ); |
95 | void slotDestSelected( bool ); | 96 | void slotDestSelected( bool ); |
96 | void slotStatusSelected( bool ); | 97 | void slotStatusSelected( bool ); |
97 | void slotStatusChanged( const QString & ); | 98 | void slotStatusChanged( const QString & ); |
98 | void slotCategorySelected( bool ); | 99 | void slotCategorySelected( bool ); |
99 | }; | 100 | }; |
100 | 101 | ||
101 | #endif | 102 | #endif |
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 8aed10d..205d7ed 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp | |||
@@ -1,323 +1,324 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "installdlg.h" | 31 | #include "installdlg.h" |
31 | 32 | ||
32 | #include <opie2/ofiledialog.h> | 33 | #include <opie2/ofiledialog.h> |
33 | 34 | ||
34 | #include <qpe/fileselector.h> | 35 | #include <qpe/fileselector.h> |
35 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
36 | #include <qpe/storage.h> | 37 | #include <qpe/storage.h> |
37 | 38 | ||
38 | #include <qapplication.h> | 39 | #include <qapplication.h> |
39 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
40 | #include <qfileinfo.h> | 41 | #include <qfileinfo.h> |
41 | #include <qgroupbox.h> | 42 | #include <qgroupbox.h> |
42 | #include <qlabel.h> | 43 | #include <qlabel.h> |
43 | #include <qlayout.h> | 44 | #include <qlayout.h> |
44 | #include <qmap.h> | 45 | #include <qmap.h> |
45 | #include <qmultilineedit.h> | 46 | #include <qmultilineedit.h> |
46 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
47 | 48 | ||
48 | #include <sys/vfs.h> | 49 | #include <sys/vfs.h> |
49 | 50 | ||
50 | #include "opackagemanager.h" | 51 | #include "opackagemanager.h" |
51 | 52 | ||
52 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, | 53 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, |
53 | OPackage::Command command1, const QStringList &packages1, | 54 | OPackage::Command command1, const QStringList &packages1, |
54 | OPackage::Command command2, const QStringList &packages2, | 55 | OPackage::Command command2, const QStringList &packages2, |
55 | OPackage::Command command3, const QStringList &packages3 ) | 56 | OPackage::Command command3, const QStringList &packages3 ) |
56 | : QWidget( 0l ) | 57 | : QWidget( 0l ) |
57 | , m_packman( pm ) | 58 | , m_packman( pm ) |
58 | , m_installFound( false ) | 59 | , m_installFound( false ) |
59 | , m_numCommands( 0 ) | 60 | , m_numCommands( 0 ) |
60 | , m_currCommand( 0 ) | 61 | , m_currCommand( 0 ) |
61 | , m_destItem( 0l ) | 62 | , m_destItem( 0l ) |
62 | { | 63 | { |
63 | // Save command/package list information | 64 | // Save command/package list information |
64 | if ( command1 != OPackage::NotDefined ) | 65 | if ( command1 != OPackage::NotDefined ) |
65 | { | 66 | { |
66 | m_command[ m_numCommands ] = command1; | 67 | m_command[ m_numCommands ] = command1; |
67 | m_packages[ m_numCommands ] = packages1; | 68 | m_packages[ m_numCommands ] = packages1; |
68 | ++m_numCommands; | 69 | ++m_numCommands; |
69 | 70 | ||
70 | if ( command1 == OPackage::Install ) | 71 | if ( command1 == OPackage::Install ) |
71 | m_installFound = true; | 72 | m_installFound = true; |
72 | } | 73 | } |
73 | if ( command2 != OPackage::NotDefined ) | 74 | if ( command2 != OPackage::NotDefined ) |
74 | { | 75 | { |
75 | m_command[ m_numCommands ] = command2; | 76 | m_command[ m_numCommands ] = command2; |
76 | m_packages[ m_numCommands ] = packages2; | 77 | m_packages[ m_numCommands ] = packages2; |
77 | ++m_numCommands; | 78 | ++m_numCommands; |
78 | 79 | ||
79 | if ( command2 == OPackage::Install ) | 80 | if ( command2 == OPackage::Install ) |
80 | m_installFound = true; | 81 | m_installFound = true; |
81 | } | 82 | } |
82 | if ( command3 != OPackage::NotDefined ) | 83 | if ( command3 != OPackage::NotDefined ) |
83 | { | 84 | { |
84 | m_command[ m_numCommands ] = command3; | 85 | m_command[ m_numCommands ] = command3; |
85 | m_packages[ m_numCommands ] = packages3; | 86 | m_packages[ m_numCommands ] = packages3; |
86 | ++m_numCommands; | 87 | ++m_numCommands; |
87 | 88 | ||
88 | if ( command3 == OPackage::Install ) | 89 | if ( command3 == OPackage::Install ) |
89 | m_installFound = true; | 90 | m_installFound = true; |
90 | } | 91 | } |
91 | 92 | ||
92 | // Initialize UI | 93 | // Initialize UI |
93 | if ( parent ) | 94 | if ( parent ) |
94 | parent->setCaption( caption ); | 95 | parent->setCaption( caption ); |
95 | 96 | ||
96 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); | 97 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); |
97 | 98 | ||
98 | if ( m_installFound ) | 99 | if ( m_installFound ) |
99 | { | 100 | { |
100 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 101 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
101 | layout->addWidget( label, 0, 0 ); | 102 | layout->addWidget( label, 0, 0 ); |
102 | m_destination = new QComboBox( this ); | 103 | m_destination = new QComboBox( this ); |
103 | m_destination->insertStringList( m_packman->destinations() ); | 104 | m_destination->insertStringList( m_packman->destinations() ); |
104 | layout->addWidget( m_destination, 0, 1 ); | 105 | layout->addWidget( m_destination, 0, 1 ); |
105 | connect( m_destination, SIGNAL(highlighted(const QString&)), | 106 | connect( m_destination, SIGNAL(highlighted(const QString&)), |
106 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); | 107 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); |
107 | 108 | ||
108 | label = new QLabel( tr( "Space Avail" ), this ); | 109 | label = new QLabel( tr( "Space Avail" ), this ); |
109 | layout->addWidget( label, 1, 0 ); | 110 | layout->addWidget( label, 1, 0 ); |
110 | m_availSpace = new QLabel( this ); | 111 | m_availSpace = new QLabel( this ); |
111 | layout->addWidget( m_availSpace, 1, 1 ); | 112 | layout->addWidget( m_availSpace, 1, 1 ); |
112 | 113 | ||
113 | // TODO - select correct destination | 114 | // TODO - select correct destination |
114 | slotDisplayAvailSpace( m_destination->currentText() ); | 115 | slotDisplayAvailSpace( m_destination->currentText() ); |
115 | } | 116 | } |
116 | else | 117 | else |
117 | { | 118 | { |
118 | m_destination = 0l; | 119 | m_destination = 0l; |
119 | m_availSpace = 0l; | 120 | m_availSpace = 0l; |
120 | } | 121 | } |
121 | 122 | ||
122 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 123 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
123 | groupBox->layout()->setSpacing( 0 ); | 124 | groupBox->layout()->setSpacing( 0 ); |
124 | groupBox->layout()->setMargin( 4 ); | 125 | groupBox->layout()->setMargin( 4 ); |
125 | 126 | ||
126 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); | 127 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); |
127 | m_output = new QMultiLineEdit( groupBox ); | 128 | m_output = new QMultiLineEdit( groupBox ); |
128 | m_output->setReadOnly( true ); | 129 | m_output->setReadOnly( true ); |
129 | groupBoxLayout->addWidget( m_output ); | 130 | groupBoxLayout->addWidget( m_output ); |
130 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); | 131 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); |
131 | 132 | ||
132 | QPixmap pic; | 133 | QPixmap pic; |
133 | pic.convertFromImage( Resource::loadImage( "packagemanager/apply" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 134 | pic.convertFromImage( Resource::loadImage( "packagemanager/apply" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
134 | m_btnStart = new QPushButton( pic, tr( "Start" ), this ); | 135 | m_btnStart = new QPushButton( pic, tr( "Start" ), this ); |
135 | m_btnStart->setMinimumHeight( AppLnk::smallIconSize() ); | 136 | m_btnStart->setMinimumHeight( AppLnk::smallIconSize() ); |
136 | layout->addWidget( m_btnStart, 3, 0 ); | 137 | layout->addWidget( m_btnStart, 3, 0 ); |
137 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); | 138 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); |
138 | 139 | ||
139 | pic.convertFromImage( Resource::loadImage( "SettingsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 140 | pic.convertFromImage( Resource::loadImage( "SettingsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
140 | m_btnOptions = new QPushButton( pic, tr( "Options" ), this ); | 141 | m_btnOptions = new QPushButton( pic, tr( "Options" ), this ); |
141 | m_btnOptions->setMinimumHeight( AppLnk::smallIconSize() ); | 142 | m_btnOptions->setMinimumHeight( AppLnk::smallIconSize() ); |
142 | layout->addWidget( m_btnOptions, 3, 1 ); | 143 | layout->addWidget( m_btnOptions, 3, 1 ); |
143 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); | 144 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); |
144 | 145 | ||
145 | // Display packages being acted upon in output widget | 146 | // Display packages being acted upon in output widget |
146 | for( int i = 0; i < m_numCommands; i++ ) | 147 | for( int i = 0; i < m_numCommands; i++ ) |
147 | { | 148 | { |
148 | if ( !m_packages[ i ].isEmpty() ) | 149 | if ( !m_packages[ i ].isEmpty() ) |
149 | { | 150 | { |
150 | QString lineStr = tr( "Packages to " ); | 151 | QString lineStr = tr( "Packages to " ); |
151 | 152 | ||
152 | switch( m_command[ i ] ) | 153 | switch( m_command[ i ] ) |
153 | { | 154 | { |
154 | case OPackage::Install : lineStr.append( tr( "install" ) ); | 155 | case OPackage::Install : lineStr.append( tr( "install" ) ); |
155 | break; | 156 | break; |
156 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); | 157 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); |
157 | break; | 158 | break; |
158 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); | 159 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); |
159 | break; | 160 | break; |
160 | case OPackage::Download : lineStr.append( tr( "download" ) ); | 161 | case OPackage::Download : lineStr.append( tr( "download" ) ); |
161 | break; | 162 | break; |
162 | default : | 163 | default : |
163 | break; | 164 | break; |
164 | }; | 165 | }; |
165 | lineStr.append( ":\n" ); | 166 | lineStr.append( ":\n" ); |
166 | 167 | ||
167 | QStringList tmpPackage = m_packages[ i ]; | 168 | QStringList tmpPackage = m_packages[ i ]; |
168 | for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it ) | 169 | for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it ) |
169 | { | 170 | { |
170 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); | 171 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); |
171 | } | 172 | } |
172 | 173 | ||
173 | m_output->append( lineStr ); | 174 | m_output->append( lineStr ); |
174 | } | 175 | } |
175 | } | 176 | } |
176 | 177 | ||
177 | m_output->append( tr( "Press the start button to begin.\n" ) ); | 178 | m_output->append( tr( "Press the start button to begin.\n" ) ); |
178 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 179 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
179 | 180 | ||
180 | } | 181 | } |
181 | 182 | ||
182 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | 183 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) |
183 | { | 184 | { |
184 | // If available space is not displayed, exit | 185 | // If available space is not displayed, exit |
185 | if ( !m_availSpace ) | 186 | if ( !m_availSpace ) |
186 | return; | 187 | return; |
187 | 188 | ||
188 | QString space = tr( "Unknown" ); | 189 | QString space = tr( "Unknown" ); |
189 | 190 | ||
190 | // Get destination | 191 | // Get destination |
191 | if ( !destination.isNull() ) | 192 | if ( !destination.isNull() ) |
192 | m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); | 193 | m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); |
193 | 194 | ||
194 | if ( m_destItem ) | 195 | if ( m_destItem ) |
195 | { | 196 | { |
196 | // Calculate available space | 197 | // Calculate available space |
197 | struct statfs fs; | 198 | struct statfs fs; |
198 | if ( !statfs( m_destItem->value(), &fs ) ) | 199 | if ( !statfs( m_destItem->value(), &fs ) ) |
199 | { | 200 | { |
200 | long mult = fs.f_bsize / 1024; | 201 | long mult = fs.f_bsize / 1024; |
201 | long div = 1024 / fs.f_bsize; | 202 | long div = 1024 / fs.f_bsize; |
202 | 203 | ||
203 | if ( !mult ) mult = 1; | 204 | if ( !mult ) mult = 1; |
204 | if ( !div ) div = 1; | 205 | if ( !div ) div = 1; |
205 | long avail = fs.f_bavail * mult / div; | 206 | long avail = fs.f_bavail * mult / div; |
206 | 207 | ||
207 | space = tr( "%1 Kb" ).arg( avail ); | 208 | space = tr( "%1 Kb" ).arg( avail ); |
208 | } | 209 | } |
209 | } | 210 | } |
210 | 211 | ||
211 | // Display available space | 212 | // Display available space |
212 | m_availSpace->setText( space ); | 213 | m_availSpace->setText( space ); |
213 | } | 214 | } |
214 | 215 | ||
215 | void InstallDlg::slotBtnStart() | 216 | void InstallDlg::slotBtnStart() |
216 | { | 217 | { |
217 | QString btnText = m_btnStart->text(); | 218 | QString btnText = m_btnStart->text(); |
218 | if ( btnText == tr( "Abort" ) ) | 219 | if ( btnText == tr( "Abort" ) ) |
219 | { | 220 | { |
220 | // Prevent unexecuted commands from executing | 221 | // Prevent unexecuted commands from executing |
221 | m_currCommand = 999; | 222 | m_currCommand = 999; |
222 | 223 | ||
223 | // Allow user to close dialog | 224 | // Allow user to close dialog |
224 | m_btnStart->setText( tr( "Close" ) ); | 225 | m_btnStart->setText( tr( "Close" ) ); |
225 | QPixmap pic; | 226 | QPixmap pic; |
226 | pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 227 | pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
227 | m_btnStart->setIconSet( pic ); | 228 | m_btnStart->setIconSet( pic ); |
228 | return; | 229 | return; |
229 | } | 230 | } |
230 | else if ( btnText == tr( "Close" ) ) | 231 | else if ( btnText == tr( "Close" ) ) |
231 | { | 232 | { |
232 | // TODO - force reload of package data | 233 | // TODO - force reload of package data |
233 | emit closeInstallDlg(); | 234 | emit closeInstallDlg(); |
234 | return; | 235 | return; |
235 | } | 236 | } |
236 | 237 | ||
237 | // Start was clicked, start executing | 238 | // Start was clicked, start executing |
238 | QString dest; | 239 | QString dest; |
239 | if ( m_installFound ) | 240 | if ( m_installFound ) |
240 | { | 241 | { |
241 | dest = m_destination->currentText(); | 242 | dest = m_destination->currentText(); |
242 | m_destination->setEnabled( false ); | 243 | m_destination->setEnabled( false ); |
243 | } | 244 | } |
244 | 245 | ||
245 | m_btnOptions->setEnabled( false ); | 246 | m_btnOptions->setEnabled( false ); |
246 | if ( m_numCommands > 1 ) | 247 | if ( m_numCommands > 1 ) |
247 | { | 248 | { |
248 | m_btnStart->setText( tr( "Abort" ) ); | 249 | m_btnStart->setText( tr( "Abort" ) ); |
249 | QPixmap pic; | 250 | QPixmap pic; |
250 | pic.convertFromImage( Resource::loadImage( "reset" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 251 | pic.convertFromImage( Resource::loadImage( "reset" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
251 | m_btnStart->setIconSet( pic ); | 252 | m_btnStart->setIconSet( pic ); |
252 | } | 253 | } |
253 | else | 254 | else |
254 | { | 255 | { |
255 | m_btnStart->setEnabled( false ); | 256 | m_btnStart->setEnabled( false ); |
256 | } | 257 | } |
257 | 258 | ||
258 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) | 259 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) |
259 | { | 260 | { |
260 | // Execute next command | 261 | // Execute next command |
261 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, | 262 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, |
262 | this, SLOT(slotOutput(const QString &)), true ); | 263 | this, SLOT(slotOutput(const QString &)), true ); |
263 | } | 264 | } |
264 | 265 | ||
265 | // All commands executed, allow user to close dialog | 266 | // All commands executed, allow user to close dialog |
266 | m_btnStart->setEnabled( true ); | 267 | m_btnStart->setEnabled( true ); |
267 | m_btnStart->setText( tr( "Close" ) ); | 268 | m_btnStart->setText( tr( "Close" ) ); |
268 | QPixmap pic; | 269 | QPixmap pic; |
269 | pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 270 | pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
270 | m_btnStart->setIconSet( pic ); | 271 | m_btnStart->setIconSet( pic ); |
271 | 272 | ||
272 | m_btnOptions->setEnabled( true ); | 273 | m_btnOptions->setEnabled( true ); |
273 | m_btnOptions->setText( tr( "Save output" ) ); | 274 | m_btnOptions->setText( tr( "Save output" ) ); |
274 | pic.convertFromImage( Resource::loadImage( "save" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 275 | pic.convertFromImage( Resource::loadImage( "save" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
275 | m_btnOptions->setIconSet( pic ); | 276 | m_btnOptions->setIconSet( pic ); |
276 | } | 277 | } |
277 | 278 | ||
278 | void InstallDlg::slotBtnOptions() | 279 | void InstallDlg::slotBtnOptions() |
279 | { | 280 | { |
280 | QString btnText = m_btnOptions->text(); | 281 | QString btnText = m_btnOptions->text(); |
281 | if ( btnText == tr( "Options" ) ) | 282 | if ( btnText == tr( "Options" ) ) |
282 | { | 283 | { |
283 | // Display configuration dialog (only options tab is enabled) | 284 | // Display configuration dialog (only options tab is enabled) |
284 | m_packman->configureDlg( true ); | 285 | m_packman->configureDlg( true ); |
285 | return; | 286 | return; |
286 | } | 287 | } |
287 | 288 | ||
288 | // Save output was clicked | 289 | // Save output was clicked |
289 | QMap<QString, QStringList> map; | 290 | QMap<QString, QStringList> map; |
290 | map.insert( tr( "All" ), QStringList() ); | 291 | map.insert( tr( "All" ), QStringList() ); |
291 | QStringList text; | 292 | QStringList text; |
292 | text << "text/*"; | 293 | text << "text/*"; |
293 | map.insert(tr( "Text" ), text ); | 294 | map.insert(tr( "Text" ), text ); |
294 | text << "*"; | 295 | text << "*"; |
295 | map.insert( tr( "All" ), text ); | 296 | map.insert( tr( "All" ), text ); |
296 | 297 | ||
297 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 298 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
298 | if( !filename.isEmpty() ) | 299 | if( !filename.isEmpty() ) |
299 | { | 300 | { |
300 | QString currentFileName = QFileInfo( filename ).fileName(); | 301 | QString currentFileName = QFileInfo( filename ).fileName(); |
301 | DocLnk doc; | 302 | DocLnk doc; |
302 | doc.setType( "text/plain" ); | 303 | doc.setType( "text/plain" ); |
303 | doc.setFile( filename ); | 304 | doc.setFile( filename ); |
304 | doc.setName( currentFileName ); | 305 | doc.setName( currentFileName ); |
305 | FileManager fm; | 306 | FileManager fm; |
306 | fm.saveFile( doc, m_output->text() ); | 307 | fm.saveFile( doc, m_output->text() ); |
307 | } | 308 | } |
308 | } | 309 | } |
309 | 310 | ||
310 | void InstallDlg::slotOutput( const QString &msg ) | 311 | void InstallDlg::slotOutput( const QString &msg ) |
311 | { | 312 | { |
312 | // Allow processing of other events | 313 | // Allow processing of other events |
313 | qApp->processEvents(); | 314 | qApp->processEvents(); |
314 | 315 | ||
315 | QString lineStr = msg; | 316 | QString lineStr = msg; |
316 | if ( lineStr[lineStr.length()-1] == '\n' ) | 317 | if ( lineStr[lineStr.length()-1] == '\n' ) |
317 | lineStr.truncate( lineStr.length() - 1 ); | 318 | lineStr.truncate( lineStr.length() - 1 ); |
318 | m_output->append( lineStr ); | 319 | m_output->append( lineStr ); |
319 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 320 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
320 | 321 | ||
321 | // Update available space | 322 | // Update available space |
322 | slotDisplayAvailSpace( QString::null ); | 323 | slotDisplayAvailSpace( QString::null ); |
323 | } | 324 | } |
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h index e633809..a41a38f 100644 --- a/noncore/settings/packagemanager/installdlg.h +++ b/noncore/settings/packagemanager/installdlg.h | |||
@@ -1,92 +1,93 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #ifndef INSTALLDLG_H | 31 | #ifndef INSTALLDLG_H |
31 | #define INSTALLDLG_H | 32 | #define INSTALLDLG_H |
32 | 33 | ||
33 | #include <qwidget.h> | 34 | #include <qwidget.h> |
34 | 35 | ||
35 | #include "opackage.h" | 36 | #include "opackage.h" |
36 | 37 | ||
37 | class QComboBox; | 38 | class QComboBox; |
38 | class QLabel; | 39 | class QLabel; |
39 | class QMultiLineEdit; | 40 | class QMultiLineEdit; |
40 | class QPushButton; | 41 | class QPushButton; |
41 | 42 | ||
42 | class OConfItem; | 43 | class OConfItem; |
43 | class OPackageManager; | 44 | class OPackageManager; |
44 | 45 | ||
45 | class InstallDlg : public QWidget | 46 | class InstallDlg : public QWidget |
46 | { | 47 | { |
47 | Q_OBJECT | 48 | Q_OBJECT |
48 | 49 | ||
49 | public: | 50 | public: |
50 | InstallDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, | 51 | InstallDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, |
51 | const QString &caption = QString::null, | 52 | const QString &caption = QString::null, |
52 | OPackage::Command command1 = OPackage::NotDefined, | 53 | OPackage::Command command1 = OPackage::NotDefined, |
53 | const QStringList &packages1 = QStringList(), | 54 | const QStringList &packages1 = QStringList(), |
54 | OPackage::Command command2 = OPackage::NotDefined, | 55 | OPackage::Command command2 = OPackage::NotDefined, |
55 | const QStringList &packages2 = QStringList(), | 56 | const QStringList &packages2 = QStringList(), |
56 | OPackage::Command command3 = OPackage::NotDefined, | 57 | OPackage::Command command3 = OPackage::NotDefined, |
57 | const QStringList &packages3 = QStringList() ); | 58 | const QStringList &packages3 = QStringList() ); |
58 | 59 | ||
59 | private: | 60 | private: |
60 | OPackageManager *m_packman; // Pointer to application instance of package manager | 61 | OPackageManager *m_packman; // Pointer to application instance of package manager |
61 | 62 | ||
62 | bool m_installFound; // Indicates if an install is being done, controls display of | 63 | bool m_installFound; // Indicates if an install is being done, controls display of |
63 | // destination selection, available space | 64 | // destination selection, available space |
64 | 65 | ||
65 | // UI controls | 66 | // UI controls |
66 | QComboBox *m_destination; // Destination selection list | 67 | QComboBox *m_destination; // Destination selection list |
67 | QLabel *m_availSpace; // Text label to display available space on selected destination | 68 | QLabel *m_availSpace; // Text label to display available space on selected destination |
68 | QMultiLineEdit *m_output; // Multi-line edit to display status | 69 | QMultiLineEdit *m_output; // Multi-line edit to display status |
69 | QPushButton *m_btnStart; // Start/abort/close button | 70 | QPushButton *m_btnStart; // Start/abort/close button |
70 | QPushButton *m_btnOptions; // Installation options button | 71 | QPushButton *m_btnOptions; // Installation options button |
71 | 72 | ||
72 | // Commands and packages to execute | 73 | // Commands and packages to execute |
73 | int m_numCommands; // Number of commands to be executed | 74 | int m_numCommands; // Number of commands to be executed |
74 | int m_currCommand; // Number of currently executing command | 75 | int m_currCommand; // Number of currently executing command |
75 | OPackage::Command m_command[3]; // List of commands to be executed | 76 | OPackage::Command m_command[3]; // List of commands to be executed |
76 | QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) | 77 | QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) |
77 | OConfItem *m_destItem; // Pointer to destination for package installation | 78 | OConfItem *m_destItem; // Pointer to destination for package installation |
78 | 79 | ||
79 | private slots: | 80 | private slots: |
80 | // UI control slots | 81 | // UI control slots |
81 | void slotDisplayAvailSpace( const QString &destination ); | 82 | void slotDisplayAvailSpace( const QString &destination ); |
82 | void slotBtnStart(); | 83 | void slotBtnStart(); |
83 | void slotBtnOptions(); | 84 | void slotBtnOptions(); |
84 | 85 | ||
85 | // Execution slots | 86 | // Execution slots |
86 | void slotOutput( const QString &msg ); | 87 | void slotOutput( const QString &msg ); |
87 | 88 | ||
88 | signals: | 89 | signals: |
89 | void closeInstallDlg(); | 90 | void closeInstallDlg(); |
90 | }; | 91 | }; |
91 | 92 | ||
92 | #endif | 93 | #endif |
diff --git a/noncore/settings/packagemanager/main.cpp b/noncore/settings/packagemanager/main.cpp index 3792881..5863662 100644 --- a/noncore/settings/packagemanager/main.cpp +++ b/noncore/settings/packagemanager/main.cpp | |||
@@ -1,34 +1,35 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "mainwindow.h" | 31 | #include "mainwindow.h" |
31 | 32 | ||
32 | #include <opie2/oapplicationfactory.h> | 33 | #include <opie2/oapplicationfactory.h> |
33 | 34 | ||
34 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MainWindow> ) | 35 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MainWindow> ) |
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 8a5b90c..0e40c01 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp | |||
@@ -1,762 +1,763 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "mainwindow.h" | 31 | #include "mainwindow.h" |
31 | #include "installdlg.h" | 32 | #include "installdlg.h" |
32 | #include "filterdlg.h" | 33 | #include "filterdlg.h" |
33 | #include "promptdlg.h" | 34 | #include "promptdlg.h" |
34 | #include "entrydlg.h" | 35 | #include "entrydlg.h" |
35 | #include "packageinfodlg.h" | 36 | #include "packageinfodlg.h" |
36 | 37 | ||
37 | #include <opie2/ofiledialog.h> | 38 | #include <opie2/ofiledialog.h> |
38 | 39 | ||
39 | #include <qpe/qcopenvelope_qws.h> | 40 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/qpeapplication.h> | 41 | #include <qpe/qpeapplication.h> |
41 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
42 | 43 | ||
43 | #include <qaction.h> | 44 | #include <qaction.h> |
44 | #include <qdir.h> | 45 | #include <qdir.h> |
45 | #include <qlayout.h> | 46 | #include <qlayout.h> |
46 | #include <qlineedit.h> | 47 | #include <qlineedit.h> |
47 | #include <qmenubar.h> | 48 | #include <qmenubar.h> |
48 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
49 | #include <qpopupmenu.h> | 50 | #include <qpopupmenu.h> |
50 | #include <qtimer.h> | 51 | #include <qtimer.h> |
51 | #include <qtoolbar.h> | 52 | #include <qtoolbar.h> |
52 | #include <qwhatsthis.h> | 53 | #include <qwhatsthis.h> |
53 | 54 | ||
54 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) | 55 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) |
55 | : QMainWindow( parent, name, WStyle_ContextHelp ) | 56 | : QMainWindow( parent, name, WStyle_ContextHelp ) |
56 | , m_config( "packman" ) | 57 | , m_config( "packman" ) |
57 | , m_packman( &m_config, this ) | 58 | , m_packman( &m_config, this ) |
58 | , m_menuBar( this ) | 59 | , m_menuBar( this ) |
59 | , m_toolBar( this ) | 60 | , m_toolBar( this ) |
60 | , m_findBar( this ) | 61 | , m_findBar( this ) |
61 | , m_widgetStack( this ) | 62 | , m_widgetStack( this ) |
62 | , m_packageList( this ) | 63 | , m_packageList( this ) |
63 | , m_statusWidget( this ) | 64 | , m_statusWidget( this ) |
64 | , m_statusText( &m_statusWidget ) | 65 | , m_statusText( &m_statusWidget ) |
65 | , m_statusBar( &m_statusWidget ) | 66 | , m_statusBar( &m_statusWidget ) |
66 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) | 67 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) |
67 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) | 68 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) |
68 | , m_iconNull( m_iconUpdated.size() ) | 69 | , m_iconNull( m_iconUpdated.size() ) |
69 | , m_filterName( QString::null ) | 70 | , m_filterName( QString::null ) |
70 | , m_filterServer( QString::null ) | 71 | , m_filterServer( QString::null ) |
71 | , m_filterDest( QString::null ) | 72 | , m_filterDest( QString::null ) |
72 | , m_filterStatus( OPackageManager::NotDefined ) | 73 | , m_filterStatus( OPackageManager::NotDefined ) |
73 | , m_filterCategory( QString::null ) | 74 | , m_filterCategory( QString::null ) |
74 | 75 | ||
75 | { | 76 | { |
76 | // setCaption( tr( "Package Manager" ) ); | 77 | // setCaption( tr( "Package Manager" ) ); |
77 | 78 | ||
78 | m_iconNull.fill( colorGroup().base() ); | 79 | m_iconNull.fill( colorGroup().base() ); |
79 | 80 | ||
80 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); | 81 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); |
81 | 82 | ||
82 | // Initialize widget stack, package list and status widget | 83 | // Initialize widget stack, package list and status widget |
83 | initStatusWidget(); | 84 | initStatusWidget(); |
84 | initPackageList(); | 85 | initPackageList(); |
85 | 86 | ||
86 | m_widgetStack.addWidget( &m_statusWidget, 2 ); | 87 | m_widgetStack.addWidget( &m_statusWidget, 2 ); |
87 | m_widgetStack.addWidget( &m_packageList, 1 ); | 88 | m_widgetStack.addWidget( &m_packageList, 1 ); |
88 | setCentralWidget( &m_widgetStack ); | 89 | setCentralWidget( &m_widgetStack ); |
89 | 90 | ||
90 | // Initialize remaining user interface items | 91 | // Initialize remaining user interface items |
91 | initUI(); | 92 | initUI(); |
92 | 93 | ||
93 | // Initialize package information | 94 | // Initialize package information |
94 | QTimer::singleShot( -1, this, SLOT( initPackageInfo() ) ); | 95 | QTimer::singleShot( -1, this, SLOT( initPackageInfo() ) ); |
95 | } | 96 | } |
96 | 97 | ||
97 | void MainWindow::closeEvent( QCloseEvent *event ) | 98 | void MainWindow::closeEvent( QCloseEvent *event ) |
98 | { | 99 | { |
99 | // Close app only if either the package or status widgets are currently active | 100 | // Close app only if either the package or status widgets are currently active |
100 | bool close = m_widgetStack.visibleWidget() == &m_packageList || | 101 | bool close = m_widgetStack.visibleWidget() == &m_packageList || |
101 | m_widgetStack.visibleWidget() == &m_statusWidget; | 102 | m_widgetStack.visibleWidget() == &m_statusWidget; |
102 | if ( close ) | 103 | if ( close ) |
103 | { | 104 | { |
104 | // TODO - write out application configuration settings | 105 | // TODO - write out application configuration settings |
105 | 106 | ||
106 | // Write out package manager configuration settings | 107 | // Write out package manager configuration settings |
107 | m_packman.saveSettings(); | 108 | m_packman.saveSettings(); |
108 | event->accept(); | 109 | event->accept(); |
109 | } | 110 | } |
110 | else | 111 | else |
111 | { | 112 | { |
112 | delete m_widgetStack.visibleWidget(); | 113 | delete m_widgetStack.visibleWidget(); |
113 | m_widgetStack.raiseWidget( &m_packageList ); | 114 | m_widgetStack.raiseWidget( &m_packageList ); |
114 | event->ignore(); | 115 | event->ignore(); |
115 | } | 116 | } |
116 | } | 117 | } |
117 | 118 | ||
118 | void MainWindow::initPackageList() | 119 | void MainWindow::initPackageList() |
119 | { | 120 | { |
120 | m_packageList.addColumn( tr( "Packages" ) ); | 121 | m_packageList.addColumn( tr( "Packages" ) ); |
121 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); | 122 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); |
122 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); | 123 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); |
123 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), | 124 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), |
124 | this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); | 125 | this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); |
125 | } | 126 | } |
126 | 127 | ||
127 | void MainWindow::initStatusWidget() | 128 | void MainWindow::initStatusWidget() |
128 | { | 129 | { |
129 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); | 130 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); |
130 | 131 | ||
131 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 132 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
132 | layout->addWidget( &m_statusText ); | 133 | layout->addWidget( &m_statusText ); |
133 | 134 | ||
134 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); | 135 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); |
135 | connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); | 136 | connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); |
136 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); | 137 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); |
137 | 138 | ||
138 | layout->addWidget( &m_statusBar ); | 139 | layout->addWidget( &m_statusBar ); |
139 | } | 140 | } |
140 | 141 | ||
141 | void MainWindow::initUI() | 142 | void MainWindow::initUI() |
142 | { | 143 | { |
143 | // Build menu and tool bars | 144 | // Build menu and tool bars |
144 | setToolBarsMovable( false ); | 145 | setToolBarsMovable( false ); |
145 | 146 | ||
146 | m_menuBar.setHorizontalStretchable( true ); | 147 | m_menuBar.setHorizontalStretchable( true ); |
147 | QMenuBar *mb = new QMenuBar( &m_menuBar ); | 148 | QMenuBar *mb = new QMenuBar( &m_menuBar ); |
148 | mb->setMargin( 0 ); | 149 | mb->setMargin( 0 ); |
149 | 150 | ||
150 | // Find toolbar | 151 | // Find toolbar |
151 | addToolBar( &m_findBar, QMainWindow::Top, true ); | 152 | addToolBar( &m_findBar, QMainWindow::Top, true ); |
152 | m_findBar.setHorizontalStretchable( true ); | 153 | m_findBar.setHorizontalStretchable( true ); |
153 | m_findEdit = new QLineEdit( &m_findBar ); | 154 | m_findEdit = new QLineEdit( &m_findBar ); |
154 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); | 155 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); |
155 | m_findBar.setStretchableWidget( m_findEdit ); | 156 | m_findBar.setStretchableWidget( m_findEdit ); |
156 | connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); | 157 | connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); |
157 | 158 | ||
158 | // Packages menu | 159 | // Packages menu |
159 | QPopupMenu *popup = new QPopupMenu( this ); | 160 | QPopupMenu *popup = new QPopupMenu( this ); |
160 | 161 | ||
161 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); | 162 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); |
162 | a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); | 163 | a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); |
163 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); | 164 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); |
164 | a->addTo( popup ); | 165 | a->addTo( popup ); |
165 | a->addTo( &m_toolBar ); | 166 | a->addTo( &m_toolBar ); |
166 | 167 | ||
167 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); | 168 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); |
168 | actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); | 169 | actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); |
169 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); | 170 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); |
170 | actionUpgrade->addTo( popup ); | 171 | actionUpgrade->addTo( popup ); |
171 | actionUpgrade->addTo( &m_toolBar ); | 172 | actionUpgrade->addTo( &m_toolBar ); |
172 | 173 | ||
173 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); | 174 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); |
174 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); | 175 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); |
175 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 176 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
176 | actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); | 177 | actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); |
177 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); | 178 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); |
178 | actionDownload->addTo( popup ); | 179 | actionDownload->addTo( popup ); |
179 | actionDownload->addTo( &m_toolBar ); | 180 | actionDownload->addTo( &m_toolBar ); |
180 | 181 | ||
181 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); | 182 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); |
182 | a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); | 183 | a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); |
183 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); | 184 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); |
184 | a->addTo( popup ); | 185 | a->addTo( popup ); |
185 | a->addTo( &m_toolBar ); | 186 | a->addTo( &m_toolBar ); |
186 | 187 | ||
187 | a = new QAction( tr( "Install local package" ), Resource::loadPixmap( "folder" ), QString::null, 0, this, 0 ); | 188 | a = new QAction( tr( "Install local package" ), Resource::loadPixmap( "folder" ), QString::null, 0, this, 0 ); |
188 | a->setWhatsThis( tr( "Tap here to install a package file located on device." ) ); | 189 | a->setWhatsThis( tr( "Tap here to install a package file located on device." ) ); |
189 | connect( a, SIGNAL(activated()), this, SLOT(slotInstallLocal()) ); | 190 | connect( a, SIGNAL(activated()), this, SLOT(slotInstallLocal()) ); |
190 | a->addTo( popup ); | 191 | a->addTo( popup ); |
191 | //a->addTo( &m_toolBar ); | 192 | //a->addTo( &m_toolBar ); |
192 | 193 | ||
193 | popup->insertSeparator(); | 194 | popup->insertSeparator(); |
194 | 195 | ||
195 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 196 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
196 | a->setWhatsThis( tr( "Tap here to configure this application." ) ); | 197 | a->setWhatsThis( tr( "Tap here to configure this application." ) ); |
197 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); | 198 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); |
198 | a->addTo( popup ); | 199 | a->addTo( popup ); |
199 | mb->insertItem( tr( "Actions" ), popup ); | 200 | mb->insertItem( tr( "Actions" ), popup ); |
200 | 201 | ||
201 | // View menu | 202 | // View menu |
202 | popup = new QPopupMenu( this ); | 203 | popup = new QPopupMenu( this ); |
203 | 204 | ||
204 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 205 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
205 | m_actionShowNotInstalled->setToggleAction( true ); | 206 | m_actionShowNotInstalled->setToggleAction( true ); |
206 | m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); | 207 | m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); |
207 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); | 208 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); |
208 | m_actionShowNotInstalled->addTo( popup ); | 209 | m_actionShowNotInstalled->addTo( popup ); |
209 | 210 | ||
210 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 211 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
211 | m_actionShowInstalled->setToggleAction( true ); | 212 | m_actionShowInstalled->setToggleAction( true ); |
212 | m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); | 213 | m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); |
213 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); | 214 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); |
214 | m_actionShowInstalled->addTo( popup ); | 215 | m_actionShowInstalled->addTo( popup ); |
215 | 216 | ||
216 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 217 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
217 | m_actionShowUpdated->setToggleAction( true ); | 218 | m_actionShowUpdated->setToggleAction( true ); |
218 | m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); | 219 | m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); |
219 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); | 220 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); |
220 | m_actionShowUpdated->addTo( popup ); | 221 | m_actionShowUpdated->addTo( popup ); |
221 | 222 | ||
222 | popup->insertSeparator(); | 223 | popup->insertSeparator(); |
223 | 224 | ||
224 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), | 225 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), |
225 | QString::null, 0, this, 0 ); | 226 | QString::null, 0, this, 0 ); |
226 | m_actionFilter->setToggleAction( true ); | 227 | m_actionFilter->setToggleAction( true ); |
227 | m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); | 228 | m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); |
228 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); | 229 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); |
229 | m_actionFilter->addTo( popup ); | 230 | m_actionFilter->addTo( popup ); |
230 | 231 | ||
231 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); | 232 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); |
232 | a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); | 233 | a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); |
233 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); | 234 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); |
234 | a->addTo( popup ); | 235 | a->addTo( popup ); |
235 | 236 | ||
236 | popup->insertSeparator(); | 237 | popup->insertSeparator(); |
237 | 238 | ||
238 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 239 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
239 | a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); | 240 | a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); |
240 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); | 241 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); |
241 | a->addTo( popup ); | 242 | a->addTo( popup ); |
242 | 243 | ||
243 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 244 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
244 | m_actionFindNext->setEnabled( false ); | 245 | m_actionFindNext->setEnabled( false ); |
245 | m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) ); | 246 | m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) ); |
246 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); | 247 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); |
247 | m_actionFindNext->addTo( popup ); | 248 | m_actionFindNext->addTo( popup ); |
248 | m_actionFindNext->addTo( &m_findBar ); | 249 | m_actionFindNext->addTo( &m_findBar ); |
249 | 250 | ||
250 | mb->insertItem( tr( "View" ), popup ); | 251 | mb->insertItem( tr( "View" ), popup ); |
251 | 252 | ||
252 | // Finish find toolbar creation | 253 | // Finish find toolbar creation |
253 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 254 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
254 | a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) ); | 255 | a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) ); |
255 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); | 256 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); |
256 | a->addTo( &m_findBar ); | 257 | a->addTo( &m_findBar ); |
257 | m_findBar.hide(); | 258 | m_findBar.hide(); |
258 | } | 259 | } |
259 | 260 | ||
260 | void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) | 261 | void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) |
261 | { | 262 | { |
262 | if ( clearList ) | 263 | if ( clearList ) |
263 | m_packageList.clear(); | 264 | m_packageList.clear(); |
264 | 265 | ||
265 | if ( packages ) | 266 | if ( packages ) |
266 | { | 267 | { |
267 | for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) | 268 | for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) |
268 | { | 269 | { |
269 | OPackage *package = packageIt.current(); | 270 | OPackage *package = packageIt.current(); |
270 | QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), | 271 | QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), |
271 | QCheckListItem::CheckBox ); | 272 | QCheckListItem::CheckBox ); |
272 | m_packageList.insertItem( item ); | 273 | m_packageList.insertItem( item ); |
273 | 274 | ||
274 | // If a different version of package is available, show update available icon | 275 | // If a different version of package is available, show update available icon |
275 | // Otherwise, show installed icon | 276 | // Otherwise, show installed icon |
276 | if ( !package->versionInstalled().isNull() ) | 277 | if ( !package->versionInstalled().isNull() ) |
277 | { | 278 | { |
278 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) | 279 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) |
279 | item->setPixmap( 0, m_iconUpdated ); | 280 | item->setPixmap( 0, m_iconUpdated ); |
280 | else | 281 | else |
281 | item->setPixmap( 0, m_iconInstalled ); | 282 | item->setPixmap( 0, m_iconInstalled ); |
282 | } | 283 | } |
283 | else | 284 | else |
284 | item->setPixmap( 0, m_iconNull ); | 285 | item->setPixmap( 0, m_iconNull ); |
285 | } | 286 | } |
286 | } | 287 | } |
287 | } | 288 | } |
288 | 289 | ||
289 | void MainWindow::searchForPackage( const QString &text ) | 290 | void MainWindow::searchForPackage( const QString &text ) |
290 | { | 291 | { |
291 | if ( !text.isEmpty() ) | 292 | if ( !text.isEmpty() ) |
292 | { | 293 | { |
293 | // look through package list for text startng at current position | 294 | // look through package list for text startng at current position |
294 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); | 295 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); |
295 | if ( start == 0 ) | 296 | if ( start == 0 ) |
296 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 297 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
297 | 298 | ||
298 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; | 299 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; |
299 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; | 300 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; |
300 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 301 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
301 | { | 302 | { |
302 | if ( item->text().lower().find( text ) != -1 ) | 303 | if ( item->text().lower().find( text ) != -1 ) |
303 | { | 304 | { |
304 | m_packageList.ensureItemVisible( item ); | 305 | m_packageList.ensureItemVisible( item ); |
305 | m_packageList.setCurrentItem( item ); | 306 | m_packageList.setCurrentItem( item ); |
306 | break; | 307 | break; |
307 | } | 308 | } |
308 | } | 309 | } |
309 | } | 310 | } |
310 | } | 311 | } |
311 | 312 | ||
312 | void MainWindow::installLocalPackage( const QString &ipkFile ) | 313 | void MainWindow::installLocalPackage( const QString &ipkFile ) |
313 | { | 314 | { |
314 | // Install selected file | 315 | // Install selected file |
315 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), | 316 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), |
316 | OPackage::Install, ipkFile ); | 317 | OPackage::Install, ipkFile ); |
317 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 318 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
318 | 319 | ||
319 | // Display widget | 320 | // Display widget |
320 | m_widgetStack.addWidget( dlg, 3 ); | 321 | m_widgetStack.addWidget( dlg, 3 ); |
321 | m_widgetStack.raiseWidget( dlg ); | 322 | m_widgetStack.raiseWidget( dlg ); |
322 | } | 323 | } |
323 | 324 | ||
324 | void MainWindow::setDocument( const QString &ipkFile ) | 325 | void MainWindow::setDocument( const QString &ipkFile ) |
325 | { | 326 | { |
326 | QString file = ipkFile; | 327 | QString file = ipkFile; |
327 | DocLnk lnk( ipkFile ); | 328 | DocLnk lnk( ipkFile ); |
328 | if ( lnk.isValid() ) | 329 | if ( lnk.isValid() ) |
329 | file = lnk.file(); | 330 | file = lnk.file(); |
330 | 331 | ||
331 | installLocalPackage( file ); | 332 | installLocalPackage( file ); |
332 | } | 333 | } |
333 | 334 | ||
334 | void MainWindow::initPackageInfo() | 335 | void MainWindow::initPackageInfo() |
335 | { | 336 | { |
336 | m_widgetStack.raiseWidget( &m_statusWidget ); | 337 | m_widgetStack.raiseWidget( &m_statusWidget ); |
337 | 338 | ||
338 | // Load package list | 339 | // Load package list |
339 | m_packman.loadAvailablePackages(); | 340 | m_packman.loadAvailablePackages(); |
340 | m_packman.loadInstalledPackages(); | 341 | m_packman.loadInstalledPackages(); |
341 | 342 | ||
342 | OPackageList *packageList = m_packman.packages(); | 343 | OPackageList *packageList = m_packman.packages(); |
343 | if ( packageList ) | 344 | if ( packageList ) |
344 | { | 345 | { |
345 | loadPackageList( packageList, true ); | 346 | loadPackageList( packageList, true ); |
346 | delete packageList; | 347 | delete packageList; |
347 | } | 348 | } |
348 | 349 | ||
349 | QWidget *widget = m_widgetStack.widget( 3 ); | 350 | QWidget *widget = m_widgetStack.widget( 3 ); |
350 | if ( !widget ) | 351 | if ( !widget ) |
351 | widget = &m_packageList; | 352 | widget = &m_packageList; |
352 | m_widgetStack.raiseWidget( widget ); | 353 | m_widgetStack.raiseWidget( widget ); |
353 | } | 354 | } |
354 | 355 | ||
355 | void MainWindow::slotWidgetStackShow( QWidget *widget ) | 356 | void MainWindow::slotWidgetStackShow( QWidget *widget ) |
356 | { | 357 | { |
357 | if ( widget == &m_packageList ) | 358 | if ( widget == &m_packageList ) |
358 | { | 359 | { |
359 | setCaption( tr( "Package Manager" ) ); | 360 | setCaption( tr( "Package Manager" ) ); |
360 | 361 | ||
361 | m_menuBar.show(); | 362 | m_menuBar.show(); |
362 | m_toolBar.show(); | 363 | m_toolBar.show(); |
363 | } | 364 | } |
364 | else | 365 | else |
365 | { | 366 | { |
366 | m_menuBar.hide(); | 367 | m_menuBar.hide(); |
367 | m_toolBar.hide(); | 368 | m_toolBar.hide(); |
368 | } | 369 | } |
369 | } | 370 | } |
370 | 371 | ||
371 | void MainWindow::slotInitStatusBar( int numSteps ) | 372 | void MainWindow::slotInitStatusBar( int numSteps ) |
372 | { | 373 | { |
373 | m_statusBar.setTotalSteps( numSteps ); | 374 | m_statusBar.setTotalSteps( numSteps ); |
374 | } | 375 | } |
375 | 376 | ||
376 | void MainWindow::slotStatusText( const QString &status ) | 377 | void MainWindow::slotStatusText( const QString &status ) |
377 | { | 378 | { |
378 | m_statusText.setText( status ); | 379 | m_statusText.setText( status ); |
379 | } | 380 | } |
380 | 381 | ||
381 | void MainWindow::slotStatusBar( int currStep ) | 382 | void MainWindow::slotStatusBar( int currStep ) |
382 | { | 383 | { |
383 | m_statusBar.setProgress( currStep ); | 384 | m_statusBar.setProgress( currStep ); |
384 | } | 385 | } |
385 | 386 | ||
386 | void MainWindow::slotUpdate() | 387 | void MainWindow::slotUpdate() |
387 | { | 388 | { |
388 | // Create package manager output widget | 389 | // Create package manager output widget |
389 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), | 390 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), |
390 | OPackage::Update ); | 391 | OPackage::Update ); |
391 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 392 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
392 | 393 | ||
393 | // Display widget | 394 | // Display widget |
394 | m_widgetStack.addWidget( dlg, 3 ); | 395 | m_widgetStack.addWidget( dlg, 3 ); |
395 | m_widgetStack.raiseWidget( dlg ); | 396 | m_widgetStack.raiseWidget( dlg ); |
396 | } | 397 | } |
397 | 398 | ||
398 | void MainWindow::slotUpgrade() | 399 | void MainWindow::slotUpgrade() |
399 | { | 400 | { |
400 | // Create package manager output widget | 401 | // Create package manager output widget |
401 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), | 402 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), |
402 | OPackage::Upgrade ); | 403 | OPackage::Upgrade ); |
403 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 404 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
404 | 405 | ||
405 | // Display widget | 406 | // Display widget |
406 | m_widgetStack.addWidget( dlg, 3 ); | 407 | m_widgetStack.addWidget( dlg, 3 ); |
407 | m_widgetStack.raiseWidget( dlg ); | 408 | m_widgetStack.raiseWidget( dlg ); |
408 | } | 409 | } |
409 | 410 | ||
410 | void MainWindow::slotDownload() | 411 | void MainWindow::slotDownload() |
411 | { | 412 | { |
412 | // Retrieve list of packages selected for download (if any) | 413 | // Retrieve list of packages selected for download (if any) |
413 | QStringList workingPackages; | 414 | QStringList workingPackages; |
414 | 415 | ||
415 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 416 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
416 | item != 0 ; | 417 | item != 0 ; |
417 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 418 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
418 | { | 419 | { |
419 | if ( item->isOn() ) | 420 | if ( item->isOn() ) |
420 | workingPackages.append( item->text() ); | 421 | workingPackages.append( item->text() ); |
421 | } | 422 | } |
422 | 423 | ||
423 | if ( workingPackages.isEmpty() ) | 424 | if ( workingPackages.isEmpty() ) |
424 | { | 425 | { |
425 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); | 426 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); |
426 | return; | 427 | return; |
427 | } | 428 | } |
428 | else | 429 | else |
429 | { | 430 | { |
430 | // Download selected packages | 431 | // Download selected packages |
431 | m_config.setGroup( "settings" ); | 432 | m_config.setGroup( "settings" ); |
432 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); | 433 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); |
433 | 434 | ||
434 | bool ok = false; | 435 | bool ok = false; |
435 | QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); | 436 | QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); |
436 | if ( ok && !text.isEmpty() ) | 437 | if ( ok && !text.isEmpty() ) |
437 | workingDir = text; // user entered something and pressed ok | 438 | workingDir = text; // user entered something and pressed ok |
438 | else | 439 | else |
439 | return; // user entered nothing or pressed cancel | 440 | return; // user entered nothing or pressed cancel |
440 | 441 | ||
441 | // Store download directory in config file | 442 | // Store download directory in config file |
442 | m_config.writeEntry( "DownloadDir", workingDir ); | 443 | m_config.writeEntry( "DownloadDir", workingDir ); |
443 | 444 | ||
444 | // Get starting directory | 445 | // Get starting directory |
445 | QDir::setCurrent( workingDir ); | 446 | QDir::setCurrent( workingDir ); |
446 | 447 | ||
447 | // Create package manager output widget | 448 | // Create package manager output widget |
448 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), | 449 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), |
449 | OPackage::Download, workingPackages ); | 450 | OPackage::Download, workingPackages ); |
450 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 451 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
451 | 452 | ||
452 | // Display widget | 453 | // Display widget |
453 | m_widgetStack.addWidget( dlg, 3 ); | 454 | m_widgetStack.addWidget( dlg, 3 ); |
454 | m_widgetStack.raiseWidget( dlg ); | 455 | m_widgetStack.raiseWidget( dlg ); |
455 | } | 456 | } |
456 | } | 457 | } |
457 | 458 | ||
458 | void MainWindow::slotApply() | 459 | void MainWindow::slotApply() |
459 | { | 460 | { |
460 | QStringList removeList; | 461 | QStringList removeList; |
461 | QStringList installList; | 462 | QStringList installList; |
462 | QStringList upgradeList; | 463 | QStringList upgradeList; |
463 | 464 | ||
464 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 465 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
465 | item != 0 ; | 466 | item != 0 ; |
466 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 467 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
467 | { | 468 | { |
468 | if ( item->isOn() ) | 469 | if ( item->isOn() ) |
469 | { | 470 | { |
470 | OPackage *package = m_packman.findPackage( item->text() ); | 471 | OPackage *package = m_packman.findPackage( item->text() ); |
471 | if ( package ) | 472 | if ( package ) |
472 | { | 473 | { |
473 | if ( !package->versionInstalled().isNull() ) | 474 | if ( !package->versionInstalled().isNull() ) |
474 | { | 475 | { |
475 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) | 476 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) |
476 | { | 477 | { |
477 | // Remove/upgrade package | 478 | // Remove/upgrade package |
478 | int answer = PromptDlg::ask( tr( "Remove or upgrade" ), | 479 | int answer = PromptDlg::ask( tr( "Remove or upgrade" ), |
479 | tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), | 480 | tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), |
480 | tr( "Remove" ), tr( "Upgrade" ), this ); | 481 | tr( "Remove" ), tr( "Upgrade" ), this ); |
481 | if ( answer == 1 ) // Remove | 482 | if ( answer == 1 ) // Remove |
482 | { | 483 | { |
483 | removeList.append( item->text() ); | 484 | removeList.append( item->text() ); |
484 | } | 485 | } |
485 | else if ( answer == 2 ) // Upgrade | 486 | else if ( answer == 2 ) // Upgrade |
486 | { | 487 | { |
487 | upgradeList.append( item->text() ); | 488 | upgradeList.append( item->text() ); |
488 | } | 489 | } |
489 | } | 490 | } |
490 | else | 491 | else |
491 | { | 492 | { |
492 | // Remove/reinstall package | 493 | // Remove/reinstall package |
493 | int answer = PromptDlg::ask( tr( "Remove or reinstall" ), | 494 | int answer = PromptDlg::ask( tr( "Remove or reinstall" ), |
494 | tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), | 495 | tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), |
495 | tr( "Remove" ), tr( "Reinstall" ), this ); | 496 | tr( "Remove" ), tr( "Reinstall" ), this ); |
496 | if ( answer == 1 ) // Remove | 497 | if ( answer == 1 ) // Remove |
497 | { | 498 | { |
498 | removeList.append( item->text() ); | 499 | removeList.append( item->text() ); |
499 | } | 500 | } |
500 | else if ( answer == 2 ) // Reinstall | 501 | else if ( answer == 2 ) // Reinstall |
501 | { | 502 | { |
502 | installList.append( item->text() ); | 503 | installList.append( item->text() ); |
503 | } | 504 | } |
504 | } | 505 | } |
505 | } | 506 | } |
506 | else | 507 | else |
507 | { | 508 | { |
508 | // Install package | 509 | // Install package |
509 | installList.append( item->text() ); | 510 | installList.append( item->text() ); |
510 | } | 511 | } |
511 | } | 512 | } |
512 | } | 513 | } |
513 | } | 514 | } |
514 | 515 | ||
515 | // If nothing is selected, display message and exit | 516 | // If nothing is selected, display message and exit |
516 | if ( removeList.isEmpty() && installList.isEmpty() && upgradeList.isEmpty() ) | 517 | if ( removeList.isEmpty() && installList.isEmpty() && upgradeList.isEmpty() ) |
517 | { | 518 | { |
518 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); | 519 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); |
519 | return; | 520 | return; |
520 | } | 521 | } |
521 | 522 | ||
522 | // Send command only if there are packages to process | 523 | // Send command only if there are packages to process |
523 | OPackage::Command removeCmd = !removeList.isEmpty() ? OPackage::Remove | 524 | OPackage::Command removeCmd = !removeList.isEmpty() ? OPackage::Remove |
524 | : OPackage::NotDefined; | 525 | : OPackage::NotDefined; |
525 | OPackage::Command installCmd = !installList.isEmpty() ? OPackage::Install | 526 | OPackage::Command installCmd = !installList.isEmpty() ? OPackage::Install |
526 | : OPackage::NotDefined; | 527 | : OPackage::NotDefined; |
527 | OPackage::Command upgradeCmd = !upgradeList.isEmpty() ? OPackage::Upgrade | 528 | OPackage::Command upgradeCmd = !upgradeList.isEmpty() ? OPackage::Upgrade |
528 | : OPackage::NotDefined; | 529 | : OPackage::NotDefined; |
529 | 530 | ||
530 | // Create package manager output widget | 531 | // Create package manager output widget |
531 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), | 532 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), |
532 | removeCmd, removeList, | 533 | removeCmd, removeList, |
533 | installCmd, installList, | 534 | installCmd, installList, |
534 | upgradeCmd, upgradeList ); | 535 | upgradeCmd, upgradeList ); |
535 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 536 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
536 | 537 | ||
537 | // Display widget | 538 | // Display widget |
538 | m_widgetStack.addWidget( dlg, 3 ); | 539 | m_widgetStack.addWidget( dlg, 3 ); |
539 | m_widgetStack.raiseWidget( dlg ); | 540 | m_widgetStack.raiseWidget( dlg ); |
540 | } | 541 | } |
541 | 542 | ||
542 | void MainWindow::slotInstallLocal() | 543 | void MainWindow::slotInstallLocal() |
543 | { | 544 | { |
544 | // Display file open dialog with only package files | 545 | // Display file open dialog with only package files |
545 | MimeTypes type; | 546 | MimeTypes type; |
546 | QStringList packages; | 547 | QStringList packages; |
547 | packages << "application/ipkg"; | 548 | packages << "application/ipkg"; |
548 | type.insert( tr( "Application Packages" ), packages ); | 549 | type.insert( tr( "Application Packages" ), packages ); |
549 | QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, | 550 | QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, |
550 | "/", QString::null, type ); | 551 | "/", QString::null, type ); |
551 | if ( !package.isNull() ) | 552 | if ( !package.isNull() ) |
552 | installLocalPackage( package ); | 553 | installLocalPackage( package ); |
553 | } | 554 | } |
554 | 555 | ||
555 | void MainWindow::slotCloseDlg() | 556 | void MainWindow::slotCloseDlg() |
556 | { | 557 | { |
557 | // Close install dialog | 558 | // Close install dialog |
558 | delete m_widgetStack.visibleWidget(); | 559 | delete m_widgetStack.visibleWidget(); |
559 | 560 | ||
560 | // Reload package list | 561 | // Reload package list |
561 | initPackageInfo(); | 562 | initPackageInfo(); |
562 | 563 | ||
563 | // Update Opie launcher links | 564 | // Update Opie launcher links |
564 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 565 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
565 | QString lf = QString::null; | 566 | QString lf = QString::null; |
566 | e << lf; | 567 | e << lf; |
567 | 568 | ||
568 | // Reapply any filters previously set | 569 | // Reapply any filters previously set |
569 | if ( m_actionShowNotInstalled->isOn() ) | 570 | if ( m_actionShowNotInstalled->isOn() ) |
570 | slotShowNotInstalled(); | 571 | slotShowNotInstalled(); |
571 | else if ( m_actionShowInstalled->isOn() ) | 572 | else if ( m_actionShowInstalled->isOn() ) |
572 | slotShowInstalled(); | 573 | slotShowInstalled(); |
573 | else if ( m_actionShowUpdated->isOn() ) | 574 | else if ( m_actionShowUpdated->isOn() ) |
574 | slotShowUpdated(); | 575 | slotShowUpdated(); |
575 | else if ( m_actionFilter->isOn() ) | 576 | else if ( m_actionFilter->isOn() ) |
576 | slotFilter( true ); | 577 | slotFilter( true ); |
577 | } | 578 | } |
578 | 579 | ||
579 | void MainWindow::slotConfigure() | 580 | void MainWindow::slotConfigure() |
580 | { | 581 | { |
581 | if ( m_packman.configureDlg( false ) ) | 582 | if ( m_packman.configureDlg( false ) ) |
582 | { | 583 | { |
583 | if ( PromptDlg::ask( tr( "Config updated" ), | 584 | if ( PromptDlg::ask( tr( "Config updated" ), |
584 | tr( "The configuration has been updated. Do you want to update server and package information now?" ), | 585 | tr( "The configuration has been updated. Do you want to update server and package information now?" ), |
585 | tr( "Yes" ), tr( "No" ), this ) == 1 ) | 586 | tr( "Yes" ), tr( "No" ), this ) == 1 ) |
586 | { | 587 | { |
587 | // Update package list and reload package info | 588 | // Update package list and reload package info |
588 | slotUpdate(); | 589 | slotUpdate(); |
589 | } | 590 | } |
590 | } | 591 | } |
591 | } | 592 | } |
592 | 593 | ||
593 | void MainWindow::slotShowNotInstalled() | 594 | void MainWindow::slotShowNotInstalled() |
594 | { | 595 | { |
595 | OPackageList *packageList; | 596 | OPackageList *packageList; |
596 | if ( m_actionShowNotInstalled->isOn() ) | 597 | if ( m_actionShowNotInstalled->isOn() ) |
597 | { | 598 | { |
598 | m_actionShowInstalled->setOn( false ); | 599 | m_actionShowInstalled->setOn( false ); |
599 | m_actionShowUpdated->setOn( false ); | 600 | m_actionShowUpdated->setOn( false ); |
600 | m_actionFilter->setOn( false ); | 601 | m_actionFilter->setOn( false ); |
601 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, | 602 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, |
602 | OPackageManager::NotInstalled, QString::null ); | 603 | OPackageManager::NotInstalled, QString::null ); |
603 | } | 604 | } |
604 | else | 605 | else |
605 | packageList = m_packman.packages(); | 606 | packageList = m_packman.packages(); |
606 | 607 | ||
607 | if ( packageList ) | 608 | if ( packageList ) |
608 | { | 609 | { |
609 | loadPackageList( packageList, true ); | 610 | loadPackageList( packageList, true ); |
610 | delete packageList; | 611 | delete packageList; |
611 | } | 612 | } |
612 | } | 613 | } |
613 | 614 | ||
614 | void MainWindow::slotShowInstalled() | 615 | void MainWindow::slotShowInstalled() |
615 | { | 616 | { |
616 | OPackageList *packageList; | 617 | OPackageList *packageList; |
617 | if ( m_actionShowInstalled->isOn() ) | 618 | if ( m_actionShowInstalled->isOn() ) |
618 | { | 619 | { |
619 | m_actionShowNotInstalled->setOn( false ); | 620 | m_actionShowNotInstalled->setOn( false ); |
620 | m_actionShowUpdated->setOn( false ); | 621 | m_actionShowUpdated->setOn( false ); |
621 | m_actionFilter->setOn( false ); | 622 | m_actionFilter->setOn( false ); |
622 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, | 623 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, |
623 | OPackageManager::Installed, QString::null ); | 624 | OPackageManager::Installed, QString::null ); |
624 | } | 625 | } |
625 | else | 626 | else |
626 | packageList = m_packman.packages(); | 627 | packageList = m_packman.packages(); |
627 | 628 | ||
628 | if ( packageList ) | 629 | if ( packageList ) |
629 | { | 630 | { |
630 | loadPackageList( packageList, true ); | 631 | loadPackageList( packageList, true ); |
631 | delete packageList; | 632 | delete packageList; |
632 | } | 633 | } |
633 | } | 634 | } |
634 | 635 | ||
635 | void MainWindow::slotShowUpdated() | 636 | void MainWindow::slotShowUpdated() |
636 | { | 637 | { |
637 | OPackageList *packageList; | 638 | OPackageList *packageList; |
638 | if ( m_actionShowUpdated->isOn() ) | 639 | if ( m_actionShowUpdated->isOn() ) |
639 | { | 640 | { |
640 | m_actionShowInstalled->setOn( false ); | 641 | m_actionShowInstalled->setOn( false ); |
641 | m_actionShowNotInstalled->setOn( false ); | 642 | m_actionShowNotInstalled->setOn( false ); |
642 | m_actionFilter->setOn( false ); | 643 | m_actionFilter->setOn( false ); |
643 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, | 644 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, |
644 | OPackageManager::Updated, QString::null ); | 645 | OPackageManager::Updated, QString::null ); |
645 | } | 646 | } |
646 | else | 647 | else |
647 | packageList = m_packman.packages(); | 648 | packageList = m_packman.packages(); |
648 | 649 | ||
649 | if ( packageList ) | 650 | if ( packageList ) |
650 | { | 651 | { |
651 | loadPackageList( packageList, true ); | 652 | loadPackageList( packageList, true ); |
652 | delete packageList; | 653 | delete packageList; |
653 | } | 654 | } |
654 | } | 655 | } |
655 | 656 | ||
656 | void MainWindow::slotFilterChange() | 657 | void MainWindow::slotFilterChange() |
657 | { | 658 | { |
658 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, | 659 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, |
659 | m_filterCategory ); | 660 | m_filterCategory ); |
660 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 661 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
661 | { | 662 | { |
662 | m_filterName = dlg.name(); | 663 | m_filterName = dlg.name(); |
663 | m_filterServer = dlg.server(); | 664 | m_filterServer = dlg.server(); |
664 | m_filterDest = dlg.destination(); | 665 | m_filterDest = dlg.destination(); |
665 | m_filterStatus = dlg.status(); | 666 | m_filterStatus = dlg.status(); |
666 | m_filterCategory = dlg.category(); | 667 | m_filterCategory = dlg.category(); |
667 | m_actionFilter->setOn( true ); | 668 | m_actionFilter->setOn( true ); |
668 | slotFilter( true ); | 669 | slotFilter( true ); |
669 | } | 670 | } |
670 | else | 671 | else |
671 | { | 672 | { |
672 | m_actionFilter->setOn( false ); | 673 | m_actionFilter->setOn( false ); |
673 | slotFilter( false ); | 674 | slotFilter( false ); |
674 | } | 675 | } |
675 | } | 676 | } |
676 | 677 | ||
677 | void MainWindow::slotFilter( bool isOn ) | 678 | void MainWindow::slotFilter( bool isOn ) |
678 | { | 679 | { |
679 | OPackageList *packageList; | 680 | OPackageList *packageList; |
680 | if ( isOn ) | 681 | if ( isOn ) |
681 | { | 682 | { |
682 | // Turn off other filtering options | 683 | // Turn off other filtering options |
683 | m_actionShowNotInstalled->setOn( false ); | 684 | m_actionShowNotInstalled->setOn( false ); |
684 | m_actionShowInstalled->setOn( false ); | 685 | m_actionShowInstalled->setOn( false ); |
685 | m_actionShowUpdated->setOn( false ); | 686 | m_actionShowUpdated->setOn( false ); |
686 | 687 | ||
687 | // If the filter settings have not been set yet, display filter dialog | 688 | // If the filter settings have not been set yet, display filter dialog |
688 | if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() && | 689 | if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() && |
689 | m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() ) | 690 | m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() ) |
690 | { | 691 | { |
691 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, | 692 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, |
692 | m_filterCategory ); | 693 | m_filterCategory ); |
693 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 694 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
694 | { | 695 | { |
695 | m_filterName = dlg.name(); | 696 | m_filterName = dlg.name(); |
696 | m_filterServer = dlg.server(); | 697 | m_filterServer = dlg.server(); |
697 | m_filterDest = dlg.destination(); | 698 | m_filterDest = dlg.destination(); |
698 | m_filterStatus = dlg.status(); | 699 | m_filterStatus = dlg.status(); |
699 | m_filterCategory = dlg.category(); | 700 | m_filterCategory = dlg.category(); |
700 | m_actionFilter->setOn( true ); | 701 | m_actionFilter->setOn( true ); |
701 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, | 702 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, |
702 | m_filterStatus, m_filterCategory ); | 703 | m_filterStatus, m_filterCategory ); |
703 | } | 704 | } |
704 | else | 705 | else |
705 | { | 706 | { |
706 | m_actionFilter->setOn( false ); | 707 | m_actionFilter->setOn( false ); |
707 | packageList = m_packman.packages(); | 708 | packageList = m_packman.packages(); |
708 | } | 709 | } |
709 | } | 710 | } |
710 | else | 711 | else |
711 | { | 712 | { |
712 | m_actionFilter->setOn( true ); | 713 | m_actionFilter->setOn( true ); |
713 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, | 714 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, |
714 | m_filterStatus, m_filterCategory ); | 715 | m_filterStatus, m_filterCategory ); |
715 | } | 716 | } |
716 | 717 | ||
717 | 718 | ||
718 | } | 719 | } |
719 | else | 720 | else |
720 | packageList = m_packman.packages(); | 721 | packageList = m_packman.packages(); |
721 | 722 | ||
722 | if ( packageList ) | 723 | if ( packageList ) |
723 | { | 724 | { |
724 | loadPackageList( packageList, true ); | 725 | loadPackageList( packageList, true ); |
725 | delete packageList; | 726 | delete packageList; |
726 | } | 727 | } |
727 | } | 728 | } |
728 | 729 | ||
729 | void MainWindow::slotFindShowToolbar() | 730 | void MainWindow::slotFindShowToolbar() |
730 | { | 731 | { |
731 | m_findBar.show(); | 732 | m_findBar.show(); |
732 | m_findEdit->setFocus(); | 733 | m_findEdit->setFocus(); |
733 | } | 734 | } |
734 | 735 | ||
735 | void MainWindow::slotFindHideToolbar() | 736 | void MainWindow::slotFindHideToolbar() |
736 | { | 737 | { |
737 | m_findBar.hide(); | 738 | m_findBar.hide(); |
738 | } | 739 | } |
739 | 740 | ||
740 | void MainWindow::slotFindChanged( const QString &findText ) | 741 | void MainWindow::slotFindChanged( const QString &findText ) |
741 | { | 742 | { |
742 | 743 | ||
743 | m_actionFindNext->setEnabled( !findText.isEmpty() ); | 744 | m_actionFindNext->setEnabled( !findText.isEmpty() ); |
744 | searchForPackage( findText ); | 745 | searchForPackage( findText ); |
745 | } | 746 | } |
746 | 747 | ||
747 | void MainWindow::slotFindNext() | 748 | void MainWindow::slotFindNext() |
748 | { | 749 | { |
749 | searchForPackage( m_findEdit->text() ); | 750 | searchForPackage( m_findEdit->text() ); |
750 | } | 751 | } |
751 | 752 | ||
752 | void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) | 753 | void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) |
753 | { | 754 | { |
754 | QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); | 755 | QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); |
755 | 756 | ||
756 | // Create package manager output widget | 757 | // Create package manager output widget |
757 | PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); | 758 | PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); |
758 | 759 | ||
759 | // Display widget | 760 | // Display widget |
760 | m_widgetStack.addWidget( dlg, 3 ); | 761 | m_widgetStack.addWidget( dlg, 3 ); |
761 | m_widgetStack.raiseWidget( dlg ); | 762 | m_widgetStack.raiseWidget( dlg ); |
762 | } | 763 | } |
diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h index f00e344..e7003e4 100644 --- a/noncore/settings/packagemanager/mainwindow.h +++ b/noncore/settings/packagemanager/mainwindow.h | |||
@@ -1,143 +1,144 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #ifndef MAINWINDOW_H | 31 | #ifndef MAINWINDOW_H |
31 | #define MAINWINDOW_H | 32 | #define MAINWINDOW_H |
32 | 33 | ||
33 | #include "opackagemanager.h" | 34 | #include "opackagemanager.h" |
34 | 35 | ||
35 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
36 | 37 | ||
37 | #include <qlabel.h> | 38 | #include <qlabel.h> |
38 | #include <qlistview.h> | 39 | #include <qlistview.h> |
39 | #include <qmainwindow.h> | 40 | #include <qmainwindow.h> |
40 | #include <qpixmap.h> | 41 | #include <qpixmap.h> |
41 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
42 | #include <qtoolbar.h> | 43 | #include <qtoolbar.h> |
43 | #include <qwidgetstack.h> | 44 | #include <qwidgetstack.h> |
44 | 45 | ||
45 | class QAction; | 46 | class QAction; |
46 | class QLineEdit; | 47 | class QLineEdit; |
47 | 48 | ||
48 | class MainWindow :public QMainWindow | 49 | class MainWindow :public QMainWindow |
49 | { | 50 | { |
50 | Q_OBJECT | 51 | Q_OBJECT |
51 | 52 | ||
52 | public: | 53 | public: |
53 | MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 ); | 54 | MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 ); |
54 | static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); }; | 55 | static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); }; |
55 | 56 | ||
56 | protected: | 57 | protected: |
57 | void closeEvent( QCloseEvent *event ); | 58 | void closeEvent( QCloseEvent *event ); |
58 | 59 | ||
59 | private: | 60 | private: |
60 | Config m_config; // Configuration file | 61 | Config m_config; // Configuration file |
61 | 62 | ||
62 | OPackageManager m_packman; // Package manager | 63 | OPackageManager m_packman; // Package manager |
63 | 64 | ||
64 | // Toolbars | 65 | // Toolbars |
65 | QToolBar m_menuBar; // Main toolbar containing menu | 66 | QToolBar m_menuBar; // Main toolbar containing menu |
66 | QToolBar m_toolBar; // Main toolbar | 67 | QToolBar m_toolBar; // Main toolbar |
67 | QToolBar m_findBar; // Find toolbar | 68 | QToolBar m_findBar; // Find toolbar |
68 | 69 | ||
69 | QWidgetStack m_widgetStack; // Main widget stack which contains m_packageList & m_statusWidget | 70 | QWidgetStack m_widgetStack; // Main widget stack which contains m_packageList & m_statusWidget |
70 | QListView m_packageList; // Main list view of all packages | 71 | QListView m_packageList; // Main list view of all packages |
71 | 72 | ||
72 | QLineEdit *m_findEdit; // Line edit box used for find toolbar | 73 | QLineEdit *m_findEdit; // Line edit box used for find toolbar |
73 | 74 | ||
74 | // Status widget controls | 75 | // Status widget controls |
75 | QWidget m_statusWidget; // Widget to display status during long operations | 76 | QWidget m_statusWidget; // Widget to display status during long operations |
76 | QLabel m_statusText; // Text status message | 77 | QLabel m_statusText; // Text status message |
77 | QProgressBar m_statusBar; // Progress bar showing % completed | 78 | QProgressBar m_statusBar; // Progress bar showing % completed |
78 | 79 | ||
79 | // Icon pixmaps | 80 | // Icon pixmaps |
80 | QPixmap m_iconUpdated; // Cached icon which shows when package can be updated | 81 | QPixmap m_iconUpdated; // Cached icon which shows when package can be updated |
81 | QPixmap m_iconInstalled; // Cached icon which shows when package is installed | 82 | QPixmap m_iconInstalled; // Cached icon which shows when package is installed |
82 | QPixmap m_iconNull; // Cached icon which shows when package is not installed | 83 | QPixmap m_iconNull; // Cached icon which shows when package is not installed |
83 | 84 | ||
84 | // Menu/tool bar actions | 85 | // Menu/tool bar actions |
85 | QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed | 86 | QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed |
86 | QAction *m_actionShowInstalled; // Action to show pakages currently installed | 87 | QAction *m_actionShowInstalled; // Action to show pakages currently installed |
87 | QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available | 88 | QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available |
88 | QAction *m_actionFilter; // Action to filter packages | 89 | QAction *m_actionFilter; // Action to filter packages |
89 | QAction *m_actionFindNext; // Action to find next match | 90 | QAction *m_actionFindNext; // Action to find next match |
90 | 91 | ||
91 | // Cached filter settings | 92 | // Cached filter settings |
92 | QString m_filterName; // Cached name filter value | 93 | QString m_filterName; // Cached name filter value |
93 | QString m_filterServer; // Cached server name filter value | 94 | QString m_filterServer; // Cached server name filter value |
94 | QString m_filterDest; // Cached destination name filter value | 95 | QString m_filterDest; // Cached destination name filter value |
95 | OPackageManager::Status m_filterStatus; // Cached status filter value | 96 | OPackageManager::Status m_filterStatus; // Cached status filter value |
96 | QString m_filterCategory; // Cached category filter value | 97 | QString m_filterCategory; // Cached category filter value |
97 | 98 | ||
98 | void initPackageList(); | 99 | void initPackageList(); |
99 | void initStatusWidget(); | 100 | void initStatusWidget(); |
100 | void initUI(); | 101 | void initUI(); |
101 | 102 | ||
102 | void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); | 103 | void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); |
103 | void searchForPackage( const QString &text ); | 104 | void searchForPackage( const QString &text ); |
104 | void installLocalPackage( const QString &ipkFile ); | 105 | void installLocalPackage( const QString &ipkFile ); |
105 | 106 | ||
106 | private slots: | 107 | private slots: |
107 | void setDocument( const QString &ipkFile ); | 108 | void setDocument( const QString &ipkFile ); |
108 | 109 | ||
109 | void initPackageInfo(); | 110 | void initPackageInfo(); |
110 | void slotWidgetStackShow( QWidget *widget ); | 111 | void slotWidgetStackShow( QWidget *widget ); |
111 | 112 | ||
112 | // Status widget slots | 113 | // Status widget slots |
113 | void slotInitStatusBar( int numSteps ); | 114 | void slotInitStatusBar( int numSteps ); |
114 | void slotStatusText( const QString &status ); | 115 | void slotStatusText( const QString &status ); |
115 | void slotStatusBar( int currStep ); | 116 | void slotStatusBar( int currStep ); |
116 | 117 | ||
117 | // Actions menu action slots | 118 | // Actions menu action slots |
118 | void slotUpdate(); | 119 | void slotUpdate(); |
119 | void slotUpgrade(); | 120 | void slotUpgrade(); |
120 | void slotDownload(); | 121 | void slotDownload(); |
121 | void slotApply(); | 122 | void slotApply(); |
122 | void slotInstallLocal(); | 123 | void slotInstallLocal(); |
123 | void slotCloseDlg(); | 124 | void slotCloseDlg(); |
124 | void slotConfigure(); | 125 | void slotConfigure(); |
125 | 126 | ||
126 | // View menu action slots | 127 | // View menu action slots |
127 | void slotShowNotInstalled(); | 128 | void slotShowNotInstalled(); |
128 | void slotShowInstalled(); | 129 | void slotShowInstalled(); |
129 | void slotShowUpdated(); | 130 | void slotShowUpdated(); |
130 | void slotFilterChange(); | 131 | void slotFilterChange(); |
131 | void slotFilter( bool isOn ); | 132 | void slotFilter( bool isOn ); |
132 | 133 | ||
133 | // Find action slots | 134 | // Find action slots |
134 | void slotFindShowToolbar(); | 135 | void slotFindShowToolbar(); |
135 | void slotFindHideToolbar(); | 136 | void slotFindHideToolbar(); |
136 | void slotFindChanged( const QString &findText ); | 137 | void slotFindChanged( const QString &findText ); |
137 | void slotFindNext(); | 138 | void slotFindNext(); |
138 | 139 | ||
139 | // Other slots | 140 | // Other slots |
140 | void slotDisplayPackageInfo( QListViewItem * ); | 141 | void slotDisplayPackageInfo( QListViewItem * ); |
141 | }; | 142 | }; |
142 | 143 | ||
143 | #endif | 144 | #endif |
diff --git a/noncore/settings/packagemanager/oconfitem.cpp b/noncore/settings/packagemanager/oconfitem.cpp index ffa936e..76c8c65 100644 --- a/noncore/settings/packagemanager/oconfitem.cpp +++ b/noncore/settings/packagemanager/oconfitem.cpp | |||
@@ -1,42 +1,41 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #include "oconfitem.h" | 31 | #include "oconfitem.h" |
33 | 32 | ||
34 | OConfItem::OConfItem( Type type, const QString &name, const QString &value, | 33 | OConfItem::OConfItem( Type type, const QString &name, const QString &value, |
35 | const QString &features, bool active ) | 34 | const QString &features, bool active ) |
36 | : m_type( type ) | 35 | : m_type( type ) |
37 | , m_name( name ) | 36 | , m_name( name ) |
38 | , m_value( value ) | 37 | , m_value( value ) |
39 | , m_features( features ) | 38 | , m_features( features ) |
40 | , m_active( active ) | 39 | , m_active( active ) |
41 | { | 40 | { |
42 | } | 41 | } |
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h index b306e93..c95039e 100644 --- a/noncore/settings/packagemanager/oconfitem.h +++ b/noncore/settings/packagemanager/oconfitem.h | |||
@@ -1,96 +1,95 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #ifndef OCONFITEM_H | 31 | #ifndef OCONFITEM_H |
33 | #define OCONFITEM_H | 32 | #define OCONFITEM_H |
34 | 33 | ||
35 | #include <qlist.h> | 34 | #include <qlist.h> |
36 | #include <qstring.h> | 35 | #include <qstring.h> |
37 | 36 | ||
38 | class OConfItem | 37 | class OConfItem |
39 | { | 38 | { |
40 | public: | 39 | public: |
41 | enum Type { Source, Destination, Option, Arch, Other, NotDefined }; | 40 | enum Type { Source, Destination, Option, Arch, Other, NotDefined }; |
42 | 41 | ||
43 | OConfItem( Type type = NotDefined, const QString &name = QString::null, | 42 | OConfItem( Type type = NotDefined, const QString &name = QString::null, |
44 | const QString &value = QString::null, const QString &features = QString::null, | 43 | const QString &value = QString::null, const QString &features = QString::null, |
45 | bool active = true ); | 44 | bool active = true ); |
46 | 45 | ||
47 | Type type() { return m_type; } | 46 | Type type() { return m_type; } |
48 | const QString &name() { return m_name; } | 47 | const QString &name() { return m_name; } |
49 | const QString &value() { return m_value; } | 48 | const QString &value() { return m_value; } |
50 | const QString &features() { return m_features; } | 49 | const QString &features() { return m_features; } |
51 | bool active() { return m_active; } | 50 | bool active() { return m_active; } |
52 | 51 | ||
53 | void setType( Type type ) { m_type = type; } | 52 | void setType( Type type ) { m_type = type; } |
54 | void setName( const QString &name ) { m_name = name; } | 53 | void setName( const QString &name ) { m_name = name; } |
55 | void setValue( const QString &value ) { m_value = value; } | 54 | void setValue( const QString &value ) { m_value = value; } |
56 | void setFeatures( const QString &features ) { m_features = features; } | 55 | void setFeatures( const QString &features ) { m_features = features; } |
57 | void setActive( bool active ) { m_active = active; } | 56 | void setActive( bool active ) { m_active = active; } |
58 | 57 | ||
59 | private: | 58 | private: |
60 | Type m_type; // Type of configuration item | 59 | Type m_type; // Type of configuration item |
61 | QString m_name; // Name of item | 60 | QString m_name; // Name of item |
62 | QString m_value; // Value of item | 61 | QString m_value; // Value of item |
63 | QString m_features; // Comma-deliminated list of features this item supports | 62 | QString m_features; // Comma-deliminated list of features this item supports |
64 | bool m_active; // Indicates whether item is currently active | 63 | bool m_active; // Indicates whether item is currently active |
65 | }; | 64 | }; |
66 | 65 | ||
67 | class OConfItemList : public QList<OConfItem> | 66 | class OConfItemList : public QList<OConfItem> |
68 | { | 67 | { |
69 | private: | 68 | private: |
70 | 69 | ||
71 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) | 70 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) |
72 | { | 71 | { |
73 | // Sort by OConfItem location then by type | 72 | // Sort by OConfItem location then by type |
74 | OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); | 73 | OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); |
75 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); | 74 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); |
76 | if ( type1 < type2 ) | 75 | if ( type1 < type2 ) |
77 | return -1; | 76 | return -1; |
78 | else if ( type1 == type2 ) | 77 | else if ( type1 == type2 ) |
79 | { | 78 | { |
80 | QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); | 79 | QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); |
81 | QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); | 80 | QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); |
82 | if ( name1 < name2 ) | 81 | if ( name1 < name2 ) |
83 | return -1; | 82 | return -1; |
84 | else if ( name1 == name2 ) | 83 | else if ( name1 == name2 ) |
85 | return 0; | 84 | return 0; |
86 | else /*if ( name1 > name2 )*/ | 85 | else /*if ( name1 > name2 )*/ |
87 | return 1; | 86 | return 1; |
88 | } | 87 | } |
89 | else /*if ( type1 > type2 )*/ | 88 | else /*if ( type1 > type2 )*/ |
90 | return 1; | 89 | return 1; |
91 | } | 90 | } |
92 | }; | 91 | }; |
93 | 92 | ||
94 | typedef QListIterator<OConfItem> OConfItemListIterator; | 93 | typedef QListIterator<OConfItem> OConfItemListIterator; |
95 | 94 | ||
96 | #endif | 95 | #endif |
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 7bc2040..ffb3687 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -1,818 +1,817 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #include "oipkg.h" | 31 | #include "oipkg.h" |
33 | 32 | ||
34 | #include <qdir.h> | 33 | #include <qdir.h> |
35 | #include <qfile.h> | 34 | #include <qfile.h> |
36 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
37 | 36 | ||
38 | #include <stdlib.h> | 37 | #include <stdlib.h> |
39 | #include <unistd.h> | 38 | #include <unistd.h> |
40 | 39 | ||
41 | extern "C" { | 40 | extern "C" { |
42 | #include <libipkg.h> | 41 | #include <libipkg.h> |
43 | }; | 42 | }; |
44 | args_t m_ipkgArgs; // libipkg configuration arguments | 43 | args_t m_ipkgArgs; // libipkg configuration arguments |
45 | 44 | ||
46 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file | 45 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file |
47 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files | 46 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files |
48 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists | 47 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists |
49 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location | 48 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location |
50 | const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location | 49 | const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location |
51 | 50 | ||
52 | OIpkg *oipkg; | 51 | OIpkg *oipkg; |
53 | 52 | ||
54 | // Ipkg callback functions | 53 | // Ipkg callback functions |
55 | 54 | ||
56 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) | 55 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) |
57 | { | 56 | { |
58 | // Display message only if it is below the message level threshold | 57 | // Display message only if it is below the message level threshold |
59 | if ( conf && ( conf->verbosity < level ) ) | 58 | if ( conf && ( conf->verbosity < level ) ) |
60 | return 0; | 59 | return 0; |
61 | else | 60 | else |
62 | oipkg->ipkgMessage( msg ); | 61 | oipkg->ipkgMessage( msg ); |
63 | 62 | ||
64 | return 0; | 63 | return 0; |
65 | } | 64 | } |
66 | 65 | ||
67 | char *fIpkgResponse( char */*question*/ ) | 66 | char *fIpkgResponse( char */*question*/ ) |
68 | { | 67 | { |
69 | return 0l; | 68 | return 0l; |
70 | } | 69 | } |
71 | 70 | ||
72 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | 71 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) |
73 | { | 72 | { |
74 | oipkg->ipkgStatus( desc ); | 73 | oipkg->ipkgStatus( desc ); |
75 | return 0; | 74 | return 0; |
76 | } | 75 | } |
77 | 76 | ||
78 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | 77 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, |
79 | void */*userdata*/ ) | 78 | void */*userdata*/ ) |
80 | { | 79 | { |
81 | oipkg->ipkgList( desc ); | 80 | oipkg->ipkgList( desc ); |
82 | return 0; | 81 | return 0; |
83 | } | 82 | } |
84 | 83 | ||
85 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 84 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) |
86 | : QObject( parent, name ) | 85 | : QObject( parent, name ) |
87 | , m_config( config ) | 86 | , m_config( config ) |
88 | , m_confInfo( NULL ) | 87 | , m_confInfo( NULL ) |
89 | , m_ipkgExecOptions( 0 ) | 88 | , m_ipkgExecOptions( 0 ) |
90 | , m_ipkgExecVerbosity( 1 ) | 89 | , m_ipkgExecVerbosity( 1 ) |
91 | { | 90 | { |
92 | // Keep pointer to self for the Ipkg callback functions | 91 | // Keep pointer to self for the Ipkg callback functions |
93 | oipkg = this; | 92 | oipkg = this; |
94 | 93 | ||
95 | // Initialize libipkg | 94 | // Initialize libipkg |
96 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 95 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
97 | 96 | ||
98 | // Default ipkg run-time arguments | 97 | // Default ipkg run-time arguments |
99 | m_ipkgArgs.noaction = false; | 98 | m_ipkgArgs.noaction = false; |
100 | m_ipkgArgs.force_defaults = true; | 99 | m_ipkgArgs.force_defaults = true; |
101 | } | 100 | } |
102 | 101 | ||
103 | OIpkg::~OIpkg() | 102 | OIpkg::~OIpkg() |
104 | { | 103 | { |
105 | // Upon destruction, ensure that items in config list are deleted with list | 104 | // Upon destruction, ensure that items in config list are deleted with list |
106 | if ( m_confInfo ) | 105 | if ( m_confInfo ) |
107 | m_confInfo->setAutoDelete( true ); | 106 | m_confInfo->setAutoDelete( true ); |
108 | 107 | ||
109 | // Free up libipkg resources | 108 | // Free up libipkg resources |
110 | ipkg_deinit( &m_ipkgArgs ); | 109 | ipkg_deinit( &m_ipkgArgs ); |
111 | } | 110 | } |
112 | 111 | ||
113 | OConfItemList *OIpkg::configItems() | 112 | OConfItemList *OIpkg::configItems() |
114 | { | 113 | { |
115 | // Retrieve all configuration items | 114 | // Retrieve all configuration items |
116 | return filterConfItems(); | 115 | return filterConfItems(); |
117 | } | 116 | } |
118 | 117 | ||
119 | OConfItemList *OIpkg::servers() | 118 | OConfItemList *OIpkg::servers() |
120 | { | 119 | { |
121 | // Retrieve only servers | 120 | // Retrieve only servers |
122 | return filterConfItems( OConfItem::Source ); | 121 | return filterConfItems( OConfItem::Source ); |
123 | } | 122 | } |
124 | 123 | ||
125 | OConfItemList *OIpkg::destinations() | 124 | OConfItemList *OIpkg::destinations() |
126 | { | 125 | { |
127 | // Retrieve only destinations | 126 | // Retrieve only destinations |
128 | return filterConfItems( OConfItem::Destination ); | 127 | return filterConfItems( OConfItem::Destination ); |
129 | } | 128 | } |
130 | 129 | ||
131 | OConfItemList *OIpkg::options() | 130 | OConfItemList *OIpkg::options() |
132 | { | 131 | { |
133 | // Retrieve only destinations | 132 | // Retrieve only destinations |
134 | return filterConfItems( OConfItem::Option ); | 133 | return filterConfItems( OConfItem::Option ); |
135 | } | 134 | } |
136 | 135 | ||
137 | void OIpkg::setConfigItems( OConfItemList *configList ) | 136 | void OIpkg::setConfigItems( OConfItemList *configList ) |
138 | { | 137 | { |
139 | if ( m_confInfo ) | 138 | if ( m_confInfo ) |
140 | delete m_confInfo; | 139 | delete m_confInfo; |
141 | 140 | ||
142 | m_confInfo = configList; | 141 | m_confInfo = configList; |
143 | 142 | ||
144 | // Write out new /etc/ipkg.conf | 143 | // Write out new /etc/ipkg.conf |
145 | QFile confFile( IPKG_CONF ); | 144 | QFile confFile( IPKG_CONF ); |
146 | if ( confFile.open( IO_WriteOnly ) ) | 145 | if ( confFile.open( IO_WriteOnly ) ) |
147 | { | 146 | { |
148 | QTextStream confStream( &confFile ); | 147 | QTextStream confStream( &confFile ); |
149 | confStream << "# Generated by Opie Package Manager\n\n"; | 148 | confStream << "# Generated by Opie Package Manager\n\n"; |
150 | 149 | ||
151 | OConfItemListIterator it( *m_confInfo ); | 150 | OConfItemListIterator it( *m_confInfo ); |
152 | for ( ; it.current(); ++it ) | 151 | for ( ; it.current(); ++it ) |
153 | { | 152 | { |
154 | OConfItem *item = it.current(); | 153 | OConfItem *item = it.current(); |
155 | 154 | ||
156 | // Only write out valid conf items | 155 | // Only write out valid conf items |
157 | if ( item->type() != OConfItem::NotDefined ) | 156 | if ( item->type() != OConfItem::NotDefined ) |
158 | { | 157 | { |
159 | QString confLine; | 158 | QString confLine; |
160 | QString name = item->name(); | 159 | QString name = item->name(); |
161 | if ( !item->active() ) | 160 | if ( !item->active() ) |
162 | confLine = "#"; | 161 | confLine = "#"; |
163 | 162 | ||
164 | switch ( item->type() ) | 163 | switch ( item->type() ) |
165 | { | 164 | { |
166 | case OConfItem::Source : | 165 | case OConfItem::Source : |
167 | { | 166 | { |
168 | if ( item->features().contains( "Compressed" ) ) | 167 | if ( item->features().contains( "Compressed" ) ) |
169 | confLine.append( "src/gz" ); | 168 | confLine.append( "src/gz" ); |
170 | else | 169 | else |
171 | confLine.append( "src" ); | 170 | confLine.append( "src" ); |
172 | } | 171 | } |
173 | break; | 172 | break; |
174 | case OConfItem::Destination : confLine.append( "dest" ); break; | 173 | case OConfItem::Destination : confLine.append( "dest" ); break; |
175 | case OConfItem::Option : confLine.append( "option" ); break; | 174 | case OConfItem::Option : confLine.append( "option" ); break; |
176 | case OConfItem::Arch : confLine.append( "arch" ); break; | 175 | case OConfItem::Arch : confLine.append( "arch" ); break; |
177 | case OConfItem::Other : | 176 | case OConfItem::Other : |
178 | { | 177 | { |
179 | // For options w/type = Other, the mapping is as follows: | 178 | // For options w/type = Other, the mapping is as follows: |
180 | // name = typeStr (e.g. "lists_dir") | 179 | // name = typeStr (e.g. "lists_dir") |
181 | // value = value | 180 | // value = value |
182 | // features = name (from configuration file) | 181 | // features = name (from configuration file) |
183 | confLine.append( item->name() ); | 182 | confLine.append( item->name() ); |
184 | name = item->features(); | 183 | name = item->features(); |
185 | } | 184 | } |
186 | break; | 185 | break; |
187 | default : break; | 186 | default : break; |
188 | }; | 187 | }; |
189 | 188 | ||
190 | confStream << confLine << " " << name << " " << item->value() << "\n"; | 189 | confStream << confLine << " " << name << " " << item->value() << "\n"; |
191 | } | 190 | } |
192 | } | 191 | } |
193 | 192 | ||
194 | confFile.close(); | 193 | confFile.close(); |
195 | } | 194 | } |
196 | else | 195 | else |
197 | { | 196 | { |
198 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files | 197 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files |
199 | return; | 198 | return; |
200 | } | 199 | } |
201 | 200 | ||
202 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings | 201 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings |
203 | QStringList confFiles; | 202 | QStringList confFiles; |
204 | QDir confDir( IPKG_CONF_DIR ); | 203 | QDir confDir( IPKG_CONF_DIR ); |
205 | if ( confDir.exists() ) | 204 | if ( confDir.exists() ) |
206 | { | 205 | { |
207 | confDir.setNameFilter( "*.conf" ); | 206 | confDir.setNameFilter( "*.conf" ); |
208 | confDir.setFilter( QDir::Files ); | 207 | confDir.setFilter( QDir::Files ); |
209 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 208 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
210 | 209 | ||
211 | QStringList::Iterator lastFile = confFiles.end(); | 210 | QStringList::Iterator lastFile = confFiles.end(); |
212 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 211 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
213 | { | 212 | { |
214 | // Create absolute file path if necessary | 213 | // Create absolute file path if necessary |
215 | QString absFile = (*it); | 214 | QString absFile = (*it); |
216 | if ( !absFile.startsWith( "/" ) ) | 215 | if ( !absFile.startsWith( "/" ) ) |
217 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 216 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
218 | 217 | ||
219 | // Delete file | 218 | // Delete file |
220 | QFile::remove( absFile ); | 219 | QFile::remove( absFile ); |
221 | } | 220 | } |
222 | } | 221 | } |
223 | 222 | ||
224 | // Reinitialize libipkg to pick up new configuration | 223 | // Reinitialize libipkg to pick up new configuration |
225 | ipkg_deinit( &m_ipkgArgs ); | 224 | ipkg_deinit( &m_ipkgArgs ); |
226 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 225 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
227 | m_ipkgArgs.noaction = false; | 226 | m_ipkgArgs.noaction = false; |
228 | m_ipkgArgs.force_defaults = true; | 227 | m_ipkgArgs.force_defaults = true; |
229 | } | 228 | } |
230 | 229 | ||
231 | void OIpkg::saveSettings() | 230 | void OIpkg::saveSettings() |
232 | { | 231 | { |
233 | // Save Ipkg execution options to application configuration file | 232 | // Save Ipkg execution options to application configuration file |
234 | if ( m_config ) | 233 | if ( m_config ) |
235 | { | 234 | { |
236 | m_config->setGroup( "Ipkg" ); | 235 | m_config->setGroup( "Ipkg" ); |
237 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); | 236 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); |
238 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); | 237 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); |
239 | } | 238 | } |
240 | } | 239 | } |
241 | 240 | ||
242 | OPackageList *OIpkg::availablePackages( const QString &server ) | 241 | OPackageList *OIpkg::availablePackages( const QString &server ) |
243 | { | 242 | { |
244 | // Load Ipkg configuration info if not already cached | 243 | // Load Ipkg configuration info if not already cached |
245 | if ( !m_confInfo ) | 244 | if ( !m_confInfo ) |
246 | loadConfiguration(); | 245 | loadConfiguration(); |
247 | 246 | ||
248 | // Build new server list (caller is responsible for deleting) | 247 | // Build new server list (caller is responsible for deleting) |
249 | OPackageList *pl = new OPackageList; | 248 | OPackageList *pl = new OPackageList; |
250 | 249 | ||
251 | // Get directory where server lists are located | 250 | // Get directory where server lists are located |
252 | QString listsDir; | 251 | QString listsDir; |
253 | OConfItem *confItem = findConfItem( OConfItem::Other, "lists_dir" ); | 252 | OConfItem *confItem = findConfItem( OConfItem::Other, "lists_dir" ); |
254 | if ( confItem ) | 253 | if ( confItem ) |
255 | listsDir = confItem->value(); | 254 | listsDir = confItem->value(); |
256 | else | 255 | else |
257 | listsDir = IPKG_PKG_PATH; | 256 | listsDir = IPKG_PKG_PATH; |
258 | 257 | ||
259 | // Open package list file | 258 | // Open package list file |
260 | QFile f( listsDir + "/" + server ); | 259 | QFile f( listsDir + "/" + server ); |
261 | if ( !f.open( IO_ReadOnly ) ) | 260 | if ( !f.open( IO_ReadOnly ) ) |
262 | return NULL; | 261 | return NULL; |
263 | QTextStream t( &f ); | 262 | QTextStream t( &f ); |
264 | 263 | ||
265 | // Process all information in package list file | 264 | // Process all information in package list file |
266 | OPackage *package = NULL; | 265 | OPackage *package = NULL; |
267 | QString line = t.readLine(); | 266 | QString line = t.readLine(); |
268 | while ( !t.eof() ) | 267 | while ( !t.eof() ) |
269 | { | 268 | { |
270 | // Determine key/value pair | 269 | // Determine key/value pair |
271 | int pos = line.find( ':', 0 ); | 270 | int pos = line.find( ':', 0 ); |
272 | QString key; | 271 | QString key; |
273 | if ( pos > -1 ) | 272 | if ( pos > -1 ) |
274 | key = line.mid( 0, pos ); | 273 | key = line.mid( 0, pos ); |
275 | else | 274 | else |
276 | key = QString::null; | 275 | key = QString::null; |
277 | QString value = line.mid( pos+2, line.length()-pos ); | 276 | QString value = line.mid( pos+2, line.length()-pos ); |
278 | 277 | ||
279 | // Allocate new package and insert into list | 278 | // Allocate new package and insert into list |
280 | if ( package == NULL && !key.isEmpty() ) | 279 | if ( package == NULL && !key.isEmpty() ) |
281 | { | 280 | { |
282 | package = new OPackage( value ); | 281 | package = new OPackage( value ); |
283 | package->setSource( server ); | 282 | package->setSource( server ); |
284 | pl->append( package ); | 283 | pl->append( package ); |
285 | } | 284 | } |
286 | 285 | ||
287 | // Update package data | 286 | // Update package data |
288 | if ( key == "Package" ) | 287 | if ( key == "Package" ) |
289 | package->setName( value ); | 288 | package->setName( value ); |
290 | else if ( key == "Version" ) | 289 | else if ( key == "Version" ) |
291 | package->setVersion( value ); | 290 | package->setVersion( value ); |
292 | else if ( key == "Section" ) | 291 | else if ( key == "Section" ) |
293 | package->setCategory( value ); | 292 | package->setCategory( value ); |
294 | //DataManager::setAvailableCategories( value ); | 293 | //DataManager::setAvailableCategories( value ); |
295 | else if ( key.isEmpty() && value.isEmpty() ) | 294 | else if ( key.isEmpty() && value.isEmpty() ) |
296 | package = NULL; | 295 | package = NULL; |
297 | 296 | ||
298 | // Skip past all description lines | 297 | // Skip past all description lines |
299 | if ( key == "Description" ) | 298 | if ( key == "Description" ) |
300 | { | 299 | { |
301 | line = t.readLine(); | 300 | line = t.readLine(); |
302 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 301 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
303 | line = t.readLine(); | 302 | line = t.readLine(); |
304 | } | 303 | } |
305 | else | 304 | else |
306 | line = t.readLine(); | 305 | line = t.readLine(); |
307 | } | 306 | } |
308 | 307 | ||
309 | f.close(); | 308 | f.close(); |
310 | 309 | ||
311 | return pl; | 310 | return pl; |
312 | } | 311 | } |
313 | 312 | ||
314 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) | 313 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) |
315 | { | 314 | { |
316 | // Load Ipkg configuration info if not already cached | 315 | // Load Ipkg configuration info if not already cached |
317 | if ( !m_confInfo ) | 316 | if ( !m_confInfo ) |
318 | loadConfiguration(); | 317 | loadConfiguration(); |
319 | 318 | ||
320 | // Build new server list (caller is responsible for deleting) | 319 | // Build new server list (caller is responsible for deleting) |
321 | OPackageList *pl = new OPackageList; | 320 | OPackageList *pl = new OPackageList; |
322 | 321 | ||
323 | // Open status file | 322 | // Open status file |
324 | QString path = destPath; | 323 | QString path = destPath; |
325 | if ( path.right( 1 ) != "/" ) | 324 | if ( path.right( 1 ) != "/" ) |
326 | path.append( "/" ); | 325 | path.append( "/" ); |
327 | path.append( IPKG_STATUS_PATH ); | 326 | path.append( IPKG_STATUS_PATH ); |
328 | 327 | ||
329 | QFile f( path ); | 328 | QFile f( path ); |
330 | if ( !f.open( IO_ReadOnly ) ) | 329 | if ( !f.open( IO_ReadOnly ) ) |
331 | return NULL; | 330 | return NULL; |
332 | QTextStream t( &f ); | 331 | QTextStream t( &f ); |
333 | 332 | ||
334 | // Process all information in status file | 333 | // Process all information in status file |
335 | bool newPackage = false; | 334 | bool newPackage = false; |
336 | QString line = t.readLine(); | 335 | QString line = t.readLine(); |
337 | QString name; | 336 | QString name; |
338 | QString version; | 337 | QString version; |
339 | QString status; | 338 | QString status; |
340 | 339 | ||
341 | while ( !t.eof() ) | 340 | while ( !t.eof() ) |
342 | { | 341 | { |
343 | // Determine key/value pair | 342 | // Determine key/value pair |
344 | int pos = line.find( ':', 0 ); | 343 | int pos = line.find( ':', 0 ); |
345 | QString key; | 344 | QString key; |
346 | if ( pos > -1 ) | 345 | if ( pos > -1 ) |
347 | key = line.mid( 0, pos ); | 346 | key = line.mid( 0, pos ); |
348 | else | 347 | else |
349 | key = QString::null; | 348 | key = QString::null; |
350 | QString value = line.mid( pos+2, line.length()-pos ); | 349 | QString value = line.mid( pos+2, line.length()-pos ); |
351 | 350 | ||
352 | // Allocate new package and insert into list | 351 | // Allocate new package and insert into list |
353 | if ( newPackage && !key.isEmpty() ) | 352 | if ( newPackage && !key.isEmpty() ) |
354 | { | 353 | { |
355 | // Add to list only if it has a valid name and is installed | 354 | // Add to list only if it has a valid name and is installed |
356 | if ( !name.isNull() && status.contains( " installed" ) ) | 355 | if ( !name.isNull() && status.contains( " installed" ) ) |
357 | { | 356 | { |
358 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 357 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
359 | name = QString::null; | 358 | name = QString::null; |
360 | version = QString::null; | 359 | version = QString::null; |
361 | status = QString::null; | 360 | status = QString::null; |
362 | 361 | ||
363 | newPackage = false; | 362 | newPackage = false; |
364 | } | 363 | } |
365 | } | 364 | } |
366 | 365 | ||
367 | // Update package data | 366 | // Update package data |
368 | if ( key == "Package" ) | 367 | if ( key == "Package" ) |
369 | name = value; | 368 | name = value; |
370 | else if ( key == "Version" ) | 369 | else if ( key == "Version" ) |
371 | version = value; | 370 | version = value; |
372 | else if ( key == "Status" ) | 371 | else if ( key == "Status" ) |
373 | status = value; | 372 | status = value; |
374 | else if ( key.isEmpty() && value.isEmpty() ) | 373 | else if ( key.isEmpty() && value.isEmpty() ) |
375 | newPackage = true; | 374 | newPackage = true; |
376 | 375 | ||
377 | // Skip past all description lines | 376 | // Skip past all description lines |
378 | if ( key == "Description" ) | 377 | if ( key == "Description" ) |
379 | { | 378 | { |
380 | line = t.readLine(); | 379 | line = t.readLine(); |
381 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 380 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
382 | line = t.readLine(); | 381 | line = t.readLine(); |
383 | } | 382 | } |
384 | else | 383 | else |
385 | line = t.readLine(); | 384 | line = t.readLine(); |
386 | } | 385 | } |
387 | 386 | ||
388 | f.close(); | 387 | f.close(); |
389 | 388 | ||
390 | // Make sure to add to list last entry | 389 | // Make sure to add to list last entry |
391 | if ( !name.isNull() && status.contains( " installed" ) ) | 390 | if ( !name.isNull() && status.contains( " installed" ) ) |
392 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 391 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
393 | 392 | ||
394 | return pl; | 393 | return pl; |
395 | } | 394 | } |
396 | 395 | ||
397 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) | 396 | OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) |
398 | { | 397 | { |
399 | // Find configuration item in list | 398 | // Find configuration item in list |
400 | OConfItemListIterator configIt( *m_confInfo ); | 399 | OConfItemListIterator configIt( *m_confInfo ); |
401 | OConfItem *config = 0l; | 400 | OConfItem *config = 0l; |
402 | for ( ; configIt.current(); ++configIt ) | 401 | for ( ; configIt.current(); ++configIt ) |
403 | { | 402 | { |
404 | config = configIt.current(); | 403 | config = configIt.current(); |
405 | if ( config->type() == type && config->name() == name ) | 404 | if ( config->type() == type && config->name() == name ) |
406 | break; | 405 | break; |
407 | } | 406 | } |
408 | 407 | ||
409 | if ( config && config->type() == type && config->name() == name ) | 408 | if ( config && config->type() == type && config->name() == name ) |
410 | return config; | 409 | return config; |
411 | 410 | ||
412 | return 0l; | 411 | return 0l; |
413 | } | 412 | } |
414 | 413 | ||
415 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, | 414 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, |
416 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 415 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
417 | { | 416 | { |
418 | if ( command == OPackage::NotDefined ) | 417 | if ( command == OPackage::NotDefined ) |
419 | return false; | 418 | return false; |
420 | 419 | ||
421 | // Set ipkg run-time options/arguments | 420 | // Set ipkg run-time options/arguments |
422 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 421 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
423 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 422 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
424 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 423 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
425 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 424 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
426 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 425 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
427 | if ( m_ipkgArgs.dest ) | 426 | if ( m_ipkgArgs.dest ) |
428 | free( m_ipkgArgs.dest ); | 427 | free( m_ipkgArgs.dest ); |
429 | if ( !destination.isNull() ) | 428 | if ( !destination.isNull() ) |
430 | { | 429 | { |
431 | int len = destination.length() + 1; | 430 | int len = destination.length() + 1; |
432 | m_ipkgArgs.dest = (char *)malloc( len ); | 431 | m_ipkgArgs.dest = (char *)malloc( len ); |
433 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 432 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
434 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 433 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
435 | } | 434 | } |
436 | else | 435 | else |
437 | m_ipkgArgs.dest = 0l; | 436 | m_ipkgArgs.dest = 0l; |
438 | 437 | ||
439 | // Connect output signal to widget | 438 | // Connect output signal to widget |
440 | 439 | ||
441 | if ( !rawOutput ) | 440 | if ( !rawOutput ) |
442 | { | 441 | { |
443 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 442 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
444 | } | 443 | } |
445 | 444 | ||
446 | switch( command ) | 445 | switch( command ) |
447 | { | 446 | { |
448 | case OPackage::Update : { | 447 | case OPackage::Update : { |
449 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 448 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
450 | ipkg_lists_update( &m_ipkgArgs ); | 449 | ipkg_lists_update( &m_ipkgArgs ); |
451 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | 450 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); |
452 | }; | 451 | }; |
453 | break; | 452 | break; |
454 | case OPackage::Upgrade : { | 453 | case OPackage::Upgrade : { |
455 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 454 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
456 | ipkg_packages_upgrade( &m_ipkgArgs ); | 455 | ipkg_packages_upgrade( &m_ipkgArgs ); |
457 | 456 | ||
458 | // Re-link non-root destinations to make sure everything is in sync | 457 | // Re-link non-root destinations to make sure everything is in sync |
459 | OConfItemList *destList = destinations(); | 458 | OConfItemList *destList = destinations(); |
460 | OConfItemListIterator it( *destList ); | 459 | OConfItemListIterator it( *destList ); |
461 | for ( ; it.current(); ++it ) | 460 | for ( ; it.current(); ++it ) |
462 | { | 461 | { |
463 | OConfItem *dest = it.current(); | 462 | OConfItem *dest = it.current(); |
464 | if ( dest->name() != "root" ) | 463 | if ( dest->name() != "root" ) |
465 | linkPackageDir( dest->name() ); | 464 | linkPackageDir( dest->name() ); |
466 | } | 465 | } |
467 | delete destList; | 466 | delete destList; |
468 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | 467 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); |
469 | }; | 468 | }; |
470 | break; | 469 | break; |
471 | case OPackage::Install : { | 470 | case OPackage::Install : { |
472 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 471 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
473 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 472 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
474 | { | 473 | { |
475 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 474 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
476 | } | 475 | } |
477 | if ( destination != "root" ) | 476 | if ( destination != "root" ) |
478 | linkPackageDir( destination ); | 477 | linkPackageDir( destination ); |
479 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | 478 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); |
480 | }; | 479 | }; |
481 | break; | 480 | break; |
482 | case OPackage::Remove : { | 481 | case OPackage::Remove : { |
483 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 482 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
484 | 483 | ||
485 | // Get list of destinations for unlinking of packages not installed to root | 484 | // Get list of destinations for unlinking of packages not installed to root |
486 | OConfItemList *destList = destinations(); | 485 | OConfItemList *destList = destinations(); |
487 | 486 | ||
488 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 487 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
489 | { | 488 | { |
490 | unlinkPackage( (*it), destList ); | 489 | unlinkPackage( (*it), destList ); |
491 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 490 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
492 | } | 491 | } |
493 | 492 | ||
494 | delete destList; | 493 | delete destList; |
495 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | 494 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); |
496 | }; | 495 | }; |
497 | break; | 496 | break; |
498 | case OPackage::Download : { | 497 | case OPackage::Download : { |
499 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); | 498 | connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); |
500 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) | 499 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
501 | { | 500 | { |
502 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 501 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
503 | } | 502 | } |
504 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); | 503 | disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); |
505 | }; | 504 | }; |
506 | break; | 505 | break; |
507 | case OPackage::Info : { | 506 | case OPackage::Info : { |
508 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); | 507 | connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); |
509 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); | 508 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); |
510 | disconnect( this, SIGNAL(signalIpkgStatus(const QString &)), 0, 0 ); | 509 | disconnect( this, SIGNAL(signalIpkgStatus(const QString &)), 0, 0 ); |
511 | }; | 510 | }; |
512 | break; | 511 | break; |
513 | case OPackage::Files : { | 512 | case OPackage::Files : { |
514 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); | 513 | connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); |
515 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); | 514 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); |
516 | disconnect( this, SIGNAL(signalIpkgList(const QString &)), 0, 0 ); | 515 | disconnect( this, SIGNAL(signalIpkgList(const QString &)), 0, 0 ); |
517 | }; | 516 | }; |
518 | break; | 517 | break; |
519 | default : break; | 518 | default : break; |
520 | }; | 519 | }; |
521 | 520 | ||
522 | return true; | 521 | return true; |
523 | } | 522 | } |
524 | 523 | ||
525 | void OIpkg::ipkgMessage( char *msg ) | 524 | void OIpkg::ipkgMessage( char *msg ) |
526 | { | 525 | { |
527 | emit signalIpkgMessage( msg ); | 526 | emit signalIpkgMessage( msg ); |
528 | } | 527 | } |
529 | 528 | ||
530 | void OIpkg::ipkgStatus( char *status ) | 529 | void OIpkg::ipkgStatus( char *status ) |
531 | { | 530 | { |
532 | emit signalIpkgStatus( status ); | 531 | emit signalIpkgStatus( status ); |
533 | } | 532 | } |
534 | 533 | ||
535 | void OIpkg::ipkgList( char *filelist ) | 534 | void OIpkg::ipkgList( char *filelist ) |
536 | { | 535 | { |
537 | emit signalIpkgList( filelist ); | 536 | emit signalIpkgList( filelist ); |
538 | } | 537 | } |
539 | 538 | ||
540 | void OIpkg::loadConfiguration() | 539 | void OIpkg::loadConfiguration() |
541 | { | 540 | { |
542 | if ( m_confInfo ) | 541 | if ( m_confInfo ) |
543 | delete m_confInfo; | 542 | delete m_confInfo; |
544 | 543 | ||
545 | // Load configuration item list | 544 | // Load configuration item list |
546 | m_confInfo = new OConfItemList(); | 545 | m_confInfo = new OConfItemList(); |
547 | 546 | ||
548 | QStringList confFiles; | 547 | QStringList confFiles; |
549 | QDir confDir( IPKG_CONF_DIR ); | 548 | QDir confDir( IPKG_CONF_DIR ); |
550 | if ( confDir.exists() ) | 549 | if ( confDir.exists() ) |
551 | { | 550 | { |
552 | confDir.setNameFilter( "*.conf" ); | 551 | confDir.setNameFilter( "*.conf" ); |
553 | confDir.setFilter( QDir::Files ); | 552 | confDir.setFilter( QDir::Files ); |
554 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 553 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
555 | } | 554 | } |
556 | confFiles << IPKG_CONF; | 555 | confFiles << IPKG_CONF; |
557 | 556 | ||
558 | QStringList::Iterator lastFile = confFiles.end(); | 557 | QStringList::Iterator lastFile = confFiles.end(); |
559 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 558 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
560 | { | 559 | { |
561 | // Create absolute file path if necessary | 560 | // Create absolute file path if necessary |
562 | QString absFile = (*it); | 561 | QString absFile = (*it); |
563 | if ( !absFile.startsWith( "/" ) ) | 562 | if ( !absFile.startsWith( "/" ) ) |
564 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 563 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
565 | 564 | ||
566 | // Read in file | 565 | // Read in file |
567 | QFile f( absFile ); | 566 | QFile f( absFile ); |
568 | if ( f.open( IO_ReadOnly ) ) | 567 | if ( f.open( IO_ReadOnly ) ) |
569 | { | 568 | { |
570 | QTextStream s( &f ); | 569 | QTextStream s( &f ); |
571 | while ( !s.eof() ) | 570 | while ( !s.eof() ) |
572 | { | 571 | { |
573 | 572 | ||
574 | QString line = s.readLine().simplifyWhiteSpace(); | 573 | QString line = s.readLine().simplifyWhiteSpace(); |
575 | 574 | ||
576 | // Parse line and save info to the conf options list | 575 | // Parse line and save info to the conf options list |
577 | if ( !line.isEmpty() ) | 576 | if ( !line.isEmpty() ) |
578 | { | 577 | { |
579 | // Strip leading comment marker if exists | 578 | // Strip leading comment marker if exists |
580 | bool comment = false; | 579 | bool comment = false; |
581 | if ( line.startsWith( "#" ) ) | 580 | if ( line.startsWith( "#" ) ) |
582 | { | 581 | { |
583 | line.remove( 0, 1 ); | 582 | line.remove( 0, 1 ); |
584 | line = line.simplifyWhiteSpace(); | 583 | line = line.simplifyWhiteSpace(); |
585 | comment = true; | 584 | comment = true; |
586 | } | 585 | } |
587 | 586 | ||
588 | bool recognizedOption = true; | 587 | bool recognizedOption = true; |
589 | int pos = line.find( ' ', 1 ) + 1; | 588 | int pos = line.find( ' ', 1 ) + 1; |
590 | int endpos = line.find( ' ', pos ); | 589 | int endpos = line.find( ' ', pos ); |
591 | 590 | ||
592 | // Name | 591 | // Name |
593 | QString name = line.mid( pos, endpos - pos ); | 592 | QString name = line.mid( pos, endpos - pos ); |
594 | 593 | ||
595 | // Value | 594 | // Value |
596 | QString value = ""; | 595 | QString value = ""; |
597 | if ( endpos > -1 ) | 596 | if ( endpos > -1 ) |
598 | value = line.right( line.length() - endpos - 1 ); | 597 | value = line.right( line.length() - endpos - 1 ); |
599 | 598 | ||
600 | // Active | 599 | // Active |
601 | bool active = !comment; | 600 | bool active = !comment; |
602 | 601 | ||
603 | // Type | 602 | // Type |
604 | // For options w/type = Other, the mapping is as follows: | 603 | // For options w/type = Other, the mapping is as follows: |
605 | // name = typeStr (e.g. "lists_dir") | 604 | // name = typeStr (e.g. "lists_dir") |
606 | // value = value | 605 | // value = value |
607 | // features = name (from configuration file) | 606 | // features = name (from configuration file) |
608 | 607 | ||
609 | QString typeStr = line.left( pos - 1 ); | 608 | QString typeStr = line.left( pos - 1 ); |
610 | OConfItem::Type type; | 609 | OConfItem::Type type; |
611 | QString features; | 610 | QString features; |
612 | if ( typeStr == "src" ) | 611 | if ( typeStr == "src" ) |
613 | type = OConfItem::Source; | 612 | type = OConfItem::Source; |
614 | else if ( typeStr == "src/gz" ) | 613 | else if ( typeStr == "src/gz" ) |
615 | { | 614 | { |
616 | type = OConfItem::Source; | 615 | type = OConfItem::Source; |
617 | features = "Compressed"; | 616 | features = "Compressed"; |
618 | } | 617 | } |
619 | else if ( typeStr == "dest" ) | 618 | else if ( typeStr == "dest" ) |
620 | type = OConfItem::Destination; | 619 | type = OConfItem::Destination; |
621 | else if ( typeStr == "option" ) | 620 | else if ( typeStr == "option" ) |
622 | type = OConfItem::Option; | 621 | type = OConfItem::Option; |
623 | else if ( typeStr == "arch" ) | 622 | else if ( typeStr == "arch" ) |
624 | type = OConfItem::Arch; | 623 | type = OConfItem::Arch; |
625 | else if ( typeStr == "lists_dir" ) | 624 | else if ( typeStr == "lists_dir" ) |
626 | { | 625 | { |
627 | type = OConfItem::Other; | 626 | type = OConfItem::Other; |
628 | features = name; | 627 | features = name; |
629 | name = typeStr; | 628 | name = typeStr; |
630 | 629 | ||
631 | // Default value when not defined | 630 | // Default value when not defined |
632 | if ( value == QString::null || value == "" ) | 631 | if ( value == QString::null || value == "" ) |
633 | value = IPKG_PKG_PATH; | 632 | value = IPKG_PKG_PATH; |
634 | } | 633 | } |
635 | else | 634 | else |
636 | recognizedOption = false; | 635 | recognizedOption = false; |
637 | 636 | ||
638 | // Add to list | 637 | // Add to list |
639 | if ( recognizedOption ) | 638 | if ( recognizedOption ) |
640 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); | 639 | m_confInfo->append( new OConfItem( type, name, value, features, active ) ); |
641 | } | 640 | } |
642 | } | 641 | } |
643 | 642 | ||
644 | f.close(); | 643 | f.close(); |
645 | } | 644 | } |
646 | } | 645 | } |
647 | 646 | ||
648 | // Load Ipkg execution options from application configuration file | 647 | // Load Ipkg execution options from application configuration file |
649 | if ( m_config ) | 648 | if ( m_config ) |
650 | { | 649 | { |
651 | m_config->setGroup( "Ipkg" ); | 650 | m_config->setGroup( "Ipkg" ); |
652 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); | 651 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); |
653 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); | 652 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); |
654 | } | 653 | } |
655 | } | 654 | } |
656 | 655 | ||
657 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) | 656 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) |
658 | { | 657 | { |
659 | // Load Ipkg configuration info if not already cached | 658 | // Load Ipkg configuration info if not already cached |
660 | if ( !m_confInfo ) | 659 | if ( !m_confInfo ) |
661 | loadConfiguration(); | 660 | loadConfiguration(); |
662 | 661 | ||
663 | // Build new server list (caller is responsible for deleting) | 662 | // Build new server list (caller is responsible for deleting) |
664 | OConfItemList *sl = new OConfItemList; | 663 | OConfItemList *sl = new OConfItemList; |
665 | 664 | ||
666 | // If typefilter is empty, retrieve all items | 665 | // If typefilter is empty, retrieve all items |
667 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); | 666 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); |
668 | 667 | ||
669 | // Parse configuration info for servers | 668 | // Parse configuration info for servers |
670 | OConfItemListIterator it( *m_confInfo ); | 669 | OConfItemListIterator it( *m_confInfo ); |
671 | for ( ; it.current(); ++it ) | 670 | for ( ; it.current(); ++it ) |
672 | { | 671 | { |
673 | OConfItem *item = it.current(); | 672 | OConfItem *item = it.current(); |
674 | if ( retrieveAll || item->type() == typefilter ) | 673 | if ( retrieveAll || item->type() == typefilter ) |
675 | { | 674 | { |
676 | sl->append( item ); | 675 | sl->append( item ); |
677 | } | 676 | } |
678 | } | 677 | } |
679 | 678 | ||
680 | return sl; | 679 | return sl; |
681 | } | 680 | } |
682 | 681 | ||
683 | const QString &OIpkg::rootPath() | 682 | const QString &OIpkg::rootPath() |
684 | { | 683 | { |
685 | if ( m_rootPath.isEmpty() ) | 684 | if ( m_rootPath.isEmpty() ) |
686 | { | 685 | { |
687 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); | 686 | OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); |
688 | rootDest ? m_rootPath = rootDest->value() | 687 | rootDest ? m_rootPath = rootDest->value() |
689 | : m_rootPath = '/'; | 688 | : m_rootPath = '/'; |
690 | if ( m_rootPath.right( 1 ) == '/' ) | 689 | if ( m_rootPath.right( 1 ) == '/' ) |
691 | m_rootPath.truncate( m_rootPath.length() - 1 ); | 690 | m_rootPath.truncate( m_rootPath.length() - 1 ); |
692 | } | 691 | } |
693 | return m_rootPath; | 692 | return m_rootPath; |
694 | } | 693 | } |
695 | 694 | ||
696 | void OIpkg::linkPackageDir( const QString &dest ) | 695 | void OIpkg::linkPackageDir( const QString &dest ) |
697 | { | 696 | { |
698 | if ( !dest.isNull() ) | 697 | if ( !dest.isNull() ) |
699 | { | 698 | { |
700 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); | 699 | OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); |
701 | 700 | ||
702 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); | 701 | emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); |
703 | 702 | ||
704 | // Set package destination directory | 703 | // Set package destination directory |
705 | QString destDir = destConfItem->value(); | 704 | QString destDir = destConfItem->value(); |
706 | QString destInfoDir = destDir; | 705 | QString destInfoDir = destDir; |
707 | if ( destInfoDir.right( 1 ) != '/' ) | 706 | if ( destInfoDir.right( 1 ) != '/' ) |
708 | destInfoDir.append( '/' ); | 707 | destInfoDir.append( '/' ); |
709 | destInfoDir.append( IPKG_INFO_PATH ); | 708 | destInfoDir.append( IPKG_INFO_PATH ); |
710 | 709 | ||
711 | // Get list of installed packages in destination | 710 | // Get list of installed packages in destination |
712 | QDir packageDir( destInfoDir ); | 711 | QDir packageDir( destInfoDir ); |
713 | QStringList packageFiles; | 712 | QStringList packageFiles; |
714 | if ( packageDir.exists() ) | 713 | if ( packageDir.exists() ) |
715 | { | 714 | { |
716 | packageDir.setNameFilter( "*.list" ); | 715 | packageDir.setNameFilter( "*.list" ); |
717 | packageDir.setFilter( QDir::Files ); | 716 | packageDir.setFilter( QDir::Files ); |
718 | packageFiles = packageDir.entryList( "*.list", QDir::Files ); | 717 | packageFiles = packageDir.entryList( "*.list", QDir::Files ); |
719 | } | 718 | } |
720 | 719 | ||
721 | // Link all files for every package installed in desination | 720 | // Link all files for every package installed in desination |
722 | QStringList::Iterator lastFile = packageFiles.end(); | 721 | QStringList::Iterator lastFile = packageFiles.end(); |
723 | for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) | 722 | for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) |
724 | { | 723 | { |
725 | //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); | 724 | //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); |
726 | QString packageFileName = destInfoDir; | 725 | QString packageFileName = destInfoDir; |
727 | packageFileName.append( '/' ); | 726 | packageFileName.append( '/' ); |
728 | packageFileName.append( (*it) ); | 727 | packageFileName.append( (*it) ); |
729 | QFile packageFile( packageFileName ); | 728 | QFile packageFile( packageFileName ); |
730 | if ( packageFile.open( IO_ReadOnly ) ) | 729 | if ( packageFile.open( IO_ReadOnly ) ) |
731 | { | 730 | { |
732 | QTextStream t( &packageFile ); | 731 | QTextStream t( &packageFile ); |
733 | QString linkFile; | 732 | QString linkFile; |
734 | while ( !t.eof() ) | 733 | while ( !t.eof() ) |
735 | { | 734 | { |
736 | // Get the name of the file to link and build the sym link filename | 735 | // Get the name of the file to link and build the sym link filename |
737 | linkFile = t.readLine(); | 736 | linkFile = t.readLine(); |
738 | QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); | 737 | QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); |
739 | linkDest.prepend( rootPath() ); | 738 | linkDest.prepend( rootPath() ); |
740 | 739 | ||
741 | // If file installed file is actually symbolic link, use actual file for linking | 740 | // If file installed file is actually symbolic link, use actual file for linking |
742 | QFileInfo fileInfo( linkFile ); | 741 | QFileInfo fileInfo( linkFile ); |
743 | if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) | 742 | if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) |
744 | linkFile = fileInfo.readLink(); | 743 | linkFile = fileInfo.readLink(); |
745 | 744 | ||
746 | // See if directory exists in 'root', if not, create | 745 | // See if directory exists in 'root', if not, create |
747 | fileInfo.setFile( linkDest ); | 746 | fileInfo.setFile( linkDest ); |
748 | QString linkDestDirName = fileInfo.dirPath( true ); | 747 | QString linkDestDirName = fileInfo.dirPath( true ); |
749 | QDir linkDestDir( linkDestDirName ); | 748 | QDir linkDestDir( linkDestDirName ); |
750 | if ( !linkDestDir.exists() ) | 749 | if ( !linkDestDir.exists() ) |
751 | { | 750 | { |
752 | linkDestDir.mkdir( linkDestDirName ); | 751 | linkDestDir.mkdir( linkDestDirName ); |
753 | } | 752 | } |
754 | else | 753 | else |
755 | { | 754 | { |
756 | // Remove any previous link to make sure we will be pointing to the current version | 755 | // Remove any previous link to make sure we will be pointing to the current version |
757 | if ( QFile::exists( linkDest ) ) | 756 | if ( QFile::exists( linkDest ) ) |
758 | QFile::remove( linkDest ); | 757 | QFile::remove( linkDest ); |
759 | } | 758 | } |
760 | 759 | ||
761 | // Link the file | 760 | // Link the file |
762 | //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); | 761 | //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); |
763 | if ( symlink( linkFile, linkDest ) == -1 ) | 762 | if ( symlink( linkFile, linkDest ) == -1 ) |
764 | emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) | 763 | emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) |
765 | .arg( linkFile ) | 764 | .arg( linkFile ) |
766 | .arg( linkDest ) ); | 765 | .arg( linkDest ) ); |
767 | } | 766 | } |
768 | packageFile.close(); | 767 | packageFile.close(); |
769 | } | 768 | } |
770 | } | 769 | } |
771 | } | 770 | } |
772 | } | 771 | } |
773 | 772 | ||
774 | void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) | 773 | void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) |
775 | { | 774 | { |
776 | if ( !package.isNull() ) | 775 | if ( !package.isNull() ) |
777 | { | 776 | { |
778 | // Find destination package is installed in | 777 | // Find destination package is installed in |
779 | if ( destList ) | 778 | if ( destList ) |
780 | { | 779 | { |
781 | OConfItemListIterator it( *destList ); | 780 | OConfItemListIterator it( *destList ); |
782 | for ( ; it.current(); ++it ) | 781 | for ( ; it.current(); ++it ) |
783 | { | 782 | { |
784 | OConfItem *dest = it.current(); | 783 | OConfItem *dest = it.current(); |
785 | QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) | 784 | QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) |
786 | .arg( IPKG_INFO_PATH ) | 785 | .arg( IPKG_INFO_PATH ) |
787 | .arg( package ); | 786 | .arg( package ); |
788 | //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); | 787 | //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); |
789 | 788 | ||
790 | // If found and destination is not 'root', remove symbolic links | 789 | // If found and destination is not 'root', remove symbolic links |
791 | if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) | 790 | if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) |
792 | { | 791 | { |
793 | QFile destInfoFile( destInfoFileName ); | 792 | QFile destInfoFile( destInfoFileName ); |
794 | if ( destInfoFile.open( IO_ReadOnly ) ) | 793 | if ( destInfoFile.open( IO_ReadOnly ) ) |
795 | { | 794 | { |
796 | QTextStream t( &destInfoFile ); | 795 | QTextStream t( &destInfoFile ); |
797 | QString linkFile; | 796 | QString linkFile; |
798 | while ( !t.eof() ) | 797 | while ( !t.eof() ) |
799 | { | 798 | { |
800 | // Get the name of the file to link and build the sym link filename | 799 | // Get the name of the file to link and build the sym link filename |
801 | linkFile = t.readLine(); | 800 | linkFile = t.readLine(); |
802 | QString linkDest( linkFile.right( linkFile.length() - | 801 | QString linkDest( linkFile.right( linkFile.length() - |
803 | dest->value().length() ) ); | 802 | dest->value().length() ) ); |
804 | linkDest.prepend( rootPath() ); | 803 | linkDest.prepend( rootPath() ); |
805 | 804 | ||
806 | //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); | 805 | //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); |
807 | QFile::remove( linkDest ); | 806 | QFile::remove( linkDest ); |
808 | } | 807 | } |
809 | destInfoFile.close(); | 808 | destInfoFile.close(); |
810 | } | 809 | } |
811 | 810 | ||
812 | emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); | 811 | emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); |
813 | return; | 812 | return; |
814 | } | 813 | } |
815 | } | 814 | } |
816 | } | 815 | } |
817 | } | 816 | } |
818 | } | 817 | } |
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h index 4e390fa..9a7802c 100644 --- a/noncore/settings/packagemanager/oipkg.h +++ b/noncore/settings/packagemanager/oipkg.h | |||
@@ -1,111 +1,110 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #ifndef OIPKG_H | 31 | #ifndef OIPKG_H |
33 | #define OIPKG_H | 32 | #define OIPKG_H |
34 | 33 | ||
35 | #include "oconfitem.h" | 34 | #include "oconfitem.h" |
36 | #include "opackage.h" | 35 | #include "opackage.h" |
37 | 36 | ||
38 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
39 | 38 | ||
40 | #include <qobject.h> | 39 | #include <qobject.h> |
41 | 40 | ||
42 | // Ipkg execution options (m_ipkgExecOptions) | 41 | // Ipkg execution options (m_ipkgExecOptions) |
43 | #define FORCE_DEPENDS 0x0001 | 42 | #define FORCE_DEPENDS 0x0001 |
44 | #define FORCE_REMOVE 0x0002 | 43 | #define FORCE_REMOVE 0x0002 |
45 | #define FORCE_REINSTALL 0x0004 | 44 | #define FORCE_REINSTALL 0x0004 |
46 | #define FORCE_OVERWRITE 0x0008 | 45 | #define FORCE_OVERWRITE 0x0008 |
47 | 46 | ||
48 | class OConfItemList; | 47 | class OConfItemList; |
49 | 48 | ||
50 | class OIpkg : public QObject | 49 | class OIpkg : public QObject |
51 | { | 50 | { |
52 | Q_OBJECT | 51 | Q_OBJECT |
53 | 52 | ||
54 | public: | 53 | public: |
55 | OIpkg( Config *config = 0l, QObject *parent = 0l, const char *name = 0l ); | 54 | OIpkg( Config *config = 0l, QObject *parent = 0l, const char *name = 0l ); |
56 | ~OIpkg(); | 55 | ~OIpkg(); |
57 | 56 | ||
58 | OConfItemList *configItems(); | 57 | OConfItemList *configItems(); |
59 | OConfItemList *servers(); | 58 | OConfItemList *servers(); |
60 | OConfItemList *destinations(); | 59 | OConfItemList *destinations(); |
61 | OConfItemList *options(); | 60 | OConfItemList *options(); |
62 | 61 | ||
63 | int ipkgExecOptions() { return m_ipkgExecOptions; } | 62 | int ipkgExecOptions() { return m_ipkgExecOptions; } |
64 | int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } | 63 | int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } |
65 | 64 | ||
66 | void setConfigItems( OConfItemList *configList ); | 65 | void setConfigItems( OConfItemList *configList ); |
67 | void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } | 66 | void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } |
68 | void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } | 67 | void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } |
69 | 68 | ||
70 | void saveSettings(); | 69 | void saveSettings(); |
71 | 70 | ||
72 | OPackageList *availablePackages( const QString &server = QString::null ); | 71 | OPackageList *availablePackages( const QString &server = QString::null ); |
73 | OPackageList *installedPackages( const QString &destName = QString::null, | 72 | OPackageList *installedPackages( const QString &destName = QString::null, |
74 | const QString &destPath = QString::null ); | 73 | const QString &destPath = QString::null ); |
75 | 74 | ||
76 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, | 75 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, |
77 | const QString &name = QString::null ); | 76 | const QString &name = QString::null ); |
78 | 77 | ||
79 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, | 78 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, |
80 | const QStringList ¶meters = QStringList(), | 79 | const QStringList ¶meters = QStringList(), |
81 | const QString &destination = QString::null, | 80 | const QString &destination = QString::null, |
82 | const QObject *receiver = 0l, | 81 | const QObject *receiver = 0l, |
83 | const char *slotOutput = 0l, | 82 | const char *slotOutput = 0l, |
84 | bool rawOutput = true ); | 83 | bool rawOutput = true ); |
85 | void abortCommand(); | 84 | void abortCommand(); |
86 | 85 | ||
87 | void ipkgMessage( char *msg ); | 86 | void ipkgMessage( char *msg ); |
88 | void ipkgStatus( char *status ); | 87 | void ipkgStatus( char *status ); |
89 | void ipkgList( char *filelist ); | 88 | void ipkgList( char *filelist ); |
90 | 89 | ||
91 | private: | 90 | private: |
92 | Config *m_config; // Pointer to application configuration file | 91 | Config *m_config; // Pointer to application configuration file |
93 | OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files | 92 | OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files |
94 | int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options | 93 | int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options |
95 | int m_ipkgExecVerbosity; // Ipkg execution verbosity level | 94 | int m_ipkgExecVerbosity; // Ipkg execution verbosity level |
96 | QString m_rootPath; // Directory path where the 'root' destination is located | 95 | QString m_rootPath; // Directory path where the 'root' destination is located |
97 | 96 | ||
98 | void loadConfiguration(); | 97 | void loadConfiguration(); |
99 | OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); | 98 | OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); |
100 | const QString &rootPath(); | 99 | const QString &rootPath(); |
101 | void linkPackageDir( const QString &dest = QString::null ); | 100 | void linkPackageDir( const QString &dest = QString::null ); |
102 | void unlinkPackage( const QString &package = QString::null, | 101 | void unlinkPackage( const QString &package = QString::null, |
103 | OConfItemList *destList = 0l ); | 102 | OConfItemList *destList = 0l ); |
104 | 103 | ||
105 | signals: | 104 | signals: |
106 | void signalIpkgMessage( const QString &msg ); | 105 | void signalIpkgMessage( const QString &msg ); |
107 | void signalIpkgStatus( const QString &status ); | 106 | void signalIpkgStatus( const QString &status ); |
108 | void signalIpkgList( const QString &filelist ); | 107 | void signalIpkgList( const QString &filelist ); |
109 | }; | 108 | }; |
110 | 109 | ||
111 | #endif | 110 | #endif |
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp index 0ad1c82..945571f 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp +++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp | |||
@@ -1,703 +1,702 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #include "oipkgconfigdlg.h" | 31 | #include "oipkgconfigdlg.h" |
33 | 32 | ||
34 | #include <opie2/ofiledialog.h> | 33 | #include <opie2/ofiledialog.h> |
35 | 34 | ||
36 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
38 | 37 | ||
39 | #include <qcheckbox.h> | 38 | #include <qcheckbox.h> |
40 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
41 | #include <qgroupbox.h> | 40 | #include <qgroupbox.h> |
42 | #include <qlabel.h> | 41 | #include <qlabel.h> |
43 | #include <qlineedit.h> | 42 | #include <qlineedit.h> |
44 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
45 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
46 | #include <qscrollview.h> | 45 | #include <qscrollview.h> |
47 | #include <qwhatsthis.h> | 46 | #include <qwhatsthis.h> |
48 | 47 | ||
49 | OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) | 48 | OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) |
50 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) | 49 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) |
51 | , m_ipkg( ipkg ) | 50 | , m_ipkg( ipkg ) |
52 | , m_configs( 0l ) | 51 | , m_configs( 0l ) |
53 | , m_installOptions( installOptions ) | 52 | , m_installOptions( installOptions ) |
54 | , m_serverCurrent( -1 ) | 53 | , m_serverCurrent( -1 ) |
55 | , m_destCurrent( -1 ) | 54 | , m_destCurrent( -1 ) |
56 | , m_layout( this, 2, 4 ) | 55 | , m_layout( this, 2, 4 ) |
57 | , m_tabWidget( this ) | 56 | , m_tabWidget( this ) |
58 | { | 57 | { |
59 | setCaption( tr( "Configuration" ) ); | 58 | setCaption( tr( "Configuration" ) ); |
60 | 59 | ||
61 | // Initialize configuration widgets | 60 | // Initialize configuration widgets |
62 | if ( !installOptions ) | 61 | if ( !installOptions ) |
63 | { | 62 | { |
64 | initServerWidget(); | 63 | initServerWidget(); |
65 | initDestinationWidget(); | 64 | initDestinationWidget(); |
66 | initProxyWidget(); | 65 | initProxyWidget(); |
67 | } | 66 | } |
68 | initOptionsWidget(); | 67 | initOptionsWidget(); |
69 | 68 | ||
70 | // Load configuration information | 69 | // Load configuration information |
71 | initData(); | 70 | initData(); |
72 | 71 | ||
73 | // Setup tabs for all info | 72 | // Setup tabs for all info |
74 | m_layout.addWidget( &m_tabWidget ); | 73 | m_layout.addWidget( &m_tabWidget ); |
75 | if ( !m_installOptions ) | 74 | if ( !m_installOptions ) |
76 | { | 75 | { |
77 | m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); | 76 | m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); |
78 | m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); | 77 | m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); |
79 | m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); | 78 | m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); |
80 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); | 79 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); |
81 | m_tabWidget.setCurrentTab( tr( "Servers" ) ); | 80 | m_tabWidget.setCurrentTab( tr( "Servers" ) ); |
82 | } | 81 | } |
83 | else | 82 | else |
84 | { | 83 | { |
85 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); | 84 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); |
86 | } | 85 | } |
87 | } | 86 | } |
88 | 87 | ||
89 | void OIpkgConfigDlg::accept() | 88 | void OIpkgConfigDlg::accept() |
90 | { | 89 | { |
91 | // Save server, destination and proxy configuration | 90 | // Save server, destination and proxy configuration |
92 | if ( !m_installOptions ) | 91 | if ( !m_installOptions ) |
93 | { | 92 | { |
94 | // Update proxy information before saving settings | 93 | // Update proxy information before saving settings |
95 | OConfItem *confItem = m_ipkg->findConfItem( OConfItem::Option, "http_proxy" ); | 94 | OConfItem *confItem = m_ipkg->findConfItem( OConfItem::Option, "http_proxy" ); |
96 | if ( confItem ) | 95 | if ( confItem ) |
97 | { | 96 | { |
98 | confItem->setValue( m_proxyHttpServer->text() ); | 97 | confItem->setValue( m_proxyHttpServer->text() ); |
99 | confItem->setActive( m_proxyHttpActive->isChecked() ); | 98 | confItem->setActive( m_proxyHttpActive->isChecked() ); |
100 | } | 99 | } |
101 | else | 100 | else |
102 | m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", | 101 | m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", |
103 | m_proxyHttpServer->text(), QString::null, | 102 | m_proxyHttpServer->text(), QString::null, |
104 | m_proxyHttpActive->isChecked() ) ); | 103 | m_proxyHttpActive->isChecked() ) ); |
105 | 104 | ||
106 | confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" ); | 105 | confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" ); |
107 | if ( confItem ) | 106 | if ( confItem ) |
108 | { | 107 | { |
109 | confItem->setValue( m_proxyFtpServer->text() ); | 108 | confItem->setValue( m_proxyFtpServer->text() ); |
110 | confItem->setActive( m_proxyFtpActive->isChecked() ); | 109 | confItem->setActive( m_proxyFtpActive->isChecked() ); |
111 | } | 110 | } |
112 | else | 111 | else |
113 | m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", | 112 | m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", |
114 | m_proxyFtpServer->text(), QString::null, | 113 | m_proxyFtpServer->text(), QString::null, |
115 | m_proxyFtpActive->isChecked() ) ); | 114 | m_proxyFtpActive->isChecked() ) ); |
116 | 115 | ||
117 | confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" ); | 116 | confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" ); |
118 | if ( confItem ) | 117 | if ( confItem ) |
119 | confItem->setValue( m_proxyUsername->text() ); | 118 | confItem->setValue( m_proxyUsername->text() ); |
120 | else | 119 | else |
121 | m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", | 120 | m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", |
122 | m_proxyUsername->text() ) ); | 121 | m_proxyUsername->text() ) ); |
123 | 122 | ||
124 | confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_password" ); | 123 | confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_password" ); |
125 | if ( confItem ) | 124 | if ( confItem ) |
126 | confItem->setValue( m_proxyPassword->text() ); | 125 | confItem->setValue( m_proxyPassword->text() ); |
127 | else | 126 | else |
128 | m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", | 127 | m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", |
129 | m_proxyPassword->text() ) ); | 128 | m_proxyPassword->text() ) ); |
130 | 129 | ||
131 | QString listsDir = m_optSourceLists->text(); | 130 | QString listsDir = m_optSourceLists->text(); |
132 | if ( listsDir == QString::null || listsDir == "" ) | 131 | if ( listsDir == QString::null || listsDir == "" ) |
133 | listsDir = "/usr/lib/ipkg/lists"; // TODO - use proper libipkg define | 132 | listsDir = "/usr/lib/ipkg/lists"; // TODO - use proper libipkg define |
134 | confItem = m_ipkg->findConfItem( OConfItem::Other, "lists_dir" ); | 133 | confItem = m_ipkg->findConfItem( OConfItem::Other, "lists_dir" ); |
135 | if ( confItem ) | 134 | if ( confItem ) |
136 | confItem->setValue( listsDir ); | 135 | confItem->setValue( listsDir ); |
137 | else | 136 | else |
138 | m_configs->append( new OConfItem( OConfItem::Other, "lists_dir", | 137 | m_configs->append( new OConfItem( OConfItem::Other, "lists_dir", |
139 | listsDir, "name" ) ); | 138 | listsDir, "name" ) ); |
140 | 139 | ||
141 | m_ipkg->setConfigItems( m_configs ); | 140 | m_ipkg->setConfigItems( m_configs ); |
142 | } | 141 | } |
143 | 142 | ||
144 | // Save options configuration | 143 | // Save options configuration |
145 | int options = 0; | 144 | int options = 0; |
146 | if ( m_optForceDepends->isChecked() ) | 145 | if ( m_optForceDepends->isChecked() ) |
147 | options |= FORCE_DEPENDS; | 146 | options |= FORCE_DEPENDS; |
148 | if ( m_optForceReinstall->isChecked() ) | 147 | if ( m_optForceReinstall->isChecked() ) |
149 | options |= FORCE_REINSTALL; | 148 | options |= FORCE_REINSTALL; |
150 | if ( m_optForceRemove->isChecked() ) | 149 | if ( m_optForceRemove->isChecked() ) |
151 | options |= FORCE_REMOVE; | 150 | options |= FORCE_REMOVE; |
152 | if ( m_optForceOverwrite->isChecked() ) | 151 | if ( m_optForceOverwrite->isChecked() ) |
153 | options |= FORCE_OVERWRITE; | 152 | options |= FORCE_OVERWRITE; |
154 | m_ipkg->setIpkgExecOptions( options ); | 153 | m_ipkg->setIpkgExecOptions( options ); |
155 | m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); | 154 | m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); |
156 | 155 | ||
157 | QDialog::accept(); | 156 | QDialog::accept(); |
158 | } | 157 | } |
159 | 158 | ||
160 | void OIpkgConfigDlg::reject() | 159 | void OIpkgConfigDlg::reject() |
161 | { | 160 | { |
162 | if ( m_configs ) | 161 | if ( m_configs ) |
163 | delete m_configs; | 162 | delete m_configs; |
164 | } | 163 | } |
165 | 164 | ||
166 | void OIpkgConfigDlg::initServerWidget() | 165 | void OIpkgConfigDlg::initServerWidget() |
167 | { | 166 | { |
168 | m_serverWidget = new QWidget( this ); | 167 | m_serverWidget = new QWidget( this ); |
169 | 168 | ||
170 | // Initialize UI | 169 | // Initialize UI |
171 | QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); | 170 | QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); |
172 | QScrollView *sv = new QScrollView( m_serverWidget ); | 171 | QScrollView *sv = new QScrollView( m_serverWidget ); |
173 | vb->addWidget( sv, 0, 0 ); | 172 | vb->addWidget( sv, 0, 0 ); |
174 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 173 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
175 | sv->setFrameStyle( QFrame::NoFrame ); | 174 | sv->setFrameStyle( QFrame::NoFrame ); |
176 | QWidget *container = new QWidget( sv->viewport() ); | 175 | QWidget *container = new QWidget( sv->viewport() ); |
177 | sv->addChild( container ); | 176 | sv->addChild( container ); |
178 | QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); | 177 | QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); |
179 | 178 | ||
180 | m_serverList = new QListBox( container ); | 179 | m_serverList = new QListBox( container ); |
181 | QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); | 180 | QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); |
182 | m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 181 | m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
183 | connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) ); | 182 | connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) ); |
184 | layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 ); | 183 | layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 ); |
185 | 184 | ||
186 | QPixmap pic; | 185 | QPixmap pic; |
187 | pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 186 | pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
188 | QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); | 187 | QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); |
189 | btn->setMinimumHeight( AppLnk::smallIconSize() ); | 188 | btn->setMinimumHeight( AppLnk::smallIconSize() ); |
190 | QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); | 189 | QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); |
191 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); | 190 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); |
192 | layout->addWidget( btn, 1, 0 ); | 191 | layout->addWidget( btn, 1, 0 ); |
193 | 192 | ||
194 | pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 193 | pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
195 | m_serverEditBtn = new QPushButton( pic, tr( "Edit" ), container ); | 194 | m_serverEditBtn = new QPushButton( pic, tr( "Edit" ), container ); |
196 | m_serverEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); | 195 | m_serverEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); |
197 | m_serverEditBtn->setEnabled( false ); | 196 | m_serverEditBtn->setEnabled( false ); |
198 | QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) ); | 197 | QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) ); |
199 | connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) ); | 198 | connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) ); |
200 | layout->addWidget( m_serverEditBtn, 1, 1 ); | 199 | layout->addWidget( m_serverEditBtn, 1, 1 ); |
201 | 200 | ||
202 | pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 201 | pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
203 | m_serverDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); | 202 | m_serverDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); |
204 | m_serverDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); | 203 | m_serverDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); |
205 | m_serverDeleteBtn->setEnabled( false ); | 204 | m_serverDeleteBtn->setEnabled( false ); |
206 | QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); | 205 | QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); |
207 | connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); | 206 | connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); |
208 | layout->addWidget( m_serverDeleteBtn, 1, 2 ); | 207 | layout->addWidget( m_serverDeleteBtn, 1, 2 ); |
209 | } | 208 | } |
210 | 209 | ||
211 | void OIpkgConfigDlg::initDestinationWidget() | 210 | void OIpkgConfigDlg::initDestinationWidget() |
212 | { | 211 | { |
213 | m_destWidget = new QWidget( this ); | 212 | m_destWidget = new QWidget( this ); |
214 | 213 | ||
215 | // Initialize UI | 214 | // Initialize UI |
216 | QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); | 215 | QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); |
217 | QScrollView *sv = new QScrollView( m_destWidget ); | 216 | QScrollView *sv = new QScrollView( m_destWidget ); |
218 | vb->addWidget( sv, 0, 0 ); | 217 | vb->addWidget( sv, 0, 0 ); |
219 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 218 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
220 | sv->setFrameStyle( QFrame::NoFrame ); | 219 | sv->setFrameStyle( QFrame::NoFrame ); |
221 | QWidget *container = new QWidget( sv->viewport() ); | 220 | QWidget *container = new QWidget( sv->viewport() ); |
222 | sv->addChild( container ); | 221 | sv->addChild( container ); |
223 | QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); | 222 | QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); |
224 | 223 | ||
225 | m_destList = new QListBox( container ); | 224 | m_destList = new QListBox( container ); |
226 | QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) ); | 225 | QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) ); |
227 | m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 226 | m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
228 | connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) ); | 227 | connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) ); |
229 | layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 ); | 228 | layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 ); |
230 | 229 | ||
231 | QPixmap pic; | 230 | QPixmap pic; |
232 | pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 231 | pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
233 | QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); | 232 | QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); |
234 | btn->setMinimumHeight( AppLnk::smallIconSize() ); | 233 | btn->setMinimumHeight( AppLnk::smallIconSize() ); |
235 | QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); | 234 | QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); |
236 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); | 235 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); |
237 | layout->addWidget( btn, 1, 0 ); | 236 | layout->addWidget( btn, 1, 0 ); |
238 | 237 | ||
239 | pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 238 | pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
240 | m_destEditBtn = new QPushButton( pic, tr( "Edit" ), container ); | 239 | m_destEditBtn = new QPushButton( pic, tr( "Edit" ), container ); |
241 | m_destEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); | 240 | m_destEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); |
242 | m_destEditBtn->setEnabled( false ); | 241 | m_destEditBtn->setEnabled( false ); |
243 | QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) ); | 242 | QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) ); |
244 | connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) ); | 243 | connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) ); |
245 | layout->addWidget( m_destEditBtn, 1, 1 ); | 244 | layout->addWidget( m_destEditBtn, 1, 1 ); |
246 | 245 | ||
247 | pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 246 | pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
248 | m_destDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); | 247 | m_destDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); |
249 | m_destDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); | 248 | m_destDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); |
250 | m_destDeleteBtn->setEnabled( false ); | 249 | m_destDeleteBtn->setEnabled( false ); |
251 | QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); | 250 | QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); |
252 | connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); | 251 | connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); |
253 | layout->addWidget( m_destDeleteBtn, 1, 2 ); | 252 | layout->addWidget( m_destDeleteBtn, 1, 2 ); |
254 | } | 253 | } |
255 | 254 | ||
256 | void OIpkgConfigDlg::initProxyWidget() | 255 | void OIpkgConfigDlg::initProxyWidget() |
257 | { | 256 | { |
258 | m_proxyWidget = new QWidget( this ); | 257 | m_proxyWidget = new QWidget( this ); |
259 | 258 | ||
260 | // Initialize UI | 259 | // Initialize UI |
261 | QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); | 260 | QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); |
262 | QScrollView *sv = new QScrollView( m_proxyWidget ); | 261 | QScrollView *sv = new QScrollView( m_proxyWidget ); |
263 | vb->addWidget( sv, 0, 0 ); | 262 | vb->addWidget( sv, 0, 0 ); |
264 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 263 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
265 | sv->setFrameStyle( QFrame::NoFrame ); | 264 | sv->setFrameStyle( QFrame::NoFrame ); |
266 | QWidget *container = new QWidget( sv->viewport() ); | 265 | QWidget *container = new QWidget( sv->viewport() ); |
267 | sv->addChild( container ); | 266 | sv->addChild( container ); |
268 | QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); | 267 | QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); |
269 | 268 | ||
270 | // HTTP proxy server configuration | 269 | // HTTP proxy server configuration |
271 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 270 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
272 | grpbox->layout()->setSpacing( 2 ); | 271 | grpbox->layout()->setSpacing( 2 ); |
273 | grpbox->layout()->setMargin( 4 ); | 272 | grpbox->layout()->setMargin( 4 ); |
274 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 273 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
275 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 274 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
276 | m_proxyHttpServer = new QLineEdit( grpbox ); | 275 | m_proxyHttpServer = new QLineEdit( grpbox ); |
277 | QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) ); | 276 | QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) ); |
278 | grplayout->addWidget( m_proxyHttpServer ); | 277 | grplayout->addWidget( m_proxyHttpServer ); |
279 | m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox ); | 278 | m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox ); |
280 | QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) ); | 279 | QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) ); |
281 | grplayout->addWidget( m_proxyHttpActive ); | 280 | grplayout->addWidget( m_proxyHttpActive ); |
282 | 281 | ||
283 | // FTP proxy server configuration | 282 | // FTP proxy server configuration |
284 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 283 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
285 | grpbox->layout()->setSpacing( 2 ); | 284 | grpbox->layout()->setSpacing( 2 ); |
286 | grpbox->layout()->setMargin( 4 ); | 285 | grpbox->layout()->setMargin( 4 ); |
287 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 286 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
288 | grplayout = new QVBoxLayout( grpbox->layout() ); | 287 | grplayout = new QVBoxLayout( grpbox->layout() ); |
289 | m_proxyFtpServer = new QLineEdit( grpbox ); | 288 | m_proxyFtpServer = new QLineEdit( grpbox ); |
290 | QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) ); | 289 | QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) ); |
291 | grplayout->addWidget( m_proxyFtpServer ); | 290 | grplayout->addWidget( m_proxyFtpServer ); |
292 | m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox ); | 291 | m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox ); |
293 | QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) ); | 292 | QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) ); |
294 | grplayout->addWidget( m_proxyFtpActive ); | 293 | grplayout->addWidget( m_proxyFtpActive ); |
295 | 294 | ||
296 | // Proxy server username and password configuration | 295 | // Proxy server username and password configuration |
297 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 296 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
298 | QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) ); | 297 | QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) ); |
299 | layout->addWidget( label, 2, 0 ); | 298 | layout->addWidget( label, 2, 0 ); |
300 | m_proxyUsername = new QLineEdit( container ); | 299 | m_proxyUsername = new QLineEdit( container ); |
301 | QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) ); | 300 | QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) ); |
302 | layout->addWidget( m_proxyUsername, 2, 1 ); | 301 | layout->addWidget( m_proxyUsername, 2, 1 ); |
303 | 302 | ||
304 | label = new QLabel( tr( "Password:" ), container ); | 303 | label = new QLabel( tr( "Password:" ), container ); |
305 | QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) ); | 304 | QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) ); |
306 | layout->addWidget( label, 3, 0 ); | 305 | layout->addWidget( label, 3, 0 ); |
307 | m_proxyPassword = new QLineEdit( container ); | 306 | m_proxyPassword = new QLineEdit( container ); |
308 | QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) ); | 307 | QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) ); |
309 | layout->addWidget( m_proxyPassword, 3, 1 ); | 308 | layout->addWidget( m_proxyPassword, 3, 1 ); |
310 | } | 309 | } |
311 | 310 | ||
312 | void OIpkgConfigDlg::initOptionsWidget() | 311 | void OIpkgConfigDlg::initOptionsWidget() |
313 | { | 312 | { |
314 | m_optionsWidget = new QWidget( this ); | 313 | m_optionsWidget = new QWidget( this ); |
315 | 314 | ||
316 | // Initialize UI | 315 | // Initialize UI |
317 | QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget ); | 316 | QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget ); |
318 | QScrollView *sv = new QScrollView( m_optionsWidget ); | 317 | QScrollView *sv = new QScrollView( m_optionsWidget ); |
319 | vb->addWidget( sv, 0, 0 ); | 318 | vb->addWidget( sv, 0, 0 ); |
320 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 319 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
321 | sv->setFrameStyle( QFrame::NoFrame ); | 320 | sv->setFrameStyle( QFrame::NoFrame ); |
322 | QWidget *container = new QWidget( sv->viewport() ); | 321 | QWidget *container = new QWidget( sv->viewport() ); |
323 | sv->addChild( container ); | 322 | sv->addChild( container ); |
324 | QGridLayout *layout = new QGridLayout( container, 8, 2, 2, 4 ); | 323 | QGridLayout *layout = new QGridLayout( container, 8, 2, 2, 4 ); |
325 | 324 | ||
326 | m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); | 325 | m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); |
327 | QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) ); | 326 | QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) ); |
328 | layout->addMultiCellWidget( m_optForceDepends, 0, 0, 0, 1 ); | 327 | layout->addMultiCellWidget( m_optForceDepends, 0, 0, 0, 1 ); |
329 | 328 | ||
330 | m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); | 329 | m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); |
331 | QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) ); | 330 | QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) ); |
332 | layout->addMultiCellWidget( m_optForceReinstall, 1, 1, 0, 1 ); | 331 | layout->addMultiCellWidget( m_optForceReinstall, 1, 1, 0, 1 ); |
333 | 332 | ||
334 | m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); | 333 | m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); |
335 | QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) ); | 334 | QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) ); |
336 | layout->addMultiCellWidget( m_optForceRemove, 2, 2, 0, 1 ); | 335 | layout->addMultiCellWidget( m_optForceRemove, 2, 2, 0, 1 ); |
337 | 336 | ||
338 | m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); | 337 | m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); |
339 | QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) ); | 338 | QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) ); |
340 | layout->addMultiCellWidget( m_optForceOverwrite, 3, 3, 0, 1 ); | 339 | layout->addMultiCellWidget( m_optForceOverwrite, 3, 3, 0, 1 ); |
341 | 340 | ||
342 | QLabel *l = new QLabel( tr( "Information level:" ), container ); | 341 | QLabel *l = new QLabel( tr( "Information level:" ), container ); |
343 | QWhatsThis::add( l, tr( "Select information level for Ipkg." ) ); | 342 | QWhatsThis::add( l, tr( "Select information level for Ipkg." ) ); |
344 | layout->addMultiCellWidget( l, 4, 4, 0, 1 ); | 343 | layout->addMultiCellWidget( l, 4, 4, 0, 1 ); |
345 | 344 | ||
346 | m_optVerboseIpkg = new QComboBox( container ); | 345 | m_optVerboseIpkg = new QComboBox( container ); |
347 | QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) ); | 346 | QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) ); |
348 | m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); | 347 | m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); |
349 | m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); | 348 | m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); |
350 | m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); | 349 | m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); |
351 | m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); | 350 | m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); |
352 | layout->addMultiCellWidget( m_optVerboseIpkg, 5, 5, 0, 1 ); | 351 | layout->addMultiCellWidget( m_optVerboseIpkg, 5, 5, 0, 1 ); |
353 | 352 | ||
354 | l = new QLabel( tr( "Package source lists directory:" ), container ); | 353 | l = new QLabel( tr( "Package source lists directory:" ), container ); |
355 | QWhatsThis::add( l, tr( "Enter the directory where package source feed information is stored." ) ); | 354 | QWhatsThis::add( l, tr( "Enter the directory where package source feed information is stored." ) ); |
356 | layout->addMultiCellWidget( l, 6, 6, 0, 1 ); | 355 | layout->addMultiCellWidget( l, 6, 6, 0, 1 ); |
357 | 356 | ||
358 | m_optSourceLists = new QLineEdit( container ); | 357 | m_optSourceLists = new QLineEdit( container ); |
359 | QWhatsThis::add( m_optSourceLists, tr( "Enter the directory where package source feed information is stored." ) ); | 358 | QWhatsThis::add( m_optSourceLists, tr( "Enter the directory where package source feed information is stored." ) ); |
360 | layout->addWidget( m_optSourceLists, 7, 0 ); | 359 | layout->addWidget( m_optSourceLists, 7, 0 ); |
361 | QPixmap pic; | 360 | QPixmap pic; |
362 | pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 361 | pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
363 | QPushButton *btn = new QPushButton( pic, QString::null, container ); | 362 | QPushButton *btn = new QPushButton( pic, QString::null, container ); |
364 | btn->setMaximumWidth( btn->height() ); | 363 | btn->setMaximumWidth( btn->height() ); |
365 | QWhatsThis::add( btn, tr( "Tap here to select the directory where package source feed information is stored." ) ); | 364 | QWhatsThis::add( btn, tr( "Tap here to select the directory where package source feed information is stored." ) ); |
366 | connect( btn, SIGNAL(clicked()), this, SLOT(slotOptSelectSourceListsPath()) ); | 365 | connect( btn, SIGNAL(clicked()), this, SLOT(slotOptSelectSourceListsPath()) ); |
367 | layout->addWidget( btn, 7, 1 ); | 366 | layout->addWidget( btn, 7, 1 ); |
368 | 367 | ||
369 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 368 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
370 | } | 369 | } |
371 | 370 | ||
372 | void OIpkgConfigDlg::initData() | 371 | void OIpkgConfigDlg::initData() |
373 | { | 372 | { |
374 | // Read ipkg configuration (server/destination/proxy) information | 373 | // Read ipkg configuration (server/destination/proxy) information |
375 | if ( m_ipkg && !m_installOptions ) | 374 | if ( m_ipkg && !m_installOptions ) |
376 | { | 375 | { |
377 | m_configs = m_ipkg->configItems(); | 376 | m_configs = m_ipkg->configItems(); |
378 | if ( m_configs ) | 377 | if ( m_configs ) |
379 | { | 378 | { |
380 | for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) | 379 | for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) |
381 | { | 380 | { |
382 | OConfItem *config = configIt.current(); | 381 | OConfItem *config = configIt.current(); |
383 | 382 | ||
384 | // Add configuration item to the appropriate dialog controls | 383 | // Add configuration item to the appropriate dialog controls |
385 | if ( config ) | 384 | if ( config ) |
386 | { | 385 | { |
387 | switch ( config->type() ) | 386 | switch ( config->type() ) |
388 | { | 387 | { |
389 | case OConfItem::Source : m_serverList->insertItem( config->name() ); break; | 388 | case OConfItem::Source : m_serverList->insertItem( config->name() ); break; |
390 | case OConfItem::Destination : m_destList->insertItem( config->name() ); break; | 389 | case OConfItem::Destination : m_destList->insertItem( config->name() ); break; |
391 | case OConfItem::Option : | 390 | case OConfItem::Option : |
392 | { | 391 | { |
393 | if ( config->name() == "http_proxy" ) | 392 | if ( config->name() == "http_proxy" ) |
394 | { | 393 | { |
395 | m_proxyHttpServer->setText( config->value() ); | 394 | m_proxyHttpServer->setText( config->value() ); |
396 | m_proxyHttpActive->setChecked( config->active() ); | 395 | m_proxyHttpActive->setChecked( config->active() ); |
397 | } | 396 | } |
398 | else if ( config->name() == "ftp_proxy" ) | 397 | else if ( config->name() == "ftp_proxy" ) |
399 | { | 398 | { |
400 | m_proxyFtpServer->setText( config->value() ); | 399 | m_proxyFtpServer->setText( config->value() ); |
401 | m_proxyFtpActive->setChecked( config->active() ); | 400 | m_proxyFtpActive->setChecked( config->active() ); |
402 | } | 401 | } |
403 | else if ( config->name() == "proxy_username" ) | 402 | else if ( config->name() == "proxy_username" ) |
404 | { | 403 | { |
405 | m_proxyUsername->setText( config->value() ); | 404 | m_proxyUsername->setText( config->value() ); |
406 | } | 405 | } |
407 | else if ( config->name() == "proxy_password" ) | 406 | else if ( config->name() == "proxy_password" ) |
408 | { | 407 | { |
409 | m_proxyPassword->setText( config->value() ); | 408 | m_proxyPassword->setText( config->value() ); |
410 | } | 409 | } |
411 | } | 410 | } |
412 | break; | 411 | break; |
413 | case OConfItem::Other : | 412 | case OConfItem::Other : |
414 | { | 413 | { |
415 | if ( config->name() == "lists_dir" ) | 414 | if ( config->name() == "lists_dir" ) |
416 | m_optSourceLists->setText( config->value() ); | 415 | m_optSourceLists->setText( config->value() ); |
417 | else // TODO - use proper libipkg define | 416 | else // TODO - use proper libipkg define |
418 | m_optSourceLists->setText( "/usr/lib/ipkg/lists" ); | 417 | m_optSourceLists->setText( "/usr/lib/ipkg/lists" ); |
419 | } | 418 | } |
420 | break; | 419 | break; |
421 | default : break; | 420 | default : break; |
422 | }; | 421 | }; |
423 | } | 422 | } |
424 | } | 423 | } |
425 | } | 424 | } |
426 | } | 425 | } |
427 | 426 | ||
428 | // Get Ipkg execution options | 427 | // Get Ipkg execution options |
429 | int options = m_ipkg->ipkgExecOptions(); | 428 | int options = m_ipkg->ipkgExecOptions(); |
430 | if ( options & FORCE_DEPENDS ) | 429 | if ( options & FORCE_DEPENDS ) |
431 | m_optForceDepends->setChecked( true ); | 430 | m_optForceDepends->setChecked( true ); |
432 | if ( options & FORCE_REINSTALL ) | 431 | if ( options & FORCE_REINSTALL ) |
433 | m_optForceReinstall->setChecked( true ); | 432 | m_optForceReinstall->setChecked( true ); |
434 | if ( options & FORCE_REMOVE ) | 433 | if ( options & FORCE_REMOVE ) |
435 | m_optForceRemove->setChecked( true ); | 434 | m_optForceRemove->setChecked( true ); |
436 | if ( options & FORCE_OVERWRITE ) | 435 | if ( options & FORCE_OVERWRITE ) |
437 | m_optForceOverwrite->setChecked( true ); | 436 | m_optForceOverwrite->setChecked( true ); |
438 | 437 | ||
439 | m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); | 438 | m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); |
440 | } | 439 | } |
441 | 440 | ||
442 | void OIpkgConfigDlg::slotServerSelected( int index ) | 441 | void OIpkgConfigDlg::slotServerSelected( int index ) |
443 | { | 442 | { |
444 | m_serverCurrent = index; | 443 | m_serverCurrent = index; |
445 | 444 | ||
446 | // Enable Edit and Delete buttons | 445 | // Enable Edit and Delete buttons |
447 | m_serverEditBtn->setEnabled( true ); | 446 | m_serverEditBtn->setEnabled( true ); |
448 | m_serverDeleteBtn->setEnabled( true ); | 447 | m_serverDeleteBtn->setEnabled( true ); |
449 | } | 448 | } |
450 | 449 | ||
451 | void OIpkgConfigDlg::slotServerNew() | 450 | void OIpkgConfigDlg::slotServerNew() |
452 | { | 451 | { |
453 | OConfItem *server = new OConfItem( OConfItem::Source ); | 452 | OConfItem *server = new OConfItem( OConfItem::Source ); |
454 | 453 | ||
455 | OIpkgServerDlg dlg( server, this ); | 454 | OIpkgServerDlg dlg( server, this ); |
456 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 455 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
457 | { | 456 | { |
458 | // Add to configuration option list | 457 | // Add to configuration option list |
459 | m_configs->append( server ); | 458 | m_configs->append( server ); |
460 | m_configs->sort(); | 459 | m_configs->sort(); |
461 | 460 | ||
462 | // Add to server list | 461 | // Add to server list |
463 | m_serverList->insertItem( server->name() ); | 462 | m_serverList->insertItem( server->name() ); |
464 | m_serverList->setCurrentItem( m_serverList->count() ); | 463 | m_serverList->setCurrentItem( m_serverList->count() ); |
465 | } | 464 | } |
466 | else | 465 | else |
467 | delete server; | 466 | delete server; |
468 | } | 467 | } |
469 | 468 | ||
470 | void OIpkgConfigDlg::slotServerEdit() | 469 | void OIpkgConfigDlg::slotServerEdit() |
471 | { | 470 | { |
472 | // Find selected server in list | 471 | // Find selected server in list |
473 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); | 472 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); |
474 | 473 | ||
475 | // Edit server | 474 | // Edit server |
476 | if ( server ) | 475 | if ( server ) |
477 | { | 476 | { |
478 | QString origName = server->name(); | 477 | QString origName = server->name(); |
479 | OIpkgServerDlg dlg( server, this ); | 478 | OIpkgServerDlg dlg( server, this ); |
480 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 479 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
481 | { | 480 | { |
482 | // Check to see if name has changed, if so update the server list | 481 | // Check to see if name has changed, if so update the server list |
483 | if ( server->name() != origName ) | 482 | if ( server->name() != origName ) |
484 | m_serverList->changeItem( server->name(), m_serverCurrent ); | 483 | m_serverList->changeItem( server->name(), m_serverCurrent ); |
485 | } | 484 | } |
486 | } | 485 | } |
487 | } | 486 | } |
488 | 487 | ||
489 | void OIpkgConfigDlg::slotServerDelete() | 488 | void OIpkgConfigDlg::slotServerDelete() |
490 | { | 489 | { |
491 | // Find selected server in list | 490 | // Find selected server in list |
492 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); | 491 | OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); |
493 | 492 | ||
494 | // Delete server | 493 | // Delete server |
495 | if ( server ) | 494 | if ( server ) |
496 | { | 495 | { |
497 | m_configs->removeRef( server ); | 496 | m_configs->removeRef( server ); |
498 | m_serverList->removeItem( m_serverCurrent ); | 497 | m_serverList->removeItem( m_serverCurrent ); |
499 | } | 498 | } |
500 | } | 499 | } |
501 | 500 | ||
502 | void OIpkgConfigDlg::slotDestSelected( int index ) | 501 | void OIpkgConfigDlg::slotDestSelected( int index ) |
503 | { | 502 | { |
504 | m_destCurrent = index; | 503 | m_destCurrent = index; |
505 | 504 | ||
506 | // Enable Edit and Delete buttons | 505 | // Enable Edit and Delete buttons |
507 | m_destEditBtn->setEnabled( true ); | 506 | m_destEditBtn->setEnabled( true ); |
508 | m_destDeleteBtn->setEnabled( true ); | 507 | m_destDeleteBtn->setEnabled( true ); |
509 | } | 508 | } |
510 | 509 | ||
511 | void OIpkgConfigDlg::slotDestNew() | 510 | void OIpkgConfigDlg::slotDestNew() |
512 | { | 511 | { |
513 | OConfItem *dest = new OConfItem( OConfItem::Destination ); | 512 | OConfItem *dest = new OConfItem( OConfItem::Destination ); |
514 | 513 | ||
515 | OIpkgDestDlg dlg( dest, this ); | 514 | OIpkgDestDlg dlg( dest, this ); |
516 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 515 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
517 | { | 516 | { |
518 | // Add to configuration option list | 517 | // Add to configuration option list |
519 | m_configs->append( dest ); | 518 | m_configs->append( dest ); |
520 | m_configs->sort(); | 519 | m_configs->sort(); |
521 | 520 | ||
522 | // Add to destination list | 521 | // Add to destination list |
523 | m_destList->insertItem( dest->name() ); | 522 | m_destList->insertItem( dest->name() ); |
524 | m_destList->setCurrentItem( m_destList->count() ); | 523 | m_destList->setCurrentItem( m_destList->count() ); |
525 | } | 524 | } |
526 | else | 525 | else |
527 | delete dest; | 526 | delete dest; |
528 | } | 527 | } |
529 | 528 | ||
530 | void OIpkgConfigDlg::slotDestEdit() | 529 | void OIpkgConfigDlg::slotDestEdit() |
531 | { | 530 | { |
532 | // Find selected destination in list | 531 | // Find selected destination in list |
533 | OConfItem *dest = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() ); | 532 | OConfItem *dest = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() ); |
534 | 533 | ||
535 | // Edit destination | 534 | // Edit destination |
536 | if ( dest ) | 535 | if ( dest ) |
537 | { | 536 | { |
538 | QString origName = dest->name(); | 537 | QString origName = dest->name(); |
539 | OIpkgDestDlg dlg( dest, this ); | 538 | OIpkgDestDlg dlg( dest, this ); |
540 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 539 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
541 | { | 540 | { |
542 | // Check to see if name has changed, if so update the dest list | 541 | // Check to see if name has changed, if so update the dest list |
543 | if ( dest->name() != origName ) | 542 | if ( dest->name() != origName ) |
544 | m_destList->changeItem( dest->name(), m_destCurrent ); | 543 | m_destList->changeItem( dest->name(), m_destCurrent ); |
545 | } | 544 | } |
546 | } | 545 | } |
547 | } | 546 | } |
548 | 547 | ||
549 | void OIpkgConfigDlg::slotDestDelete() | 548 | void OIpkgConfigDlg::slotDestDelete() |
550 | { | 549 | { |
551 | // Find selected destination in list | 550 | // Find selected destination in list |
552 | OConfItem *destination = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() ); | 551 | OConfItem *destination = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() ); |
553 | 552 | ||
554 | // Delete destination | 553 | // Delete destination |
555 | if ( destination ) | 554 | if ( destination ) |
556 | { | 555 | { |
557 | m_configs->removeRef( destination ); | 556 | m_configs->removeRef( destination ); |
558 | m_destList->removeItem( m_destCurrent ); | 557 | m_destList->removeItem( m_destCurrent ); |
559 | } | 558 | } |
560 | } | 559 | } |
561 | 560 | ||
562 | void OIpkgConfigDlg::slotOptSelectSourceListsPath() | 561 | void OIpkgConfigDlg::slotOptSelectSourceListsPath() |
563 | { | 562 | { |
564 | QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_optSourceLists->text() ); | 563 | QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_optSourceLists->text() ); |
565 | if ( path.at( path.length() - 1 ) == '/' ) | 564 | if ( path.at( path.length() - 1 ) == '/' ) |
566 | path.truncate( path.length() - 1 ); | 565 | path.truncate( path.length() - 1 ); |
567 | if ( !path.isNull() ) | 566 | if ( !path.isNull() ) |
568 | m_optSourceLists->setText( path ); | 567 | m_optSourceLists->setText( path ); |
569 | } | 568 | } |
570 | 569 | ||
571 | OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent ) | 570 | OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent ) |
572 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) | 571 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) |
573 | , m_server( server ) | 572 | , m_server( server ) |
574 | { | 573 | { |
575 | setCaption( tr( "Edit Server" ) ); | 574 | setCaption( tr( "Edit Server" ) ); |
576 | 575 | ||
577 | // Initialize UI | 576 | // Initialize UI |
578 | QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 ); | 577 | QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 ); |
579 | 578 | ||
580 | m_active = new QCheckBox( tr( "Active" ), this ); | 579 | m_active = new QCheckBox( tr( "Active" ), this ); |
581 | QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) ); | 580 | QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) ); |
582 | layout->addWidget( m_active ); | 581 | layout->addWidget( m_active ); |
583 | 582 | ||
584 | layout->addStretch(); | 583 | layout->addStretch(); |
585 | 584 | ||
586 | QLabel *label = new QLabel( tr( "Name:" ), this ); | 585 | QLabel *label = new QLabel( tr( "Name:" ), this ); |
587 | QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); | 586 | QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); |
588 | layout->addWidget( label ); | 587 | layout->addWidget( label ); |
589 | m_name = new QLineEdit( this ); | 588 | m_name = new QLineEdit( this ); |
590 | QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) ); | 589 | QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) ); |
591 | layout->addWidget( m_name ); | 590 | layout->addWidget( m_name ); |
592 | 591 | ||
593 | layout->addStretch(); | 592 | layout->addStretch(); |
594 | 593 | ||
595 | label = new QLabel( tr( "Address:" ), this ); | 594 | label = new QLabel( tr( "Address:" ), this ); |
596 | QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) ); | 595 | QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) ); |
597 | layout->addWidget( label ); | 596 | layout->addWidget( label ); |
598 | m_location = new QLineEdit( this ); | 597 | m_location = new QLineEdit( this ); |
599 | QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) ); | 598 | QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) ); |
600 | layout->addWidget( m_location ); | 599 | layout->addWidget( m_location ); |
601 | 600 | ||
602 | layout->addStretch(); | 601 | layout->addStretch(); |
603 | 602 | ||
604 | m_compressed = new QCheckBox( tr( "Compressed server feed" ), this ); | 603 | m_compressed = new QCheckBox( tr( "Compressed server feed" ), this ); |
605 | QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) ); | 604 | QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) ); |
606 | layout->addWidget( m_compressed ); | 605 | layout->addWidget( m_compressed ); |
607 | 606 | ||
608 | // Populate initial information | 607 | // Populate initial information |
609 | if ( m_server ) | 608 | if ( m_server ) |
610 | { | 609 | { |
611 | m_name->setText( m_server->name() ); | 610 | m_name->setText( m_server->name() ); |
612 | m_location->setText( m_server->value() ); | 611 | m_location->setText( m_server->value() ); |
613 | m_compressed->setChecked( m_server->features().contains( "Compressed" ) ); | 612 | m_compressed->setChecked( m_server->features().contains( "Compressed" ) ); |
614 | m_active->setChecked( m_server->active() ); | 613 | m_active->setChecked( m_server->active() ); |
615 | } | 614 | } |
616 | } | 615 | } |
617 | 616 | ||
618 | void OIpkgServerDlg::accept() | 617 | void OIpkgServerDlg::accept() |
619 | { | 618 | { |
620 | // Save information entered | 619 | // Save information entered |
621 | QString name = m_name->text(); | 620 | QString name = m_name->text(); |
622 | name.replace( QRegExp( " " ), "_" ); | 621 | name.replace( QRegExp( " " ), "_" ); |
623 | m_server->setName( name ); | 622 | m_server->setName( name ); |
624 | m_server->setValue( m_location->text() ); | 623 | m_server->setValue( m_location->text() ); |
625 | m_compressed->isChecked() ? m_server->setFeatures( "Compressed" ) | 624 | m_compressed->isChecked() ? m_server->setFeatures( "Compressed" ) |
626 | : m_server->setFeatures( QString::null ); | 625 | : m_server->setFeatures( QString::null ); |
627 | m_server->setActive( m_active->isChecked() ); | 626 | m_server->setActive( m_active->isChecked() ); |
628 | 627 | ||
629 | QDialog::accept(); | 628 | QDialog::accept(); |
630 | } | 629 | } |
631 | 630 | ||
632 | OIpkgDestDlg::OIpkgDestDlg( OConfItem *dest, QWidget *parent ) | 631 | OIpkgDestDlg::OIpkgDestDlg( OConfItem *dest, QWidget *parent ) |
633 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) | 632 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) |
634 | , m_dest( dest ) | 633 | , m_dest( dest ) |
635 | { | 634 | { |
636 | setCaption( tr( "Edit Destination" ) ); | 635 | setCaption( tr( "Edit Destination" ) ); |
637 | 636 | ||
638 | // Initialize UI | 637 | // Initialize UI |
639 | QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 ); | 638 | QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 ); |
640 | 639 | ||
641 | m_active = new QCheckBox( tr( "Active" ), this ); | 640 | m_active = new QCheckBox( tr( "Active" ), this ); |
642 | QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) ); | 641 | QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) ); |
643 | layout->addWidget( m_active ); | 642 | layout->addWidget( m_active ); |
644 | 643 | ||
645 | layout->addStretch(); | 644 | layout->addStretch(); |
646 | 645 | ||
647 | QLabel *label = new QLabel( tr( "Name:" ), this ); | 646 | QLabel *label = new QLabel( tr( "Name:" ), this ); |
648 | QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); | 647 | QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); |
649 | layout->addWidget( label ); | 648 | layout->addWidget( label ); |
650 | m_name = new QLineEdit( this ); | 649 | m_name = new QLineEdit( this ); |
651 | QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) ); | 650 | QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) ); |
652 | layout->addWidget( m_name ); | 651 | layout->addWidget( m_name ); |
653 | 652 | ||
654 | layout->addStretch(); | 653 | layout->addStretch(); |
655 | 654 | ||
656 | label = new QLabel( tr( "Location:" ), this ); | 655 | label = new QLabel( tr( "Location:" ), this ); |
657 | QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) ); | 656 | QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) ); |
658 | layout->addWidget( label ); | 657 | layout->addWidget( label ); |
659 | 658 | ||
660 | QHBoxLayout *layout2 = new QHBoxLayout( this, 2, 4 ); | 659 | QHBoxLayout *layout2 = new QHBoxLayout( this, 2, 4 ); |
661 | layout->addLayout( layout2 ); | 660 | layout->addLayout( layout2 ); |
662 | 661 | ||
663 | m_location = new QLineEdit( this ); | 662 | m_location = new QLineEdit( this ); |
664 | QWhatsThis::add( m_location, tr( "Enter the absolute directory path of this entry here." ) ); | 663 | QWhatsThis::add( m_location, tr( "Enter the absolute directory path of this entry here." ) ); |
665 | layout2->addWidget( m_location ); | 664 | layout2->addWidget( m_location ); |
666 | QPixmap pic; | 665 | QPixmap pic; |
667 | pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 666 | pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
668 | QPushButton *btn = new QPushButton( pic, QString::null, this ); | 667 | QPushButton *btn = new QPushButton( pic, QString::null, this ); |
669 | btn->setMaximumWidth( btn->height() ); | 668 | btn->setMaximumWidth( btn->height() ); |
670 | QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) ); | 669 | QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) ); |
671 | connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) ); | 670 | connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) ); |
672 | layout2->addWidget( btn ); | 671 | layout2->addWidget( btn ); |
673 | 672 | ||
674 | // Populate initial information | 673 | // Populate initial information |
675 | if ( m_dest ) | 674 | if ( m_dest ) |
676 | { | 675 | { |
677 | m_name->setText( m_dest->name() ); | 676 | m_name->setText( m_dest->name() ); |
678 | m_location->setText( m_dest->value() ); | 677 | m_location->setText( m_dest->value() ); |
679 | m_active->setChecked( m_dest->active() ); | 678 | m_active->setChecked( m_dest->active() ); |
680 | } | 679 | } |
681 | } | 680 | } |
682 | 681 | ||
683 | void OIpkgDestDlg::accept() | 682 | void OIpkgDestDlg::accept() |
684 | { | 683 | { |
685 | // Save information entered | 684 | // Save information entered |
686 | QString name = m_name->text(); | 685 | QString name = m_name->text(); |
687 | name.replace( QRegExp( " " ), "_" ); | 686 | name.replace( QRegExp( " " ), "_" ); |
688 | m_dest->setName( name ); | 687 | m_dest->setName( name ); |
689 | m_dest->setValue( m_location->text() ); | 688 | m_dest->setValue( m_location->text() ); |
690 | m_dest->setActive( m_active->isChecked() ); | 689 | m_dest->setActive( m_active->isChecked() ); |
691 | 690 | ||
692 | QDialog::accept(); | 691 | QDialog::accept(); |
693 | } | 692 | } |
694 | 693 | ||
695 | void OIpkgDestDlg::slotSelectPath() | 694 | void OIpkgDestDlg::slotSelectPath() |
696 | { | 695 | { |
697 | QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_location->text() ); | 696 | QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_location->text() ); |
698 | if ( path.at( path.length() - 1 ) == '/' ) | 697 | if ( path.at( path.length() - 1 ) == '/' ) |
699 | path.truncate( path.length() - 1 ); | 698 | path.truncate( path.length() - 1 ); |
700 | if ( !path.isNull() ) | 699 | if ( !path.isNull() ) |
701 | m_location->setText( path ); | 700 | m_location->setText( path ); |
702 | } | 701 | } |
703 | 702 | ||
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h index 9e23b62..88381ab 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.h +++ b/noncore/settings/packagemanager/oipkgconfigdlg.h | |||
@@ -1,167 +1,165 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | |||
33 | #ifndef OIPKGCONFIGDLG_H | 31 | #ifndef OIPKGCONFIGDLG_H |
34 | #define OIPKGCONFIGDLG_H | 32 | #define OIPKGCONFIGDLG_H |
35 | 33 | ||
36 | #include <opie2/otabwidget.h> | 34 | #include <opie2/otabwidget.h> |
37 | 35 | ||
38 | #include <qdialog.h> | 36 | #include <qdialog.h> |
39 | #include <qlayout.h> | 37 | #include <qlayout.h> |
40 | 38 | ||
41 | #include "oipkg.h" | 39 | #include "oipkg.h" |
42 | 40 | ||
43 | class QCheckBox; | 41 | class QCheckBox; |
44 | class QComboBox; | 42 | class QComboBox; |
45 | class QLineEdit; | 43 | class QLineEdit; |
46 | class QListBox; | 44 | class QListBox; |
47 | class QPushButton; | 45 | class QPushButton; |
48 | 46 | ||
49 | class OIpkgConfigDlg : public QDialog | 47 | class OIpkgConfigDlg : public QDialog |
50 | { | 48 | { |
51 | Q_OBJECT | 49 | Q_OBJECT |
52 | 50 | ||
53 | public: | 51 | public: |
54 | OIpkgConfigDlg( OIpkg *ipkg = 0l, bool installOptions = false, QWidget *parent = 0l ); | 52 | OIpkgConfigDlg( OIpkg *ipkg = 0l, bool installOptions = false, QWidget *parent = 0l ); |
55 | 53 | ||
56 | protected slots: | 54 | protected slots: |
57 | void accept(); | 55 | void accept(); |
58 | void reject(); | 56 | void reject(); |
59 | 57 | ||
60 | private: | 58 | private: |
61 | OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options | 59 | OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options |
62 | OConfItemList *m_configs; // Local list of configuration items | 60 | OConfItemList *m_configs; // Local list of configuration items |
63 | 61 | ||
64 | bool m_installOptions; // If true, will only display the Options tab | 62 | bool m_installOptions; // If true, will only display the Options tab |
65 | 63 | ||
66 | // Server/Destination cached information | 64 | // Server/Destination cached information |
67 | int m_serverCurrent; // Index of currently selected server in m_serverList | 65 | int m_serverCurrent; // Index of currently selected server in m_serverList |
68 | int m_destCurrent; // Index of currently selected destination in m_destList | 66 | int m_destCurrent; // Index of currently selected destination in m_destList |
69 | 67 | ||
70 | // UI controls | 68 | // UI controls |
71 | QVBoxLayout m_layout; // Main dialog layout control | 69 | QVBoxLayout m_layout; // Main dialog layout control |
72 | Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control | 70 | Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control |
73 | QWidget *m_serverWidget; // Widget containing server configuration controls | 71 | QWidget *m_serverWidget; // Widget containing server configuration controls |
74 | QWidget *m_destWidget; // Widget containing destination configuration controls | 72 | QWidget *m_destWidget; // Widget containing destination configuration controls |
75 | QWidget *m_proxyWidget; // Widget containing proxy configuration controls | 73 | QWidget *m_proxyWidget; // Widget containing proxy configuration controls |
76 | QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls | 74 | QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls |
77 | 75 | ||
78 | // Server configuration UI controls | 76 | // Server configuration UI controls |
79 | QListBox *m_serverList; // Server list selection | 77 | QListBox *m_serverList; // Server list selection |
80 | QPushButton *m_serverEditBtn; // Server edit button | 78 | QPushButton *m_serverEditBtn; // Server edit button |
81 | QPushButton *m_serverDeleteBtn; // Server edit button | 79 | QPushButton *m_serverDeleteBtn; // Server edit button |
82 | 80 | ||
83 | // Destination configuration UI controls | 81 | // Destination configuration UI controls |
84 | QListBox *m_destList; // Destination list selection | 82 | QListBox *m_destList; // Destination list selection |
85 | QPushButton *m_destEditBtn; // Destination edit button | 83 | QPushButton *m_destEditBtn; // Destination edit button |
86 | QPushButton *m_destDeleteBtn; // Destination edit button | 84 | QPushButton *m_destDeleteBtn; // Destination edit button |
87 | 85 | ||
88 | // Proxy server configuration UI controls | 86 | // Proxy server configuration UI controls |
89 | QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box | 87 | QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box |
90 | QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box | 88 | QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box |
91 | QLineEdit *m_proxyFtpServer; // FTP proxy server edit box | 89 | QLineEdit *m_proxyFtpServer; // FTP proxy server edit box |
92 | QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box | 90 | QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box |
93 | QLineEdit *m_proxyUsername; // Proxy server username edit box | 91 | QLineEdit *m_proxyUsername; // Proxy server username edit box |
94 | QLineEdit *m_proxyPassword; // Proxy server password edit box | 92 | QLineEdit *m_proxyPassword; // Proxy server password edit box |
95 | 93 | ||
96 | // Options configuration UI controls | 94 | // Options configuration UI controls |
97 | QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox | 95 | QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox |
98 | QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox | 96 | QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox |
99 | QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox | 97 | QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox |
100 | QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox | 98 | QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox |
101 | QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection | 99 | QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection |
102 | QLineEdit *m_optSourceLists; // Ipkg source lists destination directory | 100 | QLineEdit *m_optSourceLists; // Ipkg source lists destination directory |
103 | 101 | ||
104 | void initServerWidget(); | 102 | void initServerWidget(); |
105 | void initDestinationWidget(); | 103 | void initDestinationWidget(); |
106 | void initProxyWidget(); | 104 | void initProxyWidget(); |
107 | void initOptionsWidget(); | 105 | void initOptionsWidget(); |
108 | 106 | ||
109 | void initData(); | 107 | void initData(); |
110 | 108 | ||
111 | private slots: | 109 | private slots: |
112 | void slotServerSelected( int index ); | 110 | void slotServerSelected( int index ); |
113 | void slotServerNew(); | 111 | void slotServerNew(); |
114 | void slotServerEdit(); | 112 | void slotServerEdit(); |
115 | void slotServerDelete(); | 113 | void slotServerDelete(); |
116 | 114 | ||
117 | void slotDestSelected( int index ); | 115 | void slotDestSelected( int index ); |
118 | void slotDestNew(); | 116 | void slotDestNew(); |
119 | void slotDestEdit(); | 117 | void slotDestEdit(); |
120 | void slotDestDelete(); | 118 | void slotDestDelete(); |
121 | 119 | ||
122 | void slotOptSelectSourceListsPath(); | 120 | void slotOptSelectSourceListsPath(); |
123 | }; | 121 | }; |
124 | 122 | ||
125 | class OIpkgServerDlg : public QDialog | 123 | class OIpkgServerDlg : public QDialog |
126 | { | 124 | { |
127 | Q_OBJECT | 125 | Q_OBJECT |
128 | 126 | ||
129 | public: | 127 | public: |
130 | OIpkgServerDlg( OConfItem *server = 0l, QWidget *parent = 0l ); | 128 | OIpkgServerDlg( OConfItem *server = 0l, QWidget *parent = 0l ); |
131 | 129 | ||
132 | protected slots: | 130 | protected slots: |
133 | void accept(); | 131 | void accept(); |
134 | 132 | ||
135 | private: | 133 | private: |
136 | OConfItem *m_server; | 134 | OConfItem *m_server; |
137 | 135 | ||
138 | // UI controls | 136 | // UI controls |
139 | QLineEdit *m_name; // Server name edit box | 137 | QLineEdit *m_name; // Server name edit box |
140 | QLineEdit *m_location; // Server location URL edit box | 138 | QLineEdit *m_location; // Server location URL edit box |
141 | QCheckBox *m_compressed; // Indicates whether the server is a 'src/gz' feed | 139 | QCheckBox *m_compressed; // Indicates whether the server is a 'src/gz' feed |
142 | QCheckBox *m_active; // Indicates whether the server is activated | 140 | QCheckBox *m_active; // Indicates whether the server is activated |
143 | }; | 141 | }; |
144 | 142 | ||
145 | class OIpkgDestDlg : public QDialog | 143 | class OIpkgDestDlg : public QDialog |
146 | { | 144 | { |
147 | Q_OBJECT | 145 | Q_OBJECT |
148 | 146 | ||
149 | public: | 147 | public: |
150 | OIpkgDestDlg( OConfItem *dest = 0l, QWidget *parent = 0l ); | 148 | OIpkgDestDlg( OConfItem *dest = 0l, QWidget *parent = 0l ); |
151 | 149 | ||
152 | protected slots: | 150 | protected slots: |
153 | void accept(); | 151 | void accept(); |
154 | 152 | ||
155 | private: | 153 | private: |
156 | OConfItem *m_dest; | 154 | OConfItem *m_dest; |
157 | 155 | ||
158 | // UI controls | 156 | // UI controls |
159 | QLineEdit *m_name; // Destination name edit box | 157 | QLineEdit *m_name; // Destination name edit box |
160 | QLineEdit *m_location; // Destination location URL edit box | 158 | QLineEdit *m_location; // Destination location URL edit box |
161 | QCheckBox *m_active; // Indicates whether the destination is activated | 159 | QCheckBox *m_active; // Indicates whether the destination is activated |
162 | 160 | ||
163 | private slots: | 161 | private slots: |
164 | void slotSelectPath(); | 162 | void slotSelectPath(); |
165 | }; | 163 | }; |
166 | 164 | ||
167 | #endif | 165 | #endif |
diff --git a/noncore/settings/packagemanager/opackage.cpp b/noncore/settings/packagemanager/opackage.cpp index 37963fa..f3c2024 100644 --- a/noncore/settings/packagemanager/opackage.cpp +++ b/noncore/settings/packagemanager/opackage.cpp | |||
@@ -1,46 +1,45 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #include "opackage.h" | 31 | #include "opackage.h" |
33 | 32 | ||
34 | OPackage::OPackage( const QString &name, const QString &version, const QString &versionInstalled, | 33 | OPackage::OPackage( const QString &name, const QString &version, const QString &versionInstalled, |
35 | const QString &source, const QString &destination, const QString &category, | 34 | const QString &source, const QString &destination, const QString &category, |
36 | const QString &information, const QString &files ) | 35 | const QString &information, const QString &files ) |
37 | : m_name( name ) | 36 | : m_name( name ) |
38 | , m_version( version ) | 37 | , m_version( version ) |
39 | , m_versionInstalled( versionInstalled ) | 38 | , m_versionInstalled( versionInstalled ) |
40 | , m_source( source ) | 39 | , m_source( source ) |
41 | , m_destination( destination ) | 40 | , m_destination( destination ) |
42 | , m_category( category ) | 41 | , m_category( category ) |
43 | , m_information( information ) | 42 | , m_information( information ) |
44 | , m_files( files ) | 43 | , m_files( files ) |
45 | { | 44 | { |
46 | } | 45 | } |
diff --git a/noncore/settings/packagemanager/opackage.h b/noncore/settings/packagemanager/opackage.h index fbd9ec0..4da5a2b 100644 --- a/noncore/settings/packagemanager/opackage.h +++ b/noncore/settings/packagemanager/opackage.h | |||
@@ -1,81 +1,80 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #ifndef OPACKAGE_H | 31 | #ifndef OPACKAGE_H |
33 | #define OPACKAGE_H | 32 | #define OPACKAGE_H |
34 | 33 | ||
35 | #include <qlist.h> | 34 | #include <qlist.h> |
36 | #include <qstring.h> | 35 | #include <qstring.h> |
37 | 36 | ||
38 | class OPackage | 37 | class OPackage |
39 | { | 38 | { |
40 | public: | 39 | public: |
41 | enum Command { Install, Remove, Update, Upgrade, Download, Info, Files, Version, NotDefined }; | 40 | enum Command { Install, Remove, Update, Upgrade, Download, Info, Files, Version, NotDefined }; |
42 | 41 | ||
43 | OPackage( const QString &name= QString::null, | 42 | OPackage( const QString &name= QString::null, |
44 | const QString &version= QString::null, const QString &versionInstalled= QString::null, | 43 | const QString &version= QString::null, const QString &versionInstalled= QString::null, |
45 | const QString &source= QString::null, const QString &destination= QString::null, | 44 | const QString &source= QString::null, const QString &destination= QString::null, |
46 | const QString &category = "misc", const QString &information = QString::null, | 45 | const QString &category = "misc", const QString &information = QString::null, |
47 | const QString &files = QString::null ); | 46 | const QString &files = QString::null ); |
48 | 47 | ||
49 | const QString &name() { return m_name; } | 48 | const QString &name() { return m_name; } |
50 | const QString &version() { return m_version; } | 49 | const QString &version() { return m_version; } |
51 | const QString &versionInstalled() { return m_versionInstalled; } | 50 | const QString &versionInstalled() { return m_versionInstalled; } |
52 | const QString &source() { return m_source; } | 51 | const QString &source() { return m_source; } |
53 | const QString &destination() { return m_destination; } | 52 | const QString &destination() { return m_destination; } |
54 | const QString &category() { return m_category; } | 53 | const QString &category() { return m_category; } |
55 | const QString &information() { return m_information; } | 54 | const QString &information() { return m_information; } |
56 | const QString &files() { return m_files; } | 55 | const QString &files() { return m_files; } |
57 | 56 | ||
58 | void setName( const QString &name ) { m_name = name; } | 57 | void setName( const QString &name ) { m_name = name; } |
59 | void setVersion( const QString &version ) { m_version = version; } | 58 | void setVersion( const QString &version ) { m_version = version; } |
60 | void setVersionInstalled( const QString &version ) { m_versionInstalled = version; } | 59 | void setVersionInstalled( const QString &version ) { m_versionInstalled = version; } |
61 | void setSource( const QString &source ) { m_source = source; } | 60 | void setSource( const QString &source ) { m_source = source; } |
62 | void setDestination( const QString &destination ) { m_destination = destination; } | 61 | void setDestination( const QString &destination ) { m_destination = destination; } |
63 | void setCategory( const QString &category ) { m_category = category; } | 62 | void setCategory( const QString &category ) { m_category = category; } |
64 | void setInformation( const QString &information ) { m_information = information; } | 63 | void setInformation( const QString &information ) { m_information = information; } |
65 | void setFiles( const QString &files ) { m_files = files; } | 64 | void setFiles( const QString &files ) { m_files = files; } |
66 | 65 | ||
67 | private: | 66 | private: |
68 | QString m_name; // Name of item | 67 | QString m_name; // Name of item |
69 | QString m_version; // Available version number of item | 68 | QString m_version; // Available version number of item |
70 | QString m_versionInstalled; // Installed version number of item, null if not installed | 69 | QString m_versionInstalled; // Installed version number of item, null if not installed |
71 | QString m_source; // Source feed of available version | 70 | QString m_source; // Source feed of available version |
72 | QString m_destination; // Location item is installed to, null if not installed | 71 | QString m_destination; // Location item is installed to, null if not installed |
73 | QString m_category; // Item category | 72 | QString m_category; // Item category |
74 | QString m_information; // Package information | 73 | QString m_information; // Package information |
75 | QString m_files; // File list information | 74 | QString m_files; // File list information |
76 | }; | 75 | }; |
77 | 76 | ||
78 | typedef QList<OPackage> OPackageList; | 77 | typedef QList<OPackage> OPackageList; |
79 | typedef QListIterator<OPackage> OPackageListIterator; | 78 | typedef QListIterator<OPackage> OPackageListIterator; |
80 | 79 | ||
81 | #endif | 80 | #endif |
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp index c9fdec1..abd8852 100644 --- a/noncore/settings/packagemanager/opackagemanager.cpp +++ b/noncore/settings/packagemanager/opackagemanager.cpp | |||
@@ -1,394 +1,393 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #include "opackagemanager.h" | 31 | #include "opackagemanager.h" |
33 | #include "oipkgconfigdlg.h" | 32 | #include "oipkgconfigdlg.h" |
34 | 33 | ||
35 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
36 | 35 | ||
37 | #include <ctype.h> | 36 | #include <ctype.h> |
38 | 37 | ||
39 | OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name ) | 38 | OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name ) |
40 | : QObject( parent, name ) | 39 | : QObject( parent, name ) |
41 | , m_config( config ) | 40 | , m_config( config ) |
42 | , m_ipkg( m_config, this ) | 41 | , m_ipkg( m_config, this ) |
43 | , m_packages( 9973 ) | 42 | , m_packages( 9973 ) |
44 | , m_categories() | 43 | , m_categories() |
45 | { | 44 | { |
46 | m_packages.setAutoDelete( true ); | 45 | m_packages.setAutoDelete( true ); |
47 | } | 46 | } |
48 | 47 | ||
49 | void OPackageManager::loadAvailablePackages() | 48 | void OPackageManager::loadAvailablePackages() |
50 | { | 49 | { |
51 | m_packages.clear(); | 50 | m_packages.clear(); |
52 | 51 | ||
53 | OConfItemList *serverList = m_ipkg.servers(); | 52 | OConfItemList *serverList = m_ipkg.servers(); |
54 | 53 | ||
55 | if ( serverList ) | 54 | if ( serverList ) |
56 | { | 55 | { |
57 | // Initialize status messaging | 56 | // Initialize status messaging |
58 | emit initStatus( serverList->count() ); | 57 | emit initStatus( serverList->count() ); |
59 | int serverCount = 0; | 58 | int serverCount = 0; |
60 | 59 | ||
61 | bool categoryAdded = false; | 60 | bool categoryAdded = false; |
62 | 61 | ||
63 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) | 62 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) |
64 | { | 63 | { |
65 | OConfItem *server = serverIt.current(); | 64 | OConfItem *server = serverIt.current(); |
66 | 65 | ||
67 | // Process server only if it is active | 66 | // Process server only if it is active |
68 | if ( server->active() ) | 67 | if ( server->active() ) |
69 | { | 68 | { |
70 | // Update status | 69 | // Update status |
71 | QString status = tr( "Reading available packages:\n\t" ); | 70 | QString status = tr( "Reading available packages:\n\t" ); |
72 | status.append( server->name() ); | 71 | status.append( server->name() ); |
73 | emit statusText( status ); | 72 | emit statusText( status ); |
74 | ++serverCount; | 73 | ++serverCount; |
75 | emit statusBar( serverCount ); | 74 | emit statusBar( serverCount ); |
76 | qApp->processEvents(); | 75 | qApp->processEvents(); |
77 | 76 | ||
78 | OPackageList *packageList = m_ipkg.availablePackages( server->name() ); | 77 | OPackageList *packageList = m_ipkg.availablePackages( server->name() ); |
79 | if ( packageList ) | 78 | if ( packageList ) |
80 | { | 79 | { |
81 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) | 80 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) |
82 | { | 81 | { |
83 | OPackage *package = packageIt.current(); | 82 | OPackage *package = packageIt.current(); |
84 | 83 | ||
85 | // Load package info | 84 | // Load package info |
86 | if ( !m_packages.find( package->name() ) ) | 85 | if ( !m_packages.find( package->name() ) ) |
87 | m_packages.insert( package->name(), package ); | 86 | m_packages.insert( package->name(), package ); |
88 | else | 87 | else |
89 | { | 88 | { |
90 | // If new package is newer version, replace existing package | 89 | // If new package is newer version, replace existing package |
91 | OPackage *currPackage = m_packages[package->name()]; | 90 | OPackage *currPackage = m_packages[package->name()]; |
92 | if ( compareVersions( package->version(), currPackage->version() ) == 1 ) | 91 | if ( compareVersions( package->version(), currPackage->version() ) == 1 ) |
93 | m_packages.replace( package->name(), package ); | 92 | m_packages.replace( package->name(), package ); |
94 | } | 93 | } |
95 | 94 | ||
96 | // Add category to list if it doesn't already exist | 95 | // Add category to list if it doesn't already exist |
97 | if ( m_categories.grep( package->category() ).isEmpty() ) | 96 | if ( m_categories.grep( package->category() ).isEmpty() ) |
98 | { | 97 | { |
99 | m_categories << package->category(); | 98 | m_categories << package->category(); |
100 | categoryAdded = true; | 99 | categoryAdded = true; |
101 | } | 100 | } |
102 | } | 101 | } |
103 | } | 102 | } |
104 | } | 103 | } |
105 | } | 104 | } |
106 | delete serverList; | 105 | delete serverList; |
107 | 106 | ||
108 | // Sort category list if categories were added | 107 | // Sort category list if categories were added |
109 | if ( categoryAdded ) | 108 | if ( categoryAdded ) |
110 | m_categories.sort(); | 109 | m_categories.sort(); |
111 | } | 110 | } |
112 | } | 111 | } |
113 | 112 | ||
114 | void OPackageManager::loadInstalledPackages() | 113 | void OPackageManager::loadInstalledPackages() |
115 | { | 114 | { |
116 | OConfItemList *destList = m_ipkg.destinations(); | 115 | OConfItemList *destList = m_ipkg.destinations(); |
117 | 116 | ||
118 | if ( destList ) | 117 | if ( destList ) |
119 | { | 118 | { |
120 | // Initialize status messaging | 119 | // Initialize status messaging |
121 | emit initStatus( destList->count() ); | 120 | emit initStatus( destList->count() ); |
122 | int destCount = 0; | 121 | int destCount = 0; |
123 | 122 | ||
124 | bool categoryAdded = false; | 123 | bool categoryAdded = false; |
125 | 124 | ||
126 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) | 125 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) |
127 | { | 126 | { |
128 | OConfItem *destination = destIt.current(); | 127 | OConfItem *destination = destIt.current(); |
129 | 128 | ||
130 | // Process destination only if it is active | 129 | // Process destination only if it is active |
131 | if ( destination->active() ) | 130 | if ( destination->active() ) |
132 | { | 131 | { |
133 | // Update status | 132 | // Update status |
134 | QString status = tr( "Reading installed packages:\n\t" ); | 133 | QString status = tr( "Reading installed packages:\n\t" ); |
135 | status.append( destination->name() ); | 134 | status.append( destination->name() ); |
136 | emit statusText( status ); | 135 | emit statusText( status ); |
137 | ++destCount; | 136 | ++destCount; |
138 | emit statusBar( destCount ); | 137 | emit statusBar( destCount ); |
139 | qApp->processEvents(); | 138 | qApp->processEvents(); |
140 | 139 | ||
141 | OPackageList *packageList = m_ipkg.installedPackages( destination->name(), | 140 | OPackageList *packageList = m_ipkg.installedPackages( destination->name(), |
142 | destination->value() ); | 141 | destination->value() ); |
143 | if ( packageList ) | 142 | if ( packageList ) |
144 | { | 143 | { |
145 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) | 144 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) |
146 | { | 145 | { |
147 | OPackage *package = packageIt.current(); | 146 | OPackage *package = packageIt.current(); |
148 | OPackage *currPackage = m_packages[package->name()]; | 147 | OPackage *currPackage = m_packages[package->name()]; |
149 | if ( currPackage ) | 148 | if ( currPackage ) |
150 | { | 149 | { |
151 | // Package is in a current feed, update installed version, destination | 150 | // Package is in a current feed, update installed version, destination |
152 | currPackage->setVersionInstalled( package->versionInstalled() ); | 151 | currPackage->setVersionInstalled( package->versionInstalled() ); |
153 | currPackage->setDestination( package->destination() ); | 152 | currPackage->setDestination( package->destination() ); |
154 | 153 | ||
155 | delete package; | 154 | delete package; |
156 | } | 155 | } |
157 | else | 156 | else |
158 | { | 157 | { |
159 | // Package isn't in a current feed, add to list | 158 | // Package isn't in a current feed, add to list |
160 | m_packages.insert( package->name(), package ); | 159 | m_packages.insert( package->name(), package ); |
161 | 160 | ||
162 | // Add category to list if it doesn't already exist | 161 | // Add category to list if it doesn't already exist |
163 | if ( m_categories.grep( package->category() ).isEmpty() ) | 162 | if ( m_categories.grep( package->category() ).isEmpty() ) |
164 | { | 163 | { |
165 | m_categories << package->category(); | 164 | m_categories << package->category(); |
166 | categoryAdded = true; | 165 | categoryAdded = true; |
167 | } | 166 | } |
168 | } | 167 | } |
169 | } | 168 | } |
170 | } | 169 | } |
171 | } | 170 | } |
172 | } | 171 | } |
173 | delete destList; | 172 | delete destList; |
174 | 173 | ||
175 | // Sort category list if categories were added | 174 | // Sort category list if categories were added |
176 | if ( categoryAdded ) | 175 | if ( categoryAdded ) |
177 | m_categories.sort(); | 176 | m_categories.sort(); |
178 | } | 177 | } |
179 | } | 178 | } |
180 | 179 | ||
181 | OPackageList *OPackageManager::packages() | 180 | OPackageList *OPackageManager::packages() |
182 | { | 181 | { |
183 | // TODO - look to see if list is loaded, if not, load available & installed | 182 | // TODO - look to see if list is loaded, if not, load available & installed |
184 | 183 | ||
185 | OPackageList *pl = new OPackageList; | 184 | OPackageList *pl = new OPackageList; |
186 | 185 | ||
187 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) | 186 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) |
188 | pl->append( packageIt.current() ); | 187 | pl->append( packageIt.current() ); |
189 | 188 | ||
190 | return pl; | 189 | return pl; |
191 | } | 190 | } |
192 | 191 | ||
193 | OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server, | 192 | OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server, |
194 | const QString &destination, Status status, const QString &category ) | 193 | const QString &destination, Status status, const QString &category ) |
195 | { | 194 | { |
196 | // TODO - look to see if list is loaded, if not, load available & installed | 195 | // TODO - look to see if list is loaded, if not, load available & installed |
197 | 196 | ||
198 | OPackageList *pl = new OPackageList; | 197 | OPackageList *pl = new OPackageList; |
199 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) | 198 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) |
200 | { | 199 | { |
201 | OPackage *package = packageIt.current(); | 200 | OPackage *package = packageIt.current(); |
202 | 201 | ||
203 | bool nameMatch = ( name.isNull() || package->name().contains( name ) ); | 202 | bool nameMatch = ( name.isNull() || package->name().contains( name ) ); |
204 | bool serverMatch = ( server.isNull() || package->source() == server ); | 203 | bool serverMatch = ( server.isNull() || package->source() == server ); |
205 | bool destinationMatch = ( destination.isNull() || package->destination() == destination ); | 204 | bool destinationMatch = ( destination.isNull() || package->destination() == destination ); |
206 | bool statusMatch; | 205 | bool statusMatch; |
207 | switch ( status ) | 206 | switch ( status ) |
208 | { | 207 | { |
209 | case All : statusMatch = true; | 208 | case All : statusMatch = true; |
210 | break; | 209 | break; |
211 | case NotInstalled : statusMatch = package->versionInstalled().isNull(); | 210 | case NotInstalled : statusMatch = package->versionInstalled().isNull(); |
212 | break; | 211 | break; |
213 | case Installed : statusMatch = !package->versionInstalled().isNull(); | 212 | case Installed : statusMatch = !package->versionInstalled().isNull(); |
214 | break; | 213 | break; |
215 | case Updated : statusMatch = ( !package->versionInstalled().isNull() && | 214 | case Updated : statusMatch = ( !package->versionInstalled().isNull() && |
216 | compareVersions( package->version(), package->versionInstalled() ) == 1 ); | 215 | compareVersions( package->version(), package->versionInstalled() ) == 1 ); |
217 | break; | 216 | break; |
218 | default : statusMatch = true; | 217 | default : statusMatch = true; |
219 | break; | 218 | break; |
220 | }; | 219 | }; |
221 | bool categoryMatch = ( category.isNull() || package->category() == category ); | 220 | bool categoryMatch = ( category.isNull() || package->category() == category ); |
222 | 221 | ||
223 | if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch ) | 222 | if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch ) |
224 | pl->append( packageIt.current() ); | 223 | pl->append( packageIt.current() ); |
225 | } | 224 | } |
226 | 225 | ||
227 | return pl; | 226 | return pl; |
228 | } | 227 | } |
229 | 228 | ||
230 | QStringList OPackageManager::servers() | 229 | QStringList OPackageManager::servers() |
231 | { | 230 | { |
232 | QStringList sl; | 231 | QStringList sl; |
233 | 232 | ||
234 | OConfItemList *serverList = m_ipkg.servers(); | 233 | OConfItemList *serverList = m_ipkg.servers(); |
235 | if ( serverList ) | 234 | if ( serverList ) |
236 | { | 235 | { |
237 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) | 236 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) |
238 | { | 237 | { |
239 | OConfItem *server = serverIt.current(); | 238 | OConfItem *server = serverIt.current(); |
240 | 239 | ||
241 | // Add only active servers | 240 | // Add only active servers |
242 | if ( server->active() ) | 241 | if ( server->active() ) |
243 | sl << server->name(); | 242 | sl << server->name(); |
244 | } | 243 | } |
245 | } | 244 | } |
246 | 245 | ||
247 | return sl; | 246 | return sl; |
248 | } | 247 | } |
249 | 248 | ||
250 | QStringList OPackageManager::destinations() | 249 | QStringList OPackageManager::destinations() |
251 | { | 250 | { |
252 | QStringList dl; | 251 | QStringList dl; |
253 | 252 | ||
254 | OConfItemList *destList = m_ipkg.destinations(); | 253 | OConfItemList *destList = m_ipkg.destinations(); |
255 | if ( destList ) | 254 | if ( destList ) |
256 | { | 255 | { |
257 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) | 256 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) |
258 | { | 257 | { |
259 | OConfItem *destination = destIt.current(); | 258 | OConfItem *destination = destIt.current(); |
260 | 259 | ||
261 | // Add only active destinations | 260 | // Add only active destinations |
262 | if ( destination->active() ) | 261 | if ( destination->active() ) |
263 | dl << destination->name(); | 262 | dl << destination->name(); |
264 | } | 263 | } |
265 | } | 264 | } |
266 | 265 | ||
267 | return dl; | 266 | return dl; |
268 | } | 267 | } |
269 | 268 | ||
270 | OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name ) | 269 | OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name ) |
271 | { | 270 | { |
272 | return m_ipkg.findConfItem( type, name ); | 271 | return m_ipkg.findConfItem( type, name ); |
273 | } | 272 | } |
274 | 273 | ||
275 | OPackage *OPackageManager::findPackage( const QString &name ) | 274 | OPackage *OPackageManager::findPackage( const QString &name ) |
276 | { | 275 | { |
277 | return m_packages[ name ]; | 276 | return m_packages[ name ]; |
278 | } | 277 | } |
279 | 278 | ||
280 | int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) | 279 | int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) |
281 | { | 280 | { |
282 | // TODO - should this be in OIpkg??? | 281 | // TODO - should this be in OIpkg??? |
283 | 282 | ||
284 | int epoch1, epoch2; | 283 | int epoch1, epoch2; |
285 | QString version1, revision1; | 284 | QString version1, revision1; |
286 | QString version2, revision2; | 285 | QString version2, revision2; |
287 | 286 | ||
288 | parseVersion( ver1, &epoch1, &version1, &revision1 ); | 287 | parseVersion( ver1, &epoch1, &version1, &revision1 ); |
289 | parseVersion( ver2, &epoch2, &version2, &revision2 ); | 288 | parseVersion( ver2, &epoch2, &version2, &revision2 ); |
290 | 289 | ||
291 | if ( epoch1 > epoch2 ) | 290 | if ( epoch1 > epoch2 ) |
292 | return 1; | 291 | return 1; |
293 | else if ( epoch1 < epoch2 ) | 292 | else if ( epoch1 < epoch2 ) |
294 | return -1; | 293 | return -1; |
295 | 294 | ||
296 | int r = verrevcmp( version1.latin1(), version2.latin1() ); | 295 | int r = verrevcmp( version1.latin1(), version2.latin1() ); |
297 | if (r) | 296 | if (r) |
298 | return r; | 297 | return r; |
299 | 298 | ||
300 | r = verrevcmp( revision1.latin1(), revision2.latin1() ); | 299 | r = verrevcmp( revision1.latin1(), revision2.latin1() ); |
301 | return r; | 300 | return r; |
302 | } | 301 | } |
303 | 302 | ||
304 | bool OPackageManager::configureDlg( bool installOptions ) | 303 | bool OPackageManager::configureDlg( bool installOptions ) |
305 | { | 304 | { |
306 | OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); | 305 | OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); |
307 | return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 306 | return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
308 | } | 307 | } |
309 | 308 | ||
310 | void OPackageManager::saveSettings() | 309 | void OPackageManager::saveSettings() |
311 | { | 310 | { |
312 | m_ipkg.saveSettings(); | 311 | m_ipkg.saveSettings(); |
313 | } | 312 | } |
314 | 313 | ||
315 | bool OPackageManager::executeCommand( OPackage::Command command, const QStringList &packages, | 314 | bool OPackageManager::executeCommand( OPackage::Command command, const QStringList &packages, |
316 | const QString &destination, const QObject *receiver, | 315 | const QString &destination, const QObject *receiver, |
317 | const char *slotOutput, bool rawOutput ) | 316 | const char *slotOutput, bool rawOutput ) |
318 | { | 317 | { |
319 | return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput ); | 318 | return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput ); |
320 | } | 319 | } |
321 | 320 | ||
322 | void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, | 321 | void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, |
323 | QString *revision ) | 322 | QString *revision ) |
324 | { | 323 | { |
325 | *epoch = 0; | 324 | *epoch = 0; |
326 | *revision = QString::null; | 325 | *revision = QString::null; |
327 | 326 | ||
328 | // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision | 327 | // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision |
329 | 328 | ||
330 | // Get epoch | 329 | // Get epoch |
331 | int colonpos = verstr.find( ':' ); | 330 | int colonpos = verstr.find( ':' ); |
332 | if ( colonpos > -1 ) | 331 | if ( colonpos > -1 ) |
333 | { | 332 | { |
334 | *epoch = verstr.left( colonpos ).toInt(); | 333 | *epoch = verstr.left( colonpos ).toInt(); |
335 | } | 334 | } |
336 | 335 | ||
337 | // Get version and revision | 336 | // Get version and revision |
338 | int hyphenpos = verstr.find( '-', colonpos + 1 ); | 337 | int hyphenpos = verstr.find( '-', colonpos + 1 ); |
339 | int verlen = verstr.length(); | 338 | int verlen = verstr.length(); |
340 | if ( hyphenpos > -1 ) | 339 | if ( hyphenpos > -1 ) |
341 | { | 340 | { |
342 | *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); | 341 | *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); |
343 | *revision = verstr.right( verlen - hyphenpos - 1 ); | 342 | *revision = verstr.right( verlen - hyphenpos - 1 ); |
344 | } | 343 | } |
345 | else | 344 | else |
346 | { | 345 | { |
347 | *version = verstr.right( verlen - colonpos ); | 346 | *version = verstr.right( verlen - colonpos ); |
348 | } | 347 | } |
349 | } | 348 | } |
350 | 349 | ||
351 | /* | 350 | /* |
352 | * libdpkg - Debian packaging suite library routines | 351 | * libdpkg - Debian packaging suite library routines |
353 | * vercmp.c - comparison of version numbers | 352 | * vercmp.c - comparison of version numbers |
354 | * | 353 | * |
355 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> | 354 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> |
356 | */ | 355 | */ |
357 | int OPackageManager::verrevcmp( const char *val, const char *ref ) | 356 | int OPackageManager::verrevcmp( const char *val, const char *ref ) |
358 | { | 357 | { |
359 | int vc, rc; | 358 | int vc, rc; |
360 | long vl, rl; | 359 | long vl, rl; |
361 | const char *vp, *rp; | 360 | const char *vp, *rp; |
362 | const char *vsep, *rsep; | 361 | const char *vsep, *rsep; |
363 | 362 | ||
364 | if (!val) val= ""; | 363 | if (!val) val= ""; |
365 | if (!ref) ref= ""; | 364 | if (!ref) ref= ""; |
366 | for (;;) { | 365 | for (;;) { |
367 | vp= val; while (*vp && !isdigit(*vp)) vp++; | 366 | vp= val; while (*vp && !isdigit(*vp)) vp++; |
368 | rp= ref; while (*rp && !isdigit(*rp)) rp++; | 367 | rp= ref; while (*rp && !isdigit(*rp)) rp++; |
369 | for (;;) { | 368 | for (;;) { |
370 | vc= (val == vp) ? 0 : *val++; | 369 | vc= (val == vp) ? 0 : *val++; |
371 | rc= (ref == rp) ? 0 : *ref++; | 370 | rc= (ref == rp) ? 0 : *ref++; |
372 | if (!rc && !vc) break; | 371 | if (!rc && !vc) break; |
373 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ | 372 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ |
374 | if (rc && !isalpha(rc)) rc += 256; | 373 | if (rc && !isalpha(rc)) rc += 256; |
375 | if (vc != rc) return vc - rc; | 374 | if (vc != rc) return vc - rc; |
376 | } | 375 | } |
377 | val= vp; | 376 | val= vp; |
378 | ref= rp; | 377 | ref= rp; |
379 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); | 378 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); |
380 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); | 379 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); |
381 | if (vl != rl) return vl - rl; | 380 | if (vl != rl) return vl - rl; |
382 | 381 | ||
383 | vc = *val; | 382 | vc = *val; |
384 | rc = *ref; | 383 | rc = *ref; |
385 | vsep = strchr(".-", vc); | 384 | vsep = strchr(".-", vc); |
386 | rsep = strchr(".-", rc); | 385 | rsep = strchr(".-", rc); |
387 | if (vsep && !rsep) return -1; | 386 | if (vsep && !rsep) return -1; |
388 | if (!vsep && rsep) return +1; | 387 | if (!vsep && rsep) return +1; |
389 | 388 | ||
390 | if (!*val && !*ref) return 0; | 389 | if (!*val && !*ref) return 0; |
391 | if (!*val) return -1; | 390 | if (!*val) return -1; |
392 | if (!*ref) return +1; | 391 | if (!*ref) return +1; |
393 | } | 392 | } |
394 | } | 393 | } |
diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h index bc394e8..60c1643 100644 --- a/noncore/settings/packagemanager/opackagemanager.h +++ b/noncore/settings/packagemanager/opackagemanager.h | |||
@@ -1,95 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | Â Â Â Â Â Â .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | : = ...= . :.=- | 22 | : Â Â = Â ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #ifndef OPACKAGEMANAGER_H | 31 | #ifndef OPACKAGEMANAGER_H |
33 | #define OPACKAGEMANAGER_H | 32 | #define OPACKAGEMANAGER_H |
34 | 33 | ||
35 | #include "oipkg.h" | 34 | #include "oipkg.h" |
36 | 35 | ||
37 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
38 | 37 | ||
39 | #include <qdict.h> | 38 | #include <qdict.h> |
40 | #include <qobject.h> | 39 | #include <qobject.h> |
41 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
42 | 41 | ||
43 | class OPackageManager : public QObject | 42 | class OPackageManager : public QObject |
44 | { | 43 | { |
45 | Q_OBJECT | 44 | Q_OBJECT |
46 | 45 | ||
47 | public: | 46 | public: |
48 | OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); | 47 | OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); |
49 | 48 | ||
50 | void loadAvailablePackages(); | 49 | void loadAvailablePackages(); |
51 | void loadInstalledPackages(); | 50 | void loadInstalledPackages(); |
52 | 51 | ||
53 | enum Status { All, NotInstalled, Installed, Updated, NotDefined }; | 52 | enum Status { All, NotInstalled, Installed, Updated, NotDefined }; |
54 | 53 | ||
55 | OPackageList *packages(); | 54 | OPackageList *packages(); |
56 | OPackageList *filterPackages( const QString &name = QString::null, | 55 | OPackageList *filterPackages( const QString &name = QString::null, |
57 | const QString &server = QString::null, | 56 | const QString &server = QString::null, |
58 | const QString &destination = QString::null, | 57 | const QString &destination = QString::null, |
59 | Status status = NotDefined, | 58 | Status status = NotDefined, |
60 | const QString &category = QString::null ); | 59 | const QString &category = QString::null ); |
61 | 60 | ||
62 | const QStringList &categories() { return m_categories; } | 61 | const QStringList &categories() { return m_categories; } |
63 | QStringList servers(); | 62 | QStringList servers(); |
64 | QStringList destinations(); | 63 | QStringList destinations(); |
65 | 64 | ||
66 | int compareVersions( const QString &version1, const QString &version2 ); | 65 | int compareVersions( const QString &version1, const QString &version2 ); |
67 | 66 | ||
68 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, | 67 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, |
69 | const QString &name = QString::null ); | 68 | const QString &name = QString::null ); |
70 | OPackage *findPackage( const QString &name = QString::null ); | 69 | OPackage *findPackage( const QString &name = QString::null ); |
71 | 70 | ||
72 | bool configureDlg( bool installOptions = false ); | 71 | bool configureDlg( bool installOptions = false ); |
73 | void saveSettings(); | 72 | void saveSettings(); |
74 | 73 | ||
75 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, | 74 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, |
76 | const QStringList ¶meters = QStringList(), | 75 | const QStringList ¶meters = QStringList(), |
77 | const QString &destination = QString::null, const QObject *receiver = 0x0, | 76 | const QString &destination = QString::null, const QObject *receiver = 0x0, |
78 | const char *slotOutput = 0x0, bool rawOutput = true ); | 77 | const char *slotOutput = 0x0, bool rawOutput = true ); |
79 | 78 | ||
80 | private: | 79 | private: |
81 | Config *m_config; // Pointer to application configuration file | 80 | Config *m_config; // Pointer to application configuration file |
82 | OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information | 81 | OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information |
83 | QDict<OPackage> m_packages; // Global list of available packages | 82 | QDict<OPackage> m_packages; // Global list of available packages |
84 | QStringList m_categories; // List of all categories | 83 | QStringList m_categories; // List of all categories |
85 | 84 | ||
86 | void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision ); | 85 | void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision ); |
87 | int verrevcmp( const char *val, const char *ref ); | 86 | int verrevcmp( const char *val, const char *ref ); |
88 | 87 | ||
89 | signals: | 88 | signals: |
90 | void initStatus( int numSteps ); | 89 | void initStatus( int numSteps ); |
91 | void statusText( const QString &status ); | 90 | void statusText( const QString &status ); |
92 | void statusBar( int currStep ); | 91 | void statusBar( int currStep ); |
93 | }; | 92 | }; |
94 | 93 | ||
95 | #endif | 94 | #endif |
diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp index 3eef939..e034f34 100644 --- a/noncore/settings/packagemanager/packageinfodlg.cpp +++ b/noncore/settings/packagemanager/packageinfodlg.cpp | |||
@@ -1,153 +1,154 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "packageinfodlg.h" | 31 | #include "packageinfodlg.h" |
31 | #include "opackage.h" | 32 | #include "opackage.h" |
32 | #include "opackagemanager.h" | 33 | #include "opackagemanager.h" |
33 | 34 | ||
34 | #include <opie2/otabwidget.h> | 35 | #include <opie2/otabwidget.h> |
35 | 36 | ||
36 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
37 | 38 | ||
38 | #include <qlayout.h> | 39 | #include <qlayout.h> |
39 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
40 | #include <qwhatsthis.h> | 41 | #include <qwhatsthis.h> |
41 | 42 | ||
42 | PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) | 43 | PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) |
43 | : QWidget( 0l ) | 44 | : QWidget( 0l ) |
44 | , m_packman( pm ) | 45 | , m_packman( pm ) |
45 | , m_information( this ) | 46 | , m_information( this ) |
46 | , m_files( this ) | 47 | , m_files( this ) |
47 | , m_retrieveFiles( 0l ) | 48 | , m_retrieveFiles( 0l ) |
48 | { | 49 | { |
49 | // Initialize UI | 50 | // Initialize UI |
50 | if ( parent ) | 51 | if ( parent ) |
51 | parent->setCaption( package ); | 52 | parent->setCaption( package ); |
52 | 53 | ||
53 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); | 54 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); |
54 | 55 | ||
55 | Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this ); | 56 | Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this ); |
56 | layout->addWidget( tabWidget ); | 57 | layout->addWidget( tabWidget ); |
57 | 58 | ||
58 | // Information tab | 59 | // Information tab |
59 | QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) ); | 60 | QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) ); |
60 | m_information.reparent( tabWidget, QPoint( 0, 0 ) ); | 61 | m_information.reparent( tabWidget, QPoint( 0, 0 ) ); |
61 | m_information.setReadOnly( true ); | 62 | m_information.setReadOnly( true ); |
62 | tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); | 63 | tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); |
63 | 64 | ||
64 | // Retrive package information | 65 | // Retrive package information |
65 | m_package = m_packman->findPackage( package ); | 66 | m_package = m_packman->findPackage( package ); |
66 | if ( !m_package ) | 67 | if ( !m_package ) |
67 | { | 68 | { |
68 | m_information.setText( tr( "Unable to retrieve package information." ) ); | 69 | m_information.setText( tr( "Unable to retrieve package information." ) ); |
69 | return; | 70 | return; |
70 | } | 71 | } |
71 | 72 | ||
72 | // Display package information | 73 | // Display package information |
73 | if ( !m_package->information().isNull() ) | 74 | if ( !m_package->information().isNull() ) |
74 | m_information.setText( m_package->information() ); | 75 | m_information.setText( m_package->information() ); |
75 | else | 76 | else |
76 | { | 77 | { |
77 | // Package information is not cached, retrieve it | 78 | // Package information is not cached, retrieve it |
78 | QStringList list( package ); | 79 | QStringList list( package ); |
79 | m_packman->executeCommand( OPackage::Info, list, QString::null, | 80 | m_packman->executeCommand( OPackage::Info, list, QString::null, |
80 | this, SLOT(slotInfo(const QString &)), true ); | 81 | this, SLOT(slotInfo(const QString &)), true ); |
81 | } | 82 | } |
82 | 83 | ||
83 | // Files tab (display only if package is installed) | 84 | // Files tab (display only if package is installed) |
84 | if ( !m_package->versionInstalled().isNull() ) | 85 | if ( !m_package->versionInstalled().isNull() ) |
85 | { | 86 | { |
86 | QWidget *filesWidget = new QWidget( tabWidget ); | 87 | QWidget *filesWidget = new QWidget( tabWidget ); |
87 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); | 88 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); |
88 | QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) ); | 89 | QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) ); |
89 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); | 90 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); |
90 | m_files.setReadOnly( true ); | 91 | m_files.setReadOnly( true ); |
91 | filesLayout->addWidget( &m_files ); | 92 | filesLayout->addWidget( &m_files ); |
92 | 93 | ||
93 | // If file list is already cached, display | 94 | // If file list is already cached, display |
94 | if ( !m_package->files().isNull() ) | 95 | if ( !m_package->files().isNull() ) |
95 | m_files.setText( m_package->files() ); | 96 | m_files.setText( m_package->files() ); |
96 | else | 97 | else |
97 | { | 98 | { |
98 | m_retrieveFiles = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), | 99 | m_retrieveFiles = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), |
99 | tr( "Retrieve file list" ), filesWidget ); | 100 | tr( "Retrieve file list" ), filesWidget ); |
100 | QWhatsThis::add( m_retrieveFiles, tr( "Tap here to retrieve list of files contained in this package." ) ); | 101 | QWhatsThis::add( m_retrieveFiles, tr( "Tap here to retrieve list of files contained in this package." ) ); |
101 | filesLayout->addWidget( m_retrieveFiles ); | 102 | filesLayout->addWidget( m_retrieveFiles ); |
102 | connect( m_retrieveFiles, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); | 103 | connect( m_retrieveFiles, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); |
103 | } | 104 | } |
104 | 105 | ||
105 | tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); | 106 | tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); |
106 | tabWidget->setCurrentTab( tr( "Information" ) ); | 107 | tabWidget->setCurrentTab( tr( "Information" ) ); |
107 | 108 | ||
108 | } | 109 | } |
109 | else | 110 | else |
110 | m_files.hide(); | 111 | m_files.hide(); |
111 | } | 112 | } |
112 | 113 | ||
113 | PackageInfoDlg::~PackageInfoDlg() | 114 | PackageInfoDlg::~PackageInfoDlg() |
114 | { | 115 | { |
115 | if ( !m_package ) | 116 | if ( !m_package ) |
116 | return; | 117 | return; |
117 | 118 | ||
118 | // Cache package information | 119 | // Cache package information |
119 | if ( !m_information.text().isNull() ) | 120 | if ( !m_information.text().isNull() ) |
120 | m_package->setInformation( m_information.text() ); | 121 | m_package->setInformation( m_information.text() ); |
121 | 122 | ||
122 | // Cache package file list | 123 | // Cache package file list |
123 | if ( !m_files.text().isEmpty() ) | 124 | if ( !m_files.text().isEmpty() ) |
124 | m_package->setFiles( m_files.text() ); | 125 | m_package->setFiles( m_files.text() ); |
125 | } | 126 | } |
126 | 127 | ||
127 | void PackageInfoDlg::slotBtnFileScan() | 128 | void PackageInfoDlg::slotBtnFileScan() |
128 | { | 129 | { |
129 | m_files.clear(); | 130 | m_files.clear(); |
130 | 131 | ||
131 | QStringList list( m_package->name() ); | 132 | QStringList list( m_package->name() ); |
132 | m_packman->executeCommand( OPackage::Files, list, QString::null, | 133 | m_packman->executeCommand( OPackage::Files, list, QString::null, |
133 | this, SLOT(slotFiles(const QString &)), true ); | 134 | this, SLOT(slotFiles(const QString &)), true ); |
134 | 135 | ||
135 | if ( m_retrieveFiles ) | 136 | if ( m_retrieveFiles ) |
136 | m_retrieveFiles->hide(); | 137 | m_retrieveFiles->hide(); |
137 | } | 138 | } |
138 | 139 | ||
139 | void PackageInfoDlg::slotInfo( const QString &info ) | 140 | void PackageInfoDlg::slotInfo( const QString &info ) |
140 | { | 141 | { |
141 | m_information.append( info ); | 142 | m_information.append( info ); |
142 | } | 143 | } |
143 | 144 | ||
144 | void PackageInfoDlg::slotFiles( const QString &filelist ) | 145 | void PackageInfoDlg::slotFiles( const QString &filelist ) |
145 | { | 146 | { |
146 | QString str = filelist; | 147 | QString str = filelist; |
147 | 148 | ||
148 | // Skip first line of output ("Package xxx is installed...") | 149 | // Skip first line of output ("Package xxx is installed...") |
149 | if ( str.startsWith( "Package " ) ) | 150 | if ( str.startsWith( "Package " ) ) |
150 | str = str.right( str.length() - str.find( '\n' ) - 1 ); | 151 | str = str.right( str.length() - str.find( '\n' ) - 1 ); |
151 | 152 | ||
152 | m_files.append( str ); | 153 | m_files.append( str ); |
153 | } | 154 | } |
diff --git a/noncore/settings/packagemanager/packageinfodlg.h b/noncore/settings/packagemanager/packageinfodlg.h index 2962f9a..e4c6bba 100644 --- a/noncore/settings/packagemanager/packageinfodlg.h +++ b/noncore/settings/packagemanager/packageinfodlg.h | |||
@@ -1,66 +1,67 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #ifndef PACKAGEINFODLG_H | 31 | #ifndef PACKAGEINFODLG_H |
31 | #define PACKAGEINFODLG_H | 32 | #define PACKAGEINFODLG_H |
32 | 33 | ||
33 | #include "opackage.h" | 34 | #include "opackage.h" |
34 | 35 | ||
35 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
36 | #include <qwidget.h> | 37 | #include <qwidget.h> |
37 | 38 | ||
38 | class QPushButton; | 39 | class QPushButton; |
39 | 40 | ||
40 | class OPackage; | 41 | class OPackage; |
41 | class OPackageManager; | 42 | class OPackageManager; |
42 | 43 | ||
43 | class PackageInfoDlg : public QWidget | 44 | class PackageInfoDlg : public QWidget |
44 | { | 45 | { |
45 | Q_OBJECT | 46 | Q_OBJECT |
46 | 47 | ||
47 | public: | 48 | public: |
48 | PackageInfoDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, const QString &package = QString::null ); | 49 | PackageInfoDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, const QString &package = QString::null ); |
49 | ~PackageInfoDlg(); | 50 | ~PackageInfoDlg(); |
50 | 51 | ||
51 | private: | 52 | private: |
52 | OPackageManager *m_packman; // Pointer to application instance of package manager | 53 | OPackageManager *m_packman; // Pointer to application instance of package manager |
53 | OPackage *m_package; // Pointer to package to display information for | 54 | OPackage *m_package; // Pointer to package to display information for |
54 | 55 | ||
55 | // UI controls | 56 | // UI controls |
56 | QMultiLineEdit m_information; // Multi-line edit to display package information | 57 | QMultiLineEdit m_information; // Multi-line edit to display package information |
57 | QMultiLineEdit m_files; // Multi-line edit to display package file list | 58 | QMultiLineEdit m_files; // Multi-line edit to display package file list |
58 | QPushButton *m_retrieveFiles; // Push button to retrieve file list | 59 | QPushButton *m_retrieveFiles; // Push button to retrieve file list |
59 | 60 | ||
60 | private slots: | 61 | private slots: |
61 | void slotBtnFileScan(); | 62 | void slotBtnFileScan(); |
62 | void slotInfo( const QString &info ); | 63 | void slotInfo( const QString &info ); |
63 | void slotFiles( const QString &filelist ); | 64 | void slotFiles( const QString &filelist ); |
64 | }; | 65 | }; |
65 | 66 | ||
66 | #endif | 67 | #endif |
diff --git a/noncore/settings/packagemanager/promptdlg.cpp b/noncore/settings/packagemanager/promptdlg.cpp index 841b98e..5053caa 100644 --- a/noncore/settings/packagemanager/promptdlg.cpp +++ b/noncore/settings/packagemanager/promptdlg.cpp | |||
@@ -1,140 +1,141 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #include "promptdlg.h" | 31 | #include "promptdlg.h" |
31 | 32 | ||
32 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
33 | 34 | ||
34 | #include <qlabel.h> | 35 | #include <qlabel.h> |
35 | #include <qlayout.h> | 36 | #include <qlayout.h> |
36 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
37 | #include <qwidgetlist.h> | 38 | #include <qwidgetlist.h> |
38 | 39 | ||
39 | PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString &btn1, const QString &btn2, | 40 | PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString &btn1, const QString &btn2, |
40 | QWidget *parent ) | 41 | QWidget *parent ) |
41 | : QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog ) | 42 | : QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog ) |
42 | , m_btnClicked( -1 ) | 43 | , m_btnClicked( -1 ) |
43 | { | 44 | { |
44 | setCaption( caption ); | 45 | setCaption( caption ); |
45 | 46 | ||
46 | QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 ); | 47 | QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 ); |
47 | QLabel *label = new QLabel( text, this ); | 48 | QLabel *label = new QLabel( text, this ); |
48 | label->setAlignment( AlignCenter | WordBreak ); | 49 | label->setAlignment( AlignCenter | WordBreak ); |
49 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | 50 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |
50 | 51 | ||
51 | QPushButton *btn = new QPushButton( btn1, this ); | 52 | QPushButton *btn = new QPushButton( btn1, this ); |
52 | layout->addWidget( btn, 1, 0 ); | 53 | layout->addWidget( btn, 1, 0 ); |
53 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) ); | 54 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) ); |
54 | 55 | ||
55 | btn = new QPushButton( btn2, this ); | 56 | btn = new QPushButton( btn2, this ); |
56 | layout->addWidget( btn, 1, 1 ); | 57 | layout->addWidget( btn, 1, 1 ); |
57 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn2Clicked()) ); | 58 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn2Clicked()) ); |
58 | } | 59 | } |
59 | 60 | ||
60 | int PromptDlg::display() | 61 | int PromptDlg::display() |
61 | { | 62 | { |
62 | // Determine position of dialog. Derived from QT's QDialog::show() method. | 63 | // Determine position of dialog. Derived from QT's QDialog::show() method. |
63 | QWidget *w = parentWidget(); | 64 | QWidget *w = parentWidget(); |
64 | QPoint p( 0, 0 ); | 65 | QPoint p( 0, 0 ); |
65 | int extraw = 0, extrah = 0; | 66 | int extraw = 0, extrah = 0; |
66 | QWidget * desk = QApplication::desktop(); | 67 | QWidget * desk = QApplication::desktop(); |
67 | if ( w ) | 68 | if ( w ) |
68 | w = w->topLevelWidget(); | 69 | w = w->topLevelWidget(); |
69 | 70 | ||
70 | QWidgetList *list = QApplication::topLevelWidgets(); | 71 | QWidgetList *list = QApplication::topLevelWidgets(); |
71 | QWidgetListIt it( *list ); | 72 | QWidgetListIt it( *list ); |
72 | while ( (extraw == 0 || extrah == 0) && it.current() != 0 ) | 73 | while ( (extraw == 0 || extrah == 0) && it.current() != 0 ) |
73 | { | 74 | { |
74 | int w, h; | 75 | int w, h; |
75 | QWidget * current = it.current(); | 76 | QWidget * current = it.current(); |
76 | ++it; | 77 | ++it; |
77 | w = current->geometry().x() - current->x(); | 78 | w = current->geometry().x() - current->x(); |
78 | h = current->geometry().y() - current->y(); | 79 | h = current->geometry().y() - current->y(); |
79 | 80 | ||
80 | extraw = QMAX( extraw, w ); | 81 | extraw = QMAX( extraw, w ); |
81 | extrah = QMAX( extrah, h ); | 82 | extrah = QMAX( extrah, h ); |
82 | } | 83 | } |
83 | delete list; | 84 | delete list; |
84 | 85 | ||
85 | // sanity check for decoration frames. With embedding, we | 86 | // sanity check for decoration frames. With embedding, we |
86 | // might get extraordinary values | 87 | // might get extraordinary values |
87 | if ( extraw >= 10 || extrah >= 40 ) | 88 | if ( extraw >= 10 || extrah >= 40 ) |
88 | extraw = extrah = 0; | 89 | extraw = extrah = 0; |
89 | 90 | ||
90 | if ( w ) | 91 | if ( w ) |
91 | { | 92 | { |
92 | // Use mapToGlobal rather than geometry() in case w might | 93 | // Use mapToGlobal rather than geometry() in case w might |
93 | // be embedded in another application | 94 | // be embedded in another application |
94 | QPoint pp = w->mapToGlobal( QPoint(0,0) ); | 95 | QPoint pp = w->mapToGlobal( QPoint(0,0) ); |
95 | p = QPoint( pp.x() + w->width()/2, pp.y() + w->height()/ 2 ); | 96 | p = QPoint( pp.x() + w->width()/2, pp.y() + w->height()/ 2 ); |
96 | } | 97 | } |
97 | else | 98 | else |
98 | p = QPoint( desk->width()/2, desk->height()/2 ); | 99 | p = QPoint( desk->width()/2, desk->height()/2 ); |
99 | 100 | ||
100 | p = QPoint( p.x()-width()/2 - extraw, p.y()-height()/2 - extrah ); | 101 | p = QPoint( p.x()-width()/2 - extraw, p.y()-height()/2 - extrah ); |
101 | 102 | ||
102 | if ( p.x() + extraw + width() > desk->width() ) | 103 | if ( p.x() + extraw + width() > desk->width() ) |
103 | p.setX( desk->width() - width() - extraw ); | 104 | p.setX( desk->width() - width() - extraw ); |
104 | if ( p.x() < 0 ) | 105 | if ( p.x() < 0 ) |
105 | p.setX( 0 ); | 106 | p.setX( 0 ); |
106 | 107 | ||
107 | if ( p.y() + extrah + height() > desk->height() ) | 108 | if ( p.y() + extrah + height() > desk->height() ) |
108 | p.setY( desk->height() - height() - extrah ); | 109 | p.setY( desk->height() - height() - extrah ); |
109 | if ( p.y() < 0 ) | 110 | if ( p.y() < 0 ) |
110 | p.setY( 0 ); | 111 | p.setY( 0 ); |
111 | 112 | ||
112 | move( p ); | 113 | move( p ); |
113 | show(); | 114 | show(); |
114 | 115 | ||
115 | // Enter event loop for modality | 116 | // Enter event loop for modality |
116 | qApp->enter_loop(); | 117 | qApp->enter_loop(); |
117 | 118 | ||
118 | return m_btnClicked; | 119 | return m_btnClicked; |
119 | } | 120 | } |
120 | 121 | ||
121 | int PromptDlg::ask( const QString &caption, const QString &text, const QString &btn1, const QString &btn2, | 122 | int PromptDlg::ask( const QString &caption, const QString &text, const QString &btn1, const QString &btn2, |
122 | QWidget *parent ) | 123 | QWidget *parent ) |
123 | { | 124 | { |
124 | PromptDlg *dlg = new PromptDlg( caption, text, btn1, btn2, parent ); | 125 | PromptDlg *dlg = new PromptDlg( caption, text, btn1, btn2, parent ); |
125 | int rc = dlg->display(); | 126 | int rc = dlg->display(); |
126 | delete dlg; | 127 | delete dlg; |
127 | return rc; | 128 | return rc; |
128 | } | 129 | } |
129 | 130 | ||
130 | void PromptDlg::slotBtn1Clicked() | 131 | void PromptDlg::slotBtn1Clicked() |
131 | { | 132 | { |
132 | m_btnClicked = 1; | 133 | m_btnClicked = 1; |
133 | qApp->exit_loop(); | 134 | qApp->exit_loop(); |
134 | } | 135 | } |
135 | 136 | ||
136 | void PromptDlg::slotBtn2Clicked() | 137 | void PromptDlg::slotBtn2Clicked() |
137 | { | 138 | { |
138 | m_btnClicked = 2; | 139 | m_btnClicked = 2; |
139 | qApp->exit_loop(); | 140 | qApp->exit_loop(); |
140 | } | 141 | } |
diff --git a/noncore/settings/packagemanager/promptdlg.h b/noncore/settings/packagemanager/promptdlg.h index f7bc0c0..9f870fa 100644 --- a/noncore/settings/packagemanager/promptdlg.h +++ b/noncore/settings/packagemanager/promptdlg.h | |||
@@ -1,59 +1,60 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | Â Â Â Â Â Â Â Â This file is part of the Opie Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | =. |
6 | .>+-= | 6 | .=l. |
7 | _;:, .> :=|. This file is free software; you can | 7 | Â Â Â Â Â Â .>+-= |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | Â _;:, Â Â .> Â Â :=|. This program is free software; you can |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | .> <`_, Â > Â . Â <= redistribute it and/or modify it under |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | :`=1 )Y*s>-.-- Â : the terms of the GNU Library General Public |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | .="- .-=="i, Â Â .._ License as published by the Free Software |
12 | ._= =} : or (at your option) any later version. | 12 | Â - . Â .-<_> Â Â .<> Foundation; either version 2 of the License, |
13 | .%`+i> _;_. | 13 | Â Â Â ._= =} Â Â Â : or (at your option) any later version. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | Â Â .%`+i> Â Â Â _;_. |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | Â Â .i_,=:_. Â Â Â -<s. This program is distributed in the hope that |
16 | : .. .:, . . . without even the implied warranty of | 16 | Â Â Â + Â . Â -:. Â Â Â = it will be useful, but WITHOUT ANY WARRANTY; |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | : .. Â Â .:, Â Â . . . without even the implied warranty of |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | Â Â =_ Â Â Â Â + Â Â =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | ..}^=.= = ; Public License for more details. | 19 | Â _.=:. Â Â Â : Â Â :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ++= -. .` .: | 20 | ..}^=.= Â Â Â = Â Â Â ; Library General Public License for more |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | ++= Â -. Â Â .` Â Â .: details. |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | : Â Â = Â ...= . :.=- |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | Â -. Â .:....=;==+<; You should have received a copy of the GNU |
24 | -- :-=` Free Software Foundation, Inc., | 24 | Â -_. . . Â )=. Â = Library General Public License along with |
25 | 59 Temple Place - Suite 330, | 25 | Â Â -- Â Â Â Â :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
27 | |||
28 | */ | 29 | */ |
29 | 30 | ||
30 | #ifndef PROMPTDLG_H | 31 | #ifndef PROMPTDLG_H |
31 | #define PROMPTDLG_H | 32 | #define PROMPTDLG_H |
32 | 33 | ||
33 | #include <qwidget.h> | 34 | #include <qwidget.h> |
34 | 35 | ||
35 | class PromptDlg : public QWidget | 36 | class PromptDlg : public QWidget |
36 | { | 37 | { |
37 | Q_OBJECT | 38 | Q_OBJECT |
38 | 39 | ||
39 | public: | 40 | public: |
40 | PromptDlg( const QString &caption = QString::null, const QString &text = QString::null, | 41 | PromptDlg( const QString &caption = QString::null, const QString &text = QString::null, |
41 | const QString &btn1 = QString::null, const QString &btn2 = QString::null, | 42 | const QString &btn1 = QString::null, const QString &btn2 = QString::null, |
42 | QWidget *parent = 0x0 ); | 43 | QWidget *parent = 0x0 ); |
43 | 44 | ||
44 | int display(); | 45 | int display(); |
45 | int btnPressed() { return m_btnClicked; } | 46 | int btnPressed() { return m_btnClicked; } |
46 | 47 | ||
47 | static int ask( const QString &caption = QString::null, const QString &text = QString::null, | 48 | static int ask( const QString &caption = QString::null, const QString &text = QString::null, |
48 | const QString &btn1 = QString::null, const QString &btn2 = QString::null, | 49 | const QString &btn1 = QString::null, const QString &btn2 = QString::null, |
49 | QWidget *parent = 0x0 ); | 50 | QWidget *parent = 0x0 ); |
50 | 51 | ||
51 | private: | 52 | private: |
52 | int m_btnClicked; // Indicator for which button was pressed | 53 | int m_btnClicked; // Indicator for which button was pressed |
53 | 54 | ||
54 | private slots: | 55 | private slots: |
55 | void slotBtn1Clicked(); | 56 | void slotBtn1Clicked(); |
56 | void slotBtn2Clicked(); | 57 | void slotBtn2Clicked(); |
57 | }; | 58 | }; |
58 | 59 | ||
59 | #endif | 60 | #endif |