File indexing completed on 2024-04-28 09:40:15
0001 /*************************************************************************** 0002 * Copyright (C) 2008-2011 by Daniel Nicoletti * 0003 * dantti12@gmail.com * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; see the file COPYING. If not, write to * 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0018 * Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 0021 #ifndef APPER_KCM_U 0022 #define APPER_KCM_U 0023 0024 #include <PkTransaction.h> 0025 0026 #include <KToolBarPopupAction> 0027 #include <KCategorizedSortFilterProxyModel> 0028 0029 #include <Transaction> 0030 0031 using namespace PackageKit; 0032 0033 namespace Ui { 0034 class ApperKCM; 0035 } 0036 0037 class PackageModel; 0038 class FiltersMenu; 0039 class TransactionHistory; 0040 class CategoryModel; 0041 class Settings; 0042 class Updater; 0043 class ApperKCM : public QWidget 0044 { 0045 Q_OBJECT 0046 Q_PROPERTY(QString page READ page WRITE setPage USER true) 0047 public: 0048 ApperKCM(QWidget *parent); 0049 ~ApperKCM() override; 0050 0051 QString page() const; 0052 0053 Q_SIGNALS: 0054 void changed(bool state); 0055 void caption(const QString &title = QString()); 0056 0057 public Q_SLOTS: 0058 void daemonChanged(); 0059 void load(); 0060 void save(); 0061 void defaults(); 0062 void setPage(const QString &page); 0063 0064 private Q_SLOTS: 0065 void search(); 0066 void setupHomeModel(); 0067 void genericActionKTriggered(); 0068 0069 void on_backTB_clicked(); 0070 void showReviewPages(); 0071 0072 void on_actionFindName_triggered(); 0073 void on_actionFindDescription_triggered(); 0074 void on_actionFindFile_triggered(); 0075 0076 void on_homeView_activated(const QModelIndex &index); 0077 0078 void finished(); 0079 void errorCode(PackageKit::Transaction::Error error, const QString &detail); 0080 0081 void checkChanged(); 0082 void changed(); 0083 0084 void refreshCache(); 0085 0086 protected: 0087 void closeEvent(QCloseEvent *event) override; 0088 0089 private: 0090 void disconnectTransaction(); 0091 bool canChangePage(); 0092 void setCurrentActionEnabled(bool state); 0093 void setCurrentAction(QAction *action); 0094 void setCurrentActionCancel(bool cancel); 0095 0096 void setActionCancel(bool enabled); 0097 void keyPressEvent(QKeyEvent *event) override; 0098 0099 Ui::ApperKCM *ui; 0100 KToolBarPopupAction *m_genericActionK; 0101 QAction *m_currentAction = nullptr; 0102 CategoryModel *m_groupsModel; 0103 KCategorizedSortFilterProxyModel *m_groupsProxyModel = nullptr; 0104 PackageModel *m_browseModel; 0105 PackageModel *m_changesModel; 0106 Settings *m_settingsPage = nullptr; 0107 Updater *m_updaterPage = nullptr; 0108 0109 Transaction *m_searchTransaction = nullptr; 0110 0111 QIcon m_findIcon; 0112 QIcon m_cancelIcon; 0113 0114 FiltersMenu *m_filtersMenu; 0115 Transaction::Roles m_roles; 0116 bool m_forceRefreshCache = false; 0117 uint m_cacheAge = 600; 0118 0119 TransactionHistory *m_history = nullptr; 0120 0121 // Old search cache 0122 Transaction::Role m_searchRole = Transaction::RoleUnknown; 0123 QString m_searchString; 0124 QString m_searchGroupCategory; 0125 PackageKit::Transaction::Group m_searchGroup; 0126 QModelIndex m_searchParentCategory; 0127 QStringList m_searchCategory; 0128 }; 0129 0130 #endif