forked from qt-creator/qt-creator
CodecSelector: Use Utils::TreeView
No functionality change. Change-Id: I09c3cd4afd84c75125ed184d8e96be9f537b62e0 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
#include "codecselector.h"
|
||||
#include "basetextdocument.h"
|
||||
|
||||
#include <utils/itemviews.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QTextCodec>
|
||||
@@ -45,10 +47,10 @@ namespace Internal {
|
||||
|
||||
/* custom class to make sure the width is wide enough for the
|
||||
* contents. Should be easier with Qt. */
|
||||
class CodecListWidget : public QListWidget
|
||||
class CodecListWidget : public Utils::ListWidget
|
||||
{
|
||||
public:
|
||||
CodecListWidget(QWidget *parent):QListWidget(parent){}
|
||||
CodecListWidget(QWidget *parent) : Utils::ListWidget(parent){}
|
||||
QSize sizeHint() const {
|
||||
return QListWidget::sizeHint().expandedTo(
|
||||
QSize(sizeHintForColumn(0) + verticalScrollBar()->sizeHint().width() + 4, 0));
|
||||
@@ -77,6 +79,7 @@ CodecSelector::CodecSelector(QWidget *parent, BaseTextDocument *doc)
|
||||
m_label->setText(tr("Select encoding for \"%1\".%2").arg(QFileInfo(doc->filePath()).fileName()).arg(decodingErrorHint));
|
||||
|
||||
m_listWidget = new CodecListWidget(this);
|
||||
m_listWidget->setActivationMode(Utils::DoubleClickActivation);
|
||||
|
||||
QStringList encodings;
|
||||
|
||||
@@ -122,7 +125,7 @@ CodecSelector::CodecSelector(QWidget *parent, BaseTextDocument *doc)
|
||||
m_saveButton = m_dialogButtonBox->addButton(tr("Save with Encoding"), QDialogButtonBox::DestructiveRole);
|
||||
m_dialogButtonBox->addButton(QDialogButtonBox::Cancel);
|
||||
connect(m_dialogButtonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
|
||||
connect(m_listWidget, SIGNAL(doubleClicked(QModelIndex)), m_reloadButton, SLOT(animateClick()));
|
||||
connect(m_listWidget, SIGNAL(activated(QModelIndex)), m_reloadButton, SLOT(click()));
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout(this);
|
||||
vbox->addWidget(m_label);
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <QDialogButtonBox>
|
||||
#include <QListWidget>
|
||||
|
||||
namespace Utils { class ListWidget; }
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
class BaseTextDocument;
|
||||
@@ -65,7 +67,7 @@ private:
|
||||
bool m_hasDecodingError;
|
||||
bool m_isModified;
|
||||
QLabel *m_label;
|
||||
QListWidget *m_listWidget;
|
||||
Utils::ListWidget *m_listWidget;
|
||||
QDialogButtonBox *m_dialogButtonBox;
|
||||
QAbstractButton *m_reloadButton;
|
||||
QAbstractButton *m_saveButton;
|
||||
|
||||
Reference in New Issue
Block a user