Author: durner Date: 2006-06-17 16:42:05 -0700 (Sat, 17 Jun 2006) New Revision: 3018
Added: gnunet-qt/src/plugins/fs/downloadsModel.cc gnunet-qt/src/plugins/fs/downloadsModel.h gnunet-qt/src/plugins/fs/searchesModel.cc gnunet-qt/src/plugins/fs/searchesModel.h gnunet-qt/src/plugins/fs/uploadsModel.cc gnunet-qt/src/plugins/fs/uploadsModel.h Modified: gnunet-qt/pixmaps/pixmaps.qrc gnunet-qt/src/plugins/fs/fs-search.cc gnunet-qt/src/plugins/fs/fs-search.h gnunet-qt/src/plugins/fs/fs.cc gnunet-qt/src/plugins/fs/fs.h gnunet-qt/src/plugins/fs/fs.pro.in gnunet-qt/src/plugins/fs/fs.ui gnunet-qt/src/plugins/fs/searchModel.cc gnunet-qt/src/plugins/fs/searchModel.h Log: add FS status tab and display number of search results in each search tab Modified: gnunet-qt/pixmaps/pixmaps.qrc =================================================================== --- gnunet-qt/pixmaps/pixmaps.qrc 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/pixmaps/pixmaps.qrc 2006-06-17 23:42:05 UTC (rev 3018) @@ -1,5 +1,6 @@ <RCC> <qresource prefix="/pixmaps" > + <file>clear.png</file> <file>clock.png</file> <file>close.png</file> <file>connected.png</file> @@ -11,8 +12,10 @@ <file>gnunet-gtk-welcome.png</file> <file>gnunet-logo-small.png</file> <file>gnunet-qt-logo.png</file> + <file>info.png</file> <file>not-connected.png</file> <file>search.png</file> <file>start.png</file> + <file>stop.png</file> </qresource> </RCC> Added: gnunet-qt/src/plugins/fs/downloadsModel.cc =================================================================== --- gnunet-qt/src/plugins/fs/downloadsModel.cc 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/downloadsModel.cc 2006-06-17 23:42:05 UTC (rev 3018) @@ -0,0 +1,79 @@ +/* + This file is part of gnunet-qt. + (C) 2006 Nils Durner (and other contributing authors) + + gnunet-qt 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 2, or (at your + option) any later version. + + gnunet-qt 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/** + * @file src/plugins/fs/downloadsModel.cc + * @brief MVC model for the downloads display in the status tab + * @author Nils Durner + */ + +#include "downloadsModel.h" + + +QVariant GFSDownloadsModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + if (role == Qt::DisplayRole) + { + if (section == 0) + return QVariant(tr("Filename")); + if (section == 1) + return QVariant(tr("Progress")); + if (section == 2) + return QVariant(tr("Size")); + if (section == 3) + return QVariant(tr("URI")); + } + + return QVariant(); +} + +GFSDownloadsModel::GFSDownloadsModel() : QAbstractItemModel() +{ +} + +QModelIndex GFSDownloadsModel::index(int row, int column, + const QModelIndex &parent) const +{ + return createIndex(row, column); +} + +QModelIndex GFSDownloadsModel::parent(const QModelIndex &index) const +{ + return QModelIndex(); +} + +int GFSDownloadsModel::rowCount(const QModelIndex &parent) const +{ + return 0; +} + +int GFSDownloadsModel::columnCount(const QModelIndex &parent) const +{ + return 4; +} + +QVariant GFSDownloadsModel::data(const QModelIndex &index, int role) const +{ + return QVariant(); +} + + +/* end of downloadsModel.cc */ Added: gnunet-qt/src/plugins/fs/downloadsModel.h =================================================================== --- gnunet-qt/src/plugins/fs/downloadsModel.h 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/downloadsModel.h 2006-06-17 23:42:05 UTC (rev 3018) @@ -0,0 +1,51 @@ +/* + This file is part of gnunet-qt. + (C) 2006 Nils Durner (and other contributing authors) + + gnunet-qt 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 2, or (at your + option) any later version. + + gnunet-qt 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/** + * @file src/plugins/fs/dowloadsModel.h + * @brief MVC model for the downloads display in the status tab + * @author Nils Durner + */ + +#ifndef DOWNLOADSMODEL_H_ +#define DOWNLOADSMODEL_H_ + +#include <QAbstractItemModel> +#include <QList> + +class GFSDownloadsModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + GFSDownloadsModel(); + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, const QModelIndex &parent = + QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; +}; + +#endif /*DOWNLOADSMODEL_H_*/ + +/* end of downloadsModel.h */ Modified: gnunet-qt/src/plugins/fs/fs-search.cc =================================================================== --- gnunet-qt/src/plugins/fs/fs-search.cc 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/fs-search.cc 2006-06-17 23:42:05 UTC (rev 3018) @@ -31,7 +31,7 @@ #include "fshelper.h" #include "fs-search.h" -GFSSearch::GFSSearch() : QWidget() +GFSSearch::GFSSearch(QTabWidget *tab) : QWidget() { QHeaderView *header; model = new GFSSearchModel(); @@ -41,10 +41,13 @@ treeResults->setModel(model); header = treeResults->header(); header->setContextMenuPolicy(Qt::CustomContextMenu); + this->tab = tab; connect(pbClose, SIGNAL(clicked(bool)), this, SLOT(closeClicked())); connect(header, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(headerRightClicked(const QPoint &))); + connect(model, SIGNAL(resultsChanged(QString &, int)), this, + SLOT(resultsChanged(QString &, int))); } void GFSSearch::closeClicked() @@ -97,4 +100,22 @@ delete menu; } +void GFSSearch::resultsChanged(QString &strSearch, int searchResults) +{ + tab->setTabText(tab->indexOf(this), + strSearch + " (" + QString::number(searchResults) + ")"); + emit searchChanged(strSearch, searchResults); +} + +void GFSSearch::start(QString &strSearch, QString &strNS, int anonymity) +{ + this->strSearch = strSearch; + model->startSearch(strSearch, strNS, anonymity); +} + +QString &GFSSearch::searchText() +{ + return strSearch; +} + /* fs-search.cc */ Modified: gnunet-qt/src/plugins/fs/fs-search.h =================================================================== --- gnunet-qt/src/plugins/fs/fs-search.h 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/fs-search.h 2006-06-17 23:42:05 UTC (rev 3018) @@ -27,6 +27,8 @@ #ifndef SEARCHRESULTS_H_ #define SEARCHRESULTS_H_ +#include <QTabWidget> + #include "searchModel.h" #include "ui_fs-search-result.h" @@ -35,18 +37,23 @@ Q_OBJECT public: - GFSSearch(); + GFSSearch(QTabWidget *tab); + QString &searchText(); void clear(); + void start(QString &strSearch, QString &strNS, int anonymity); signals: void closeSearchWnd(class GFSSearch *wnd); + void searchChanged(QString &strSearch, int searchResults); protected: GFSSearchModel *model; - + QTabWidget *tab; + QString strSearch; protected slots: void closeClicked(); void headerRightClicked(const QPoint &pos); + void resultsChanged(QString &strSearch, int searchResults); }; #endif /*SEARCHRESULTS_H_*/ Modified: gnunet-qt/src/plugins/fs/fs.cc =================================================================== --- gnunet-qt/src/plugins/fs/fs.cc 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/fs.cc 2006-06-17 23:42:05 UTC (rev 3018) @@ -33,7 +33,13 @@ GFSPlugin::GFSPlugin() : GPlugin() { setupUi(this); + + // Status tab + treeSearches->setModel(&searchesModel); + treeDownloads->setModel(&downloadsModel); + treeUploads->setModel(&uploadsModel); + // FS tab connect(pbSearch, SIGNAL(clicked(bool)), this, SLOT(searchClicked())); connect(cmbSearchFor->lineEdit(), SIGNAL(returnPressed()), this, SLOT(searchClicked())); @@ -45,10 +51,12 @@ { GFSSearch *ret; - ret = new GFSSearch(); + ret = new GFSSearch(tabResults); connect(ret, SIGNAL(closeSearchWnd(GFSSearch *)), this, SLOT(closeSearchClicked(GFSSearch *))); + connect(ret, SIGNAL(searchChanged(QString &, int)), + &searchesModel, SLOT(searchChanged(QString &, int))); ret->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tabResults->addTab(ret, strLabel); @@ -59,7 +67,7 @@ { GFSSearch *searchWnd; int tab; - QString strSearch; + QString strSearch, strNS; strSearch = cmbSearchFor->lineEdit()->text(); if (strSearch == "") @@ -71,6 +79,8 @@ if (cmbSearchFor->findText(strSearch) == -1) cmbSearchFor->addItem(strSearch); + + strNS = cmbNS->lineEdit()->text(); tabResults->setUpdatesEnabled(false); @@ -88,8 +98,8 @@ tab = 0; } - tabResults->setTabText(tab, strSearch); tabResults->setCurrentIndex(tab); + searchWnd->start(strSearch, strNS, spinAnon->value()); tabResults->setUpdatesEnabled(true); } @@ -105,6 +115,8 @@ wnd->setEnabled(false); tabResults->setTabText(0, tr("Search results")); } + + searchesModel.searchClosed(wnd->searchText()); } extern "C" Modified: gnunet-qt/src/plugins/fs/fs.h =================================================================== --- gnunet-qt/src/plugins/fs/fs.h 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/fs.h 2006-06-17 23:42:05 UTC (rev 3018) @@ -30,6 +30,9 @@ #include "gnunet_qt_common.h" #include "ui_fs.h" #include "fs-search.h" +#include "searchesModel.h" +#include "downloadsModel.h" +#include "uploadsModel.h" class GFSPlugin : public GPlugin, protected Ui::FSWnd { @@ -38,6 +41,10 @@ public: GFSPlugin(); protected: + GFSSearchesModel searchesModel; + GFSDownloadsModel downloadsModel; + GFSUploadsModel uploadsModel; + GFSSearch *addSearchWnd(QString strLabel); protected slots: void searchClicked(); Modified: gnunet-qt/src/plugins/fs/fs.pro.in =================================================================== --- gnunet-qt/src/plugins/fs/fs.pro.in 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/fs.pro.in 2006-06-17 23:42:05 UTC (rev 3018) @@ -8,6 +8,19 @@ QMAKE_CFLAGS += @CPPFLAGS@ QMAKE_CXXFLAGS += @CXXFLAGS@ -SOURCES = fshelper.cc fs.cc fs-search.cc searchModel.cc -HEADERS = fshelper.h fs.h fs-search.h searchModel.h ../../include/gnunet_qt_common.h +SOURCES = fshelper.cc \ + fs.cc \ + fs-search.cc \ + searchesModel.cc \ + downloadsModel.cc \ + uploadsModel.cc \ + searchModel.cc +HEADERS = fshelper.h \ + fs.h \ + fs-search.h \ + searchesModel.h \ + downloadsModel.h \ + uploadsModel.h \ + searchModel.h \ + ../../include/gnunet_qt_common.h FORMS = fs.ui fs-search-result.ui Modified: gnunet-qt/src/plugins/fs/fs.ui =================================================================== --- gnunet-qt/src/plugins/fs/fs.ui 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/fs.ui 2006-06-17 23:42:05 UTC (rev 3018) @@ -9,7 +9,7 @@ <x>0</x> <y>0</y> <width>534</width> - <height>398</height> + <height>397</height> </rect> </property> <property name="windowTitle" > @@ -30,10 +30,247 @@ <property name="currentIndex" > <number>0</number> </property> + <widget class="QWidget" name="tabStatus" > + <attribute name="title" > + <string>Status</string> + </attribute> + <attribute name="icon" > + <iconset resource="..\..\..\pixmaps\pixmaps.qrc" >:/pixmaps/info.png</iconset> + </attribute> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QGroupBox" name="groupBox_2" > + <property name="title" > + <string>Active searches</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTreeView" name="treeSearches" > + <property name="sizePolicy" > + <sizepolicy> + <hsizetype>4</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize" > + <size> + <width>200</width> + <height>16777215</height> + </size> + </property> + <property name="alternatingRowColors" > + <bool>true</bool> + </property> + <property name="selectionMode" > + <enum>QAbstractItemView::NoSelection</enum> + </property> + <property name="rootIsDecorated" > + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QGroupBox" name="groupBox_3" > + <property name="title" > + <string>Active downloads</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTreeView" name="treeDownloads" > + <property name="alternatingRowColors" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="pbStopDL" > + <property name="toolTip" > + <string>Stop selected downloads</string> + </property> + <property name="text" > + <string>Stop</string> + </property> + <property name="icon" > + <iconset resource="../../../pixmaps/pixmaps.qrc" >:/pixmaps/stop.png</iconset> + </property> + <property name="iconSize" > + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="toolButtonStyle" > + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="pbClearDL" > + <property name="toolTip" > + <string>Clear inactive downloads</string> + </property> + <property name="text" > + <string>Clear</string> + </property> + <property name="icon" > + <iconset resource="../../../pixmaps/pixmaps.qrc" >:/pixmaps/clear.png</iconset> + </property> + <property name="iconSize" > + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="toolButtonStyle" > + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_4" > + <property name="title" > + <string>Active uploads</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QTreeView" name="treeUploads" > + <property name="alternatingRowColors" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="pbClearUL" > + <property name="toolTip" > + <string>Clear finished uploads</string> + </property> + <property name="text" > + <string>Clear</string> + </property> + <property name="icon" > + <iconset resource="../../../pixmaps/pixmaps.qrc" >:/pixmaps/clear.png</iconset> + </property> + <property name="iconSize" > + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="toolButtonStyle" > + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> + </layout> + </item> + </layout> + </widget> <widget class="QWidget" name="tabSearch" > <attribute name="title" > <string>Search and download</string> </attribute> + <attribute name="icon" > + <iconset resource="..\..\..\pixmaps\pixmaps.qrc" >:/pixmaps/download_small.png</iconset> + </attribute> <layout class="QVBoxLayout" > <property name="margin" > <number>9</number> @@ -123,7 +360,7 @@ </widget> </item> <item> - <widget class="QSpinBox" name="spinBox" > + <widget class="QSpinBox" name="spinAnon" > <property name="minimum" > <number>1</number> </property> Modified: gnunet-qt/src/plugins/fs/searchModel.cc =================================================================== --- gnunet-qt/src/plugins/fs/searchModel.cc 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/searchModel.cc 2006-06-17 23:42:05 UTC (rev 3018) @@ -120,4 +120,9 @@ endRemoveColumns(); } +void GFSSearchModel::startSearch(QString &strSearch, QString &strNS, int anonymity) +{ + emit resultsChanged(strSearch, 0); +} + /* end of searchModel.cc */ Modified: gnunet-qt/src/plugins/fs/searchModel.h =================================================================== --- gnunet-qt/src/plugins/fs/searchModel.h 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/searchModel.h 2006-06-17 23:42:05 UTC (rev 3018) @@ -48,6 +48,10 @@ const QList<EXTRACTOR_KeywordType> &columns(); void addColumn(EXTRACTOR_KeywordType type); void removeColumn(EXTRACTOR_KeywordType type); + + void startSearch(QString &strSearch, QString &strNS, int anonymity); +signals: + void resultsChanged(QString &strSearch, int searchResults); protected: QString columnName(EXTRACTOR_KeywordType type) const; Added: gnunet-qt/src/plugins/fs/searchesModel.cc =================================================================== --- gnunet-qt/src/plugins/fs/searchesModel.cc 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/searchesModel.cc 2006-06-17 23:42:05 UTC (rev 3018) @@ -0,0 +1,136 @@ +/* + This file is part of gnunet-qt. + (C) 2006 Nils Durner (and other contributing authors) + + gnunet-qt 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 2, or (at your + option) any later version. + + gnunet-qt 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/** + * @file src/plugins/fs/searchModel.cc + * @brief MVC model for the search results display in the status tab + * @author Nils Durner + */ + +#include "gnunet_qt_common.h" +#include "searchesModel.h" + + +QVariant GFSSearchesModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + if (role == Qt::DisplayRole) + { + if (section == 0) + return QVariant(tr("Request")); + if (section == 1) + return QVariant(tr("Results")); + } + + return QVariant(); +} + +GFSSearchesModel::GFSSearchesModel() : QAbstractItemModel() +{ +} + +QModelIndex GFSSearchesModel::index(int row, int column, + const QModelIndex &parent) const +{ + return createIndex(row, column); +} + +QModelIndex GFSSearchesModel::parent(const QModelIndex &index) const +{ + return QModelIndex(); +} + +int GFSSearchesModel::rowCount(const QModelIndex &parent) const +{ + if (parent.row() == -1 && parent.column() == -1) + return results.count(); + else + return 0; +} + +int GFSSearchesModel::columnCount(const QModelIndex &parent) const +{ + return 2; +} + +QVariant GFSSearchesModel::data(const QModelIndex &index, int role) const +{ + if (index.row() > rowCount() - 1) + return QVariant(); + + GFSSearchResultCount result = results[index.row()]; + if (role == Qt::DisplayRole) + { + if (index.column() == 0) + return QVariant(result.strSearch); + else + return QVariant(result.count); + } + + return QVariant(); +} + +void GFSSearchesModel::searchChanged(QString &strSearch, int searchResults) +{ + int idx = 0; + GFSSearchResultList::iterator it = results.begin(); + while(it != results.end()) + { + if (it->strSearch == strSearch) + { + it->count = searchResults; + dataChanged(index(idx, 0), index(idx, 0)); + } + + it++; + idx++; + } + + if (it == results.end()) + { + GFSSearchResultCount result; + + beginInsertRows(index(-1, -1), idx, idx); + result.strSearch = strSearch; + result.count = searchResults; + results.append(result); + endInsertRows(); + } +} + +void GFSSearchesModel::searchClosed(QString &strSearch) +{ + int idx = 0; + GFSSearchResultList::iterator it = results.begin(); + while(it != results.end()) + { + if (it->strSearch == strSearch) + { + results.removeAt(idx); + reset(); // FIXME + break; + } + + it++; + idx++; + } +} + +/* end of searchesModel.cc */ Added: gnunet-qt/src/plugins/fs/searchesModel.h =================================================================== --- gnunet-qt/src/plugins/fs/searchesModel.h 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/searchesModel.h 2006-06-17 23:42:05 UTC (rev 3018) @@ -0,0 +1,64 @@ +/* + This file is part of gnunet-qt. + (C) 2006 Nils Durner (and other contributing authors) + + gnunet-qt 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 2, or (at your + option) any later version. + + gnunet-qt 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/** + * @file src/plugins/fs/searchesModel.h + * @brief MVC model for the search results display in the status tab + * @author Nils Durner + */ + +#ifndef SEARCHESMODEL_H_ +#define SEARCHESMODEL_H_ + +#include <QAbstractItemModel> +#include <QList> + +class GFSSearchesModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + GFSSearchesModel(); + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, const QModelIndex &parent = + QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + void searchClosed(QString &strSearch); +public slots: + void searchChanged(QString &strSearch, int searchResults); +protected: + typedef struct + { + QString strSearch; + int count; + } GFSSearchResultCount; + + typedef QList<GFSSearchResultCount> GFSSearchResultList; + + GFSSearchResultList results; +}; + +#endif /*SEARCHESMODEL_H_*/ + +/* end of searchesModel.h */ Added: gnunet-qt/src/plugins/fs/uploadsModel.cc =================================================================== --- gnunet-qt/src/plugins/fs/uploadsModel.cc 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/uploadsModel.cc 2006-06-17 23:42:05 UTC (rev 3018) @@ -0,0 +1,79 @@ +/* + This file is part of gnunet-qt. + (C) 2006 Nils Durner (and other contributing authors) + + gnunet-qt 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 2, or (at your + option) any later version. + + gnunet-qt 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/** + * @file src/plugins/fs/uploadsModel.cc + * @brief MVC model for the uploads display in the status tab + * @author Nils Durner + */ + +#include "uploadsModel.h" + + +QVariant GFSUploadsModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + if (role == Qt::DisplayRole) + { + if (section == 0) + return QVariant(tr("Filename")); + if (section == 1) + return QVariant(tr("Progress")); + if (section == 2) + return QVariant(tr("Size")); + if (section == 3) + return QVariant(tr("URI")); + } + + return QVariant(); +} + +GFSUploadsModel::GFSUploadsModel() : QAbstractItemModel() +{ +} + +QModelIndex GFSUploadsModel::index(int row, int column, + const QModelIndex &parent) const +{ + return createIndex(row, column); +} + +QModelIndex GFSUploadsModel::parent(const QModelIndex &index) const +{ + return QModelIndex(); +} + +int GFSUploadsModel::rowCount(const QModelIndex &parent) const +{ + return 0; +} + +int GFSUploadsModel::columnCount(const QModelIndex &parent) const +{ + return 4; +} + +QVariant GFSUploadsModel::data(const QModelIndex &index, int role) const +{ + return QVariant(); +} + + +/* end of uploadsModel.cc */ Added: gnunet-qt/src/plugins/fs/uploadsModel.h =================================================================== --- gnunet-qt/src/plugins/fs/uploadsModel.h 2006-06-16 21:47:52 UTC (rev 3017) +++ gnunet-qt/src/plugins/fs/uploadsModel.h 2006-06-17 23:42:05 UTC (rev 3018) @@ -0,0 +1,51 @@ +/* + This file is part of gnunet-qt. + (C) 2006 Nils Durner (and other contributing authors) + + gnunet-qt 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 2, or (at your + option) any later version. + + gnunet-qt 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +/** + * @file src/plugins/fs/uploadsModel.h + * @brief MVC model for the uploads display in the status tab + * @author Nils Durner + */ + +#ifndef UPLOADSMODEL_H_ +#define UPLOADSMODEL_H_ + +#include <QAbstractItemModel> +#include <QList> + +class GFSUploadsModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + GFSUploadsModel(); + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, const QModelIndex &parent = + QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; +}; + +#endif /*UPLOADSMODEL_H_*/ + +/* end of uploadsModel.h */ _______________________________________________ GNUnet-SVN mailing list GNUnet-SVN@gnu.org http://lists.gnu.org/mailman/listinfo/gnunet-svn