-/*
- This file is part of Faster Application Manager.
-
- Faster Application Manager is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Faster Application Manager is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Faster Application Manager. If not, see <http://www.gnu.org/licenses/>.
-
- (C) Heikki Holstila 2010
-*/
-
#ifdef MYDEF_GTK_EXISTS
extern "C"
{
- #include <gdk/gdk.h>
- #include <gtk/gtk.h>
+ #include <gdk/gdk.h>
+ #include <gtk/gtk.h>
}
#endif
extern "C"
{
- #include <sys/vfs.h>
+ #include <sys/vfs.h>
}
#include "mainwindow.h"
#include "logview.h"
#include "rotatingbackground.h"
#include "dpkginterface.h"
+#include "installfile.h"
+#include "repository.h"
MainWindow::MainWindow(QWidget *parent) :
{
ui->setupUi(this);
- iAptInterface = new AAptInterface(this);
- iWinPackageView = new PackageView(this);
- iWinPackageView->setAptInterface(iAptInterface);
- iWinRepoView = new RepoView(this);
- iWinRepoView->setAptInterface(iAptInterface);
- iSettings = new Settings(this);
- iSettings->setAptInterface(iAptInterface);
- iSettings->setPackageView(iWinPackageView);
- iWinPackageView->setSettings(iSettings);
- iAptInterface->setSettings(iSettings);
- iDpkgInterface = new DpkgInterface(this);
-
- iWinPackageView->setSortOrder( (PackageView::sortOrder)iSettings->qsettings()->value("default_sort_order",0).toInt() );
-
- iWinPackageView->setSearchOptions( iSettings->qsettings()->value("search_pkgnames",true).toBool(),
- iSettings->qsettings()->value("search_displaynames",true).toBool(),
- iSettings->qsettings()->value("search_descshort",true).toBool(),
- iSettings->qsettings()->value("search_desclong",false).toBool() );
+ iAptInterface = new AAptInterface(this);
+ iWinPackageView = new PackageView(this);
+ iWinPackageView->setAptInterface(iAptInterface);
+ iWinRepoView = new RepoView(this);
+ iWinRepoView->setAptInterface(iAptInterface);
+ iSettings = new Settings(this);
+ iSettings->setAptInterface(iAptInterface);
+ iSettings->setPackageView(iWinPackageView);
+ iWinPackageView->setSettings(iSettings);
+ iAptInterface->setSettings(iSettings);
+ iDpkgInterface = new DpkgInterface(this);
+
+ iWinPackageView->setSortOrder( (PackageView::sortOrder)iSettings->qsettings()->value("default_sort_order",0).toInt() );
+
+ iWinPackageView->setSearchOptions( iSettings->qsettings()->value("search_pkgnames",true).toBool(),
+ iSettings->qsettings()->value("search_displaynames",true).toBool(),
+ iSettings->qsettings()->value("search_descshort",true).toBool(),
+ iSettings->qsettings()->value("search_desclong",false).toBool() );
#ifdef Q_WS_MAEMO_5
- if( !iSettings->qsettings()->value("disable_autorotation",false).toBool() ) {
- this->setAttribute(Qt::WA_Maemo5AutoOrientation);
- } else {
- this->setAttribute(Qt::WA_Maemo5LandscapeOrientation);
- }
- this->setAttribute(Qt::WA_Maemo5StackedWindow);
+ if( !iSettings->qsettings()->value("disable_autorotation",false).toBool() ) {
+ this->setAttribute(Qt::WA_Maemo5AutoOrientation);
+ } else {
+ this->setAttribute(Qt::WA_Maemo5LandscapeOrientation);
+ }
+ this->setAttribute(Qt::WA_Maemo5StackedWindow);
#endif
- iDimmer = new dimmer(this);
-
- iReposAutoUpdating = false;
- iUpgradeAutoUpdate = true;
- iNextOperation = OpNone;
-
- connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged()));
-
- ui->centralWidget->loadWallpaper();
-
- /*
- QString stylesheet_mainscreen =
- "QPushButton {"
- "border-radius: 16px;"
- "border-width: 1px;"
- "border-color: palette(light);"
- "border-style: outset;"
- "padding-right: 10px;"
- "padding-left: 10px;"
- "color: palette(buttontext);"
- "background: rgba(255,255,255,80);"
- "}"
- "QPushButton:pressed {"
- "border-style: inset;"
- "background-color: rgba(255,255,255,150);"
- "}";
- */
-
- if( ((QApplication*)QApplication::instance())->styleSheet().isEmpty() )
- {
- QString stylesheet_file;
- QFile f("/root/.fapman/style.css");
- if( f.open(QIODevice::ReadOnly | QIODevice::Text ) )
- {
- while(!f.atEnd()) {
- stylesheet_file += f.readLine().trimmed();
- }
- f.close();
- }
-
- if( stylesheet_file.isEmpty() ) {
- //ui->centralWidget->setStyleSheet(stylesheet_mainscreen);
- } else {
- ((QApplication*)QApplication::instance())->setStyleSheet(stylesheet_file);
- }
- }
-
-
- iMediaObject = new Phonon::MediaObject(this);
- Phonon::AudioOutput* aout = new Phonon::AudioOutput(Phonon::NotificationCategory, this);
- Phonon::createPath(iMediaObject, aout);
-
- showFreeSpace();
-
- iNetworkConfigurationManager = new QNetworkConfigurationManager(this);
- iNetworkSession = new QNetworkSession(iNetworkConfigurationManager->defaultConfiguration(),this);
-
- show();
- rescaleMenuView();
+ iDimmer = new dimmer(this);
+
+ iReposAutoUpdating = false;
+ iUpgradeAutoUpdate = true;
+ iNextOperation = OpNone;
+
+ connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged()));
+
+ ui->centralWidget->loadWallpaper();
+
+ /*
+ QString stylesheet_mainscreen =
+ "QPushButton {"
+ "border-radius: 16px;"
+ "border-width: 1px;"
+ "border-color: palette(light);"
+ "border-style: outset;"
+ "padding-right: 10px;"
+ "padding-left: 10px;"
+ "color: palette(buttontext);"
+ "background: rgba(255,255,255,80);"
+ "}"
+ "QPushButton:pressed {"
+ "border-style: inset;"
+ "background-color: rgba(255,255,255,150);"
+ "}";
+ */
+
+ if( ((QApplication*)QApplication::instance())->styleSheet().isEmpty() )
+ {
+ QString stylesheet_file;
+ QFile f("/root/.fapman/style.css");
+ if( f.open(QIODevice::ReadOnly | QIODevice::Text ) )
+ {
+ while(!f.atEnd()) {
+ stylesheet_file += f.readLine().trimmed();
+ }
+ f.close();
+ }
+
+ if( stylesheet_file.isEmpty() ) {
+ //ui->centralWidget->setStyleSheet(stylesheet_mainscreen);
+ } else {
+ ((QApplication*)QApplication::instance())->setStyleSheet(stylesheet_file);
+ }
+ }
+
+
+ iMediaObject = new Phonon::MediaObject(this);
+ Phonon::AudioOutput* aout = new Phonon::AudioOutput(Phonon::NotificationCategory, this);
+ Phonon::createPath(iMediaObject, aout);
+
+ showFreeSpace();
+
+ iNetworkConfigurationManager = new QNetworkConfigurationManager(this);
+ iNetworkSession = new QNetworkSession(iNetworkConfigurationManager->defaultConfiguration(),this);
+
+ show();
+ rescaleMenuView();
}
MainWindow::~MainWindow()
{
- // save "need repo refresh" status
- iSettings->qsettings()->setValue("need_repo_refresh", iAptInterface->needRepoRefresh());
-
- if( iNetworkSession && iNetworkSession->isOpen() ) {
- iNetworkSession->close();
- }
- // iNetworkSession automatically deleted by parent
-
- delete iWinPackageView; iWinPackageView=0;
- delete iWinRepoView; iWinRepoView=0;
- delete iAptInterface; iAptInterface=0;
- delete iDpkgInterface; iDpkgInterface=0;
- delete iDimmer; iDimmer=0;
- delete iSettings; iSettings=0;
- delete ui; ui=0;
- //iMediaObject and aout automatically deleted by their parent
+ // save "need repo refresh" status
+ iSettings->qsettings()->setValue("need_repo_refresh", iAptInterface->needRepoRefresh());
+
+ if( iNetworkSession && iNetworkSession->isOpen() ) {
+ iNetworkSession->close();
+ }
+ // iNetworkSession automatically deleted by parent
+
+ delete iWinPackageView; iWinPackageView=0;
+ delete iWinRepoView; iWinRepoView=0;
+ delete iAptInterface; iAptInterface=0;
+ delete iDpkgInterface; iDpkgInterface=0;
+ delete iDimmer; iDimmer=0;
+ delete iSettings; iSettings=0;
+ delete ui; ui=0;
+ //iMediaObject and aout automatically deleted by their parent
}
void MainWindow::openNetworkConnection()
{
- if( iNetworkSession->isOpen() )
- return;
-
- iNetworkSession->open();
- if( !iNetworkSession->waitForOpened(20000) )
- {
- ConfirmDialog d(false, this);
- d.setText("Network error","Unable to open a network connection");
- d.exec();
- }
+ if( iNetworkSession->isOpen() )
+ return;
+
+ iNetworkSession->open();
+ if( !iNetworkSession->waitForOpened(20000) )
+ {
+ ConfirmDialog d(false, this);
+ d.setText("Network error","Unable to open a network connection");
+ d.exec();
+ }
}
void MainWindow::changeEvent(QEvent *e)
void MainWindow::on_btnRepos_clicked()
{
- iWinRepoView->openWin();
+ iWinRepoView->openWin();
}
void MainWindow::on_btnUpdate_clicked()
-{
- // update catalogs
+{
+ // update catalogs
- openNetworkConnection();
+ openNetworkConnection();
- busyDialog(true, tr("Operation in progress"), tr("Updating catalogs"));
+ busyDialog(true, tr("Operation in progress"), tr("Updating catalogs"));
- iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetUpdate);
- iAptInterface->run(iDimmer);
+ iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetUpdate);
+ iAptInterface->run(iDimmer);
}
#ifdef Q_WS_MAEMO_5
int MainWindow::top_application()
{
- show();
- activateWindow();
- raise();
- return 0;
+ show();
+ activateWindow();
+ raise();
+ return 0;
}
#endif
void MainWindow::dateFetchAsk()
{
- if( !iSettings->qsettings()->value("firstrun_asked_fetch_dates",false).toBool() &&
- !iSettings->qsettings()->value("fetch_dates",false).toBool() )
- {
- iSettings->qsettings()->setValue("firstrun_asked_fetch_dates", true);
- ConfirmDialog d(true, this);
- d.setText("Fetch date information?","Enable date information fetching for packages? You have to enable it in order to be "
- "able to sort packages by date. The first fetch can be slow but the dates are cached for later use. You can later "
- "change this selection from the options menu.");
- if( d.exec() )
- iSettings->qsettings()->setValue("fetch_dates", true);
- }
- if( iSettings->qsettings()->value("fetch_dates",false).toBool() )
- {
- iSettings->qsettings()->setValue("firstrun_asked_fetch_dates", true); // don't ask if the option has already been enabled
- if( !iAptInterface->dateCacheExists() )
- {
- ConfirmDialog d(false, this);
- d.setText("Notice","Date information will be fetched only for packages from maemo.org and only for user categories.");
- d.exec();
- }
- iAptInterface->addQueuedOperation(AAptInterface::ModeFetchDates);
- }
+ if( !iSettings->qsettings()->value("firstrun_asked_fetch_dates",false).toBool() &&
+ !iSettings->qsettings()->value("fetch_dates",false).toBool() )
+ {
+ iSettings->qsettings()->setValue("firstrun_asked_fetch_dates", true);
+ ConfirmDialog d(true, this);
+ d.setText("Fetch date information?","Enable date information fetching for packages? You have to enable it in order to be "
+ "able to sort packages by date. The first fetch can be slow but the dates are cached for later use. You can later "
+ "change this selection from the options menu.");
+ if( d.exec() )
+ iSettings->qsettings()->setValue("fetch_dates", true);
+ }
+ if( iSettings->qsettings()->value("fetch_dates",false).toBool() )
+ {
+ iSettings->qsettings()->setValue("firstrun_asked_fetch_dates", true); // don't ask if the option has already been enabled
+ if( !iAptInterface->dateCacheExists() )
+ {
+ ConfirmDialog d(false, this);
+ d.setText("Notice","Date information will be fetched only for packages from maemo.org and only for user categories.");
+ d.exec();
+ }
+ iAptInterface->addQueuedOperation(AAptInterface::ModeFetchDates);
+ }
}
void MainWindow::on_btnListInstallable_clicked()
{
- //install
+ //install
- openNetworkConnection();
+ openNetworkConnection();
- int listupd = -1;
- int dpkgupd = -1;
- if( iAptInterface->lastListUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
- listupd = 1;
- if( iAptInterface->lastDpkgUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
- dpkgupd = 1;
- iAptInterface->setNeedRefresh(-1,listupd,dpkgupd,listupd);
+ int listupd = -1;
+ int dpkgupd = -1;
+ if( iAptInterface->lastListUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
+ listupd = 1;
+ if( iAptInterface->lastDpkgUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
+ dpkgupd = 1;
+ iAptInterface->setNeedRefresh(-1,listupd,dpkgupd,listupd);
- iWinPackageView->setStatFilter( Package::PkgStatNotInstalled );
+ iWinPackageView->setStatFilter( Package::PkgStatNotInstalled );
- if( iAptInterface->needRepoRefresh() && !iSettings->qsettings()->value("no_catalogs_autoupdate",false).toBool() )
- iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetUpdate);
+ if( iAptInterface->needRepoRefresh() && !iSettings->qsettings()->value("no_catalogs_autoupdate",false).toBool() )
+ iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetUpdate);
- busyDialog(true, tr("Operation in progress"), tr("Reading package lists"));
+ busyDialog(true, tr("Operation in progress"), tr("Reading package lists"));
- iNextOperation = OpOpenPkgView;
- iAptInterface->addQueuedOperation(AAptInterface::ModeReadPackages);
+ iNextOperation = OpOpenPkgView;
+ iAptInterface->addQueuedOperation(AAptInterface::ModeReadPackages);
- dateFetchAsk();
+ dateFetchAsk();
- iAptInterface->run(iDimmer);
+ iAptInterface->run(iDimmer);
}
void MainWindow::on_btnUpgrade_clicked()
{
- // upgrade
+ // upgrade
- openNetworkConnection();
+ openNetworkConnection();
- int listupd = -1;
- int dpkgupd = -1;
- if( iAptInterface->lastListUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
- listupd = 1;
- if( iAptInterface->lastDpkgUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
- dpkgupd = 1;
- iAptInterface->setNeedRefresh(-1,listupd,dpkgupd,listupd);
+ int listupd = -1;
+ int dpkgupd = -1;
+ if( iAptInterface->lastListUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
+ listupd = 1;
+ if( iAptInterface->lastDpkgUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
+ dpkgupd = 1;
+ iAptInterface->setNeedRefresh(-1,listupd,dpkgupd,listupd);
- iWinPackageView->setStatFilter( Package::PkgStatUpgradeable );
+ iWinPackageView->setStatFilter( Package::PkgStatUpgradeable );
- if( iAptInterface->needRepoRefresh() && !iSettings->qsettings()->value("no_catalogs_autoupdate",false).toBool() )
- iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetUpdate);
+ if( iAptInterface->needRepoRefresh() && !iSettings->qsettings()->value("no_catalogs_autoupdate",false).toBool() )
+ iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetUpdate);
- busyDialog(true, tr("Operation in progress"), tr("Reading package lists"));
+ busyDialog(true, tr("Operation in progress"), tr("Reading package lists"));
- iNextOperation = OpOpenPkgView;
- iAptInterface->addQueuedOperation(AAptInterface::ModeReadPackages);
+ iNextOperation = OpOpenPkgView;
+ iAptInterface->addQueuedOperation(AAptInterface::ModeReadPackages);
- dateFetchAsk();
+ dateFetchAsk();
- iAptInterface->run(iDimmer);
+ iAptInterface->run(iDimmer);
}
void MainWindow::on_btnListInstalled_clicked()
{
- //remove
+ //remove
- if( !iSettings->qsettings()->value("remove_readfull",false).toBool() )
- iAptInterface->setSkipListAndDates();
+ if( !iSettings->qsettings()->value("remove_readfull",false).toBool() )
+ iAptInterface->setSkipListAndDates();
- int dpkgupd = -1;
- if( iAptInterface->lastDpkgUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
- dpkgupd = 1;
- iAptInterface->setNeedRefresh(-1,-1,dpkgupd,-1);
+ int dpkgupd = -1;
+ if( iAptInterface->lastDpkgUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
+ dpkgupd = 1;
+ iAptInterface->setNeedRefresh(-1,-1,dpkgupd,-1);
- iWinPackageView->setStatFilter( Package::PkgStatInstalled );
+ iWinPackageView->setStatFilter( Package::PkgStatInstalled );
- busyDialog(true, tr("Operation in progress"), tr("Reading package lists"));
+ busyDialog(true, tr("Operation in progress"), tr("Reading package lists"));
- iNextOperation = OpOpenPkgView;
- iAptInterface->addQueuedOperation(AAptInterface::ModeReadPackages);
+ iNextOperation = OpOpenPkgView;
+ iAptInterface->addQueuedOperation(AAptInterface::ModeReadPackages);
- dateFetchAsk();
+ dateFetchAsk();
- iAptInterface->run(iDimmer);
+ iAptInterface->run(iDimmer);
}
void MainWindow::operationQueueFinished(QList<AAptInterface::interfaceMode> lastModes, bool success, QString title, QStringList msgs)
{
- if( lastModes.contains(AAptInterface::ModeAptGetSimulate) && success ) {
- iNextOperation = OpPromptSimulated;
- }
- if( lastModes.contains(AAptInterface::ModeAptGetInstall) && success ) {
- iWinPackageView->clearSelections();
- busyDialog(false);
- iWinPackageView->close();
- iNextOperation = OpNone;
-
- GdkEventIconThemeReload();
- }
-
- QWidget* dialogParent = this;
- if( iWinPackageView->isVisible() )
- dialogParent = iWinPackageView;
-
- if( iNextOperation == OpOpenPkgView && success )
- {
- iWinPackageView->openWin();
- busyDialog(false);
- iNextOperation = OpNone;
- } else if( iNextOperation == OpPromptSimulated && success )
- {
- QStringList inst,remv,instver,remvver;
- QStringList all = iAptInterface->processPackages();
- QStringList vers = iAptInterface->processPackageVersions();
- for(int zyx=0; zyx<all.count(); zyx++)
- {
- if( all.at(zyx).endsWith('-') )
- {
- remv.append( all.at(zyx).left( all.at(zyx).size()-1 ) );
- if( vers.count()>zyx )
- remvver.append( vers.at(zyx) );
- } else {
- inst.append( all.at(zyx) );
- if( vers.count()>zyx )
- instver.append( vers.at(zyx) );
- }
- }
-
- int total_dl_size = 0;
- for( int i=0; i<inst.count(); i++ ) {
- Package* pkg = iAptInterface->packagesAvailable()->value(inst.at(i),0);
- if( pkg ) {
- total_dl_size += pkg->size()/1024;
- }
- }
-
- QString pkglist;
- pkglist = QString("<b>The following operations will be performed:</b><br>"
- "%1 to install/upgrade, %2 to remove<br>").arg(inst.count()).arg(remv.count());
- if( inst.count()>0 )
- pkglist += QString("Total download size: %L1 kB<br>").arg(total_dl_size);
- bool mismatch = false;
- bool warn_system_package_remove = false;
- bool warn_system_package_install = false;
-
- if( remv.count()>0 ) {
- pkglist += "<br><b><u>REMOVE:</u></b><br><font size=\"-1\">";
- for( int i=0; i<remv.count(); i++ ) {
- pkglist += "<b>" + remv.at(i) + "</b>";
- Package* pkg = iAptInterface->packagesInstalled()->value(remv.at(i),0);
- if( !pkg ) {
- qDebug() << "Warning: unknown package" << remv.at(i);
- pkglist += "<font color=\"red\">***UNKNOWN***</font>";
- mismatch = true;
- }
+ if( lastModes.contains(AAptInterface::ModeAptGetSimulate) && success ) {
+ iNextOperation = OpPromptSimulated;
+ }
+ if( lastModes.contains(AAptInterface::ModeAptGetInstall) && success ) {
+ iWinPackageView->clearSelections();
+ busyDialog(false);
+ iWinPackageView->close();
+ iNextOperation = OpNone;
+
+ GdkEventIconThemeReload();
+ }
+
+ QWidget* dialogParent = this;
+ if( iWinPackageView->isVisible() )
+ dialogParent = iWinPackageView;
+
+ if( iNextOperation == OpOpenPkgView && success )
+ {
+ iWinPackageView->openWin();
+ busyDialog(false);
+ iNextOperation = OpNone;
+ } else if( iNextOperation == OpPromptSimulated && success )
+ {
+ QStringList inst,remv,instver,remvver;
+ QStringList all = iAptInterface->processPackages();
+ QStringList vers = iAptInterface->processPackageVersions();
+ for(int zyx=0; zyx<all.count(); zyx++)
+ {
+ if( all.at(zyx).endsWith('-') )
+ {
+ remv.append( all.at(zyx).left( all.at(zyx).size()-1 ) );
+ if( vers.count()>zyx )
+ remvver.append( vers.at(zyx) );
+ } else {
+ inst.append( all.at(zyx) );
+ if( vers.count()>zyx )
+ instver.append( vers.at(zyx) );
+ }
+ }
+
+ int total_dl_size = 0;
+ for( int i=0; i<inst.count(); i++ ) {
+ Package* pkg = iAptInterface->packagesAvailable()->value(inst.at(i),0);
+ if( pkg ) {
+ total_dl_size += pkg->size()/1024;
+ }
+ }
+
+ QString pkglist;
+ pkglist = QString("<b>The following operations will be performed:</b><br>"
+ "%1 to install/upgrade, %2 to remove<br>").arg(inst.count()).arg(remv.count());
+ if( inst.count()>0 )
+ pkglist += QString("Total download size: %L1 kB<br>").arg(total_dl_size);
+ bool mismatch = false;
+ bool warn_system_package_remove = false;
+ bool warn_system_package_install = false;
+
+ if( remv.count()>0 ) {
+ pkglist += "<br><b><u>REMOVE:</u></b><br><font size=\"-1\">";
+ for( int i=0; i<remv.count(); i++ ) {
+ pkglist += "<b>" + remv.at(i) + "</b>";
+ Package* pkg = iAptInterface->packagesInstalled()->value(remv.at(i),0);
+ if( !pkg ) {
+ qDebug() << "Warning: unknown package" << remv.at(i);
+ pkglist += "<font color=\"red\">***UNKNOWN***</font>";
+ mismatch = true;
+ }
#ifdef Q_WS_MAEMO_5
- if( pkg && pkg->maemoDisplayName()=="Maemo 5" ) {
- warn_system_package_remove = true;
- }
+ if( pkg && pkg->maemoDisplayName()=="Maemo 5" ) {
+ warn_system_package_remove = true;
+ }
#endif
- if( remvver.count()>i ) {
- pkglist += " " + remvver.at(i);
- if( pkg && remvver.at(i) != pkg->version() ) {
- qDebug() << "Version mismatch, database version is" << pkg->version() << "but removing" << remvver.at(i);
- mismatch = true;
- pkglist += " <font color=\"red\">***TRYING TO REMOVE " + pkg->version() + "***</font> ";
- }
- }
- if( pkg && pkg->installedSize()>0 )
- pkglist += QString(" (%L1 kB)").arg(pkg->installedSize());
- pkglist += "<br>";
- }
- }
- pkglist += "</font>";
-
- bool installing_blacklisted = false;
- if( inst.count()>0 ) {
- pkglist += "<br><b><u>INSTALL/UPGRADE:</u></b><br><font size=\"-1\">";
- for( int i=0; i<inst.count(); i++ ) {
- pkglist += "<b>" + inst.at(i) + "</b>";
- Package* pkg = iAptInterface->packagesAvailable()->value(inst.at(i),0);
- if( !pkg ) {
- qDebug() << "Warning: unknown package" << inst.at(i);
- pkglist += "<font color=\"red\">***NEW/UNKNOWN***</font>";
- mismatch = true;
- }
- if( pkg && pkg->isBlacklisted() ) {
- qDebug() << "Warning: installing blacklisted package" << inst.at(i);
- pkglist += "<font color=\"red\">***BLACKLISTED***</font>";
- installing_blacklisted = true;
- }
+ if( remvver.count()>i ) {
+ pkglist += " " + remvver.at(i);
+ if( pkg && remvver.at(i) != pkg->version() ) {
+ qDebug() << "Version mismatch, database version is" << pkg->version() << "but removing" << remvver.at(i);
+ mismatch = true;
+ pkglist += " <font color=\"red\">***TRYING TO REMOVE " + pkg->version() + "***</font> ";
+ }
+ }
+ if( pkg && pkg->installedSize()>0 )
+ pkglist += QString(" (%L1 kB)").arg(pkg->installedSize());
+ pkglist += "<br>";
+ }
+ }
+ pkglist += "</font>";
+
+ bool installing_blacklisted = false;
+ if( inst.count()>0 ) {
+ pkglist += "<br><b><u>INSTALL/UPGRADE:</u></b><br><font size=\"-1\">";
+ for( int i=0; i<inst.count(); i++ ) {
+ pkglist += "<b>" + inst.at(i) + "</b>";
+ Package* pkg = iAptInterface->packagesAvailable()->value(inst.at(i),0);
+ if( !pkg ) {
+ qDebug() << "Warning: unknown package" << inst.at(i);
+ pkglist += "<font color=\"red\">***NEW/UNKNOWN***</font>";
+ mismatch = true;
+ }
+ if( pkg && pkg->isBlacklisted() ) {
+ qDebug() << "Warning: installing blacklisted package" << inst.at(i);
+ pkglist += "<font color=\"red\">***BLACKLISTED***</font>";
+ installing_blacklisted = true;
+ }
#ifdef Q_WS_MAEMO_5
- if( pkg && pkg->maemoDisplayName()=="Maemo 5" ) { // unreliable?
- warn_system_package_install = true;
- }
+ if( pkg && pkg->maemoDisplayName()=="Maemo 5" ) { // unreliable?
+ warn_system_package_install = true;
+ }
#endif
- if( instver.count()>i ) {
- pkglist += " " + instver.at(i);
- if( pkg && instver.at(i) != pkg->version() ) {
- qDebug() << "Version mismatch, database version is" << pkg->version() << "but installing" << instver.at(i);
- mismatch = true;
- pkglist += " <font color=\"red\">***TRYING TO INSTALL " + pkg->version() + "***</font> ";
- }
- }
- if( pkg && pkg->size()>0 ) {
- pkglist += QString(" (%L1 kB)").arg(pkg->size()/1024);
- }
- pkglist += "<br>";
- }
- }
- pkglist += "</font>";
-
- if( mismatch ) {
- ConfirmDialog m(false, dialogParent);
- m.setText("Warning", "There is a version mismatch between your original package selections and some of the packages being installed " \
- "from the repositories. This could be due to your application catalogs being out of date.");
- m.exec();
- }
- if( installing_blacklisted ) {
- ConfirmDialog b(false, dialogParent);
- b.setText("Warning","Blacklisted package(s) will be installed");
- b.exec();
- }
- if( warn_system_package_remove ) {
- ConfirmDialog s(false, dialogParent);
- s.setText("Warning","You are about to remove a critical system package.");
- s.exec();
- }
- if( warn_system_package_install ) {
- ConfirmDialog s(false, dialogParent);
- s.setText("Warning","You are trying to perform an install/upgrade operation on a critical system package. Doing a system upgrade with " \
- "Faster Application Manager has not been tested and it could result in a horrible failure. You have been warned.");
- s.exec();
- }
-
- busyDialog(false);
- ConfirmDialog d(true, dialogParent);
- if( inst.count()==0 && remv.count()==0 )
- {
- pkglist = "None of the packages can be installed";
- d.disableButton();
- }
- d.setText("Confirmation",pkglist);
- if( d.exec() ) {
- iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetInstall);
-
- if( iSettings->qsettings()->value("enable_autoclean",true).toBool() && inst.count()>0 )
- iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetClean);
-
- QString busytext;
- if( remv.count() > 0 )
- busytext += QString("Remove %1 package(s)<br>").arg(remv.count());
- if( inst.count() > 0 )
- busytext += QString("Install %1 package(s)<br>").arg(inst.count());
- busytext += "Preparing...";
- busyDialog(true, "Operation in progress", busytext);
-
- // "run" really does nothing here since the previous item should still be running
- if( iWinPackageView->isVisible() ) {
- iAptInterface->run(iWinPackageView->mydimmer());
- } else {
- iAptInterface->run(iDimmer);
- }
- }
- iNextOperation = OpNone;
- return;
- } else {
- busyDialog(false);
- iNextOperation = OpNone;
-
- if( iSettings->qsettings()->value("sound_notify",false).toBool() )
- {
- qDebug() << "playing sound";
- iMediaObject->setCurrentSource( Phonon::MediaSource(iSettings->qsettings()->value("sound_file","/usr/share/sounds/ui-operation_ready.wav").toString()) );
- iMediaObject->play();
- }
-
- QString text = "<br><b><u>Faster Application Manager</u></b><br>"
- "<b>"+title+"</b><br>" + msgs.join("<br>") + "<br>";
-
- QRect r = QApplication::desktop()->rect();
- if(r.width() < r.height()) {
- ConfirmDialog d(false, dialogParent);
- d.setText(title,msgs.join("<br>"));
- d.exec();
- } else {
+ if( instver.count()>i ) {
+ pkglist += " " + instver.at(i);
+ if( pkg && instver.at(i) != pkg->version() ) {
+ qDebug() << "Version mismatch, database version is" << pkg->version() << "but installing" << instver.at(i);
+ mismatch = true;
+ pkglist += " <font color=\"red\">***TRYING TO INSTALL " + pkg->version() + "***</font> ";
+ }
+ }
+ if( pkg && pkg->size()>0 ) {
+ pkglist += QString(" (%L1 kB)").arg(pkg->size()/1024);
+ }
+ pkglist += "<br>";
+ }
+ }
+ pkglist += "</font>";
+
+ if( mismatch ) {
+ ConfirmDialog m(false, dialogParent);
+ m.setText("Warning", "There is a version mismatch between your original package selections and some of the packages being installed " \
+ "from the repositories. This could be due to your application catalogs being out of date.");
+ m.exec();
+ }
+ if( installing_blacklisted ) {
+ ConfirmDialog b(false, dialogParent);
+ b.setText("Warning","Blacklisted package(s) will be installed");
+ b.exec();
+ }
+ if( warn_system_package_remove ) {
+ ConfirmDialog s(false, dialogParent);
+ s.setText("Warning","You are about to remove a critical system package.");
+ s.exec();
+ }
+ if( warn_system_package_install ) {
+ ConfirmDialog s(false, dialogParent);
+ s.setText("Warning","You are trying to perform an install/upgrade operation on a critical system package. Doing a system upgrade with " \
+ "Faster Application Manager has not been tested and it could result in a horrible failure. You have been warned.");
+ s.exec();
+ }
+
+ busyDialog(false);
+ ConfirmDialog d(true, dialogParent);
+ if( inst.count()==0 && remv.count()==0 )
+ {
+ pkglist = "None of the packages can be installed";
+ d.disableButton();
+ }
+ d.setText("Confirmation",pkglist);
+ if( d.exec() ) {
+ iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetInstall);
+
+ if( iSettings->qsettings()->value("enable_autoclean",true).toBool() && inst.count()>0 )
+ iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetClean);
+
+ QString busytext;
+ if( remv.count() > 0 )
+ busytext += QString("Remove %1 package(s)<br>").arg(remv.count());
+ if( inst.count() > 0 )
+ busytext += QString("Install %1 package(s)<br>").arg(inst.count());
+ busytext += "Preparing...";
+ busyDialog(true, "Operation in progress", busytext);
+
+ // "run" really does nothing here since the previous item should still be running
+ if( iWinPackageView->isVisible() ) {
+ iAptInterface->run(iWinPackageView->mydimmer());
+ } else {
+ iAptInterface->run(iDimmer);
+ }
+ }
+ iNextOperation = OpNone;
+ return;
+ } else {
+ busyDialog(false);
+ iNextOperation = OpNone;
+
+ if( iSettings->qsettings()->value("sound_notify",false).toBool() )
+ {
+ qDebug() << "playing sound";
+ iMediaObject->setCurrentSource( Phonon::MediaSource(iSettings->qsettings()->value("sound_file","/usr/share/sounds/ui-operation_ready.wav").toString()) );
+ iMediaObject->play();
+ }
+
+ QString text = "<br><b><u>Faster Application Manager</u></b><br>"
+ "<b>"+title+"</b><br>" + msgs.join("<br>") + "<br>";
+
+ QRect r = QApplication::desktop()->rect();
+ if(r.width() < r.height()) {
+ ConfirmDialog d(false, dialogParent);
+ d.setText(title,msgs.join("<br>"));
+ d.exec();
+ } else {
#ifdef Q_WS_MAEMO_5
- QMaemo5InformationBox::information(0, text, QMaemo5InformationBox::NoTimeout);
+ QMaemo5InformationBox::information(0, text, QMaemo5InformationBox::NoTimeout);
#else
- ConfirmDialog d(false, dialogParent);
- d.setText(title,msgs.join("<br>"));
- d.exec();
+ ConfirmDialog d(false, dialogParent);
+ d.setText(title,msgs.join("<br>"));
+ d.exec();
#endif
- }
+ }
- showFreeSpace();
- }
+ showFreeSpace();
+ }
}
void MainWindow::busyDialog(bool show_, QString title, QString text)
{
- if( show_ ) {
- iDimmer->setProgress(-1);
- ui->menuMenu->setEnabled(false);
- ui->centralWidget->setEnabled(false);
- iWinPackageView->disableMenu();
- iDimmer->resizeEvent(0);
- iDimmer->dim(title, text);
- iWinPackageView->mydimmer()->resizeEvent(0);
- iWinPackageView->mydimmer()->dim(title, text);
- } else {
- iDimmer->undim();
- iWinPackageView->mydimmer()->undim();
- ui->menuMenu->setEnabled(true);
- ui->centralWidget->setEnabled(true);
- iWinPackageView->enableMenu();
- }
+ if( show_ ) {
+ iDimmer->setProgress(-1);
+ ui->menuMenu->setEnabled(false);
+ ui->centralWidget->setEnabled(false);
+ iWinPackageView->disableMenu();
+ iDimmer->resizeEvent(0);
+ iDimmer->dim(title, text);
+ iWinPackageView->mydimmer()->resizeEvent(0);
+ iWinPackageView->mydimmer()->dim(title, text);
+ } else {
+ iDimmer->undim();
+ iWinPackageView->mydimmer()->undim();
+ ui->menuMenu->setEnabled(true);
+ ui->centralWidget->setEnabled(true);
+ iWinPackageView->enableMenu();
+ }
}
void MainWindow::on_actionAbout_triggered()
{
- ConfirmDialog d(false, this);
- d.setText("About","Faster Application Manager<br>"
- "<font size=\"-1\">Version " + PROGRAM_VERSION + "</font><br><br>"
- "(C) Heikki Holstila 2010<br>Donate using "
- "<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=6ZKRY5QFHL42A&lc=FI&item_name=Faster%20Application%20Manager"
- "%20for%20Maemo5¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted\">PayPal</a>");
- d.exec();
+ ConfirmDialog d(false, this);
+ d.setText("About","Faster Application Manager<br>"
+ "<font size=\"-1\">Version " + PROGRAM_VERSION + "</font><br><br>"
+ "(C) Heikki Holstila 2010<br>Donate using "
+ "<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=6ZKRY5QFHL42A&lc=FI&item_name=Faster%20Application%20Manager"
+ "%20for%20Maemo5¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted\">PayPal</a>");
+ d.exec();
}
void MainWindow::on_actionClean_triggered()
{
- //if( iOperation != OpNone ) return;
- //iOperation = OpClean;
- iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetClean);
- iAptInterface->run(iDimmer);
+ //if( iOperation != OpNone ) return;
+ //iOperation = OpClean;
+ iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetClean);
+ iAptInterface->run(iDimmer);
}
void MainWindow::closeEvent(QCloseEvent *event)
{
- if( iDimmer->busy() ) {
- iAptInterface->cancel();
- event->ignore();
- } else {
- event->accept();
- }
+ if( iDimmer->busy() ) {
+ iAptInterface->cancel();
+ event->ignore();
+ } else {
+ event->accept();
+ }
}
void MainWindow::on_actionView_log_triggered()
{
- QByteArray log = iAptInterface->readLogFile();
- LogView l(log, this);
- l.exec();
+ QByteArray log = iAptInterface->readLogFile();
+ LogView l(log, this);
+ l.exec();
}
void MainWindow::on_actionOptions_triggered()
{
- iSettings->openWin();
+ iSettings->openWin();
}
void MainWindow::notifyDialog(QString title, QString msg)
{
- QWidget* dialogParent = this;
- if( iWinPackageView->isVisible() )
- dialogParent = iWinPackageView;
+ QWidget* dialogParent = this;
+ if( iWinPackageView->isVisible() )
+ dialogParent = iWinPackageView;
- ConfirmDialog d(false, dialogParent);
- d.setText(title, msg);
- d.exec();
+ ConfirmDialog d(false, dialogParent);
+ d.setText(title, msg);
+ d.exec();
}
bool MainWindow::confirmDialog(QString title, QString msg)
{
- QWidget* dialogParent = this;
- if( iWinPackageView->isVisible() )
- dialogParent = iWinPackageView;
+ QWidget* dialogParent = this;
+ if( iWinPackageView->isVisible() )
+ dialogParent = iWinPackageView;
- ConfirmDialog d(true, dialogParent);
- d.setText(title, msg);
- return d.exec();
+ ConfirmDialog d(true, dialogParent);
+ d.setText(title, msg);
+ return d.exec();
}
void MainWindow::GdkEventIconThemeReload()
{
- // DOES NOT EVEN WORK (at least not reliably) - disabled from the project file
+ // DOES NOT EVEN WORK (at least not reliably) - disabled from the project file
#ifdef MYDEF_GTK_EXISTS
- qDebug() << "Sending GDK icon theme reload event";
+ qDebug() << "Sending GDK icon theme reload event";
- gdk_init((int*)QApplication::argc(),(gchar***)QApplication::argv());
+ gdk_init((int*)QApplication::argc(),(gchar***)QApplication::argv());
- // taken from hildon application manager
- GdkEventClient ev;
- ev.type = GDK_CLIENT_EVENT;
- ev.window = NULL;
- ev.send_event = TRUE;
- ev.message_type = gdk_atom_intern_static_string("_GTK_LOAD_ICONTHEMES");
- ev.data_format = 32;
- gdk_event_send_clientmessage_toall((GdkEvent*)&ev);
+ // taken from hildon application manager
+ GdkEventClient ev;
+ ev.type = GDK_CLIENT_EVENT;
+ ev.window = NULL;
+ ev.send_event = TRUE;
+ ev.message_type = gdk_atom_intern_static_string("_GTK_LOAD_ICONTHEMES");
+ ev.data_format = 32;
+ gdk_event_send_clientmessage_toall((GdkEvent*)&ev);
- while(gdk_events_pending()) {
- g_main_context_iteration(NULL, true);
- }
+ while(gdk_events_pending()) {
+ g_main_context_iteration(NULL, true);
+ }
#endif
}
void MainWindow::on_actionLoad_file_triggered()
{
- QStringList files = QFileDialog::getOpenFileNames(this, "Open files", "/", "Files (*.deb *.install)");
- if( files.count() > 0 ) {
- QStringList debs = files.filter(QRegExp(".*\\.deb$"));
- QStringList installs = files.filter(QRegExp(".*\\.install$"));
- if( debs.count()>0 && installs.count()>0 ) {
- ConfirmDialog d(false, this);
- d.setText("Error", "You can't mix different file types in your selection");
- d.exec();
- return;
- }
- if( debs.count()>0 )
- iDpkgInterface->loadDebFiles(debs);
- else if( installs.count()>0 )
- iAptInterface->loadInstallFiles(installs);
- }
+ /*
+ QStringList files = QFileDialog::getOpenFileNames(this, "Open files", "/", "Files (*.deb *.install)");
+ QStringList debs;
+ QStringList installs;
+ if( files.count() > 0 ) {
+ debs = files.filter(QRegExp(".*\\.deb$"));
+ installs = files.filter(QRegExp(".*\\.install$"));
+ if( debs.count()>0 && installs.count()>0 ) {
+ ConfirmDialog d(false, this);
+ d.setText("Error", "You can't mix different file types in your selection");
+ d.exec();
+ return;
+ } else if( installs.count() != 1 ) {
+ ConfirmDialog d(false, this);
+ d.setText("Error","Select only one install file");
+ d.exec();
+ return;
+ }
+ if( debs.count()>0 )
+ iDpkgInterface->loadDebFiles(debs);
+ else if( installs.count()==1 )
+ InstallFile instf(installs.at(0));
+ }
+ */
+
+ QString file = QFileDialog::getOpenFileName(this, "Open file", "/", "Install files (*.install)");
+ if( !file.isEmpty() ) {
+ InstallFile instf( file );
+ bool reposchanged = false;
+ if( instf.isValid() ) {
+ qDebug() << "SUCCESS";
+ for(int i=0; i<instf.repositories().count(); i++) {
+ qDebug() << instf.repositories().at(i)->toString();
+ bool found=false;
+ for(int j=0; j<iAptInterface->repositories()->count(); j++) {
+ if( instf.repositories().at(i) && iAptInterface->repositories()->at(j) &&
+ instf.repositories().at(i)->toString(true) == iAptInterface->repositories()->at(j)->toString(true) )
+ {
+ found = true;
+ qDebug() << "found";
+ if( !iAptInterface->repositories()->at(j)->enabled() ) {
+ iAptInterface->repositories()->at(j)->setEnabled(true);
+ reposchanged = true;
+ qDebug() << "not enabled, enabling";
+ }
+ }
+ }
+ if( !found ) {
+ qDebug() << "repo not found, adding";
+ Repository* r = new Repository();
+ r->setFromString( instf.repositories().at(i)->toString(true) );
+ iAptInterface->repositories()->append(r);
+ reposchanged = true;
+ }
+ }
+
+
+ if( reposchanged ) {
+ iAptInterface->writeRepositories();
+ }
+ iAptInterface->setNeedRefresh(1,1,-1,1);
+ this->on_btnUpdate_clicked();
+
+ } else {
+ qDebug() << "FAIL";
+ ConfirmDialog d(false, this);
+ d.setText("Error",instf.errorString());
+ d.exec();
+ }
+ }
}
void MainWindow::resizeEvent(QResizeEvent* event)
{
- rescaleMenuView();
+ rescaleMenuView();
- if( iDimmer ) {
- iDimmer->resize( this->size() );
- }
+ if( iDimmer ) {
+ iDimmer->resize( this->size() );
+ }
- QMainWindow::resizeEvent(event);
+ QMainWindow::resizeEvent(event);
}
void MainWindow::rescaleMenuView()
{
- QRect sg = ui->listWidget->rect();
+ QRect sg = ui->listWidget->rect();
- if( sg.width() > sg.height() ) {
- ui->listWidget->setGridSize( QSize((sg.width()-12)/5, (sg.height()-12)/2) );
- } else {
- ui->listWidget->setGridSize( QSize((sg.width()-12)/3, (sg.height()-12)/3) );
- }
+ if( sg.width() > sg.height() ) {
+ ui->listWidget->setGridSize( QSize((sg.width()-12)/5, (sg.height()-12)/2) );
+ } else {
+ ui->listWidget->setGridSize( QSize((sg.width()-12)/3, (sg.height()-12)/3) );
+ }
}
void MainWindow::orientationChanged()
void MainWindow::showFreeSpace()
{
- quint64 warn_limit_root = 5120;
- quint64 warn_limit_opt = 51200;
- struct statfs root_stat;
- struct statfs opt_stat;
- statfs("/",&root_stat);
- statfs("/opt",&opt_stat);
- quint64 free_root = static_cast<quint64>(root_stat.f_bavail) * static_cast<quint64>(root_stat.f_bsize) / 1024;
- quint64 free_opt = static_cast<quint64>(opt_stat.f_bavail) * static_cast<quint64>(opt_stat.f_bsize) / 1024;
- quint64 total_root = static_cast<quint64>(root_stat.f_blocks) * static_cast<quint64>(root_stat.f_bsize) / 1024;
- quint64 total_opt = static_cast<quint64>(opt_stat.f_blocks) * static_cast<quint64>(opt_stat.f_bsize) / 1024;
- qDebug() << "rootfs" << free_root << "/" << total_root << "kB free";
- qDebug() << "opt fs" << free_opt << "/" << total_opt << "kB free";
-
- QString rootstr = QString("rootfs: %L1 / %L2 MB free").arg(free_root/1024).arg(total_root/1024);
- QString optstr = QString("opt: %L1 / %L2 MB free").arg(free_opt/1024).arg(total_opt/1024);
-
- ui->label->setText("<font size=\"-1\">" + rootstr + "<br>" + optstr + "</font>");
-
- /*
- ui->progressBarRoot->setFormat(rootstr);
- ui->progressBarRoot->setMaximum(total_root/1024);
- ui->progressBarRoot->setValue(free_root/1024);
- ui->progressBarOpt->setFormat(optstr);
- ui->progressBarOpt->setMaximum(total_opt/1024);
- ui->progressBarOpt->setValue(free_opt/1024);
- */
-
- if( free_root < warn_limit_root || free_opt < warn_limit_opt )
- {
- ConfirmDialog d(false, this);
- QString t;
- if( free_root < warn_limit_root )
- t += QString("Root filesystem has %L1 kB available<br>").arg(free_root);
- if( free_opt < warn_limit_opt )
- t += QString("Opt (home) filesystem has %L1 kB available<br>").arg(free_opt);
- t += "<br>You may proceed, but consider freeing up space to prevent problems in the future";
- d.setText("Warning: Low disk space",t);
- d.exec();
- }
+ quint64 warn_limit_root = 5120;
+ quint64 warn_limit_opt = 51200;
+ struct statfs root_stat;
+ struct statfs opt_stat;
+ statfs("/",&root_stat);
+ statfs("/opt",&opt_stat);
+ quint64 free_root = static_cast<quint64>(root_stat.f_bavail) * static_cast<quint64>(root_stat.f_bsize) / 1024;
+ quint64 free_opt = static_cast<quint64>(opt_stat.f_bavail) * static_cast<quint64>(opt_stat.f_bsize) / 1024;
+ quint64 total_root = static_cast<quint64>(root_stat.f_blocks) * static_cast<quint64>(root_stat.f_bsize) / 1024;
+ quint64 total_opt = static_cast<quint64>(opt_stat.f_blocks) * static_cast<quint64>(opt_stat.f_bsize) / 1024;
+ qDebug() << "rootfs" << free_root << "/" << total_root << "kB free";
+ qDebug() << "opt fs" << free_opt << "/" << total_opt << "kB free";
+
+ QString rootstr = QString("rootfs: %L1 / %L2 MB free").arg(free_root/1024).arg(total_root/1024);
+ QString optstr = QString("opt: %L1 / %L2 MB free").arg(free_opt/1024).arg(total_opt/1024);
+
+ ui->label->setText("<font size=\"-1\">" + rootstr + "<br>" + optstr + "</font>");
+
+ /*
+ ui->progressBarRoot->setFormat(rootstr);
+ ui->progressBarRoot->setMaximum(total_root/1024);
+ ui->progressBarRoot->setValue(free_root/1024);
+ ui->progressBarOpt->setFormat(optstr);
+ ui->progressBarOpt->setMaximum(total_opt/1024);
+ ui->progressBarOpt->setValue(free_opt/1024);
+ */
+
+ if( free_root < warn_limit_root || free_opt < warn_limit_opt )
+ {
+ ConfirmDialog d(false, this);
+ QString t;
+ if( free_root < warn_limit_root )
+ t += QString("Root filesystem has %L1 kB available<br>").arg(free_root);
+ if( free_opt < warn_limit_opt )
+ t += QString("Opt (home) filesystem has %L1 kB available<br>").arg(free_opt);
+ t += "<br>You may proceed, but consider freeing up space to prevent problems in the future";
+ d.setText("Warning: Low disk space",t);
+ d.exec();
+ }
}
void MainWindow::on_listWidget_itemClicked(QListWidgetItem* item)
{
- qDebug() << "main menu:" << item->statusTip();
-
- if( item->statusTip() == "manage_repos" ) {
- on_btnRepos_clicked();
- }
- else if( item->statusTip() == "update_catalogs" ) {
- on_btnUpdate_clicked();
- }
- else if( item->statusTip() == "install_apps" ) {
- on_btnListInstallable_clicked();
- }
- else if( item->statusTip() == "remove_apps" ) {
- on_btnListInstalled_clicked();
- }
- else if( item->statusTip() == "upgrade_apps" ) {
- on_btnUpgrade_clicked();
- }
- else {
- qDebug() << "Warning: Unhandled main menu item";
- }
- item->setSelected(false);
+ qDebug() << "main menu:" << item->statusTip();
+
+ if( item->statusTip() == "manage_repos" ) {
+ on_btnRepos_clicked();
+ }
+ else if( item->statusTip() == "update_catalogs" ) {
+ on_btnUpdate_clicked();
+ }
+ else if( item->statusTip() == "install_apps" ) {
+ on_btnListInstallable_clicked();
+ }
+ else if( item->statusTip() == "remove_apps" ) {
+ on_btnListInstalled_clicked();
+ }
+ else if( item->statusTip() == "upgrade_apps" ) {
+ on_btnUpgrade_clicked();
+ }
+ else {
+ qDebug() << "Warning: Unhandled main menu item";
+ }
+ item->setSelected(false);
}
/*
- This file is part of Faster Application Manager.
+ This file is part of Faster Application Manager.
- Faster Application Manager is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
+ Faster Application Manager is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- Faster Application Manager is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ Faster Application Manager is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with Faster Application Manager. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU General Public License
+ along with Faster Application Manager. If not, see <http://www.gnu.org/licenses/>.
- (C) Heikki Holstila 2010
+ (C) Heikki Holstila 2010
*/
#include "packageview.h"
PackageListWidgetItem::PackageListWidgetItem(Package* p_, QString name_) : QListWidgetItem(name_)
{
- iPackage = p_;
+ iPackage = p_;
}
void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
- //QTime t;
- //t.start();
-
- QString name = index.data(UserRoleName).toString();
- QString version = index.data(UserRoleVersion).toString();
- QString desc = index.data(UserRoleDescShort).toString();
- Package::operation marked = (Package::operation) index.data(UserRoleMarked).toInt();
- bool installed = index.data(UserRoleInstalled).toBool();
- bool upgradeable = index.data(UserRoleUpgradeable).toBool();
- int statfilter = index.data(UserRoleCurrentStatFilter).toInt();
- int catfilter = index.data(UserRoleCurrentCatFilter).toInt();
- QString upg_version = index.data(UserRoleAvailVersion).toString();
- BlacklistSelect::blackList blacklisted = static_cast<BlacklistSelect::blackList>( index.data(UserRoleBlacklisted).toInt() );
-
- painter->save();
- QRect r = option.rect;
-
- QLinearGradient gradientBase(r.topLeft(), r.bottomLeft());
- QColor base = option.palette.color(QPalette::Window);
- QColor base2 = base;
- int r1=base.red()+15;
- int g1=base.green()+15;
- int b1=base.blue()+15;
- if( r1>255 ) r1=255;
- if( g1>255 ) g1=255;
- if( b1>255 ) b1=255;
- int r2=base2.red()-20;
- int g2=base2.green()-20;
- int b2=base2.blue()-20;
- if( r2<0 ) r2=0;
- if( g2<0 ) g2=0;
- if( b2<0 ) b2=0;
- base.setRgb( r1, g1, b1 );
- base2.setRgb( r2, g2, b2 );
- gradientBase.setColorAt(0, base);
- gradientBase.setColorAt(1, base2);
-
- painter->fillRect(r, gradientBase);
- painter->drawLine(QPoint(r.left(),r.bottom()), QPoint(r.right(),r.bottom()));
-
- QPixmap icon = index.data(Qt::DecorationRole).value<QPixmap>();
- if( icon.isNull() ) {
- // use default icon
- painter->drawPixmap( r.left(), r.top()+4, 48, 48, iDefaultIcon );
- } else {
- painter->drawPixmap( r.left(), r.top()+4, 48, 48, icon );
- }
-
- QPixmap statusicon;
- if( marked == Package::PkgOpNone )
- {
- if( installed && upgradeable )
- statusicon = iIconPkgNoOpInstalledUpgradeable;
- else if( installed )
- statusicon = iIconPkgNoOpInstalled;
- else if( !installed )
- statusicon = iIconPkgNoOpNotInstalled;
- } else if( marked == Package::PkgOpInstallUpgrade ) {
- if( upgradeable )
- statusicon = iIconPkgUpgrade;
- else
- statusicon = iIconPkgInstall;
- } else if( marked == Package::PkgOpRemove ) {
- statusicon = iIconPkgRemove;
- }
-
- QString showVer;
- if( upgradeable && (statfilter==Package::PkgStatUpgradeable ||
- (statfilter==Package::PkgStatUnknown && marked==Package::PkgOpInstallUpgrade) ||
- (catfilter==PackageView::CatFilterAllMarked && marked==Package::PkgOpInstallUpgrade) ))
- {
- showVer = upg_version;
- } else {
- showVer = version;
- }
-
- int ver_w = 0;
- if( QApplication::desktop()->width() > QApplication::desktop()->height() )
- {
- r = option.rect;
- r.setRight( r.right()-statusicon.width()-4 );
-
- if( catfilter != PackageView::CatFilterBlacklisted ) {
- painter->drawText(r, Qt::AlignTop|Qt::AlignRight, showVer, &r);
- ver_w = r.width();
- } else if( blacklisted==BlacklistSelect::BlacklistThis ) {
- if( upgradeable && !upg_version.isEmpty() ) {
- showVer = upg_version;
- } else {
- showVer = version;
- }
- painter->drawText(r, Qt::AlignTop|Qt::AlignRight, showVer, &r);
- ver_w = r.width();
- }
- }
-
- r = option.rect;
- r.setRight( r.right()-statusicon.width()-4-ver_w ); //does not work as it should?
- QFont f = painter->font();
- f.setBold(true);
- painter->setFont(f);
- painter->drawText(r.left()+iDefaultIcon.width()+2, r.top(), r.width(), r.height(), Qt::AlignTop|Qt::AlignLeft, name, &r);
- f.setBold(false);
- painter->setFont(f);
-
- f.setPointSize( f.pointSize()-4 );
- painter->setFont(f);
- r = option.rect;
- painter->drawText(r.left()+iDefaultIcon.width()+2, r.top(), r.width(), r.height(), Qt::AlignBottom|Qt::AlignLeft, desc, &r);
-
- r = option.rect;
- painter->drawPixmap(r.right()-statusicon.width()-2, r.top()+4, 24, 24, statusicon);
-
- painter->restore();
-
- //if( t.elapsed()>=100 )
- //qDebug() << name << t.elapsed();
+ //QTime t;
+ //t.start();
+
+ QString name = index.data(UserRoleName).toString();
+ QString version = index.data(UserRoleVersion).toString();
+ QString desc = index.data(UserRoleDescShort).toString();
+ Package::operation marked = (Package::operation) index.data(UserRoleMarked).toInt();
+ bool installed = index.data(UserRoleInstalled).toBool();
+ bool upgradeable = index.data(UserRoleUpgradeable).toBool();
+ int statfilter = index.data(UserRoleCurrentStatFilter).toInt();
+ int catfilter = index.data(UserRoleCurrentCatFilter).toInt();
+ QString upg_version = index.data(UserRoleAvailVersion).toString();
+ BlacklistSelect::blackList blacklisted = static_cast<BlacklistSelect::blackList>( index.data(UserRoleBlacklisted).toInt() );
+
+ painter->save();
+ QRect r = option.rect;
+
+ QPixmap icon = index.data(Qt::DecorationRole).value<QPixmap>();
+ if( icon.isNull() ) {
+ // use default icon
+ painter->drawPixmap( r.left()+6, r.top()+10, 48, 48, iDefaultIcon );
+ } else {
+ painter->drawPixmap( r.left()+6, r.top()+10, 48, 48, icon );
+ }
+
+ QPixmap statusicon;
+ if( marked == Package::PkgOpNone )
+ {
+ if( installed && upgradeable )
+ statusicon = iIconPkgNoOpInstalledUpgradeable;
+ else if( installed )
+ statusicon = iIconPkgNoOpInstalled;
+ else if( !installed )
+ statusicon = iIconPkgNoOpNotInstalled;
+ } else if( marked == Package::PkgOpInstallUpgrade ) {
+ if( upgradeable )
+ statusicon = iIconPkgUpgrade;
+ else
+ statusicon = iIconPkgInstall;
+ } else if( marked == Package::PkgOpRemove ) {
+ statusicon = iIconPkgRemove;
+ }
+
+ QString showVer;
+ if( upgradeable && (statfilter==Package::PkgStatUpgradeable ||
+ (statfilter==Package::PkgStatUnknown && marked==Package::PkgOpInstallUpgrade) ||
+ (catfilter==PackageView::CatFilterAllMarked && marked==Package::PkgOpInstallUpgrade) ))
+ {
+ showVer = upg_version;
+ } else {
+ showVer = version;
+ }
+
+ int ver_w = 0;
+ if( QApplication::desktop()->width() > QApplication::desktop()->height() )
+ {
+ r = option.rect;
+ r.setTop( r.top()+6 );
+ r.setRight( r.right()-statusicon.width()-6 );
+
+ if( catfilter != PackageView::CatFilterBlacklisted ) {
+ painter->drawText(r, Qt::AlignTop|Qt::AlignRight, showVer, &r);
+ ver_w = r.width();
+ } else if( blacklisted==BlacklistSelect::BlacklistThis ) {
+ if( upgradeable && !upg_version.isEmpty() ) {
+ showVer = upg_version;
+ } else {
+ showVer = version;
+ }
+ painter->drawText(r, Qt::AlignTop|Qt::AlignRight, showVer, &r);
+ ver_w = r.width();
+ }
+ }
+
+ r = option.rect;
+ r.setRight( r.right()-statusicon.width()-4-ver_w ); //does not work as it should?
+ QFont f = painter->font();
+ painter->setFont(f);
+ painter->drawText(r.left()+iDefaultIcon.width()+2, r.top()+5, r.width(), r.height(), Qt::AlignTop|Qt::AlignLeft, name, &r);
+
+ f.setPointSize( f.pointSize()-4 );
+ painter->setFont(f);
+ r = option.rect;
+ QColor gray;
+ gray = QColor(156, 154, 156);
+ painter->save();
+ f.setPointSize(13);
+ painter->setFont(f);
+ painter->setPen(gray);
+ r.setBottom(r.bottom()-10);
+ painter->drawText(r.left()+iDefaultIcon.width()+2, r.top(), r.width(), r.height(), Qt::AlignBottom|Qt::AlignLeft, desc, &r);
+ painter->restore();
+
+ r = option.rect;
+ painter->drawPixmap(r.right()-statusicon.width()-2, r.top()+10, 24, 24, statusicon);
+
+ painter->restore();
+
+ //if( t.elapsed()>=100 )
+ //qDebug() << name << t.elapsed();
}
void ListItemDelegate::loadIcons()
{
- iDefaultIcon = QPixmap(":/icons/icons/appdefault.png");
- iIconPkgInstall = QPixmap(":/icons/icons/pkg_install.png");
- iIconPkgUpgrade = QPixmap(":/icons/icons/pkg_upgrade.png");
- iIconPkgRemove = QPixmap(":/icons/icons/pkg_remove.png");
- iIconPkgNoOpInstalled = QPixmap(":/icons/icons/pkg_nop_installed.png");
- iIconPkgNoOpNotInstalled = QPixmap(":/icons/icons/pkg_nop_notinstalled.png");
- iIconPkgNoOpInstalledUpgradeable = QPixmap(":/icons/icons/pkg_nop_instupgr.png");
+#ifdef Q_WS_MAEMO_5
+ iDefaultIcon = QPixmap("/usr/share/icons/hicolor/64x64/hildon/tasklaunch_default_application.png");
+#else
+ iDefaultIcon = QPixmap(":/icons/icons/appdefault.png");
+#endif
+ iIconPkgInstall = QPixmap(":/icons/icons/pkg_install.png");
+ iIconPkgUpgrade = QPixmap(":/icons/icons/pkg_upgrade.png");
+ iIconPkgRemove = QPixmap(":/icons/icons/pkg_remove.png");
+ iIconPkgNoOpInstalled = QPixmap(":/icons/icons/pkg_nop_installed.png");
+ iIconPkgNoOpNotInstalled = QPixmap(":/icons/icons/pkg_nop_notinstalled.png");
+ iIconPkgNoOpInstalledUpgradeable = QPixmap(":/icons/icons/pkg_nop_instupgr.png");
}
QSize ListItemDelegate::sizeHint(const QStyleOptionViewItem&, const QModelIndex&) const
{
- return QSize(400, 58);
+ return QSize(400, 70);
}
PackageView::PackageView(QWidget *parent) : QMainWindow(parent), ui(new Ui::PackageView)
{
- iMainWindow = dynamic_cast<MainWindow*>(parent);
- ui->setupUi(this);
+ iMainWindow = dynamic_cast<MainWindow*>(parent);
+ ui->setupUi(this);
#ifdef Q_WS_MAEMO_5
- this->setAttribute(Qt::WA_Maemo5StackedWindow);
- this->setWindowFlags(Qt::Window);
- this->setAttribute(Qt::WA_Maemo5AutoOrientation);
+ this->setAttribute(Qt::WA_Maemo5StackedWindow);
+ this->setWindowFlags(Qt::Window);
+ this->setAttribute(Qt::WA_Maemo5AutoOrientation);
#endif
- iSettings = 0;
- iAptInterface = 0;
-
- connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged()));
-
- iCatFilterLabels
- << tr("All marked packages") // a special case
- << tr("All user categories")
- << tr("\tDesktop")
- << tr("\tEducation")
- << tr("\tGames")
- << tr("\tGraphics")
- << tr("\tInternet & Networking")
- << tr("\tLocation & Navigation")
- << tr("\tMultimedia")
- << tr("\tOffice")
- << tr("\tOther")
- << tr("\tProgramming")
- << tr("\tScience")
- << tr("\tSystem")
- << tr("\tUtilities")
- << tr("All packages (ADVANCED)")
- << tr("Blacklisted packages"); // a special case
-
- iCatFilterStrings
- << ""
- << "user/"
- << "user/desktop"
- << "user/education"
- << "user/games"
- << "user/graphics"
- << "user/network"
- << "user/navigation"
- << "user/multimedia"
- << "user/office"
- << "user/other"
- << "user/development"
- << "user/science"
- << "user/system"
- << "user/utilities"
- << ""
- << "";
-
- iDefaultCatFilter = CatFilterAllUser;
- iSelectedCatFilter = iDefaultCatFilter;
-
- iStatFilterLabels
- << tr("All")
- << tr("Not installed")
- << tr("Upgradeable")
- << tr("Installed");
-
- iSelectedStatFilter = Package::PkgStatUnknown;
- iSortOrder = SortAlpha;
-
- iDimmer = new dimmer(this);
-
- ui->searchBar->hide();
-
- iListCoverLabel = new QLabel(ui->listWidget);
- iListCoverLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- iListCoverLabel->setAlignment(Qt::AlignCenter);
-
- iKeyFilter = new KeyEventGrabber(this);
- ui->listWidget->installEventFilter(iKeyFilter);
-
- iSortNoticeShown = false;
-
- iSearchPkgName = true;
- iSearchDisplayName = true;
- iSearchDescShort = true;
- iSearchDescLong = false;
-
- // fine-tune kinetic scrolling parameters
+ iSettings = 0;
+ iAptInterface = 0;
+
+ connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged()));
+
+ iCatFilterLabels
+ << tr("All marked packages") // a special case
+ << tr("All user categories")
+ << tr("\tDesktop")
+ << tr("\tEducation")
+ << tr("\tGames")
+ << tr("\tGraphics")
+ << tr("\tInternet & Networking")
+ << tr("\tLocation & Navigation")
+ << tr("\tMultimedia")
+ << tr("\tOffice")
+ << tr("\tOther")
+ << tr("\tProgramming")
+ << tr("\tScience")
+ << tr("\tSystem")
+ << tr("\tUtilities")
+ << tr("All packages (ADVANCED)")
+ << tr("Blacklisted packages"); // a special case
+
+ iCatFilterStrings
+ << ""
+ << "user/"
+ << "user/desktop"
+ << "user/education"
+ << "user/games"
+ << "user/graphics"
+ << "user/network"
+ << "user/navigation"
+ << "user/multimedia"
+ << "user/office"
+ << "user/other"
+ << "user/development"
+ << "user/science"
+ << "user/system"
+ << "user/utilities"
+ << ""
+ << "";
+
+ iDefaultCatFilter = CatFilterAllUser;
+ iSelectedCatFilter = iDefaultCatFilter;
+
+ iStatFilterLabels
+ << tr("All")
+ << tr("Not installed")
+ << tr("Upgradeable")
+ << tr("Installed");
+
+ iSelectedStatFilter = Package::PkgStatUnknown;
+ iSortOrder = SortAlpha;
+
+ iDimmer = new dimmer(this);
+
+ ui->searchBar->hide();
+
+ iListCoverLabel = new QLabel(ui->listWidget);
+ iListCoverLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ iListCoverLabel->setAlignment(Qt::AlignCenter);
+
+ iKeyFilter = new KeyEventGrabber(this);
+ ui->listWidget->installEventFilter(iKeyFilter);
+
+ iSortNoticeShown = false;
+
+ iSearchPkgName = true;
+ iSearchDisplayName = true;
+ iSearchDescShort = true;
+ iSearchDescLong = false;
+
+ // fine-tune kinetic scrolling parameters
#ifdef Q_WS_MAEMO_5
- QAbstractKineticScroller* listscroller = ui->listWidget->property("kineticScroller").value<QAbstractKineticScroller*>();
- if( listscroller )
- {
- //qDebug() << listscroller->dragInertia() << listscroller->decelerationFactor()
- // << listscroller->minimumVelocity() << listscroller->maximumVelocity();
- listscroller->setDecelerationFactor(0.75); // default is 0.85
- listscroller->setDragInertia(0.60); // default is 0.85
- listscroller->setMaximumVelocity(1800); // default is 3500
-
- // not good because it alse sets horizontal overshoot:
- //listscroller->setOvershootPolicy( QAbstractKineticScroller::OvershootAlwaysOn );
- }
+ QAbstractKineticScroller* listscroller = ui->listWidget->property("kineticScroller").value<QAbstractKineticScroller*>();
+ if( listscroller )
+ {
+ //qDebug() << listscroller->dragInertia() << listscroller->decelerationFactor()
+ // << listscroller->minimumVelocity() << listscroller->maximumVelocity();
+ listscroller->setDecelerationFactor(0.75); // default is 0.85
+ listscroller->setDragInertia(0.60); // default is 0.85
+ listscroller->setMaximumVelocity(1800); // default is 3500
+
+ // not good because it alse sets horizontal overshoot:
+ //listscroller->setOvershootPolicy( QAbstractKineticScroller::OvershootAlwaysOn );
+ }
#endif
}
PackageView::~PackageView()
{
- delete iListCoverLabel; iListCoverLabel=0;
- delete iKeyFilter; iKeyFilter=0;
- delete iDimmer; iDimmer=0;
- delete ui; ui=0;
+ delete iListCoverLabel; iListCoverLabel=0;
+ delete iKeyFilter; iKeyFilter=0;
+ delete iDimmer; iDimmer=0;
+ delete ui; ui=0;
}
void PackageView::orientationChanged()
{
- ui->listWidget->scroll(1,1); // this causes all items to be repainted
- iListCoverLabel->setGeometry( ui->listWidget->rect() );
+ ui->listWidget->scroll(1,1); // this causes all items to be repainted
+ iListCoverLabel->setGeometry( ui->listWidget->rect() );
}
void PackageView::resizeEvent(QResizeEvent* event)
{
- if( iDimmer ) {
- iDimmer->resize( this->size() );
- }
+ if( iDimmer ) {
+ iDimmer->resize( this->size() );
+ }
- iListCoverLabel->setGeometry( ui->listWidget->rect() );
- QWidget::resizeEvent(event);
+ iListCoverLabel->setGeometry( ui->listWidget->rect() );
+ QWidget::resizeEvent(event);
}
bool PackageView::doFilterCategory(Package* pkg)
{
- if( pkg->section()=="user/hidden" && iSelectedStatFilter!=Package::PkgStatInstalled && iSelectedStatFilter!=Package::PkgStatUnknown )
- return false;
- if( pkg->section()=="user/hidden" && !pkg->isInstalled() )
- return false;
-
- Package* upg_pkg = pkg->availablePackage();
-
- if( iSelectedStatFilter==Package::PkgStatUpgradeable && iSelectedCatFilter!=CatFilterBlacklisted &&
- pkg->isUpgradeable() && upg_pkg && upg_pkg->isBlacklisted() )
- return false;
-
- if( pkg->isBlacklisted() || (upg_pkg && upg_pkg->isBlacklisted()) )
- {
- if( iSelectedCatFilter == CatFilterBlacklisted )
- return true;
- if( pkg->isInstalled() && (iSelectedStatFilter==Package::PkgStatInstalled || iSelectedStatFilter==Package::PkgStatUnknown) )
- return true;
- if( pkg->isBlacklisted() && iSelectedCatFilter != CatFilterBlacklisted )
- return false;
- } else if( !pkg->isBlacklisted() && iSelectedCatFilter == CatFilterBlacklisted )
- return false;
-
- if( iSelectedCatFilter==CatFilterAllMarked ) {
- if( pkg->isMarkedForOperation() )
- return true;
- else
- return false;
- }
- if( pkg->section().startsWith( iCatFilterStrings.at(iSelectedCatFilter) ) )
- return true;
-
- return false;
+ if( pkg->section()=="user/hidden" && iSelectedStatFilter!=Package::PkgStatInstalled && iSelectedStatFilter!=Package::PkgStatUnknown )
+ return false;
+ if( pkg->section()=="user/hidden" && !pkg->isInstalled() )
+ return false;
+
+ Package* upg_pkg = pkg->availablePackage();
+
+ if( iSelectedStatFilter==Package::PkgStatUpgradeable && iSelectedCatFilter!=CatFilterBlacklisted &&
+ pkg->isUpgradeable() && upg_pkg && upg_pkg->isBlacklisted() )
+ return false;
+
+ if( pkg->isBlacklisted() || (upg_pkg && upg_pkg->isBlacklisted()) )
+ {
+ if( iSelectedCatFilter == CatFilterBlacklisted )
+ return true;
+ if( pkg->isInstalled() && (iSelectedStatFilter==Package::PkgStatInstalled || iSelectedStatFilter==Package::PkgStatUnknown) )
+ return true;
+ if( pkg->isBlacklisted() && iSelectedCatFilter != CatFilterBlacklisted )
+ return false;
+ } else if( !pkg->isBlacklisted() && iSelectedCatFilter == CatFilterBlacklisted )
+ return false;
+
+ if( iSelectedCatFilter==CatFilterAllMarked ) {
+ if( pkg->isMarkedForOperation() )
+ return true;
+ else
+ return false;
+ }
+ if( pkg->section().startsWith( iCatFilterStrings.at(iSelectedCatFilter) ) )
+ return true;
+
+ return false;
}
QString PackageView::generateSortString(Package* pkg)
{
- QString sortstr;
-
- if( iSortOrder==SortAlpha ) {
- sortstr = pkg->displayName();
- }
- else if( iSortOrder==SortDateDesc ) {
- Package* upg = 0;
- if( pkg->isUpgradeable() )
- upg = pkg->availablePackage();
-
- if( (!upg && pkg->date().isValid()) || iSelectedStatFilter==Package::PkgStatInstalled )
- sortstr = pkg->date().toString("yyyy-MM-dd hh:mm:ss");
- else if( upg && upg->date().isValid() ) {
- sortstr = upg->date().toString("yyyy-MM-dd hh:mm:ss");
- } else {
- sortstr = "";
- iPackagesEmptySort++;
- }
- }
- else if( iSortOrder==SortSizeDesc ) {
- if( pkg->isInstalled() )
- sortstr = QString("%1").arg(pkg->installedSize()*1024, 12 );
- else
- sortstr = QString("%1").arg(pkg->size(), 12 );
- }
-
- //qDebug() << sortstr;
-
- return sortstr;
+ QString sortstr;
+
+ if( iSortOrder==SortAlpha ) {
+ sortstr = pkg->displayName();
+ }
+ else if( iSortOrder==SortDateDesc ) {
+ Package* upg = 0;
+ if( pkg->isUpgradeable() )
+ upg = pkg->availablePackage();
+
+ if( (!upg && pkg->date().isValid()) || iSelectedStatFilter==Package::PkgStatInstalled )
+ sortstr = pkg->date().toString("yyyy-MM-dd hh:mm:ss");
+ else if( upg && upg->date().isValid() ) {
+ sortstr = upg->date().toString("yyyy-MM-dd hh:mm:ss");
+ } else {
+ sortstr = "";
+ iPackagesEmptySort++;
+ }
+ }
+ else if( iSortOrder==SortSizeDesc ) {
+ if( pkg->isInstalled() )
+ sortstr = QString("%1").arg(pkg->installedSize()*1024, 12 );
+ else
+ sortstr = QString("%1").arg(pkg->size(), 12 );
+ }
+
+ //qDebug() << sortstr;
+
+ return sortstr;
}
void PackageView::openWin()
{
- ui->listWidget->clear();
- ui->listWidget->setSortingEnabled(true);
- iPackagesEmptySort = 0;
-
- if( !isVisible() ) {
- iMainWindow->busyDialog(false);
- iListCoverLabel->setText("Loading...");
- iListCoverLabel->setAutoFillBackground(true);
- iListCoverLabel->show();
- show();
- QApplication::processEvents();
- }
-
- if( iSortOrder==SortDateDesc || iSortOrder==SortSizeDesc )
- ui->listWidget->sortItems(Qt::DescendingOrder);
- else
- ui->listWidget->sortItems(Qt::AscendingOrder);
-
- delete ui->listWidget->itemDelegate();
- ListItemDelegate* delegate = new ListItemDelegate(ui->listWidget);
- delegate->loadIcons();
- ui->listWidget->setItemDelegate( delegate );
-
- if( !ui->searchBar->isVisible() )
- {
- if( iSelectedStatFilter == Package::PkgStatNotInstalled || iSelectedStatFilter == Package::PkgStatUnknown ||
- iSelectedCatFilter == CatFilterAllMarked || iSelectedCatFilter == CatFilterBlacklisted )
- {
- QHashIterator<QString, Package*> i( *iAptInterface->packagesAvailable() );
- while (i.hasNext())
- {
- i.next();
- Package* inst = iAptInterface->packagesInstalled()->value(i.value()->name(),0);
- if( doFilterCategory(i.value()) && !inst )
- addListItem(i.value(), generateSortString(i.value()));
- }
- }
- if( iSelectedStatFilter == Package::PkgStatInstalled || iSelectedStatFilter == Package::PkgStatUpgradeable ||
- iSelectedStatFilter == Package::PkgStatUnknown || iSelectedCatFilter == CatFilterAllMarked ||
- iSelectedCatFilter == CatFilterBlacklisted )
- {
- QHashIterator<QString, Package*> i( *iAptInterface->packagesInstalled() );
- while (i.hasNext())
- {
- i.next();
- if( iSelectedStatFilter == Package::PkgStatUpgradeable && iSelectedCatFilter != CatFilterBlacklisted ) {
- if( i.value()->isUpgradeable() && doFilterCategory(i.value()) )
- addListItem(i.value(), generateSortString(i.value()));
- } else {
- if( doFilterCategory(i.value()) )
- addListItem(i.value(), generateSortString(i.value()));
- }
- }
- }
- } else {
- for( int j=0; j<iSearchResults.count(); j++ )
- {
- addListItem(iSearchResults.at(j), generateSortString( iSearchResults.at(j) ));
- }
- }
-
- iListCoverLabel->hide();
- iListCoverLabel->setAutoFillBackground(false);
-
- updateLabel();
-
- if( iSelectedStatFilter==Package::PkgStatUpgradeable && ui->listWidget->count()>0 &&
- iSelectedCatFilter != CatFilterAllMarked && iSelectedCatFilter != CatFilterBlacklisted )
- {
- ui->actionUpgrade_all->setVisible(true);
- } else {
- ui->actionUpgrade_all->setVisible(false);
- }
-
- if( iSelectedCatFilter == CatFilterBlacklisted && ui->listWidget->count()>0 ) {
- ui->actionRestore_all->setVisible(true);
- } else {
- ui->actionRestore_all->setVisible(false);
- }
-
- if( iSelectedStatFilter==Package::PkgStatInstalled ) {
- ui->actionStore_list->setVisible(true);
- } else {
- ui->actionStore_list->setVisible(false);
- }
-
- show();
-
- if( !ui->searchBar->isVisible() ) {
- ui->listWidget->setFocusPolicy(Qt::StrongFocus);
- ui->listWidget->setFocus();
- } else {
- ui->listWidget->setFocusPolicy(Qt::NoFocus);
- ui->lineEdit->setFocus();
- }
-
- if( ui->listWidget->count() == 0 )
- {
- iListCoverLabel->setGeometry( ui->listWidget->rect() );
- iListCoverLabel->setText("No packages");
- iListCoverLabel->show();
- }
-
- if( ui->listWidget->count()>1 && iPackagesEmptySort == ui->listWidget->count() && !iSortNoticeShown ) {
- ConfirmDialog d(false, this);
- QString msg = "No shown packages currently have the required information for sorting by this criterion. The list is unsorted.";
- if( iSortOrder == SortDateDesc && !iSettings->qsettings()->value("fetch_dates",false).toBool() )
- msg += " You can enable date fetching in the options menu.";
- d.setText("Notice", msg);
- d.exec();
- iSortNoticeShown = true;
- }
+ ui->listWidget->clear();
+ ui->listWidget->setSortingEnabled(true);
+ iPackagesEmptySort = 0;
+
+ if( !isVisible() ) {
+ iMainWindow->busyDialog(false);
+ iListCoverLabel->setText("Loading...");
+ iListCoverLabel->setAutoFillBackground(true);
+ iListCoverLabel->show();
+ show();
+ QApplication::processEvents();
+ }
+
+ if( iSortOrder==SortDateDesc || iSortOrder==SortSizeDesc )
+ ui->listWidget->sortItems(Qt::DescendingOrder);
+ else
+ ui->listWidget->sortItems(Qt::AscendingOrder);
+
+ delete ui->listWidget->itemDelegate();
+ ListItemDelegate* delegate = new ListItemDelegate(ui->listWidget);
+ delegate->loadIcons();
+ ui->listWidget->setItemDelegate( delegate );
+
+ if( !ui->searchBar->isVisible() )
+ {
+ if( iSelectedStatFilter == Package::PkgStatNotInstalled || iSelectedStatFilter == Package::PkgStatUnknown ||
+ iSelectedCatFilter == CatFilterAllMarked || iSelectedCatFilter == CatFilterBlacklisted )
+ {
+ QHashIterator<QString, Package*> i( *iAptInterface->packagesAvailable() );
+ while (i.hasNext())
+ {
+ i.next();
+ Package* inst = iAptInterface->packagesInstalled()->value(i.value()->name(),0);
+ if( doFilterCategory(i.value()) && !inst )
+ addListItem(i.value(), generateSortString(i.value()));
+ }
+ }
+ if( iSelectedStatFilter == Package::PkgStatInstalled || iSelectedStatFilter == Package::PkgStatUpgradeable ||
+ iSelectedStatFilter == Package::PkgStatUnknown || iSelectedCatFilter == CatFilterAllMarked ||
+ iSelectedCatFilter == CatFilterBlacklisted )
+ {
+ QHashIterator<QString, Package*> i( *iAptInterface->packagesInstalled() );
+ while (i.hasNext())
+ {
+ i.next();
+ if( iSelectedStatFilter == Package::PkgStatUpgradeable && iSelectedCatFilter != CatFilterBlacklisted ) {
+ if( i.value()->isUpgradeable() && doFilterCategory(i.value()) )
+ addListItem(i.value(), generateSortString(i.value()));
+ } else {
+ if( doFilterCategory(i.value()) )
+ addListItem(i.value(), generateSortString(i.value()));
+ }
+ }
+ }
+ } else {
+ for( int j=0; j<iSearchResults.count(); j++ )
+ {
+ addListItem(iSearchResults.at(j), generateSortString( iSearchResults.at(j) ));
+ }
+ }
+
+ iListCoverLabel->hide();
+ iListCoverLabel->setAutoFillBackground(false);
+
+ updateLabel();
+
+ if( iSelectedStatFilter==Package::PkgStatUpgradeable && ui->listWidget->count()>0 &&
+ iSelectedCatFilter != CatFilterAllMarked && iSelectedCatFilter != CatFilterBlacklisted )
+ {
+ ui->actionUpgrade_all->setVisible(true);
+ } else {
+ ui->actionUpgrade_all->setVisible(false);
+ }
+
+ if( iSelectedCatFilter == CatFilterBlacklisted && ui->listWidget->count()>0 ) {
+ ui->actionRestore_all->setVisible(true);
+ } else {
+ ui->actionRestore_all->setVisible(false);
+ }
+
+ if( iSelectedStatFilter==Package::PkgStatInstalled ) {
+ ui->actionStore_list->setVisible(true);
+ } else {
+ ui->actionStore_list->setVisible(false);
+ }
+
+ show();
+
+ if( !ui->searchBar->isVisible() ) {
+ ui->listWidget->setFocusPolicy(Qt::StrongFocus);
+ ui->listWidget->setFocus();
+ } else {
+ ui->listWidget->setFocusPolicy(Qt::NoFocus);
+ ui->lineEdit->setFocus();
+ }
+
+ if( ui->listWidget->count() == 0 )
+ {
+ iListCoverLabel->setGeometry( ui->listWidget->rect() );
+ iListCoverLabel->setText("No packages");
+ iListCoverLabel->show();
+ }
+
+ if( ui->listWidget->count()>1 && iPackagesEmptySort == ui->listWidget->count() && !iSortNoticeShown ) {
+ ConfirmDialog d(false, this);
+ QString msg = "No shown packages currently have the required information for sorting by this criterion. The list is unsorted.";
+ if( iSortOrder == SortDateDesc && !iSettings->qsettings()->value("fetch_dates",false).toBool() )
+ msg += " You can enable date fetching in the options menu.";
+ d.setText("Notice", msg);
+ d.exec();
+ iSortNoticeShown = true;
+ }
}
void PackageView::enableMenu()
{
- ui->menuMenu->setEnabled(true);
+ ui->menuMenu->setEnabled(true);
}
void PackageView::disableMenu()
{
- ui->menuMenu->setEnabled(false);
+ ui->menuMenu->setEnabled(false);
}
void PackageView::addListItem(Package* pkg_, QString listname_)
{
- PackageListWidgetItem* p = new PackageListWidgetItem( pkg_, listname_ );
-
- if( pkg_ != 0 )
- {
- QString name = pkg_->name();
- if( !pkg_->maemoDisplayName().isEmpty() )
- name = pkg_->maemoDisplayName();
- p->setData(UserRoleName, name);
- } else {
- p->setData(UserRoleName, listname_);
- }
-
- if( pkg_ != 0 )
- {
- p->setData(UserRoleDescShort, pkg_->descShort());
- p->setData(UserRoleVersion, pkg_->version());
- p->setData(UserRoleMarked, static_cast<int>(pkg_->markedOperation()) );
- p->setData(UserRoleInstalled, pkg_->isInstalled());
- p->setData(UserRoleUpgradeable, pkg_->isUpgradeable());
- p->setData(UserRoleAvailVersion, pkg_->upgradeableVersion());
- p->setData(UserRoleCurrentStatFilter, iSelectedStatFilter);
- p->setData(UserRoleCurrentCatFilter, iSelectedCatFilter);
-
- if( pkg_->availablePackage() )
- p->setData(UserRoleBlacklisted, static_cast<int>(pkg_->availablePackage()->blacklisted()) );
- else
- p->setData(UserRoleBlacklisted, static_cast<int>(pkg_->blacklisted()) );
-
- //qDebug() << pkg_->name();
-
- pkg_->convertIcon();
- p->setData(Qt::DecorationRole, *pkg_->icon());
- }
- ui->listWidget->addItem( p );
+ PackageListWidgetItem* p = new PackageListWidgetItem( pkg_, listname_ );
+
+ if( pkg_ != 0 )
+ {
+ QString name = pkg_->name();
+ if( !pkg_->maemoDisplayName().isEmpty() )
+ name = pkg_->maemoDisplayName();
+ p->setData(UserRoleName, name);
+ } else {
+ p->setData(UserRoleName, listname_);
+ }
+
+ if( pkg_ != 0 )
+ {
+ p->setData(UserRoleDescShort, pkg_->descShort());
+ p->setData(UserRoleVersion, pkg_->version());
+ p->setData(UserRoleMarked, static_cast<int>(pkg_->markedOperation()) );
+ p->setData(UserRoleInstalled, pkg_->isInstalled());
+ p->setData(UserRoleUpgradeable, pkg_->isUpgradeable());
+ p->setData(UserRoleAvailVersion, pkg_->upgradeableVersion());
+ p->setData(UserRoleCurrentStatFilter, iSelectedStatFilter);
+ p->setData(UserRoleCurrentCatFilter, iSelectedCatFilter);
+
+ if( pkg_->availablePackage() )
+ p->setData(UserRoleBlacklisted, static_cast<int>(pkg_->availablePackage()->blacklisted()) );
+ else
+ p->setData(UserRoleBlacklisted, static_cast<int>(pkg_->blacklisted()) );
+
+ //qDebug() << pkg_->name();
+
+ pkg_->convertIcon();
+ p->setData(Qt::DecorationRole, *pkg_->icon());
+ }
+ ui->listWidget->addItem( p );
}
void PackageView::closeEvent(QCloseEvent *event)
{
- if( !iAptInterface ) {
- resetWindow();
- event->accept();
- }
-
- if( iDimmer->busy() )
- {
- iAptInterface->cancel();
- event->ignore();
- return;
- }
-
- if( iAptInterface->numSelectedPackages() == 0 )
- {
- resetWindow();
- event->accept();
- } else {
- QString c;
- c.setNum( iAptInterface->numSelectedPackages() );
- ConfirmDialog d(true, this);
- d.setText("Returning to main menu", QString("Clear %1 package selection(s) and lose all the pending changes?").arg(iAptInterface->numSelectedPackages()));
- if( d.exec() ) {
- resetWindow();
- event->accept();
- } else {
- event->ignore();
- }
- }
+ if( !iAptInterface ) {
+ resetWindow();
+ event->accept();
+ }
+
+ if( iDimmer->busy() )
+ {
+ iAptInterface->cancel();
+ event->ignore();
+ return;
+ }
+
+ if( iAptInterface->numSelectedPackages() == 0 )
+ {
+ resetWindow();
+ event->accept();
+ } else {
+ QString c;
+ c.setNum( iAptInterface->numSelectedPackages() );
+ ConfirmDialog d(true, this);
+ d.setText("Returning to main menu", QString("Clear %1 package selection(s) and lose all the pending changes?").arg(iAptInterface->numSelectedPackages()));
+ if( d.exec() ) {
+ resetWindow();
+ event->accept();
+ } else {
+ event->ignore();
+ }
+ }
}
void PackageView::changeEvent(QEvent *e)
void PackageView::on_btn_Commit_clicked()
{
- QStringList pkgnames;
-
- QHashIterator<QString, Package*> i( *iAptInterface->packagesAvailable() );
- while (i.hasNext())
- {
- i.next();
-
- if( i.value()->markedOperation() == Package::PkgOpInstallUpgrade )
- pkgnames << i.value()->name();
- if( i.value()->markedOperation() == Package::PkgOpRemove ) {
- qDebug() << "warning: trying to add package marked from the wrong list";
- //pkgnames << i.value()->name() + "-";
- }
- }
-
- QHashIterator<QString, Package*> r( *iAptInterface->packagesInstalled() );
- while (r.hasNext())
- {
- r.next();
-
- if( r.value()->markedOperation() == Package::PkgOpInstallUpgrade )
- pkgnames << r.value()->name();
- if( r.value()->markedOperation() == Package::PkgOpRemove )
- pkgnames << r.value()->name() + "-";
- }
-
- iMainWindow->busyDialog(true, "Operation in progress", "Reading dependencies");
-
- iAptInterface->setProcessPackages(pkgnames);
- iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetSimulate);
- iAptInterface->run(iDimmer);
+ QStringList pkgnames;
+
+ QHashIterator<QString, Package*> i( *iAptInterface->packagesAvailable() );
+ while (i.hasNext())
+ {
+ i.next();
+
+ if( i.value()->markedOperation() == Package::PkgOpInstallUpgrade )
+ pkgnames << i.value()->name();
+ if( i.value()->markedOperation() == Package::PkgOpRemove ) {
+ qDebug() << "warning: trying to add package marked from the wrong list";
+ //pkgnames << i.value()->name() + "-";
+ }
+ }
+
+ QHashIterator<QString, Package*> r( *iAptInterface->packagesInstalled() );
+ while (r.hasNext())
+ {
+ r.next();
+
+ if( r.value()->markedOperation() == Package::PkgOpInstallUpgrade )
+ pkgnames << r.value()->name();
+ if( r.value()->markedOperation() == Package::PkgOpRemove )
+ pkgnames << r.value()->name() + "-";
+ }
+
+ iMainWindow->busyDialog(true, "Operation in progress", "Reading dependencies");
+
+ iAptInterface->setProcessPackages(pkgnames);
+ iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetSimulate);
+ iAptInterface->run(iDimmer);
}
void PackageView::on_actionClear_selections_triggered()
{
- QString c;
- c.setNum( iAptInterface->numSelectedPackages() );
- ConfirmDialog d(true, this);
- d.setText(tr("Confirmation"), tr("Clear ") + c + tr(" package selection(s) and lose all the pending changes?"));
- if( d.exec() )
- {
- clearSelections();
- openWin();
- }
+ QString c;
+ c.setNum( iAptInterface->numSelectedPackages() );
+ ConfirmDialog d(true, this);
+ d.setText(tr("Confirmation"), tr("Clear ") + c + tr(" package selection(s) and lose all the pending changes?"));
+ if( d.exec() )
+ {
+ clearSelections();
+ openWin();
+ }
}
void PackageView::clearSelections()
{
- QHashIterator<QString, Package*> i( *iAptInterface->packagesInstalled() );
- while (i.hasNext())
- {
- i.next();
- i.value()->setMarkedForOperation(Package::PkgOpNone);
- }
- QHashIterator<QString, Package*> a( *iAptInterface->packagesAvailable() );
- while (a.hasNext())
- {
- a.next();
- a.value()->setMarkedForOperation(Package::PkgOpNone);
- }
- iAptInterface->setNumSelectedPackages(0);
+ QHashIterator<QString, Package*> i( *iAptInterface->packagesInstalled() );
+ while (i.hasNext())
+ {
+ i.next();
+ i.value()->setMarkedForOperation(Package::PkgOpNone);
+ }
+ QHashIterator<QString, Package*> a( *iAptInterface->packagesAvailable() );
+ while (a.hasNext())
+ {
+ a.next();
+ a.value()->setMarkedForOperation(Package::PkgOpNone);
+ }
+ iAptInterface->setNumSelectedPackages(0);
}
void PackageView::on_listWidget_itemClicked(QListWidgetItem* item)
{
- Package* pkg = dynamic_cast<PackageListWidgetItem*>(item)->package();
- if( !pkg )
- return;
-
- bool bl = pkg->isBlacklisted();
- bool bl_u = false;
-
- Package* upg_pkg = pkg->availablePackage();
- if( upg_pkg )
- bl_u = upg_pkg->isBlacklisted();
-
- PackageSelector s(pkg, iAptInterface, iSettings, iMainWindow, this);
- s.exec();
- Package::operation op = s.selectedOperation();
-
- QStringList confl = pkg->checkConflicts_RichText();
- if( confl.count() > 0 && op != Package::PkgOpNone ) {
- ConfirmDialog d(true, this);
- QString t = "Package " + pkg->name() + " conflicts with another installed or marked package. Mark anyway?";
- t += "<font size=\"-1\"><br><br>Conflicts: ";
- t += confl.join(", ");
- t += "</font>";
- d.setText("Conflicting packages", t);
- if( !d.exec() )
- op = Package::PkgOpNone;
- }
-
- if( pkg->isPinned() && op != Package::PkgOpNone ) {
- ConfirmDialog d(true, this);
- d.setText("Warning","Package has been pinned in apt preferences. Operation might not go as expected. Mark anyway?");
- if( !d.exec() )
- op = Package::PkgOpNone;
- }
-
- pkg->setMarkedForOperation( op );
- item->setData( UserRoleMarked, (int)op );
- updateLabel();
-
- if( pkg->isBlacklisted() != bl ) {
- openWin();
- }
- else if( upg_pkg && upg_pkg->isBlacklisted() != bl_u ) {
- openWin();
- }
+ Package* pkg = dynamic_cast<PackageListWidgetItem*>(item)->package();
+ if( !pkg )
+ return;
+
+ bool bl = pkg->isBlacklisted();
+ bool bl_u = false;
+
+ Package* upg_pkg = pkg->availablePackage();
+ if( upg_pkg )
+ bl_u = upg_pkg->isBlacklisted();
+
+ PackageSelector s(pkg, iAptInterface, iSettings, iMainWindow, this);
+ s.exec();
+ Package::operation op = s.selectedOperation();
+
+ QStringList confl = pkg->checkConflicts_RichText();
+ if( confl.count() > 0 && op != Package::PkgOpNone ) {
+ ConfirmDialog d(true, this);
+ QString t = "Package " + pkg->name() + " conflicts with another installed or marked package. Mark anyway?";
+ t += "<font size=\"-1\"><br><br>Conflicts: ";
+ t += confl.join(", ");
+ t += "</font>";
+ d.setText("Conflicting packages", t);
+ if( !d.exec() )
+ op = Package::PkgOpNone;
+ }
+
+ if( pkg->isPinned() && op != Package::PkgOpNone ) {
+ ConfirmDialog d(true, this);
+ d.setText("Warning","Package has been pinned in apt preferences. Operation might not go as expected. Mark anyway?");
+ if( !d.exec() )
+ op = Package::PkgOpNone;
+ }
+
+ pkg->setMarkedForOperation( op );
+ item->setData( UserRoleMarked, (int)op );
+ updateLabel();
+
+ if( pkg->isBlacklisted() != bl ) {
+ openWin();
+ }
+ else if( upg_pkg && upg_pkg->isBlacklisted() != bl_u ) {
+ openWin();
+ }
}
void PackageView::updateLabel()
{
- QString s;
- s.setNum( iAptInterface->numSelectedPackages() );
- QString s2;
- s2.setNum( ui->listWidget->count() );
- QString statlabel = iStatFilterLabels.at(iSelectedStatFilter);
- if( iSelectedCatFilter == CatFilterAllMarked || iSelectedCatFilter == CatFilterBlacklisted )
- statlabel = "All";
- ui->label->setText("<font size=\"-2\"><b>" + s + "</b> package(s) marked<br>"
- + "Showing: <b>" + statlabel + "</b><br>"
- + "Filter: " + iCatFilterLabels.at(iSelectedCatFilter) + " - " + s2 + " package(s)</font>");
-
- if( iAptInterface->numSelectedPackages()==0 ) {
- ui->btn_Commit->setEnabled(false);
- ui->actionClear_selections->setVisible(false);
- ui->actionSave_selections->setVisible(false);
- } else {
- ui->btn_Commit->setEnabled(true);
- ui->actionClear_selections->setVisible(true);
- ui->actionSave_selections->setVisible(true);
- }
+ QString s;
+ s.setNum( iAptInterface->numSelectedPackages() );
+ QString s2;
+ s2.setNum( ui->listWidget->count() );
+ QString statlabel = iStatFilterLabels.at(iSelectedStatFilter);
+ if( iSelectedCatFilter == CatFilterAllMarked || iSelectedCatFilter == CatFilterBlacklisted )
+ statlabel = "All";
+ ui->label->setText("<font size=\"-2\"><b>" + s + "</b> package(s) marked<br>"
+ + "Showing: <b>" + statlabel + "</b><br>"
+ + "Filter: " + iCatFilterLabels.at(iSelectedCatFilter) + " - " + s2 + " package(s)</font>");
+
+ if( iAptInterface->numSelectedPackages()==0 ) {
+ ui->btn_Commit->setEnabled(false);
+ ui->actionClear_selections->setVisible(false);
+ ui->actionSave_selections->setVisible(false);
+ } else {
+ ui->btn_Commit->setEnabled(true);
+ ui->actionClear_selections->setVisible(true);
+ ui->actionSave_selections->setVisible(true);
+ }
}
void PackageView::on_btn_CategoryFilter_clicked()
{
- FilterSelect f("Category filter", this);
- f.setList( iCatFilterLabels, iSelectedCatFilter );
-
- bool s = f.exec();
-
- if( s )
- iSelectedCatFilter = f.selection();
-
- if( iSelectedCatFilter == CatFilterAllMarked || iSelectedCatFilter == CatFilterBlacklisted ) {
- ui->btn_StatusFilter->setEnabled(false);
- } else {
- ui->btn_StatusFilter->setEnabled(true);
- }
-
- if( s ) {
- iListCoverLabel->setText("Loading...");
- iListCoverLabel->setAutoFillBackground(true);
- iListCoverLabel->show();
- QApplication::processEvents();
- iSortNoticeShown = false;
-
- openWin();
-
- if( iSelectedCatFilter==CatFilterBlacklisted && iAptInterface->needListOrDateRefresh() )
- {
- ConfirmDialog d(false, this);
- d.setText("Notice","Since you don't have all package lists currently loaded, not all blacklisted "
- "packages are necessarily shown");
- d.exec();
- }
- }
+ FilterSelect f("Category filter", this);
+ f.setList( iCatFilterLabels, iSelectedCatFilter );
+
+ bool s = f.exec();
+
+ if( s )
+ iSelectedCatFilter = f.selection();
+
+ if( iSelectedCatFilter == CatFilterAllMarked || iSelectedCatFilter == CatFilterBlacklisted ) {
+ ui->btn_StatusFilter->setEnabled(false);
+ } else {
+ ui->btn_StatusFilter->setEnabled(true);
+ }
+
+ if( s ) {
+ iListCoverLabel->setText("Loading...");
+ iListCoverLabel->setAutoFillBackground(true);
+ iListCoverLabel->show();
+ QApplication::processEvents();
+ iSortNoticeShown = false;
+
+ openWin();
+
+ if( iSelectedCatFilter==CatFilterBlacklisted && iAptInterface->needListOrDateRefresh() )
+ {
+ ConfirmDialog d(false, this);
+ d.setText("Notice","Since you don't have all package lists currently loaded, not all blacklisted "
+ "packages are necessarily shown");
+ d.exec();
+ }
+ }
}
void PackageView::setStatFilter(Package::packageStatus f_)
{
- iSelectedStatFilter = f_;
+ iSelectedStatFilter = f_;
}
void PackageView::on_btn_StatusFilter_clicked()
{
- FilterSelect f("Status filter", this);
- f.setList( iStatFilterLabels, iSelectedStatFilter );
+ FilterSelect f("Status filter", this);
+ f.setList( iStatFilterLabels, iSelectedStatFilter );
- int oldfilter = iSelectedStatFilter;
+ int oldfilter = iSelectedStatFilter;
- bool s = f.exec();
+ bool s = f.exec();
- if( s ) {
- iSelectedStatFilter = (Package::packageStatus)f.selection();
+ if( s ) {
+ iSelectedStatFilter = (Package::packageStatus)f.selection();
- iListCoverLabel->setText("Loading...");
- iListCoverLabel->setAutoFillBackground(true);
- iListCoverLabel->show();
- QApplication::processEvents();
- iSortNoticeShown = false;
+ iListCoverLabel->setText("Loading...");
+ iListCoverLabel->setAutoFillBackground(true);
+ iListCoverLabel->show();
+ QApplication::processEvents();
+ iSortNoticeShown = false;
- openWin();
+ openWin();
- if( oldfilter==Package::PkgStatInstalled && iSelectedStatFilter!=Package::PkgStatInstalled &&
- iAptInterface->needListOrDateRefresh() )
- {
- iMainWindow->openNetworkConnection();
+ if( oldfilter==Package::PkgStatInstalled && iSelectedStatFilter!=Package::PkgStatInstalled &&
+ iAptInterface->needListOrDateRefresh() )
+ {
+ iMainWindow->openNetworkConnection();
- iMainWindow->setNextOperation(MainWindow::OpOpenPkgView);
- iMainWindow->busyDialog(true,"Operation in progress","Reading the rest of the package lists");
+ iMainWindow->setNextOperation(MainWindow::OpOpenPkgView);
+ iMainWindow->busyDialog(true,"Operation in progress","Reading the rest of the package lists");
- if( iAptInterface->needRepoRefresh() && !iSettings->qsettings()->value("no_catalogs_autoupdate",false).toBool() )
- iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetUpdate);
+ if( iAptInterface->needRepoRefresh() && !iSettings->qsettings()->value("no_catalogs_autoupdate",false).toBool() )
+ iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetUpdate);
- iAptInterface->addQueuedOperation(AAptInterface::ModeReadPackages);
- iAptInterface->addQueuedOperation(AAptInterface::ModeFetchDates);
- iAptInterface->run(iDimmer);
- }
- }
+ iAptInterface->addQueuedOperation(AAptInterface::ModeReadPackages);
+ iAptInterface->addQueuedOperation(AAptInterface::ModeFetchDates);
+ iAptInterface->run(iDimmer);
+ }
+ }
}
void PackageView::resetWindow()
{
- iAptInterface->writeBlacklist();
+ iAptInterface->writeBlacklist();
- ui->btn_StatusFilter->setEnabled(true);
- iSelectedCatFilter = iDefaultCatFilter;
- //iSortOrder = SortAlpha;
- iSortNoticeShown = false;
+ ui->btn_StatusFilter->setEnabled(true);
+ iSelectedCatFilter = iDefaultCatFilter;
+ //iSortOrder = SortAlpha;
+ iSortNoticeShown = false;
- clearSelections();
- clearSearch();
+ clearSelections();
+ clearSearch();
}
void PackageView::on_actionHelp_triggered()
{
- Help h(this);
- h.exec();
+ Help h(this);
+ h.exec();
}
void PackageView::on_btn_searchClose_clicked()
{
- clearSearch();
+ clearSearch();
- iListCoverLabel->setText("Loading...");
- iListCoverLabel->setAutoFillBackground(true);
- iListCoverLabel->show();
- QApplication::processEvents();
+ iListCoverLabel->setText("Loading...");
+ iListCoverLabel->setAutoFillBackground(true);
+ iListCoverLabel->show();
+ QApplication::processEvents();
- openWin();
+ openWin();
}
void PackageView::clearSearch()
{
- ui->lineEdit->clear();
- ui->searchBar->hide();
- ui->toolBar->show();
- ui->listWidget->setFocusPolicy(Qt::StrongFocus);
+ ui->lineEdit->clear();
+ ui->searchBar->hide();
+ ui->toolBar->show();
+ ui->listWidget->setFocusPolicy(Qt::StrongFocus);
- iSearchResults.clear();
+ iSearchResults.clear();
}
void PackageView::on_actionSearch_triggered()
{
- if( ui->searchBar->isVisible() )
- return;
-
- ui->listWidget->setFocusPolicy(Qt::NoFocus);
- ui->searchLabel->setText( QString("%1 results").arg(ui->listWidget->count()) );
- ui->toolBar->hide();
- ui->searchBar->show();
- ui->lineEdit->setFocus();
- iPrevSearchText = "";
+ if( ui->searchBar->isVisible() )
+ return;
+
+ ui->listWidget->setFocusPolicy(Qt::NoFocus);
+ ui->searchLabel->setText( QString("%1 results").arg(ui->listWidget->count()) );
+ ui->toolBar->hide();
+ ui->searchBar->show();
+ ui->lineEdit->setFocus();
+ iPrevSearchText = "";
}
void PackageView::on_lineEdit_textEdited(QString text)
{
- if( !ui->searchBar->isVisible() )
- return;
-
- if( text.isEmpty() ) {
- on_btn_searchClose_clicked();
- return;
- }
-
- if( iPrevSearchText.length() > text.length() )
- {
- iListCoverLabel->setText("Loading...");
- iListCoverLabel->setAutoFillBackground(true);
- iListCoverLabel->show();
- QApplication::processEvents();
-
- ui->searchBar->hide();
- openWin();
- ui->searchBar->show();
- ui->toolBar->hide(); // ensure it stays hidden
- ui->lineEdit->setFocus();
- }
-
- iPrevSearchText = text;
-
- QList<Package*> packages;
- iSearchResults.clear();
-
- for( int i=0; i<(ui->listWidget->count()); i++ ) {
- packages.append( dynamic_cast<PackageListWidgetItem*>( ui->listWidget->item(i) )->package() );
- }
-
- if( text.startsWith(":") ) {
- for( int i=0; i<packages.count(); i++ ) {
- if( packages.at(i) ) {
- if( (iSearchPkgName && packages.at(i)->name().startsWith(text.mid(1), Qt::CaseInsensitive)) ||
- (iSearchDisplayName && packages.at(i)->displayName().startsWith(text.mid(1), Qt::CaseInsensitive)) ||
- (iSearchDescShort && packages.at(i)->descShort().startsWith(text.mid(1), Qt::CaseInsensitive)) ||
- (iSearchDescLong && packages.at(i)->descLong().startsWith(text.mid(1), Qt::CaseInsensitive)) )
- {
- iSearchResults.append( packages.at(i) );
- }
- }
- }
- } else {
- for( int i=0; i<packages.count(); i++ ) {
- if( packages.at(i) ) {
- if( (iSearchPkgName && packages.at(i)->name().contains(text, Qt::CaseInsensitive)) ||
- (iSearchDisplayName && packages.at(i)->displayName().contains(text, Qt::CaseInsensitive)) ||
- (iSearchDescShort && packages.at(i)->descShort().contains(text, Qt::CaseInsensitive)) ||
- (iSearchDescLong && packages.at(i)->descLong().contains(text, Qt::CaseInsensitive)) )
- {
- iSearchResults.append( packages.at(i) );
- }
- }
- }
- }
-
- ui->searchLabel->setText( QString("%1 results").arg( iSearchResults.count()) );
-
- openWin();
+ if( !ui->searchBar->isVisible() )
+ return;
+
+ if( text.isEmpty() ) {
+ on_btn_searchClose_clicked();
+ return;
+ }
+
+ if( iPrevSearchText.length() > text.length() )
+ {
+ iListCoverLabel->setText("Loading...");
+ iListCoverLabel->setAutoFillBackground(true);
+ iListCoverLabel->show();
+ QApplication::processEvents();
+
+ ui->searchBar->hide();
+ openWin();
+ ui->searchBar->show();
+ ui->toolBar->hide(); // ensure it stays hidden
+ ui->lineEdit->setFocus();
+ }
+
+ iPrevSearchText = text;
+
+ QList<Package*> packages;
+ iSearchResults.clear();
+
+ for( int i=0; i<(ui->listWidget->count()); i++ ) {
+ packages.append( dynamic_cast<PackageListWidgetItem*>( ui->listWidget->item(i) )->package() );
+ }
+
+ if( text.startsWith(":") ) {
+ for( int i=0; i<packages.count(); i++ ) {
+ if( packages.at(i) ) {
+ if( (iSearchPkgName && packages.at(i)->name().startsWith(text.mid(1), Qt::CaseInsensitive)) ||
+ (iSearchDisplayName && packages.at(i)->displayName().startsWith(text.mid(1), Qt::CaseInsensitive)) ||
+ (iSearchDescShort && packages.at(i)->descShort().startsWith(text.mid(1), Qt::CaseInsensitive)) ||
+ (iSearchDescLong && packages.at(i)->descLong().startsWith(text.mid(1), Qt::CaseInsensitive)) )
+ {
+ iSearchResults.append( packages.at(i) );
+ }
+ }
+ }
+ } else {
+ for( int i=0; i<packages.count(); i++ ) {
+ if( packages.at(i) ) {
+ if( (iSearchPkgName && packages.at(i)->name().contains(text, Qt::CaseInsensitive)) ||
+ (iSearchDisplayName && packages.at(i)->displayName().contains(text, Qt::CaseInsensitive)) ||
+ (iSearchDescShort && packages.at(i)->descShort().contains(text, Qt::CaseInsensitive)) ||
+ (iSearchDescLong && packages.at(i)->descLong().contains(text, Qt::CaseInsensitive)) )
+ {
+ iSearchResults.append( packages.at(i) );
+ }
+ }
+ }
+ }
+
+ ui->searchLabel->setText( QString("%1 results").arg( iSearchResults.count()) );
+
+ openWin();
}
void PackageView::setSearchText(QString text)
{
- ui->lineEdit->setText(text);
- on_lineEdit_textEdited(text);
+ ui->lineEdit->setText(text);
+ on_lineEdit_textEdited(text);
}
KeyEventGrabber::KeyEventGrabber(QObject* parent) : QObject(parent)
bool KeyEventGrabber::eventFilter(QObject *obj, QEvent *event)
{
- if( event->type() == QEvent::KeyPress ) {
- QString text = dynamic_cast<QKeyEvent*>(event)->text();
- int key = dynamic_cast<QKeyEvent*>(event)->key();
- if( (text.trimmed() != "" || text==" ") && key!=Qt::Key_Backspace ) {
- dynamic_cast<PackageView*>(this->parent())->on_actionSearch_triggered();
- dynamic_cast<PackageView*>(this->parent())->setSearchText( text );
- return true;
- }
- }
- return QObject::eventFilter(obj, event);
+ if( event->type() == QEvent::KeyPress ) {
+ QString text = dynamic_cast<QKeyEvent*>(event)->text();
+ int key = dynamic_cast<QKeyEvent*>(event)->key();
+ if( (text.trimmed() != "" || text==" ") && key!=Qt::Key_Backspace ) {
+ dynamic_cast<PackageView*>(this->parent())->on_actionSearch_triggered();
+ dynamic_cast<PackageView*>(this->parent())->setSearchText( text );
+ return true;
+ }
+ }
+ return QObject::eventFilter(obj, event);
}
void PackageView::on_pushButton_searchOptions_clicked()
{
- SearchOptions s(this);
- s.setSelections(iSearchPkgName, iSearchDisplayName, iSearchDescShort, iSearchDescLong);
- if( s.exec() )
- {
- iSearchPkgName = s.searchPkgName();
- iSearchDisplayName = s.searchDisplayName();
- iSearchDescShort = s.searchDescShort();
- iSearchDescLong = s.searchDescLong();
-
- iPrevSearchText += " ";
- on_lineEdit_textEdited( ui->lineEdit->text() );
- }
+ SearchOptions s(this);
+ s.setSelections(iSearchPkgName, iSearchDisplayName, iSearchDescShort, iSearchDescLong);
+ if( s.exec() )
+ {
+ iSearchPkgName = s.searchPkgName();
+ iSearchDisplayName = s.searchDisplayName();
+ iSearchDescShort = s.searchDescShort();
+ iSearchDescLong = s.searchDescLong();
+
+ iPrevSearchText += " ";
+ on_lineEdit_textEdited( ui->lineEdit->text() );
+ }
}
void PackageView::setSearchOptions(bool pkgname, bool dispname, bool dshort, bool dlong)
{
- iSearchPkgName = pkgname;
- iSearchDisplayName = dispname;
- iSearchDescShort = dshort;
- iSearchDescLong = dlong;
+ iSearchPkgName = pkgname;
+ iSearchDisplayName = dispname;
+ iSearchDescShort = dshort;
+ iSearchDescLong = dlong;
}
void PackageView::on_actionUpgrade_all_triggered()
{
- for( int i=0; i<ui->listWidget->count(); i++ )
- {
- Package* pkg = dynamic_cast<PackageListWidgetItem*>(ui->listWidget->item(i))->package();
- if( pkg && pkg->isUpgradeable() ) {
- pkg->setMarkedForOperation( Package::PkgOpInstallUpgrade );
- ui->listWidget->item(i)->setData(UserRoleMarked, (int)Package::PkgOpInstallUpgrade);
- }
- }
- updateLabel();
+ for( int i=0; i<ui->listWidget->count(); i++ )
+ {
+ Package* pkg = dynamic_cast<PackageListWidgetItem*>(ui->listWidget->item(i))->package();
+ if( pkg && pkg->isUpgradeable() ) {
+ pkg->setMarkedForOperation( Package::PkgOpInstallUpgrade );
+ ui->listWidget->item(i)->setData(UserRoleMarked, (int)Package::PkgOpInstallUpgrade);
+ }
+ }
+ updateLabel();
}
void PackageView::on_actionView_log_triggered()
{
- QByteArray log = iAptInterface->readLogFile();
- LogView l(log, this);
- l.exec();
+ QByteArray log = iAptInterface->readLogFile();
+ LogView l(log, this);
+ l.exec();
}
void PackageView::on_btn_Sort_clicked()
{
- SortSelector s(iSortOrder, this);
- if( s.exec() ) {
- iSortOrder = s.selectedOperation();
- iSortNoticeShown = false;
- openWin();
- }
+ SortSelector s(iSortOrder, this);
+ if( s.exec() ) {
+ iSortOrder = s.selectedOperation();
+ iSortNoticeShown = false;
+ openWin();
+ }
}
void PackageView::on_actionLoad_selections_triggered()
{
- if( iAptInterface->numSelectedPackages() > 0 ) {
- ConfirmDialog d(true, this);
- d.setText("Confirmation", "Proceed loading selections? All current selections will be cleared.");
- if( !d.exec() )
- return;
- }
-
- QString filename = QFileDialog::getOpenFileName(this, "Open selections list", KDefaultUserOpenSaveDir, "Selection lists (*.slist)");
- if( filename.isNull() || filename.isEmpty() )
- return;
-
- clearSelections();
-
- QStringList unknownList;
- QStringList wrongverList;
- QStringList wrongstatusList;
- int success=0;
- int errors=0;
-
- QFile f( filename );
- if( f.open(QIODevice::ReadOnly | QIODevice::Text ) )
- {
- while(!f.atEnd()) {
- QString line = f.readLine().trimmed();
- QStringList parts = line.split(' ');
- if( parts.count()==3 ) {
- Package* pkgAv = iAptInterface->packagesAvailable()->value(parts.at(0),0);
- Package* pkgIn = iAptInterface->packagesInstalled()->value(parts.at(0),0);
- if( parts.at(2)=="install" ) {
- if( !pkgAv && !pkgIn ) {
- unknownList << parts.at(0);
- }
- else if( pkgIn ) {
- wrongstatusList << parts.at(0);
- }
- else if( pkgAv ) {
- if( !pkgAv->isInstalled() )
- {
- pkgAv->setMarkedForOperation(Package::PkgOpInstallUpgrade);
- success++;
- if( pkgAv->version() != parts.at(1) ) {
- wrongverList << parts.at(0);
- }
- } else {
- wrongstatusList << parts.at(0);
- }
- }
-
- } else if( parts.at(2)=="upgrade" ) {
- if( !pkgAv && !pkgIn ) {
- unknownList << parts.at(0);
- }
- else if( (pkgAv && !pkgIn) || (pkgIn && !pkgAv) ) {
- wrongstatusList << parts.at(0);
- }
- else if( pkgIn && pkgAv ) {
- if( pkgIn->isInstalled() && pkgIn->isUpgradeable() )
- {
- pkgIn->setMarkedForOperation(Package::PkgOpInstallUpgrade);
- success++;
- if( pkgIn->version() != parts.at(1) ) {
- wrongverList << parts.at(0);
- }
- } else {
- wrongstatusList << parts.at(0);
- }
- }
-
- } else if( parts.at(2)=="remove" ) {
- if( !pkgAv && !pkgIn ) {
- unknownList << parts.at(0);
- }
- else if( pkgAv && !pkgIn ) {
- wrongstatusList << parts.at(0);
- }
- else if( pkgIn ) {
- if( pkgIn->isInstalled() )
- {
- pkgIn->setMarkedForOperation(Package::PkgOpRemove);
- success++;
- if( pkgIn->version() != parts.at(1) ) {
- wrongverList << parts.at(0);
- }
- } else {
- wrongstatusList << parts.at(0);
- }
- }
- } else {
- errors++;
- }
- } else if( !line.isEmpty() ){
- errors++;
- }
- }
- f.close();
- }
-
- ConfirmDialog d(false, this);
- QString msg;
- msg += QString("<b>%1 successful</b><br>").arg(success);
-
- if( wrongverList.count() > 0 ) {
- msg += QString("%1 version mismatches (selected anyway):<br>").arg(wrongverList.count());
- msg += "<font size=\"-1\">";
- for( int i=0; i<wrongverList.count(); i++ ) {
- msg += wrongverList.at(i) + " ";
- }
- msg += "</font><br>";
- }
-
- if( wrongstatusList.count() > 0 ) {
- msg += QString("%1 status mismatches (packages ignored):<br>").arg(wrongstatusList.count());
- msg += "<font size=\"-1\">";
- for( int i=0; i<wrongstatusList.count(); i++ ) {
- msg += wrongstatusList.at(i) + " ";
- }
- msg += "</font><br>";
- }
-
- if( unknownList.count() > 0 ) {
- msg += QString("%1 unknown packages:<br>").arg(unknownList.count());
- msg += "<font size=\"-1\">";
- for( int i=0; i<unknownList.count(); i++ ) {
- msg += unknownList.at(i) + " ";
- }
- msg += "</font><br>";
- }
-
- if( errors>0 || (wrongstatusList.count()==0 && unknownList.count()==0) ) {
- msg += QString("%1 errors<br>").arg(errors);
- }
- if( success==0 && wrongstatusList.count()==0 && unknownList.count()==0 )
- msg = "No stored selections";
- QString title;
- if( success > 0 )
- title = "Selections loaded";
- else
- title = "No selections loaded";
- d.setText(title, msg);
- d.exec();
-
- if( unknownList.count()>0 && iAptInterface->needListOrDateRefresh() )
- {
- ConfirmDialog f(false, this);
- f.setText("About Unknown packages","You encountered unknown packages. You might want to try "
- "loading the selections again after loading the full package lists (by selecting install or upgrade view)");
- f.exec();
- }
-
- if( success > 0 ) {
- ui->btn_StatusFilter->setEnabled(false);
- iSelectedCatFilter = CatFilterAllMarked;
- }
- openWin();
+ if( iAptInterface->numSelectedPackages() > 0 ) {
+ ConfirmDialog d(true, this);
+ d.setText("Confirmation", "Proceed loading selections? All current selections will be cleared.");
+ if( !d.exec() )
+ return;
+ }
+
+ QString filename = QFileDialog::getOpenFileName(this, "Open selections list", KDefaultUserOpenSaveDir, "Selection lists (*.slist)");
+ if( filename.isNull() || filename.isEmpty() )
+ return;
+
+ clearSelections();
+
+ QStringList unknownList;
+ QStringList wrongverList;
+ QStringList wrongstatusList;
+ int success=0;
+ int errors=0;
+
+ QFile f( filename );
+ if( f.open(QIODevice::ReadOnly | QIODevice::Text ) )
+ {
+ while(!f.atEnd()) {
+ QString line = f.readLine().trimmed();
+ QStringList parts = line.split(' ');
+ if( parts.count()==3 ) {
+ Package* pkgAv = iAptInterface->packagesAvailable()->value(parts.at(0),0);
+ Package* pkgIn = iAptInterface->packagesInstalled()->value(parts.at(0),0);
+ if( parts.at(2)=="install" ) {
+ if( !pkgAv && !pkgIn ) {
+ unknownList << parts.at(0);
+ }
+ else if( pkgIn ) {
+ wrongstatusList << parts.at(0);
+ }
+ else if( pkgAv ) {
+ if( !pkgAv->isInstalled() )
+ {
+ pkgAv->setMarkedForOperation(Package::PkgOpInstallUpgrade);
+ success++;
+ if( pkgAv->version() != parts.at(1) ) {
+ wrongverList << parts.at(0);
+ }
+ } else {
+ wrongstatusList << parts.at(0);
+ }
+ }
+
+ } else if( parts.at(2)=="upgrade" ) {
+ if( !pkgAv && !pkgIn ) {
+ unknownList << parts.at(0);
+ }
+ else if( (pkgAv && !pkgIn) || (pkgIn && !pkgAv) ) {
+ wrongstatusList << parts.at(0);
+ }
+ else if( pkgIn && pkgAv ) {
+ if( pkgIn->isInstalled() && pkgIn->isUpgradeable() )
+ {
+ pkgIn->setMarkedForOperation(Package::PkgOpInstallUpgrade);
+ success++;
+ if( pkgIn->version() != parts.at(1) ) {
+ wrongverList << parts.at(0);
+ }
+ } else {
+ wrongstatusList << parts.at(0);
+ }
+ }
+
+ } else if( parts.at(2)=="remove" ) {
+ if( !pkgAv && !pkgIn ) {
+ unknownList << parts.at(0);
+ }
+ else if( pkgAv && !pkgIn ) {
+ wrongstatusList << parts.at(0);
+ }
+ else if( pkgIn ) {
+ if( pkgIn->isInstalled() )
+ {
+ pkgIn->setMarkedForOperation(Package::PkgOpRemove);
+ success++;
+ if( pkgIn->version() != parts.at(1) ) {
+ wrongverList << parts.at(0);
+ }
+ } else {
+ wrongstatusList << parts.at(0);
+ }
+ }
+ } else {
+ errors++;
+ }
+ } else if( !line.isEmpty() ){
+ errors++;
+ }
+ }
+ f.close();
+ }
+
+ ConfirmDialog d(false, this);
+ QString msg;
+ msg += QString("<b>%1 successful</b><br>").arg(success);
+
+ if( wrongverList.count() > 0 ) {
+ msg += QString("%1 version mismatches (selected anyway):<br>").arg(wrongverList.count());
+ msg += "<font size=\"-1\">";
+ for( int i=0; i<wrongverList.count(); i++ ) {
+ msg += wrongverList.at(i) + " ";
+ }
+ msg += "</font><br>";
+ }
+
+ if( wrongstatusList.count() > 0 ) {
+ msg += QString("%1 status mismatches (packages ignored):<br>").arg(wrongstatusList.count());
+ msg += "<font size=\"-1\">";
+ for( int i=0; i<wrongstatusList.count(); i++ ) {
+ msg += wrongstatusList.at(i) + " ";
+ }
+ msg += "</font><br>";
+ }
+
+ if( unknownList.count() > 0 ) {
+ msg += QString("%1 unknown packages:<br>").arg(unknownList.count());
+ msg += "<font size=\"-1\">";
+ for( int i=0; i<unknownList.count(); i++ ) {
+ msg += unknownList.at(i) + " ";
+ }
+ msg += "</font><br>";
+ }
+
+ if( errors>0 || (wrongstatusList.count()==0 && unknownList.count()==0) ) {
+ msg += QString("%1 errors<br>").arg(errors);
+ }
+ if( success==0 && wrongstatusList.count()==0 && unknownList.count()==0 )
+ msg = "No stored selections";
+ QString title;
+ if( success > 0 )
+ title = "Selections loaded";
+ else
+ title = "No selections loaded";
+ d.setText(title, msg);
+ d.exec();
+
+ if( unknownList.count()>0 && iAptInterface->needListOrDateRefresh() )
+ {
+ ConfirmDialog f(false, this);
+ f.setText("About Unknown packages","You encountered unknown packages. You might want to try "
+ "loading the selections again after loading the full package lists (by selecting install or upgrade view)");
+ f.exec();
+ }
+
+ if( success > 0 ) {
+ ui->btn_StatusFilter->setEnabled(false);
+ iSelectedCatFilter = CatFilterAllMarked;
+ }
+ openWin();
}
void PackageView::on_actionSave_selections_triggered()
{
- if( iAptInterface->numSelectedPackages() == 0 )
- return;
-
- QString filename = QFileDialog::getSaveFileName(this, "Save selections to...", KDefaultUserOpenSaveDir, "Selection lists (*.slist)");
- if( filename.isNull() || filename.isEmpty() )
- return;
-
- if( !filename.endsWith(".slist") )
- filename.append(".slist");
-
- QFile f( filename );
- bool fail = false;
- int count = 0;
- if( f.open(QIODevice::WriteOnly | QIODevice::Text) )
- {
- QTextStream out(&f);
-
- QHashIterator<QString, Package*> i( *iAptInterface->packagesAvailable() );
- while (i.hasNext())
- {
- i.next();
-
- if( i.value()->markedOperation() == Package::PkgOpInstallUpgrade ) {
- out << i.value()->name() << " " << i.value()->version() << " install\n";
- count++;
- }
- if( i.value()->markedOperation() == Package::PkgOpRemove )
- qDebug() << "Warning: package is marked for removal in the wrong list";
- }
-
- QHashIterator<QString, Package*> r( *iAptInterface->packagesInstalled() );
- while (r.hasNext())
- {
- r.next();
-
- if( r.value()->markedOperation() == Package::PkgOpInstallUpgrade ) {
- out << r.value()->name() << " " << r.value()->version() << " upgrade\n";
- count++;
- }
- if( r.value()->markedOperation() == Package::PkgOpRemove ) {
- out << r.value()->name() << " " << r.value()->version() << " remove\n";
- count++;
- }
- }
-
- f.close();
- } else {
- fail = true;
- }
-
- ConfirmDialog d(false, this);
- if( fail )
- d.setText( "Error", "Failed to write package selections" );
- else
- d.setText( "Selections stored", QString("Stored %1 selections").arg(count) );
- d.exec();
+ if( iAptInterface->numSelectedPackages() == 0 )
+ return;
+
+ QString filename = QFileDialog::getSaveFileName(this, "Save selections to...", KDefaultUserOpenSaveDir, "Selection lists (*.slist)");
+ if( filename.isNull() || filename.isEmpty() )
+ return;
+
+ if( !filename.endsWith(".slist") )
+ filename.append(".slist");
+
+ QFile f( filename );
+ bool fail = false;
+ int count = 0;
+ if( f.open(QIODevice::WriteOnly | QIODevice::Text) )
+ {
+ QTextStream out(&f);
+
+ QHashIterator<QString, Package*> i( *iAptInterface->packagesAvailable() );
+ while (i.hasNext())
+ {
+ i.next();
+
+ if( i.value()->markedOperation() == Package::PkgOpInstallUpgrade ) {
+ out << i.value()->name() << " " << i.value()->version() << " install\n";
+ count++;
+ }
+ if( i.value()->markedOperation() == Package::PkgOpRemove )
+ qDebug() << "Warning: package is marked for removal in the wrong list";
+ }
+
+ QHashIterator<QString, Package*> r( *iAptInterface->packagesInstalled() );
+ while (r.hasNext())
+ {
+ r.next();
+
+ if( r.value()->markedOperation() == Package::PkgOpInstallUpgrade ) {
+ out << r.value()->name() << " " << r.value()->version() << " upgrade\n";
+ count++;
+ }
+ if( r.value()->markedOperation() == Package::PkgOpRemove ) {
+ out << r.value()->name() << " " << r.value()->version() << " remove\n";
+ count++;
+ }
+ }
+
+ f.close();
+ } else {
+ fail = true;
+ }
+
+ ConfirmDialog d(false, this);
+ if( fail )
+ d.setText( "Error", "Failed to write package selections" );
+ else
+ d.setText( "Selections stored", QString("Stored %1 selections").arg(count) );
+ d.exec();
}
void PackageView::on_actionRestore_all_triggered()
{
- ConfirmDialog d(true, this);
- d.setText("Confirmation","Restore all shown blacklisted packages?");
- if( !d.exec() )
- return;
-
- for( int i=0; i<ui->listWidget->count(); i++ )
- {
- Package* pkg = dynamic_cast<PackageListWidgetItem*>(ui->listWidget->item(i))->package();
- Package* p1 = iAptInterface->packagesInstalled()->value(pkg->name(),0);
- Package* p2 = iAptInterface->packagesAvailable()->value(pkg->name(),0);
- if( p1 && p1->isBlacklisted() ) {
- BlacklistSelect::blackList old = p1->blacklisted();
- p1->setBlacklisted(BlacklistSelect::BlacklistNone);
- iAptInterface->removeFromBlacklist(p1, old);
- }
- if( p2 && p2->isBlacklisted() ) {
- BlacklistSelect::blackList old = p2->blacklisted();
- p2->setBlacklisted(BlacklistSelect::BlacklistNone);
- iAptInterface->removeFromBlacklist(p2, old);
- }
- }
- iAptInterface->writeBlacklist();
- openWin();
+ ConfirmDialog d(true, this);
+ d.setText("Confirmation","Restore all shown blacklisted packages?");
+ if( !d.exec() )
+ return;
+
+ for( int i=0; i<ui->listWidget->count(); i++ )
+ {
+ Package* pkg = dynamic_cast<PackageListWidgetItem*>(ui->listWidget->item(i))->package();
+ Package* p1 = iAptInterface->packagesInstalled()->value(pkg->name(),0);
+ Package* p2 = iAptInterface->packagesAvailable()->value(pkg->name(),0);
+ if( p1 && p1->isBlacklisted() ) {
+ BlacklistSelect::blackList old = p1->blacklisted();
+ p1->setBlacklisted(BlacklistSelect::BlacklistNone);
+ iAptInterface->removeFromBlacklist(p1, old);
+ }
+ if( p2 && p2->isBlacklisted() ) {
+ BlacklistSelect::blackList old = p2->blacklisted();
+ p2->setBlacklisted(BlacklistSelect::BlacklistNone);
+ iAptInterface->removeFromBlacklist(p2, old);
+ }
+ }
+ iAptInterface->writeBlacklist();
+ openWin();
}
void PackageView::on_actionStore_list_triggered()
{
- QString filename = QFileDialog::getSaveFileName(this, "Save application list to...", KDefaultUserOpenSaveDir, "Selection lists (*.slist)");
- if( filename.isNull() || filename.isEmpty() )
- return;
-
- if( !filename.endsWith(".slist") )
- filename.append(".slist");
-
- QFile f( filename );
- bool fail = false;
- int count = 0;
- if( f.open(QIODevice::WriteOnly | QIODevice::Text) )
- {
- QTextStream out(&f);
-
- QHashIterator<QString, Package*> r( *iAptInterface->packagesInstalled() );
- while (r.hasNext())
- {
- r.next();
-
- if( r.value()->isInstalled() && r.value()->section().startsWith("user/") ) {
- out << r.value()->name() << " " << r.value()->version() << " install\n";
- count++;
- }
- }
-
- f.close();
- } else {
- fail = true;
- }
-
- ConfirmDialog d(false, this);
- if( fail )
- d.setText( "Error", "Failed to write application list" );
- else
- d.setText( "List stored", QString("Stored %1 selections.").arg(count) + "<br>"
- "The list can be used to restore removed applications later." );
- d.exec();
+ QString filename = QFileDialog::getSaveFileName(this, "Save application list to...", KDefaultUserOpenSaveDir, "Selection lists (*.slist)");
+ if( filename.isNull() || filename.isEmpty() )
+ return;
+
+ if( !filename.endsWith(".slist") )
+ filename.append(".slist");
+
+ QFile f( filename );
+ bool fail = false;
+ int count = 0;
+ if( f.open(QIODevice::WriteOnly | QIODevice::Text) )
+ {
+ QTextStream out(&f);
+
+ QHashIterator<QString, Package*> r( *iAptInterface->packagesInstalled() );
+ while (r.hasNext())
+ {
+ r.next();
+
+ if( r.value()->isInstalled() && r.value()->section().startsWith("user/") ) {
+ out << r.value()->name() << " " << r.value()->version() << " install\n";
+ count++;
+ }
+ }
+
+ f.close();
+ } else {
+ fail = true;
+ }
+
+ ConfirmDialog d(false, this);
+ if( fail )
+ d.setText( "Error", "Failed to write application list" );
+ else
+ d.setText( "List stored", QString("Stored %1 selections.").arg(count) + "<br>"
+ "The list can be used to restore removed applications later." );
+ d.exec();
}