Commit bc7736d2 authored by Henrique Pinto's avatar Henrique Pinto

* New information panel

svn path=/branches/work/libarchive-based-ark/ark/; revision=689901
parent 1b58b923
......@@ -13,9 +13,8 @@ set(arkpart_PART_SRCS
extractiondialog.cpp
)
#kde4_add_kcfg_files(arkpart_PART_SRCS settings.kcfgc)
kde4_add_ui_files(arkpart_PART_SRCS extractiondialog.ui )
kde4_add_ui_files(arkpart_PART_SRCS infopanel.ui )
kde4_add_plugin(arkpart WITH_PREFIX ${arkpart_PART_SRCS})
......
......@@ -27,21 +27,16 @@
#include <KLocale>
#include <KMimeType>
#include <KIconLoader>
#include <KIO/NetAccess>
InfoPanel::InfoPanel( QWidget *parent )
: QWidget( parent ), m_icon( new QLabel( this ) ), m_name( new QLabel( this ) ), m_mimetype( new QLabel( this ) )
: QFrame( parent )
{
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget( m_icon );
layout->addWidget( m_name );
layout->addWidget( m_mimetype );
layout->addStretch();
setLayout( layout );
setupUi( this );
setDefaultValues();
m_icon->setAlignment( Qt::AlignCenter );
m_name->setAlignment( Qt::AlignCenter );
m_mimetype->setAlignment( Qt::AlignCenter );
iconLabel->setFixedHeight( K3Icon::SizeEnormous );
iconLabel->setMinimumWidth( K3Icon::SizeEnormous );
setMaximumWidth( 2 * K3Icon::SizeEnormous );
}
InfoPanel::~InfoPanel()
......@@ -51,9 +46,11 @@ InfoPanel::~InfoPanel()
void InfoPanel::setDefaultValues()
{
KMimeType::Ptr defaultMime = KMimeType::defaultMimeTypePtr();
m_icon->setPixmap( KIconLoader::global()->loadMimeTypeIcon( defaultMime->iconName(), K3Icon::Desktop ) );
m_name->setText( QString( "<font size=+1><b>%1</b></font>" ).arg( i18n( "No file selected" ) ) );
m_mimetype->setText( QString() );
iconLabel->setPixmap( KIconLoader::global()->loadMimeTypeIcon( defaultMime->iconName(), K3Icon::Desktop, K3Icon::SizeEnormous ) );
fileName->setText( QString( "<font size=+1><b>%1</b></font>" ).arg( i18n( "No file selected" ) ) );
additionalInfo->setText( QString() );
hideMetaData();
hideActions();
}
void InfoPanel::setEntry( const ArchiveEntry& entry )
......@@ -65,12 +62,67 @@ void InfoPanel::setEntry( const ArchiveEntry& entry )
else
{
KMimeType::Ptr mimeType = KMimeType::findByPath( entry[ FileName ].toString(), 0, true );
m_icon->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType->iconName(), K3Icon::Desktop ) );
iconLabel->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType->iconName(), K3Icon::Desktop, K3Icon::SizeEnormous ) );
QStringList nameParts = entry[ FileName ].toString().split( '/', QString::SkipEmptyParts );
QString name = ( nameParts.count() > 0 )? nameParts.last() : entry[ FileName ].toString();
m_name->setText( QString( "<font size=+1><b>%1</b></font>" ).arg( name ) );
m_mimetype->setText( mimeType->comment() );
fileName->setText( QString( "<font size=+1><b>%1</b></font>" ).arg( name ) );
additionalInfo->setText( mimeType->comment() );
metadataLabel->setText( metadataTextFor( entry ) );
showMetaData();
}
}
void InfoPanel::showMetaData()
{
firstSeparator->show();
metadataLabel->show();
}
void InfoPanel::hideMetaData()
{
firstSeparator->hide();
metadataLabel->hide();
}
void InfoPanel::showActions()
{
secondSeparator->show();
actionsLabel->show();
}
void InfoPanel::hideActions()
{
secondSeparator->hide();
actionsLabel->hide();
}
QString InfoPanel::metadataTextFor( const ArchiveEntry& entry )
{
QString text;
if ( entry.contains( Size ) )
{
text += QString( "<b>%1:</b> %2<br/>" ).arg( i18n( "Size" ) ).arg( KIO::convertSize( entry[ Size ].toULongLong() ) );
}
if ( entry.contains( Owner ) )
{
text += QString( "<b>%1:</b> %2<br/>" ).arg( i18n( "Owner" ) ).arg( entry[ Owner ].toString() );
}
if ( entry.contains( Group ) )
{
text += QString( "<b>%1:</b> %2<br/>" ).arg( i18n( "Group" ) ).arg( entry[ Group ].toString() );
}
if ( text.isEmpty() )
{
text = i18n( "No metadata available for this file." );
}
return text;
}
#include "infopanel.moc"
......@@ -21,12 +21,13 @@
#ifndef INFOPANEL_H
#define INFOPANEL_H
#include <QWidget>
#include <QFrame>
#include "kerfuffle/arch.h"
#include "ui_infopanel.h"
class QLabel;
class InfoPanel: public QWidget
class InfoPanel: public QFrame, Ui::InformationPanel
{
Q_OBJECT
public:
......@@ -34,12 +35,17 @@ class InfoPanel: public QWidget
~InfoPanel();
void setEntry( const ArchiveEntry& entry );
private:
void setDefaultValues();
QLabel *m_icon;
QLabel *m_name;
QLabel *m_mimetype;
void showMetaData();
void hideMetaData();
void showActions();
void hideActions();
QString metadataTextFor( const ArchiveEntry& entry );
};
#endif // INFOPANEL_H
<ui version="4.0" >
<class>InformationPanel</class>
<widget class="QWidget" name="InformationPanel" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>300</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<string>Information Panel</string>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="iconLabel" >
<property name="text" >
<string/>
</property>
<property name="pixmap" >
<pixmap>../../../../../../home/kde-devel/ark-trunk/pics/ox32-action-ark_view.png</pixmap>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fileName" >
<property name="text" >
<string>&lt;font size=+2>&lt;b>Filename&lt;/b>&lt;/font></string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="additionalInfo" >
<property name="text" >
<string>Unknown file type</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="firstSeparator" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="metadataLabel" >
<property name="text" >
<string>Metadata Label</string>
</property>
<property name="margin" >
<number>10</number>
</property>
<property name="indent" >
<number>20</number>
</property>
</widget>
</item>
<item>
<widget class="Line" name="secondSeparator" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="actionsLabel" >
<property name="text" >
<string>ActionsLabel</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -75,6 +75,7 @@ void Part::setupView()
{
m_view->setSelectionMode( QAbstractItemView::ExtendedSelection );
m_view->setModel( m_model );
m_view->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
connect( m_view->selectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection & ) ),
this, SLOT( updateActions() ) );
connect( m_view->selectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection & ) ),
......
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