Commit 2c6216e0 authored by Tony Murray's avatar Tony Murray

Fix up some of the models abit.

RemoteDesktopsModel:
 -Fix a crash when views tried to update persistent model indexes of deleted data.
TabbedViewWidgetModel:
 -Emit the proper signals when data is inserted/removed.
 -Override function KTabWidget::removePage(QWidget *w)


svn path=/trunk/KDE/kdenetwork/krdc/; revision=1026647
parent 44376e12
......@@ -80,11 +80,10 @@ RemoteDesktopsModel::~RemoteDesktopsModel()
void RemoteDesktopsModel::bookmarksChanged()
{
kDebug(5010);
emit layoutAboutToBeChanged();
bookmarkItem->clearChildren();
buildModelFromBookmarkGroup(m_manager->root(), bookmarkItem);
reset();
emit layoutChanged();
}
int RemoteDesktopsModel::columnCount(const QModelIndex &parent) const
......@@ -222,7 +221,6 @@ void RemoteDesktopsModel::servicesChanged() {
//redo list because it is easier than finding and removing one
QList<DNSSD::RemoteService::Ptr> services = zeroconfBrowser->services();
KUrl url;
emit layoutAboutToBeChanged();
zeroconfItem->clearChildren();
foreach(DNSSD::RemoteService::Ptr service, services) {
url.setProtocol(m_protocols[service->type()].toLower());
......@@ -232,7 +230,7 @@ void RemoteDesktopsModel::servicesChanged() {
RemoteDesktopsItem *newItem = new RemoteDesktopsItem(QList<QVariant>() << service->serviceName() << url.url(), zeroconfItem);
zeroconfItem->appendChild(newItem);
}
emit layoutChanged();
reset();
}
#endif
#if 0
......
......@@ -121,41 +121,51 @@ TabbedViewWidgetModel* TabbedViewWidget::getModel()
int TabbedViewWidget::addTab(QWidget *page, const QString &label)
{
m_model->emitLayoutAboutToBeChanged();
int count = KTabWidget::count();
m_model->beginInsertRows(QModelIndex(), count, count);
int ret = KTabWidget::addTab(page, label);
m_model->emitLayoutChanged();
m_model->endInsertRows();
return ret;
}
int TabbedViewWidget::addTab(QWidget *page, const QIcon &icon, const QString &label)
{
m_model->emitLayoutAboutToBeChanged();
int count = KTabWidget::count();
m_model->beginInsertRows(QModelIndex(), count, count);
int ret = KTabWidget::addTab(page, icon, label);
m_model->emitLayoutChanged();
m_model->endInsertRows();
return ret;
}
int TabbedViewWidget::insertTab(int index, QWidget *page, const QString &label)
{
m_model->emitLayoutAboutToBeChanged();
m_model->beginInsertRows(QModelIndex(), index, index);
int ret = KTabWidget::insertTab(index, page, label);
m_model->emitLayoutChanged();
m_model->endInsertRows();
return ret;
}
int TabbedViewWidget::insertTab(int index, QWidget *page, const QIcon &icon, const QString &label)
{
m_model->emitLayoutAboutToBeChanged();
m_model->beginInsertRows(QModelIndex(), index, index);
int ret = KTabWidget::insertTab(index, page, icon, label);
m_model->emitLayoutChanged();
m_model->endInsertRows();
return ret;
}
void TabbedViewWidget::removePage(QWidget *page)
{
int index = KTabWidget::indexOf(page);
m_model->beginRemoveRows(QModelIndex(), index, index);
KTabWidget::removePage(page);
m_model->endRemoveRows();
}
void TabbedViewWidget::removeTab(int index)
{
m_model->emitLayoutAboutToBeChanged();
m_model->beginRemoveRows(QModelIndex(), index, index);
KTabWidget::removeTab(index);
m_model->emitLayoutChanged();
m_model->endRemoveRows();
}
void TabbedViewWidget::moveTab(int from, int to)
......
......@@ -60,6 +60,7 @@ public:
int insertTab(int index, QWidget *page, const QString &label);
int insertTab(int index, QWidget *page, const QIcon &icon, const QString &label);
void removeTab(int index);
void removePage(QWidget *page);
void moveTab(int from, int to);
void setTabText(int index, const QString &label);
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment