[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7270 - in gnunet-qt/src: common include plugins/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7270 - in gnunet-qt/src: common include plugins/fs |
Date: |
Tue, 17 Jun 2008 14:40:41 -0600 (MDT) |
Author: durner
Date: 2008-06-17 14:40:41 -0600 (Tue, 17 Jun 2008)
New Revision: 7270
Added:
gnunet-qt/src/common/itemModel.cc
gnunet-qt/src/common/itemModel.h
Modified:
gnunet-qt/src/common/Makefile.am
gnunet-qt/src/include/gnunet_qt_common.h
gnunet-qt/src/plugins/fs/downloadController.cc
gnunet-qt/src/plugins/fs/downloadController.h
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/searchController.cc
gnunet-qt/src/plugins/fs/searchController.h
gnunet-qt/src/plugins/fs/uploadController.cc
gnunet-qt/src/plugins/fs/uploadController.h
Log:
thread safe item model
Modified: gnunet-qt/src/common/Makefile.am
===================================================================
--- gnunet-qt/src/common/Makefile.am 2008-06-17 06:31:26 UTC (rev 7269)
+++ gnunet-qt/src/common/Makefile.am 2008-06-17 20:40:41 UTC (rev 7270)
@@ -10,6 +10,8 @@
gstring.cc \
event.cc \
eventDispatcher.cc \
+ itemModel.h \
+ itemModel.cc \
textEditor.cc \
plugin.h \
pluginLoader.h \
@@ -28,6 +30,7 @@
moc_pluginLoader.cpp \
moc_event.cpp \
moc_eventDispatcher.cpp \
+ moc_itemModel.cpp \
moc_textEditor.cpp
EXTRA_DIST = \
Added: gnunet-qt/src/common/itemModel.cc
===================================================================
--- gnunet-qt/src/common/itemModel.cc (rev 0)
+++ gnunet-qt/src/common/itemModel.cc 2008-06-17 20:40:41 UTC (rev 7270)
@@ -0,0 +1,538 @@
+#include "itemModel.h"
+
+GItemModel::GItemModel(QObject *parent)
+{
+ lock = new QMutex(QMutex::Recursive);
+}
+
+GItemModel::~GItemModel()
+{
+ delete lock;
+}
+
+bool GItemModel::hasIndex(int row, int column, const QModelIndex &parent) const
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::hasIndex(row, column, parent);
+ lock->unlock();
+ return ret;
+}
+
+QModelIndex GItemModel::index(int row, int column, const QModelIndex &parent)
const
+{
+ QModelIndex ret;
+
+ lock->lock();
+ ret = QStandardItemModel::index(row, column, parent);
+ lock->unlock();
+ return ret;
+}
+
+QModelIndex GItemModel::parent(const QModelIndex &child) const
+{
+ QModelIndex ret;
+
+ lock->lock();
+ ret = QStandardItemModel::parent(child);
+ lock->unlock();
+ return ret;
+}
+
+void GItemModel::setColumnCount(int columns)
+{
+ lock->lock();
+ QStandardItemModel::setColumnCount(columns);
+ lock->unlock();
+}
+
+QStandardItem *GItemModel::itemFromIndex(const QModelIndex &index) const
+{
+ QStandardItem *ret;
+
+ lock->lock();
+ ret = QStandardItemModel::itemFromIndex(index);
+ lock->unlock();
+ return ret;
+}
+
+QStandardItem *GItemModel::invisibleRootItem() const
+{
+ QStandardItem *ret;
+
+ lock->lock();
+ ret = QStandardItemModel::invisibleRootItem();
+ lock->unlock();
+ return ret;
+}
+
+QStandardItem *GItemModel::item(int row, int column) const
+{
+ QStandardItem *ret;
+
+ lock->lock();
+ ret = QStandardItemModel::item(row, column);
+ lock->unlock();
+ return ret;
+}
+
+void GItemModel::clear()
+{
+ lock->lock();
+ QStandardItemModel::clear();
+ lock->unlock();
+}
+
+void GItemModel::appendRow(QStandardItem *item)
+{
+ lock->lock();
+ QStandardItemModel::appendRow(item);
+ lock->unlock();
+}
+
+int GItemModel::rowCount(const QModelIndex &parent) const
+{
+ int ret;
+
+ lock->lock();
+ ret = QStandardItemModel::rowCount(parent);
+ lock->unlock();
+ return ret;
+}
+
+int GItemModel::columnCount(const QModelIndex &parent) const
+{
+ int ret;
+
+ lock->lock();
+ ret = QStandardItemModel::columnCount(parent);
+ lock->unlock();
+ return ret;
+}
+
+bool GItemModel::hasChildren(const QModelIndex &parent) const
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::hasChildren(parent);
+ lock->unlock();
+ return ret;
+}
+
+QVariant GItemModel::data(const QModelIndex &index, int role) const
+{
+ QVariant ret;
+
+ lock->lock();
+ ret = QStandardItemModel::data(index, role);
+ lock->unlock();
+ return ret;
+}
+
+bool GItemModel::setData(const QModelIndex &index, const QVariant &value, int
role)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::setData(index, value, role);
+ lock->unlock();
+ return ret;
+}
+
+QVariant GItemModel::headerData(int section, Qt::Orientation orientation, int
role) const
+{
+ QVariant ret;
+
+ lock->lock();
+ ret = QStandardItemModel::headerData(section, orientation, role);
+ lock->unlock();
+ return ret;
+}
+
+bool GItemModel::setHeaderData(int section, Qt::Orientation orientation, const
QVariant &value, int role)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::setHeaderData(section, orientation, value, role);
+ lock->unlock();
+ return ret;
+}
+
+QMap<int, QVariant> GItemModel::itemData(const QModelIndex &index) const
+{
+ QMap<int, QVariant> ret;
+
+ lock->lock();
+ ret = QStandardItemModel::itemData(index);
+ lock->unlock();
+
+ return ret;
+}
+
+bool GItemModel::setItemData(const QModelIndex &index, const QMap<int,
QVariant> &roles)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::setItemData(index, roles);
+ lock->unlock();
+ return ret;
+}
+
+QStringList GItemModel::mimeTypes() const
+{
+ QStringList ret;
+
+ lock->lock();
+ ret = QStandardItemModel::mimeTypes();
+ lock->unlock();
+
+ return ret;
+}
+
+QMimeData *GItemModel::mimeData(const QModelIndexList &indexes) const
+{
+ QMimeData *ret;
+
+ lock->lock();
+ ret = QStandardItemModel::mimeData(indexes);
+ lock->unlock();
+ return ret;
+}
+
+bool GItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::dropMimeData(data, action, row, column, parent);
+ lock->unlock();
+ return ret;
+}
+
+Qt::DropActions GItemModel::supportedDropActions() const
+{
+ Qt::DropActions ret;
+
+ lock->lock();
+ ret = QStandardItemModel::supportedDropActions();
+ lock->unlock();
+ return ret;
+}
+
+Qt::DropActions GItemModel::supportedDragActions() const
+{
+ Qt::DropActions ret;
+
+ lock->lock();
+ ret = QStandardItemModel::supportedDragActions();
+ lock->unlock();
+ return ret;
+}
+
+void GItemModel::setSupportedDragActions(Qt::DropActions x)
+{
+ lock->lock();
+ QStandardItemModel::setSupportedDragActions(x);
+ lock->unlock();
+}
+
+
+bool GItemModel::insertRows(int row, int count, const QModelIndex &parent)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::insertRows(row, count, parent);
+ lock->unlock();
+ return ret;
+}
+
+bool GItemModel::insertColumns(int column, int count, const QModelIndex
&parent)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::insertColumns(column, count, parent);
+ lock->unlock();
+ return ret;
+}
+
+bool GItemModel::removeRows(int row, int count, const QModelIndex &parent)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::removeRows(row, count, parent);
+ lock->unlock();
+ return ret;
+}
+
+bool GItemModel::removeColumns(int column, int count, const QModelIndex
&parent)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::removeColumns(column, count, parent);
+ lock->unlock();
+ return ret;
+}
+
+inline bool GItemModel::insertRow(int row, const QModelIndex &parent)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::insertRow(row, parent);
+ lock->unlock();
+
+ return ret;
+}
+
+inline bool GItemModel::insertColumn(int column, const QModelIndex &parent)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::insertColumn(column, parent);
+ lock->unlock();
+ return ret;
+}
+
+bool GItemModel::removeRow(int row, const QModelIndex &parent)
+{
+ bool ret;
+
+ lock->lock();
+ QStandardItemModel::removeRow(row, parent);
+ lock->unlock();
+
+ return ret;
+}
+
+inline bool GItemModel::removeColumn(int column, const QModelIndex &parent)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::removeColumn(column, parent);
+ lock->unlock();
+ return ret;
+}
+
+void GItemModel::fetchMore(const QModelIndex &parent)
+{
+ lock->lock();
+ QStandardItemModel::fetchMore(parent);
+ lock->unlock();
+}
+
+bool GItemModel::canFetchMore(const QModelIndex &parent) const
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::canFetchMore(parent);
+ lock->unlock();
+ return ret;
+}
+
+Qt::ItemFlags GItemModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags ret;
+
+ lock->lock();
+ ret = QStandardItemModel::flags(index);
+ lock->unlock();
+ return ret;
+}
+
+void GItemModel::sort(int column, Qt::SortOrder order)
+{
+ lock->lock();
+ QStandardItemModel::sort(column, order);
+ lock->unlock();
+}
+
+QModelIndex GItemModel::buddy(const QModelIndex &index) const
+{
+ QModelIndex ret;
+
+ lock->lock();
+ ret = QStandardItemModel::buddy(index);
+ lock->unlock();
+ return ret;
+}
+
+QModelIndexList GItemModel::match(const QModelIndex &start, int role, const
QVariant &value, int hits, Qt::MatchFlags flags) const
+{
+ QModelIndexList ret;
+
+ lock->lock();
+ ret = QStandardItemModel::match(start, role, value, hits, flags);
+ lock->unlock();
+ return ret;
+}
+
+QSize GItemModel::span(const QModelIndex &index) const
+{
+ QSize ret;
+
+ lock->lock();
+ ret = QStandardItemModel::span(index);
+ lock->unlock();
+ return ret;
+}
+
+inline QModelIndex GItemModel::createIndex(int row, int column, void *data)
const
+{
+ QModelIndex ret;
+
+ lock->lock();
+ ret = QStandardItemModel::createIndex(row, column, data);
+ lock->unlock();
+ return ret;
+}
+
+inline QModelIndex GItemModel::createIndex(int row, int column, int id) const
+{
+ QModelIndex ret;
+
+ lock->lock();
+ ret = QStandardItemModel::createIndex(row, column, id);
+ lock->unlock();
+ return ret;
+}
+
+inline QModelIndex GItemModel::createIndex(int row, int column, quint32 id)
const
+{
+ QModelIndex ret;
+
+ lock->lock();
+ ret = QStandardItemModel::createIndex(row, column, id);
+ lock->unlock();
+ return ret;
+}
+
+void GItemModel::encodeData(const QModelIndexList &indexes, QDataStream
&stream) const
+{
+ lock->lock();
+ QStandardItemModel::encodeData(indexes, stream);
+ lock->unlock();
+}
+
+bool GItemModel::decodeData(int row, int column, const QModelIndex &parent,
QDataStream &stream)
+{
+ bool ret;
+
+ lock->lock();
+ ret = QStandardItemModel::decodeData(row, column, parent, stream);
+ lock->unlock();
+ return ret;
+}
+
+void GItemModel::beginInsertRows(const QModelIndex &parent, int first, int
last)
+{
+ lock->lock();
+ QStandardItemModel::beginInsertRows(parent, first, last);
+ lock->unlock();
+}
+
+void GItemModel::endInsertRows()
+{
+ lock->lock();
+ QStandardItemModel::endInsertRows();
+ lock->unlock();
+}
+
+
+void GItemModel::beginRemoveRows(const QModelIndex &parent, int first, int
last)
+{
+ lock->lock();
+ QStandardItemModel::beginRemoveRows(parent, first, last);
+ lock->unlock();
+}
+
+void GItemModel::endRemoveRows()
+{
+ lock->lock();
+ QStandardItemModel::endRemoveRows();
+ lock->unlock();
+}
+
+
+void GItemModel::beginInsertColumns(const QModelIndex &parent, int first, int
last)
+{
+ lock->lock();
+ QStandardItemModel::beginInsertColumns(parent, first, last);
+ lock->unlock();
+}
+
+void GItemModel::endInsertColumns()
+{
+ lock->lock();
+ QStandardItemModel::endInsertColumns();
+ lock->unlock();
+}
+
+
+void GItemModel::beginRemoveColumns(const QModelIndex &parent, int first, int
last)
+{
+ lock->lock();
+ QStandardItemModel::beginRemoveColumns(parent, first, last);
+ lock->unlock();
+}
+
+void GItemModel::endRemoveColumns()
+{
+ lock->lock();
+ QStandardItemModel::endRemoveColumns();
+ lock->unlock();
+}
+
+
+void GItemModel::reset()
+{
+ lock->lock();
+ QStandardItemModel::reset();
+ lock->unlock();
+}
+
+
+void GItemModel::changePersistentIndex(const QModelIndex &from, const
QModelIndex &to)
+{
+ lock->lock();
+ QStandardItemModel::changePersistentIndex(from, to);
+ lock->unlock();
+}
+
+void GItemModel::changePersistentIndexList(const QModelIndexList &from, const
QModelIndexList &to)
+{
+ lock->lock();
+ QStandardItemModel::changePersistentIndexList(from, to);
+ lock->unlock();
+}
+
+QModelIndexList GItemModel::persistentIndexList() const
+{
+ QModelIndexList ret;
+
+ lock->lock();
+ ret = QStandardItemModel::persistentIndexList();
+ lock->unlock();
+ return ret;
+}
+
+QAbstractItemModel *GItemModel::abstractItemModel()
+{
+ return this;
+}
+
+QObject *GItemModel::object()
+{
+ return this;
+}
+
Added: gnunet-qt/src/common/itemModel.h
===================================================================
--- gnunet-qt/src/common/itemModel.h (rev 0)
+++ gnunet-qt/src/common/itemModel.h 2008-06-17 20:40:41 UTC (rev 7270)
@@ -0,0 +1,130 @@
+#ifndef ITEMMODEL_H_
+#define ITEMMODEL_H_
+
+#include <QStandardItemModel>
+#include <QAbstractItemModel>
+#include <QMutex>
+
+class GItemModel : protected QStandardItemModel
+{
+ Q_OBJECT
+
+public:
+ explicit GItemModel(QObject *parent = 0);
+ virtual ~GItemModel();
+
+ bool hasIndex(int row, int column, const QModelIndex &parent =
QModelIndex()) const;
+ virtual QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const;
+ virtual QModelIndex parent(const QModelIndex &child) const;
+
+ inline QModelIndex sibling(int row, int column, const QModelIndex &idx) const
+ { return index(row, column, parent(idx)); }
+
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
+
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole)
const;
+ virtual bool setData(const QModelIndex &index, const QVariant &value, int
role = Qt::EditRole);
+
+ virtual QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ virtual bool setHeaderData(int section, Qt::Orientation orientation, const
QVariant &value,
+ int role = Qt::EditRole);
+
+ virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
+ virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant>
&roles);
+
+ virtual QStringList mimeTypes() const;
+ virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
+ virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+ virtual Qt::DropActions supportedDropActions() const;
+
+ Qt::DropActions supportedDragActions() const;
+ void setSupportedDragActions(Qt::DropActions);
+
+ virtual bool insertRows(int row, int count, const QModelIndex &parent =
QModelIndex());
+ virtual bool insertColumns(int column, int count, const QModelIndex &parent
= QModelIndex());
+ virtual bool removeRows(int row, int count, const QModelIndex &parent =
QModelIndex());
+ virtual bool removeColumns(int column, int count, const QModelIndex &parent
= QModelIndex());
+
+ bool insertRow(int row, const QModelIndex &parent = QModelIndex());
+ bool insertColumn(int column, const QModelIndex &parent = QModelIndex());
+ bool removeRow(int row, const QModelIndex &parent = QModelIndex());
+ bool removeColumn(int column, const QModelIndex &parent = QModelIndex());
+
+ virtual void fetchMore(const QModelIndex &parent);
+ virtual bool canFetchMore(const QModelIndex &parent) const;
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+ virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+ virtual QModelIndex buddy(const QModelIndex &index) const;
+ virtual QModelIndexList match(const QModelIndex &start, int role,
+ const QVariant &value, int hits = 1,
+ Qt::MatchFlags flags =
+
Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
+ virtual QSize span(const QModelIndex &index) const;
+
+ QObject *parent() const { return QObject::parent(); }
+
+ void setColumnCount(int columns);
+ QStandardItem *itemFromIndex(const QModelIndex &index) const;
+ QStandardItem *invisibleRootItem() const;
+ QStandardItem *item(int row, int column = 0) const;
+ void clear();
+ void appendRow(QStandardItem *item);
+
+ QAbstractItemModel *abstractItemModel();
+ QObject *object();
+Q_SIGNALS:
+ void dataChanged(const QModelIndex &topLeft, const QModelIndex
&bottomRight);
+ void headerDataChanged(Qt::Orientation orientation, int first, int last);
+ void layoutChanged();
+ void layoutAboutToBeChanged();
+
+private: // can only be emitted by QAbstractItemModel
+ void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
+ void rowsInserted(const QModelIndex &parent, int first, int last);
+
+ void rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
+ void rowsRemoved(const QModelIndex &parent, int first, int last);
+
+ void columnsAboutToBeInserted(const QModelIndex &parent, int first, int
last);
+ void columnsInserted(const QModelIndex &parent, int first, int last);
+
+ void columnsAboutToBeRemoved(const QModelIndex &parent, int first, int
last);
+ void columnsRemoved(const QModelIndex &parent, int first, int last);
+
+ void modelAboutToBeReset();
+ void modelReset();
+
+ QMutex *lock;
+protected:
+ QModelIndex createIndex(int row, int column, void *data = 0) const;
+ QModelIndex createIndex(int row, int column, int id) const;
+ QModelIndex createIndex(int row, int column, quint32 id) const;
+
+ void encodeData(const QModelIndexList &indexes, QDataStream &stream) const;
+ bool decodeData(int row, int column, const QModelIndex &parent,
QDataStream &stream);
+
+ void beginInsertRows(const QModelIndex &parent, int first, int last);
+ void endInsertRows();
+
+ void beginRemoveRows(const QModelIndex &parent, int first, int last);
+ void endRemoveRows();
+
+ void beginInsertColumns(const QModelIndex &parent, int first, int last);
+ void endInsertColumns();
+
+ void beginRemoveColumns(const QModelIndex &parent, int first, int last);
+ void endRemoveColumns();
+
+ void reset();
+
+ void changePersistentIndex(const QModelIndex &from, const QModelIndex &to);
+ void changePersistentIndexList(const QModelIndexList &from, const
QModelIndexList &to);
+ QModelIndexList persistentIndexList() const;
+};
+
+#endif /*ITEMMODEL_H_*/
Modified: gnunet-qt/src/include/gnunet_qt_common.h
===================================================================
--- gnunet-qt/src/include/gnunet_qt_common.h 2008-06-17 06:31:26 UTC (rev
7269)
+++ gnunet-qt/src/include/gnunet_qt_common.h 2008-06-17 20:40:41 UTC (rev
7270)
@@ -33,6 +33,7 @@
#include "../common/event.h"
#include "../common/eventDispatcher.h"
+#include "../common/itemModel.h"
#include "../common/textEditor.h"
#include "../common/plugin.h"
#include "../common/pluginLoader.h"
Modified: gnunet-qt/src/plugins/fs/downloadController.cc
===================================================================
--- gnunet-qt/src/plugins/fs/downloadController.cc 2008-06-17 06:31:26 UTC
(rev 7269)
+++ gnunet-qt/src/plugins/fs/downloadController.cc 2008-06-17 20:40:41 UTC
(rev 7270)
@@ -52,7 +52,7 @@
downloadModel.setHeaderData(COL_DST_PATH, Qt::Horizontal,
tr("Destination path"), Qt::DisplayRole);
- view->setModel(&downloadModel);
+ view->setModel(downloadModel.abstractItemModel());
view->setItemDelegate(&delegate);
view->hideColumn(COL_ETA);
view->hideColumn(COL_DST_PATH);
@@ -274,7 +274,7 @@
QAbstractItemModel *GFSDownloadController::model()
{
- return &downloadModel;
+ return downloadModel.abstractItemModel();
}
/* end of downloadController.cc */
Modified: gnunet-qt/src/plugins/fs/downloadController.h
===================================================================
--- gnunet-qt/src/plugins/fs/downloadController.h 2008-06-17 06:31:26 UTC
(rev 7269)
+++ gnunet-qt/src/plugins/fs/downloadController.h 2008-06-17 20:40:41 UTC
(rev 7270)
@@ -28,7 +28,7 @@
#define DOWNLOADCONTROLLER_H_
#include <QObject>
-#include <QStandardItemModel>
+#include "gnunet_qt_common.h"
#include "fs.h"
#include "ecrsMetaData.h"
#include "downloadItemDelegate.h"
@@ -80,7 +80,7 @@
typedef QMap<GFSEcrsUri, QPersistentModelIndex> GFSDownloadList;
GFSPlugin *fs;
- QStandardItemModel downloadModel;
+ GItemModel downloadModel;
GFSDownloadItemDelegate delegate;
GFSDownloadList downloadList;
Modified: gnunet-qt/src/plugins/fs/fs-search.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs-search.cc 2008-06-17 06:31:26 UTC (rev
7269)
+++ gnunet-qt/src/plugins/fs/fs-search.cc 2008-06-17 20:40:41 UTC (rev
7270)
@@ -195,12 +195,12 @@
treeResults->setColumnWidth(SEARCH_RANK_COLUMN, 50);
}
-void GFSSearch::setModel(QStandardItemModel *model)
+void GFSSearch::setModel(GItemModel *model)
{
QByteArray data;
m = model;
- treeResults->setModel(model);
+ treeResults->setModel(model->abstractItemModel());
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this,
SLOT(resultInserted()));
Modified: gnunet-qt/src/plugins/fs/fs-search.h
===================================================================
--- gnunet-qt/src/plugins/fs/fs-search.h 2008-06-17 06:31:26 UTC (rev
7269)
+++ gnunet-qt/src/plugins/fs/fs-search.h 2008-06-17 20:40:41 UTC (rev
7270)
@@ -28,9 +28,9 @@
#define SEARCHRESULTS_H_
#include <QTabWidget>
-#include <QStandardItemModel>
#include <GNUnet/gnunet_fsui_lib.h>
+#include "gnunet_qt_common.h"
#include "fs.h"
#include "ecrsuri.h"
#include "ui_fs-search-result.h"
@@ -42,21 +42,21 @@
public:
GFSSearch(class GFSPlugin *fs, QTabWidget *tab);
void clear();
- void setModel(QStandardItemModel *model);
+ void setModel(GItemModel *model);
void setItemDelegate(QAbstractItemDelegate *itemDelegate);
void setUri(GFSEcrsUri &uri);
- QStandardItemModel *model();
+ GItemModel *model();
signals:
void closeSearchWnd(GFSEcrsUri &uri);
- void download(QStandardItemModel *model, GFSEcrsUri &uri,
+ void download(GItemModel *model, GFSEcrsUri &uri,
QModelIndexList indexes, int anonymity, bool recursive);
protected:
class GFSPlugin *fs;
GFSEcrsUri uri;
QTabWidget *tab;
- QStandardItemModel *m;
+ GItemModel *m;
void setColHidden(int col, bool hidden);
void setupColumns();
Modified: gnunet-qt/src/plugins/fs/fs.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs.cc 2008-06-17 06:31:26 UTC (rev 7269)
+++ gnunet-qt/src/plugins/fs/fs.cc 2008-06-17 20:40:41 UTC (rev 7270)
@@ -30,7 +30,6 @@
#include <QFileDialog>
#include <QDir>
#include <QUrl>
-#include <QStandardItemModel>
#include <QDesktopServices>
#include <GNUnet/gnunet_fsui_lib.h>
#if defined(Q_WS_WIN)
@@ -156,7 +155,7 @@
setupUi(this);
qRegisterMetaType<GFSEcrsUri>("GFSEcrsUri&");
- qRegisterMetaType<QStandardItemModel *>("QStandardItemModel*");
+ qRegisterMetaType<GItemModel *>("GItemModel*");
qRegisterMetaType<QModelIndex>("QModelIndex");
qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
qRegisterMetaType<QModelIndexList>("QModelIndexList");
Modified: gnunet-qt/src/plugins/fs/fs.h
===================================================================
--- gnunet-qt/src/plugins/fs/fs.h 2008-06-17 06:31:26 UTC (rev 7269)
+++ gnunet-qt/src/plugins/fs/fs.h 2008-06-17 20:40:41 UTC (rev 7270)
@@ -27,8 +27,6 @@
#ifndef FS_H_
#define FS_H_
-#include <QStandardItemModel>
-
#include "gnunet_qt_common.h"
#include "ecrsMetaData.h"
#include "ui_fs.h"
@@ -41,7 +39,7 @@
typedef struct
{
- QStandardItemModel *model;
+ GItemModel *model;
GFSEcrsUri uri;
} GFSNewSearchInfo;
Modified: gnunet-qt/src/plugins/fs/searchController.cc
===================================================================
--- gnunet-qt/src/plugins/fs/searchController.cc 2008-06-17 06:31:26 UTC
(rev 7269)
+++ gnunet-qt/src/plugins/fs/searchController.cc 2008-06-17 20:40:41 UTC
(rev 7270)
@@ -73,7 +73,7 @@
QSemaphore sem;
- info.model = new QStandardItemModel;
+ info.model = new GItemModel;
info.uri = uri;
event = new GEvent((QEvent::Type) GFSPlugin::NewSearch, &info, (void **)
&view, &sem);
@@ -84,9 +84,9 @@
connect(view, SIGNAL(closeSearchWnd(GFSEcrsUri &)), this,
SLOT(closed(GFSEcrsUri &)));
connect(view,
- SIGNAL(download(QStandardItemModel *, GFSEcrsUri &, QModelIndexList, int,
bool)),
+ SIGNAL(download(GItemModel *, GFSEcrsUri &, QModelIndexList, int, bool)),
this,
- SLOT(download(QStandardItemModel *, GFSEcrsUri &, QModelIndexList, int,
bool)));
+ SLOT(download(GItemModel *, GFSEcrsUri &, QModelIndexList, int, bool)));
searchSummaryCntrl->searchStarted(list, uri);
@@ -105,7 +105,7 @@
return searchInfo;
}
-void GFSSearchController::addSearchResult(QStandardItemModel *model,
+void GFSSearchController::addSearchResult(GItemModel *model,
QModelIndex parent, const GNUNET_ECRS_FileInfo *info)
{
int row;
@@ -197,7 +197,7 @@
* @param info file information
* @notice called by started() if there are results from the last session
*/
-void GFSSearchController::result(QStandardItemModel *model,
+void GFSSearchController::result(GItemModel *model,
const struct GNUNET_FSUI_SearchList *list, const GNUNET_ECRS_FileInfo *info)
{
addSearchResult(model, QModelIndex(), info);
@@ -219,7 +219,7 @@
searchSummaryCntrl->searchStopped(info->handle);
if (!lastTab)
- info->model->deleteLater();
+ info->model->object()->deleteLater();
delete info;
}
@@ -233,7 +233,7 @@
const struct GNUNET_ECRS_URI *searchURI, int avail, unsigned int cert,
unsigned int relevance)
{
- QStandardItemModel *model;
+ GItemModel *model;
GFSEcrsUri ecrsUri;
QModelIndexList lst;
int row, availmax, availmin;
@@ -289,7 +289,7 @@
searches.remove(uri);
}
-void GFSSearchController::download(QStandardItemModel *model, GFSEcrsUri &uri,
+void GFSSearchController::download(GItemModel *model, GFSEcrsUri &uri,
QModelIndexList indexes, int anonymity, bool recurse)
{
QModelIndexList::iterator it;
@@ -338,7 +338,7 @@
Q_UNUSED(key)
QPersistentModelIndex *pIdx;
- QStandardItemModel *model;
+ GItemModel *model;
QModelIndex parentIdx, child;
if (isRoot == GNUNET_YES)
@@ -347,7 +347,7 @@
GFSEcrsUri uri(fi->uri);
pIdx = (QPersistentModelIndex *) closure;
- model = (QStandardItemModel *) pIdx->model();
+ model = (GItemModel *) pIdx->model();
if (!pIdx->isValid())
return GNUNET_NO;
Modified: gnunet-qt/src/plugins/fs/searchController.h
===================================================================
--- gnunet-qt/src/plugins/fs/searchController.h 2008-06-17 06:31:26 UTC (rev
7269)
+++ gnunet-qt/src/plugins/fs/searchController.h 2008-06-17 20:40:41 UTC (rev
7270)
@@ -29,7 +29,7 @@
#include <QObject>
#include <QMap>
-#include <QStandardItemModel>
+#include <gnunet_qt_common.h>
#include "fs.h"
#include "ecrsuri.h"
#include "fs-search.h"
@@ -37,7 +37,7 @@
typedef struct
{
- QStandardItemModel *model;
+ GItemModel *model;
QWidget *searchWindow;
const struct GNUNET_FSUI_SearchList *handle;
} GFSSearchInfo;
@@ -54,7 +54,7 @@
const struct GNUNET_ECRS_URI *uri, unsigned int resultCount,
const GNUNET_ECRS_FileInfo *results);
void result(GFSSearchInfo *searchInfo, const GNUNET_ECRS_FileInfo *info);
- void result(QStandardItemModel *model, const struct GNUNET_FSUI_SearchList
*list,
+ void result(GItemModel *model, const struct GNUNET_FSUI_SearchList *list,
const GNUNET_ECRS_FileInfo *info);
void stopped(GFSSearchInfo *info);
void downloadCompleted(QPersistentModelIndex &idx, GString file);
@@ -65,11 +65,11 @@
bool isActive(GFSEcrsUri uri);
- static void addSearchResult(QStandardItemModel *model, QModelIndex parent,
+ static void addSearchResult(GItemModel *model, QModelIndex parent,
const GNUNET_ECRS_FileInfo *info);
protected slots:
void closed(GFSEcrsUri &uri);
- void download(QStandardItemModel *model ,GFSEcrsUri &uri,
+ void download(GItemModel *model ,GFSEcrsUri &uri,
QModelIndexList indexes, int anonymity, bool recurse);
protected:
Modified: gnunet-qt/src/plugins/fs/uploadController.cc
===================================================================
--- gnunet-qt/src/plugins/fs/uploadController.cc 2008-06-17 06:31:26 UTC
(rev 7269)
+++ gnunet-qt/src/plugins/fs/uploadController.cc 2008-06-17 20:40:41 UTC
(rev 7270)
@@ -58,7 +58,7 @@
uploadModel.setHeaderData(1, Qt::Horizontal, tr("Progress"),
Qt::DisplayRole);
uploadModel.setHeaderData(2, Qt::Horizontal, tr("Status"), Qt::DisplayRole);
- fs->uploadView()->setModel(&uploadModel);
+ fs->uploadView()->setModel(uploadModel.abstractItemModel());
fs->uploadView()->setItemDelegate(&delegate);
}
@@ -218,7 +218,7 @@
QAbstractItemModel *GFSUploadController::model()
{
- return &uploadModel;
+ return uploadModel.abstractItemModel();
}
QPersistentModelIndex *GFSUploadController::started(QPersistentModelIndex
*parent,
Modified: gnunet-qt/src/plugins/fs/uploadController.h
===================================================================
--- gnunet-qt/src/plugins/fs/uploadController.h 2008-06-17 06:31:26 UTC (rev
7269)
+++ gnunet-qt/src/plugins/fs/uploadController.h 2008-06-17 20:40:41 UTC (rev
7270)
@@ -28,8 +28,8 @@
#define UPLOADCONTROLLER_H_
#include <QPersistentModelIndex>
-#include <QStandardItemModel>
+#include "gnunet_qt_common.h"
#include "fs.h"
#include "uploadDialog.h"
#include "uploadItemDelegate.h"
@@ -58,7 +58,7 @@
GFSPlugin *fs;
EXTRACTOR_ExtractorList *extractors;
- QStandardItemModel uploadModel;
+ GItemModel uploadModel;
GFSUploadItemDelegate delegate;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7270 - in gnunet-qt/src: common include plugins/fs,
gnunet <=