2 This file is part of Faster Application Manager.
4 Faster Application Manager is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Faster Application Manager is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Faster Application Manager. If not, see <http://www.gnu.org/licenses/>.
17 (C) Heikki Holstila 2010
22 #include "ui_repoview.h"
23 #include "mainwindow.h"
24 #include "aaptinterface.h"
25 #include "confirmdialog.h"
26 #include "repository.h"
29 RepoView::RepoView(QWidget *parent) :
33 iMainWindow = dynamic_cast<MainWindow*>(parent);
36 this->setAttribute(Qt::WA_Maemo5StackedWindow);
37 this->setWindowFlags(Qt::Window);
38 this->setAttribute(Qt::WA_Maemo5AutoOrientation);
49 void RepoView::changeEvent(QEvent *e)
51 QMainWindow::changeEvent(e);
53 case QEvent::LanguageChange:
54 ui->retranslateUi(this);
61 void RepoView::openWin()
67 ui->listWidget->clear();
69 for( int i=0; i<iAptInterface->repositories()->count(); i++ )
71 QListWidgetItem* l = new QListWidgetItem( ui->listWidget );
72 if( iAptInterface->repositories()->at(i)->enabled() )
73 l->setIcon(QPixmap(":/icons/icons/pkg_install.png"));
75 l->setIcon(QPixmap(":/icons/icons/pkg_remove.png"));
76 l->setText( iAptInterface->repositories()->at(i)->name() );
77 l->setData(Qt::UserRole, i);
78 ui->listWidget->addItem( l );
84 void RepoView::closeEvent(QCloseEvent *event)
90 iAptInterface->writeRepositories();
91 iMainWindow->on_btnUpdate_clicked();
95 void RepoView::on_btnNew_clicked()
97 Repository* n = new Repository();
98 iAptInterface->repositories()->append(n);
100 // add an option to set these directly
101 //"deb http://repository.maemo.org/extras-testing/ fremantle free non-free"
102 //"deb http://repository.maemo.org/extras-devel/ fremantle free non-free";
104 RepoEdit e(iAptInterface, n, iAptInterface->repositories()->count()-1, this);
108 iAptInterface->repositories()->removeAt( iAptInterface->repositories()->count()-1 );
118 void RepoView::on_listWidget_itemClicked(QListWidgetItem* item)
120 Repository* r = iAptInterface->repositories()->at( item->data(Qt::UserRole).toInt() );
122 RepoEdit e(iAptInterface, r, item->data(Qt::UserRole).toInt(), this);
129 void RepoView::on_actionRe_import_HAM_repo_settings_triggered()
131 ConfirmDialog d(true, this);
132 d.setText("Confirm repository import","You're about to re-read the repository settings from Hildon Application Manager. This will import the "
133 "repositories that are currently enabled in HAM and it will clear your current repository settings here. Continue?");
136 QFile r(KOwnRepoFile);
137 QFile n(KOwnRepoNamesFile);
140 iAptInterface->readRepositoryInfo();
142 openWin(); // refresh view