• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • kasten
  • controllers
  • document
  • info
documentinfoview.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Kasten module, made within the KDE community.
3 
4  Copyright 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "documentinfoview.h"
24 
25 //
26 #include "documentinfotool.h"
27 // KDE
28 #include <KLocale>
29 #include <KIconLoader>
30 #include <KSeparator>
31 #include <KSqueezedTextLabel>
32 #include <KGlobal>
33 #include <KDateTime>
34 #include <kio/netaccess.h>
35 // Qt
36 #include <QtGui/QFont>
37 #include <QtGui/QLabel>
38 #include <QtGui/QLayout>
39 #include <QtGui/QGridLayout>
40 
41 
42 namespace Kasten2
43 {
44 
45 DocumentInfoView::DocumentInfoView( DocumentInfoTool* tool, QWidget* parent )
46  : QWidget( parent ), mTool( tool )
47 {
48  QVBoxLayout* baseLayout = new QVBoxLayout( this );
49  baseLayout->setMargin( 0 );
50 
51  // icon
52  mIconLabel = new QLabel( this );
53 // int bsize = 66 + 2 * mIconLabel->style()->pixelMetric( QStyle::PM_ButtonMargin );
54 // mIconLabel->setFixedSize(bsize, bsize);
55  mIconLabel->setFixedHeight( KIconLoader::SizeEnormous );
56  mIconLabel->setMinimumWidth( KIconLoader::SizeEnormous );
57  mIconLabel->setAlignment( Qt::AlignHCenter );
58  baseLayout->addWidget( mIconLabel );
59 
60  // file label
61  mDocumentTitleLabel = new QLabel( this );
62  QFont font = mDocumentTitleLabel->font();
63  font.setBold(true);
64  mDocumentTitleLabel->setFont( font );
65  mDocumentTitleLabel->setAlignment( Qt::AlignHCenter );
66  mDocumentTitleLabel->setWordWrap( true );
67  mDocumentTitleLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
68  baseLayout->addWidget( mDocumentTitleLabel );
69 
70  // separator
71  KSeparator* separator = new KSeparator( Qt::Horizontal, this );
72  baseLayout->addWidget( separator );
73 
74  // property grid
75  QGridLayout *propertyGrid = new QGridLayout(); // unknown rows
76  propertyGrid->setColumnStretch( 0, 0 );
77  propertyGrid->setColumnStretch( 1, 1 );
78 
79  int currentPropertyRow = 0;
80 
81  // type property
82  QLabel* label = new QLabel( i18n("Type:"), this );
83  propertyGrid->addWidget( label, currentPropertyRow, 0, Qt::AlignRight);
84 
85  mMimeTypeLabel = new QLabel( QString(), this );
86  propertyGrid->addWidget( mMimeTypeLabel, currentPropertyRow++, 1);
87 
88  // location property
89  label = new QLabel( i18n("Location:"), this );
90  propertyGrid->addWidget( label, currentPropertyRow, 0, Qt::AlignRight);
91 
92  mLocationLabel = new KSqueezedTextLabel( this );
93  // force the layout direction to be always LTR
94  mLocationLabel->setLayoutDirection( Qt::LeftToRight );
95  // but if we are in RTL mode, align the text to the right
96  // otherwise the text is on the wrong side of the dialog
97  if( layoutDirection() == Qt::RightToLeft )
98  mLocationLabel->setAlignment( Qt::AlignRight );
99  // TODO: for some reason if building with enable_final flag the compiler sees
100  // an ambiguous conversion without the explicit Qt::TextInteractionFlags(...)
101  mLocationLabel->setTextInteractionFlags( Qt::TextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard) );
102  propertyGrid->addWidget( mLocationLabel, currentPropertyRow++, 1 );
103 
104  // size property
105  label = new QLabel( i18n("Size:"), this );
106  propertyGrid->addWidget( label, currentPropertyRow, 0, Qt::AlignRight );
107 
108  mSizeLabel = new QLabel( this );
109  propertyGrid->addWidget( mSizeLabel, currentPropertyRow++, 1 );
110 
111 #if 0
112  label = new QLabel( i18n("Created/Loaded:"), this ); // TODO: make adjustable depending on document
113  propertyGrid->addWidget( label, currentPropertyRow, 0, Qt::AlignRight);
114  currentPropertyRow++;
115 
116  label = new QLabel( i18n("Last modified:"), this );
117  propertyGrid->addWidget( label, currentPropertyRow, 0, Qt::AlignRight);
118  currentPropertyRow++;
119 
120  label = new QLabel( i18n("Last synchronized:"), this );
121  propertyGrid->addWidget( label, currentPropertyRow, 0, Qt::AlignRight);
122  currentPropertyRow++;
123 // last accessed from remote
124 
125  KDateTime dt;// = item.time(KFileItem::CreationTime);
126  if ( !dt.isNull() )
127  {
128  label = new QLabel(i18n("Created:"), this );
129  propertyGrid->addWidget(label, currentPropertyRow, 0, Qt::AlignRight);
130 
131  label = new QLabel(KGlobal::locale()->formatDateTime(dt), this );
132  propertyGrid->addWidget(label, currentPropertyRow++, 2);
133  }
134 #endif
135 
136  baseLayout->addLayout( propertyGrid );
137  baseLayout->addStretch( 10 );
138 
139  connect( mTool, SIGNAL(documentTitleChanged(QString)),
140  SLOT(onDocumentTitleChanged(QString)) );
141  connect( mTool, SIGNAL(documentMimeTypeChanged(KMimeType::Ptr)),
142  SLOT(onMimeTypeChanged(KMimeType::Ptr)) );
143  connect( mTool, SIGNAL(locationChanged(QString)),
144  SLOT(onLocationChanged(QString)) );
145  connect( mTool, SIGNAL(documentSizeChanged(int)),
146  SLOT(onDocumentSizeChanged(int)) );
147  onDocumentTitleChanged( mTool->documentTitle() );
148  onMimeTypeChanged( mTool->mimeType() );
149  onLocationChanged( mTool->location() );
150  onDocumentSizeChanged( mTool->documentSize() );
151 }
152 
153 
154 void DocumentInfoView::onDocumentTitleChanged( const QString& documentTitle )
155 {
156  mDocumentTitleLabel->setText( documentTitle );
157 }
158 
159 void DocumentInfoView::onMimeTypeChanged( KMimeType::Ptr mimeTypePtr )
160 {
161  QString mimeTypeComment;
162  QPixmap mimeTypeIcon;
163 
164  if( mimeTypePtr.isNull() )
165  {
166  mimeTypeComment = QLatin1String( "-" );
167 // mimeTypeIcon = ?
168  }
169  else
170  {
171  mimeTypeComment = mimeTypePtr->comment();
172  mimeTypeIcon = KIconLoader::global()->loadIcon( mimeTypePtr->iconName(), KIconLoader::Desktop, KIconLoader::SizeEnormous );
173  }
174 
175  mIconLabel->setPixmap( mimeTypeIcon );
176  mMimeTypeLabel->setText( mimeTypeComment );
177 }
178 
179 void DocumentInfoView::onLocationChanged( const QString& location )
180 {
181  const QString entry = location.isEmpty() ?
182  i18nc( "There is no storage location assigned to yet.", "[None]" ) :
183  location;
184  mLocationLabel->setText( entry );
185 }
186 
187 void DocumentInfoView::onDocumentSizeChanged( int newSize )
188 {
189  const QString size = ( newSize != -1 ) ?
190  QString::fromLatin1( "%1 (%2)" )
191  .arg( KIO::convertSize(newSize) )
192  .arg( KGlobal::locale()->formatNumber(newSize, 0) ) :
193  QString::fromLatin1( "-" );
194  mSizeLabel->setText( size );
195 }
196 
197 DocumentInfoView::~DocumentInfoView() {}
198 
199 }
Kasten2::DocumentInfoTool::location
QString location() const
Definition: documentinfotool.cpp:68
Kasten2::DocumentInfoTool::documentTitle
QString documentTitle() const
Definition: documentinfotool.cpp:63
QWidget
Kasten2::DocumentInfoView::~DocumentInfoView
virtual ~DocumentInfoView()
Definition: documentinfoview.cpp:197
Kasten2::DocumentInfoTool::mimeType
KMimeType::Ptr mimeType() const
Definition: documentinfotool.h:95
documentinfotool.h
Kasten2::DocumentInfoTool
Definition: documentinfotool.h:49
Kasten2::DocumentInfoView::DocumentInfoView
DocumentInfoView(DocumentInfoTool *tool, QWidget *parent=0)
Definition: documentinfoview.cpp:45
Kasten2::DocumentInfoTool::documentSize
int documentSize() const
Definition: documentinfotool.cpp:79
documentinfoview.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal