Text editor: Remove unused member

Reviewed-by: mae
This commit is contained in:
Leandro Melo
2011-02-04 15:00:43 +01:00
parent 66e894478e
commit 3c8ff2bee4
2 changed files with 16 additions and 29 deletions

View File

@@ -199,7 +199,6 @@ public:
bool m_fileHasUtf8Bom; bool m_fileHasUtf8Bom;
bool m_fileIsReadOnly; bool m_fileIsReadOnly;
bool m_isBinaryData;
bool m_hasDecodingError; bool m_hasDecodingError;
QByteArray m_decodingErrorSample; QByteArray m_decodingErrorSample;
static const int kChunkSize = 65536; static const int kChunkSize = 65536;
@@ -213,7 +212,6 @@ BaseTextDocumentPrivate::BaseTextDocumentPrivate(BaseTextDocument *q) :
m_codec(Core::EditorManager::instance()->defaultTextEncoding()), m_codec(Core::EditorManager::instance()->defaultTextEncoding()),
m_fileHasUtf8Bom(false), m_fileHasUtf8Bom(false),
m_fileIsReadOnly(false), m_fileIsReadOnly(false),
m_isBinaryData(false),
m_hasDecodingError(false) m_hasDecodingError(false)
{ {
} }
@@ -300,14 +298,9 @@ SyntaxHighlighter *BaseTextDocument::syntaxHighlighter() const
return d->m_highlighter; return d->m_highlighter;
} }
bool BaseTextDocument::isBinaryData() const
{
return d->m_isBinaryData;
}
bool BaseTextDocument::hasDecodingError() const bool BaseTextDocument::hasDecodingError() const
{ {
return d->m_hasDecodingError || d->m_isBinaryData; return d->m_hasDecodingError;
} }
QTextCodec *BaseTextDocument::codec() const QTextCodec *BaseTextDocument::codec() const
@@ -381,7 +374,6 @@ bool BaseTextDocument::save(const QString &fileName)
emit titleChanged(fi.fileName()); emit titleChanged(fi.fileName());
emit changed(); emit changed();
d->m_isBinaryData = false;
d->m_hasDecodingError = false; d->m_hasDecodingError = false;
d->m_decodingErrorSample.clear(); d->m_decodingErrorSample.clear();
@@ -398,7 +390,7 @@ void BaseTextDocument::rename(const QString &newName)
bool BaseTextDocument::isReadOnly() const bool BaseTextDocument::isReadOnly() const
{ {
if (d->m_isBinaryData || d->m_hasDecodingError) if (d->m_hasDecodingError)
return true; return true;
if (d->m_fileName.isEmpty()) //have no corresponding file, so editing is ok if (d->m_fileName.isEmpty()) //have no corresponding file, so editing is ok
return false; return false;
@@ -521,26 +513,22 @@ bool BaseTextDocument::open(const QString &fileName)
} }
d->m_document->setModified(false); d->m_document->setModified(false);
if (d->m_isBinaryData) { const int chunks = content.size();
d->m_document->setHtml(tr("<em>Binary data</em>")); if (chunks == 1) {
d->m_document->setPlainText(content.at(0));
} else { } else {
const int chunks = content.size(); QFutureInterface<void> interface;
if (chunks == 1) { interface.setProgressRange(0, chunks);
d->m_document->setPlainText(content.at(0)); Core::ICore::instance()->progressManager()->addTask(
} else { interface.future(), tr("Opening file"), Constants::TASK_OPEN_FILE);
QFutureInterface<void> interface; interface.reportStarted();
interface.setProgressRange(0, chunks); QTextCursor c(d->m_document);
Core::ICore::instance()->progressManager()->addTask( for (int i = 0; i < chunks; ++i) {
interface.future(), tr("Opening file"), Constants::TASK_OPEN_FILE); c.insertText(content.at(i));
interface.reportStarted(); interface.setProgressValue(i + 1);
QTextCursor c(d->m_document); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
for (int i = 0; i < chunks; ++i) {
c.insertText(content.at(i));
interface.setProgressValue(i + 1);
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
interface.reportFinished();
} }
interface.reportFinished();
} }
BaseTextDocumentLayout *documentLayout = BaseTextDocumentLayout *documentLayout =
qobject_cast<BaseTextDocumentLayout*>(d->m_document->documentLayout()); qobject_cast<BaseTextDocumentLayout*>(d->m_document->documentLayout());

View File

@@ -97,7 +97,6 @@ public:
SyntaxHighlighter *syntaxHighlighter() const; SyntaxHighlighter *syntaxHighlighter() const;
bool isBinaryData() const;
bool hasDecodingError() const; bool hasDecodingError() const;
QTextCodec *codec() const; QTextCodec *codec() const;
void setCodec(QTextCodec *c); void setCodec(QTextCodec *c);