Konsole
ViewProperties.h
Go to the documentation of this file.00001 /* 00002 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com> 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301 USA. 00018 */ 00019 00020 #ifndef VIEWPROPERTIES_H 00021 #define VIEWPROPERTIES_H 00022 00023 // Qt 00024 #include <QtGui/QIcon> 00025 #include <QtCore/QObject> 00026 #include <QtCore/QHash> 00027 #include <QtCore/QMimeData> 00028 00029 // KDE 00030 #include <KUrl> 00031 00032 namespace Konsole 00033 { 00034 00042 class ViewProperties : public QObject 00043 { 00044 Q_OBJECT 00045 00046 public: 00047 ViewProperties(QObject* parent); 00048 virtual ~ViewProperties(); 00049 00051 QIcon icon() const; 00053 QString title() const; 00054 00059 virtual KUrl url() const; 00060 00066 virtual QString currentDir() const; 00067 00072 int identifier() const; 00073 00079 virtual bool confirmClose() const 00080 { return true; } 00081 00083 static ViewProperties* propertiesById(int id); 00084 00086 static QString mimeType() 00087 { return _mimeType; } 00088 00092 static QMimeData* createMimeData(int id) 00093 { 00094 QMimeData* mimeData = new QMimeData; 00095 QByteArray data((char*)&id,sizeof(int)); 00096 mimeData->setData(mimeType(),data); 00097 return mimeData; 00098 } 00105 static int decodeMimeData(const QMimeData* mimeData) 00106 { 00107 return *(int*)(mimeData->data(ViewProperties::mimeType()).constData()); 00108 } 00109 00110 signals: 00112 void iconChanged(ViewProperties* properties); 00114 void titleChanged(ViewProperties* properties); 00116 void activity(ViewProperties* item); 00117 00118 public slots: 00123 virtual void rename(); 00124 00125 protected slots: 00127 void fireActivity(); 00128 00129 protected: 00134 void setTitle(const QString& title); 00139 void setIcon(const QIcon& icon); 00141 void setIdentifier(int id); 00142 private: 00143 QIcon _icon; 00144 QString _title; 00145 int _id; 00146 00147 static QHash<int,ViewProperties*> _viewProperties; 00148 static QString _mimeType; 00149 }; 00150 00151 } 00152 00153 #endif //VIEWPROPERTIES_H