2 This file is part of Faster Application Manager.
4 Faster Application Manager is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Faster Application Manager is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Faster Application Manager. If not, see <http://www.gnu.org/licenses/>.
17 (C) Heikki Holstila 2010
24 #include <QMainWindow>
25 #include "mainwindow.h"
36 class KeyEventGrabber;
39 enum UserRoles { UserRoleName=Qt::UserRole, UserRoleVersion, UserRoleDescShort,
40 UserRoleMarked, UserRoleInstalled, UserRoleUpgradeable, UserRoleAvailVersion,
41 UserRoleCurrentStatFilter, UserRoleCurrentCatFilter, UserRoleBlacklisted };
44 class PackageListWidgetItem : public QListWidgetItem
47 PackageListWidgetItem(Package* p_, QString name_);
49 Package* package() { return iPackage; }
56 class ListItemDelegate : public QStyledItemDelegate
59 explicit ListItemDelegate(QObject *parent=0) : QStyledItemDelegate(parent) {}
60 virtual ~ListItemDelegate() {}
62 void paint (QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
63 QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
67 ListItemDelegate(const ListItemDelegate& old);
68 ListItemDelegate operator= (const ListItemDelegate& old);
71 QPixmap iIconPkgInstall;
72 QPixmap iIconPkgUpgrade;
73 QPixmap iIconPkgRemove;
74 QPixmap iIconPkgNoOpInstalled;
75 QPixmap iIconPkgNoOpNotInstalled;
76 QPixmap iIconPkgNoOpInstalledUpgradeable;
80 class PackageView : public QMainWindow
86 enum sortOrder { SortAlpha, SortDateDesc, SortSizeDesc };
88 explicit PackageView(QWidget *parent = 0);
89 virtual ~PackageView();
92 void resizeEvent(QResizeEvent* event);
93 void setAptInterface(AAptInterface* a_) { iAptInterface=a_; }
94 void setSettings(Settings* s_) { iSettings=s_; }
95 dimmer* mydimmer() { return iDimmer; }
98 void setStatFilter(Package::packageStatus f_);
99 void setSortOrder(sortOrder s_) { iSortOrder = s_; }
100 void clearSelections();
101 void setSearchText(QString text);
102 void setSearchOptions(bool pkgname, bool dispname, bool dshort, bool dlong);
104 #ifdef Q_WS_MAEMO_5 // workaround for buggy Qt autorotation
107 QRect r = dynamic_cast<QMainWindow*>(this->parent())->rect();
108 if(r.width() < r.height()) {
109 this->setAttribute(Qt::WA_Maemo5PortraitOrientation);
112 if( dynamic_cast<QMainWindow*>(this->parent())->testAttribute( Qt::WA_Maemo5AutoOrientation ) ) {
113 this->setAttribute( Qt::WA_Maemo5AutoOrientation );
115 this->setAttribute( Qt::WA_Maemo5LandscapeOrientation );
117 this->setAttribute(Qt::WA_Maemo5StackedWindow);
118 this->setWindowFlags(Qt::Window);
125 static const int CatFilterAllMarked = 0;
126 static const int CatFilterAllUser = 1;
127 static const int CatFilterBlacklisted = 16;
130 void orientationChanged();
131 void on_actionSearch_triggered();
134 void changeEvent(QEvent *e);
135 AAptInterface* iAptInterface;
136 //MainWindow::operation iOperation;
137 void closeEvent(QCloseEvent *event);
140 PackageView(const PackageView& old);
141 PackageView operator= (const PackageView& old);
143 bool doFilterCategory(Package* pkg);
144 QString generateSortString(Package* pkg);
145 void addListItem(Package* pkg_, QString listname_);
146 void updateLabel(void);
151 MainWindow* iMainWindow;
152 QBoxLayout* iPkgLayout;
154 QLabel* iListCoverLabel;
157 QStringList iCatFilterLabels;
158 QStringList iCatFilterStrings;
159 int iSelectedCatFilter;
160 int iDefaultCatFilter;
162 QStringList iStatFilterLabels;
163 int iSelectedStatFilter;
164 sortOrder iSortOrder;
165 bool iSortNoticeShown;
167 QList<Package*> iSearchResults;
168 QString iPrevSearchText;
169 KeyEventGrabber* iKeyFilter;
172 bool iSearchDisplayName;
173 bool iSearchDescShort;
174 bool iSearchDescLong;
176 int iPackagesEmptySort;
179 void on_pushButton_searchOptions_clicked();
180 void on_actionRestore_all_triggered();
181 void on_actionSave_selections_triggered();
182 void on_actionLoad_selections_triggered();
183 void on_btn_Sort_clicked();
184 void on_actionView_log_triggered();
185 void on_actionUpgrade_all_triggered();
186 void on_lineEdit_textEdited(QString );
187 void on_btn_searchClose_clicked();
188 void on_actionHelp_triggered();
189 void on_btn_StatusFilter_clicked();
190 void on_btn_CategoryFilter_clicked();
191 void on_listWidget_itemClicked(QListWidgetItem* item);
192 void on_actionClear_selections_triggered();
193 void on_btn_Commit_clicked();
197 class KeyEventGrabber : public QObject
201 KeyEventGrabber(QObject* parent = 0);
204 bool eventFilter(QObject *obj, QEvent *event);
209 #endif // PACKAGEVIEW_H