KNewStuff
itemsview.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> * 00003 * Copyright (C) 2005 - 2007 Josef Spillner <spillner@kde.org> * 00004 * Copyright (C) 2007 Dirk Mueller <mueller@kde.org> * 00005 * Copyright (C) 2007 Jeremy Whiting <jeremy@scitools.com> * 00006 * * 00007 * This library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU Lesser General Public * 00009 * License as published by the Free Software Foundation; either * 00010 * version 2 of the License, or (at your option) any later version. * 00011 * * 00012 * This library is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00015 * Lesser General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU Lesser General Public * 00018 * License along with this library; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 ***************************************************************************/ 00021 00022 #ifndef KNEWSTUFF2_UI_ITEMSVIEW_H 00023 #define KNEWSTUFF2_UI_ITEMSVIEW_H 00024 00025 #include <QtCore/QSet> 00026 #include <QtGui/QListView> 00027 #include <QtGui/QLabel> 00028 #include <QtGui/QSortFilterProxyModel> 00029 00030 #include <knewstuff2/dxs/dxsengine.h> 00031 #include <knewstuff2/core/category.h> 00032 00033 namespace Ui 00034 { 00035 class DownloadDialog; 00036 } 00037 00038 class QLabel; 00039 00040 namespace KNS 00041 { 00042 00043 class EntryView; 00044 00046 class ItemsView : public QListView 00047 { 00048 Q_OBJECT 00049 public: 00050 ItemsView(QWidget * parentWidget); 00051 ~ItemsView(); 00052 00053 void setEngine(DxsEngine *engine); 00054 00058 void setProvider(const Provider * provider, const Feed * feed); 00059 00063 void setFeed(const Feed*); 00064 00065 public slots: 00069 void setSearchText(const QString & text); 00073 void updateItem(Entry *entry); 00074 00075 // not used because the ui doesn't support it yet 00076 void setSorting(int sortType); 00077 00078 private: 00079 00080 void buildContents(); 00081 00082 const Provider* m_currentProvider; 00083 const Feed* m_currentFeed; 00084 00085 QWidget *m_root; 00086 int m_sorting; 00087 DxsEngine *m_engine; 00088 QMap<Entry*, EntryView*> m_views; 00089 QString m_searchText; 00090 00091 QSortFilterProxyModel * m_filteredModel; 00092 }; 00093 00094 00096 class EntryView : public QLabel 00097 { 00098 Q_OBJECT 00099 public: 00100 EntryView(QWidget * parentWidget); 00101 00102 void setEntry(Entry *entry); 00103 void updateEntry(Entry *entry); 00104 00105 private slots: 00106 void urlSelected(const QString &link); 00107 00108 private: 00109 // generate the HTML contents to be displayed by the class itself 00110 void buildContents(); 00111 00112 void setTheAaronnesqueStyle(); 00113 00114 Entry *m_entry; 00115 }; 00116 00117 } 00118 00119 #endif