File indexing completed on 2024-04-21 05:51:28

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 // Own
0008 #include "ViewProperties.h"
0009 
0010 using Konsole::ViewProperties;
0011 
0012 QHash<int, ViewProperties *> ViewProperties::_viewProperties;
0013 
0014 ViewProperties::ViewProperties(QObject *parent)
0015     : QObject(parent)
0016     , _icon(QIcon())
0017     , _title(QString())
0018     , _identifier(0)
0019 {
0020 }
0021 
0022 ViewProperties::~ViewProperties()
0023 {
0024     _viewProperties.remove(_identifier);
0025 }
0026 
0027 ViewProperties *ViewProperties::propertiesById(int id)
0028 {
0029     return _viewProperties[id];
0030 }
0031 
0032 QUrl ViewProperties::url() const
0033 {
0034     return QUrl();
0035 }
0036 
0037 QString ViewProperties::currentDir() const
0038 {
0039     return QString();
0040 }
0041 
0042 void ViewProperties::fireActivity()
0043 {
0044     Q_EMIT activity(this);
0045 }
0046 
0047 void ViewProperties::rename()
0048 {
0049 }
0050 
0051 void ViewProperties::setTitle(const QString &title)
0052 {
0053     if (title != _title) {
0054         _title = title;
0055         Q_EMIT titleChanged(this);
0056     }
0057 }
0058 
0059 void ViewProperties::setIcon(const QIcon &icon)
0060 {
0061     // the icon's cache key is used to determine whether this icon is the same
0062     // as the old one.  if so no signal is emitted.
0063 
0064     if (icon.cacheKey() != _icon.cacheKey()) {
0065         _icon = icon;
0066         Q_EMIT iconChanged(this);
0067     }
0068 }
0069 
0070 void ViewProperties::setColor(const QColor &color)
0071 {
0072     if (color != _color) {
0073         _color = color;
0074         Q_EMIT colorChanged(this);
0075     }
0076 }
0077 
0078 void ViewProperties::setIdentifier(int id)
0079 {
0080     if (_viewProperties.contains(_identifier)) {
0081         _viewProperties.remove(_identifier);
0082     }
0083 
0084     _identifier = id;
0085 
0086     _viewProperties.insert(id, this);
0087 }
0088 
0089 QString ViewProperties::title() const
0090 {
0091     return _title;
0092 }
0093 
0094 QIcon ViewProperties::icon() const
0095 {
0096     return _icon;
0097 }
0098 
0099 int ViewProperties::identifier() const
0100 {
0101     return _identifier;
0102 }
0103 
0104 QColor ViewProperties::color() const
0105 {
0106     return _color;
0107 }
0108 
0109 #include "moc_ViewProperties.cpp"