75 , m_historyTreeModel(0) |
75 , m_historyTreeModel(0) |
76 { |
76 { |
77 m_expiredTimer.setSingleShot(true); |
77 m_expiredTimer.setSingleShot(true); |
78 connect(&m_expiredTimer, SIGNAL(timeout()), |
78 connect(&m_expiredTimer, SIGNAL(timeout()), |
79 this, SLOT(checkForExpired())); |
79 this, SLOT(checkForExpired())); |
80 connect(this, SIGNAL(entryAdded(const HistoryItem &)), |
80 connect(this, SIGNAL(entryAdded(HistoryItem)), |
81 m_saveTimer, SLOT(changeOccurred())); |
81 m_saveTimer, SLOT(changeOccurred())); |
82 connect(this, SIGNAL(entryRemoved(const HistoryItem &)), |
82 connect(this, SIGNAL(entryRemoved(HistoryItem)), |
83 m_saveTimer, SLOT(changeOccurred())); |
83 m_saveTimer, SLOT(changeOccurred())); |
84 load(); |
84 load(); |
85 |
85 |
86 m_historyModel = new HistoryModel(this, this); |
86 m_historyModel = new HistoryModel(this, this); |
87 m_historyFilterModel = new HistoryFilterModel(m_historyModel, this); |
87 m_historyFilterModel = new HistoryFilterModel(m_historyModel, this); |
367 , m_history(history) |
367 , m_history(history) |
368 { |
368 { |
369 Q_ASSERT(m_history); |
369 Q_ASSERT(m_history); |
370 connect(m_history, SIGNAL(historyReset()), |
370 connect(m_history, SIGNAL(historyReset()), |
371 this, SLOT(historyReset())); |
371 this, SLOT(historyReset())); |
372 connect(m_history, SIGNAL(entryRemoved(const HistoryItem &)), |
372 connect(m_history, SIGNAL(entryRemoved(HistoryItem)), |
373 this, SLOT(historyReset())); |
373 this, SLOT(historyReset())); |
374 |
374 |
375 connect(m_history, SIGNAL(entryAdded(const HistoryItem &)), |
375 connect(m_history, SIGNAL(entryAdded(HistoryItem)), |
376 this, SLOT(entryAdded())); |
376 this, SLOT(entryAdded())); |
377 connect(m_history, SIGNAL(entryUpdated(int)), |
377 connect(m_history, SIGNAL(entryUpdated(int)), |
378 this, SLOT(entryUpdated(int))); |
378 this, SLOT(entryUpdated(int))); |
379 } |
379 } |
380 |
380 |
685 tree->setAlternatingRowColors(true); |
685 tree->setAlternatingRowColors(true); |
686 QFontMetrics fm(font()); |
686 QFontMetrics fm(font()); |
687 int header = fm.width(QLatin1Char('m')) * 40; |
687 int header = fm.width(QLatin1Char('m')) * 40; |
688 tree->header()->resizeSection(0, header); |
688 tree->header()->resizeSection(0, header); |
689 tree->header()->setStretchLastSection(true); |
689 tree->header()->setStretchLastSection(true); |
690 connect(tree, SIGNAL(activated(const QModelIndex&)), |
690 connect(tree, SIGNAL(activated(QModelIndex)), |
691 this, SLOT(open())); |
691 this, SLOT(open())); |
692 tree->setContextMenuPolicy(Qt::CustomContextMenu); |
692 tree->setContextMenuPolicy(Qt::CustomContextMenu); |
693 connect(tree, SIGNAL(customContextMenuRequested(const QPoint &)), |
693 connect(tree, SIGNAL(customContextMenuRequested(QPoint)), |
694 this, SLOT(customContextMenuRequested(const QPoint &))); |
694 this, SLOT(customContextMenuRequested(QPoint))); |
695 } |
695 } |
696 |
696 |
697 void HistoryDialog::customContextMenuRequested(const QPoint &pos) |
697 void HistoryDialog::customContextMenuRequested(const QPoint &pos) |
698 { |
698 { |
699 QMenu menu; |
699 QMenu menu; |
749 |
749 |
750 void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel) |
750 void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel) |
751 { |
751 { |
752 if (sourceModel()) { |
752 if (sourceModel()) { |
753 disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
753 disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
754 disconnect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), |
754 disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
755 this, SLOT(dataChanged(const QModelIndex &, const QModelIndex &))); |
755 this, SLOT(dataChanged(QModelIndex,QModelIndex))); |
756 disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), |
756 disconnect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), |
757 this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); |
757 this, SLOT(sourceRowsInserted(QModelIndex,int,int))); |
758 disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
758 disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), |
759 this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); |
759 this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); |
760 } |
760 } |
761 |
761 |
762 QAbstractProxyModel::setSourceModel(newSourceModel); |
762 QAbstractProxyModel::setSourceModel(newSourceModel); |
763 |
763 |
764 if (sourceModel()) { |
764 if (sourceModel()) { |
765 m_loaded = false; |
765 m_loaded = false; |
766 connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
766 connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
767 connect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), |
767 connect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), |
768 this, SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &))); |
768 this, SLOT(sourceDataChanged(QModelIndex,QModelIndex))); |
769 connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), |
769 connect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), |
770 this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); |
770 this, SLOT(sourceRowsInserted(QModelIndex,int,int))); |
771 connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
771 connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), |
772 this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); |
772 this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); |
773 } |
773 } |
774 } |
774 } |
775 |
775 |
776 void HistoryFilterModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) |
776 void HistoryFilterModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) |
777 { |
777 { |
904 bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &parent) |
904 bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &parent) |
905 { |
905 { |
906 if (row < 0 || count <= 0 || row + count > rowCount(parent) || parent.isValid()) |
906 if (row < 0 || count <= 0 || row + count > rowCount(parent) || parent.isValid()) |
907 return false; |
907 return false; |
908 int lastRow = row + count - 1; |
908 int lastRow = row + count - 1; |
909 disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
909 disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), |
910 this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); |
910 this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); |
911 beginRemoveRows(parent, row, lastRow); |
911 beginRemoveRows(parent, row, lastRow); |
912 int oldCount = rowCount(); |
912 int oldCount = rowCount(); |
913 int start = sourceModel()->rowCount() - m_sourceRow.value(row); |
913 int start = sourceModel()->rowCount() - m_sourceRow.value(row); |
914 int end = sourceModel()->rowCount() - m_sourceRow.value(lastRow); |
914 int end = sourceModel()->rowCount() - m_sourceRow.value(lastRow); |
915 sourceModel()->removeRows(start, end - start + 1); |
915 sourceModel()->removeRows(start, end - start + 1); |
916 endRemoveRows(); |
916 endRemoveRows(); |
917 connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
917 connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), |
918 this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); |
918 this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); |
919 m_loaded = false; |
919 m_loaded = false; |
920 if (oldCount - count != rowCount()) |
920 if (oldCount - count != rowCount()) |
921 reset(); |
921 reset(); |
922 return true; |
922 return true; |
923 } |
923 } |
986 |
986 |
987 void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel) |
987 void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel) |
988 { |
988 { |
989 if (sourceModel()) { |
989 if (sourceModel()) { |
990 disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
990 disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
991 disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), |
991 disconnect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), |
992 this, SLOT(sourceReset())); |
992 this, SLOT(sourceReset())); |
993 disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
993 disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), |
994 this, SLOT(sourceReset())); |
994 this, SLOT(sourceReset())); |
995 } |
995 } |
996 |
996 |
997 QAbstractProxyModel::setSourceModel(newSourceModel); |
997 QAbstractProxyModel::setSourceModel(newSourceModel); |
998 |
998 |
999 if (newSourceModel) { |
999 if (newSourceModel) { |
1000 connect(newSourceModel, SIGNAL(modelReset()), this, SLOT(sourceReset())); |
1000 connect(newSourceModel, SIGNAL(modelReset()), this, SLOT(sourceReset())); |
1001 connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), |
1001 connect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), |
1002 this, SLOT(sourceReset())); |
1002 this, SLOT(sourceReset())); |
1003 connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
1003 connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), |
1004 this, SLOT(sourceReset())); |
1004 this, SLOT(sourceReset())); |
1005 } |
1005 } |
1006 |
1006 |
1007 reset(); |
1007 reset(); |
1008 } |
1008 } |
1175 void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) |
1175 void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) |
1176 { |
1176 { |
1177 if (sourceModel()) { |
1177 if (sourceModel()) { |
1178 disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
1178 disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
1179 disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); |
1179 disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); |
1180 disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), |
1180 disconnect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), |
1181 this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); |
1181 this, SLOT(sourceRowsInserted(QModelIndex,int,int))); |
1182 disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
1182 disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), |
1183 this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); |
1183 this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); |
1184 } |
1184 } |
1185 |
1185 |
1186 QAbstractProxyModel::setSourceModel(newSourceModel); |
1186 QAbstractProxyModel::setSourceModel(newSourceModel); |
1187 |
1187 |
1188 if (newSourceModel) { |
1188 if (newSourceModel) { |
1189 connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
1189 connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); |
1190 connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); |
1190 connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); |
1191 connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), |
1191 connect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), |
1192 this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); |
1192 this, SLOT(sourceRowsInserted(QModelIndex,int,int))); |
1193 connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), |
1193 connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)), |
1194 this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); |
1194 this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); |
1195 } |
1195 } |
1196 |
1196 |
1197 reset(); |
1197 reset(); |
1198 } |
1198 } |
1199 |
1199 |