30 #include <KPushButton>
34 #include <KApplication>
35 #include <KGlobalSettings>
37 #include <QtGui/QSortFilterProxyModel>
38 #include <QtGui/QLabel>
39 #include <QtGui/QLayout>
40 #include <QtGui/QHeaderView>
41 #include <QtGui/QTreeView>
42 #include <QtGui/QFontMetrics>
49 :
QWidget( parent ), mTool( tool )
51 QVBoxLayout *baseLayout =
new QVBoxLayout(
this );
52 baseLayout->setMargin( 0 );
54 QHBoxLayout* topLineLayout =
new QHBoxLayout();
56 QLabel *label =
new QLabel( i18nc(
"@label size of selected bytes",
"Size:"),
this );
57 topLineLayout->addWidget( label );
59 mSizeLabel =
new QLabel(
this );
60 const QString sizeToolTip =
61 i18nc(
"@info:tooltip",
62 "The number of the bytes the statistic was built for." );
63 label->setToolTip( sizeToolTip );
64 mSizeLabel->setToolTip( sizeToolTip );
65 topLineLayout->addWidget( mSizeLabel, 10 );
69 topLineLayout->addStretch();
71 const KGuiItem updateGuiItem =
72 KGuiItem(i18nc(
"@action:button build the statistic of the byte frequency",
74 QLatin1String(
"run-build"),
75 i18nc(
"@info:tooltip",
76 "Builds the byte frequency statistic for the bytes in the selected range."),
77 i18nc(
"@info:whatsthis",
78 "If you press the <interface>Build</interface> button,"
79 " the byte frequency statistic is built for the bytes in the selected range.") );
80 mUpdateButton =
new KPushButton( updateGuiItem,
this );
82 connect( mTool, SIGNAL(isApplyableChanged(
bool)), mUpdateButton, SLOT(setEnabled(
bool)) );
83 connect( mUpdateButton, SIGNAL(clicked(
bool)), mTool, SLOT(updateStatistic()) );
84 topLineLayout->addWidget( mUpdateButton );
86 baseLayout->addLayout( topLineLayout );
88 mStatisticTableView =
new QTreeView(
this );
89 connect( KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
90 SLOT(setFixedFontByGlobalSettings()) );
91 connect( KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
92 SLOT(resizeColumnsWidth()) );
93 connect( KGlobalSettings::self(), SIGNAL(kdisplayStyleChanged()),
94 SLOT(resizeColumnsWidth()) );
95 setFixedFontByGlobalSettings();
96 mStatisticTableView->setObjectName( QLatin1String(
"StatisticTable" ) );
97 mStatisticTableView->setRootIsDecorated(
false );
98 mStatisticTableView->setItemsExpandable(
false );
99 mStatisticTableView->setUniformRowHeights(
true );
100 mStatisticTableView->setAllColumnsShowFocus(
true );
101 mStatisticTableView->setSortingEnabled(
true );
102 QHeaderView* header = mStatisticTableView->header();
103 header->setFont( font() );
104 header->setResizeMode( QHeaderView::Interactive );
105 header->setStretchLastSection(
false );
107 QSortFilterProxyModel *proxyModel =
new QSortFilterProxyModel(
this );
108 proxyModel->setDynamicSortFilter(
true );
110 mStatisticTableView->setModel( proxyModel );
114 baseLayout->addWidget( mStatisticTableView, 10 );
120 const QString styleName = KApplication::style()->objectName();
121 const QString fixedFontData = KGlobalSettings::fixedFont().toString();
125 resizeColumnsWidth();
131 header->resizeSection( i, columnsWidth.at( i ) );
139 mStatisticTableView->header()->headerDataChanged( Qt::Horizontal,
143 void InfoView::resizeColumnsWidth()
148 mStatisticTableView->resizeColumnToContents( i );
154 const QString sizeText = ( size < 1 ) ?
155 QString::fromLatin1(
"-" ) :
156 i18np(
"1 byte",
"%1 bytes", size );
158 mSizeLabel->setText( sizeText );
161 void InfoView::setFixedFontByGlobalSettings()
163 mStatisticTableView->setFont( KGlobalSettings::fixedFont() );
169 const QHeaderView* header = mStatisticTableView->header();
172 columnsWidth.append( header->sectionSize( i ) );
static QString style()
Get Style.
void setByteArraySize(int size)
static InfoViewSettings * self()
static void setColumnsWidth(const QList< int > &v)
Set ColumnsWidth.
static QString fixedFont()
Get FixedFont.
InfoView(InfoTool *tool, QWidget *parent=0)
static QList< int > columnsWidth()
Get ColumnsWidth.
static void setStyle(const QString &v)
Set Style.
static void setFixedFont(const QString &v)
Set FixedFont.
StringDataInformation * toString(const QScriptValue &value, const ParserInfo &info)