forked from qt-creator/qt-creator
remove non-compiling standalone texteditor
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
MainWindow mw;
|
||||
mw.show();
|
||||
QStringList args = app.arguments();
|
||||
args.removeFirst(); // program name..
|
||||
mw.loadFiles(args);
|
||||
return app.exec();
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "texteditor/basetexteditor.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QTabWidget>
|
||||
#include <QtGui/QTextBlock>
|
||||
#include <QtGui/QToolBar>
|
||||
|
||||
|
||||
class MyEditor;
|
||||
|
||||
class MyEditable : public TextEditor::BaseTextEditorEditable
|
||||
{
|
||||
public:
|
||||
MyEditable(MyEditor *editor);
|
||||
~MyEditable() {}
|
||||
|
||||
// Core::IContext
|
||||
const QList<int>& context() const { return m_context; }
|
||||
// Core::IEditor
|
||||
const char* kind() const { return "MYEDITOR"; }
|
||||
bool duplicateSupported() const { return false; }
|
||||
Core::IEditor* duplicate(QWidget*) { return 0; }
|
||||
|
||||
MyEditor *m_editor;
|
||||
QList<int> m_context;
|
||||
};
|
||||
|
||||
|
||||
class MyEditor : public TextEditor::BaseTextEditor
|
||||
{
|
||||
public:
|
||||
MyEditor(QWidget *parent)
|
||||
: TextEditor::BaseTextEditor(parent, 0)
|
||||
{}
|
||||
|
||||
TextEditor::BaseTextEditorEditable* createEditableInterface()
|
||||
{
|
||||
return new MyEditable(this);
|
||||
}
|
||||
|
||||
void setPlainText(const QString &contents)
|
||||
{
|
||||
qDebug() << "Setting contents to:\n" << contents;
|
||||
QPlainTextEdit::setPlainText(contents);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
MyEditable::MyEditable(MyEditor *editor)
|
||||
: TextEditor::BaseTextEditorEditable(editor), m_editor(editor)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MainWindow
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
//
|
||||
// Source code view
|
||||
//
|
||||
m_textViewers = new QTabWidget(this);
|
||||
m_textViewers->setObjectName("Editors");
|
||||
m_textViewers->setElideMode(Qt::ElideLeft);
|
||||
setCentralWidget(m_textViewers);
|
||||
setGeometry(QRect(0, 0, 800, 600));
|
||||
|
||||
|
||||
m_fileOpenAction = new QAction("Open", this);
|
||||
m_quitAction = new QAction("Quit", this);
|
||||
|
||||
//
|
||||
// Menubar
|
||||
//
|
||||
QMenu *fileMenu = new QMenu(menuBar());
|
||||
fileMenu->setTitle(tr("File"));
|
||||
fileMenu->addAction(m_fileOpenAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(m_quitAction);
|
||||
menuBar()->addMenu(fileMenu);
|
||||
|
||||
//
|
||||
// Toolbar
|
||||
//
|
||||
QToolBar *toolbar = new QToolBar(this);
|
||||
toolbar->setObjectName("ToolBar");
|
||||
toolbar->addAction(m_fileOpenAction);
|
||||
toolbar->addAction(m_quitAction);
|
||||
addToolBar(Qt::TopToolBarArea, toolbar);
|
||||
|
||||
//
|
||||
// Statusbar
|
||||
//
|
||||
QStatusBar *statusbar = new QStatusBar(this);
|
||||
statusbar->setObjectName("StatusBar");
|
||||
setStatusBar(statusbar);
|
||||
|
||||
show();
|
||||
restoreState(settings().value("MainWindow/State").toByteArray());
|
||||
setGeometry(settings().value("MainWindow/Geometry").toRect());
|
||||
|
||||
//
|
||||
// Connections
|
||||
//
|
||||
connect(m_fileOpenAction, SIGNAL(triggered()),
|
||||
this, SLOT(fileOpen()));
|
||||
connect(m_quitAction, SIGNAL(triggered()),
|
||||
this, SLOT(close()));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
settings().setValue("MainWindow/State", saveState());
|
||||
settings().setValue("MainWindow/Geometry", geometry());
|
||||
settings().sync();
|
||||
}
|
||||
|
||||
QSettings &MainWindow::settings()
|
||||
{
|
||||
static QSettings s("Nokia", "TextEditor");
|
||||
return s;
|
||||
}
|
||||
|
||||
void MainWindow::loadFile(const QString &fileName)
|
||||
{
|
||||
findOrCreateTextViewer(fileName);
|
||||
}
|
||||
|
||||
void MainWindow::loadFiles(const QStringList &fileNames)
|
||||
{
|
||||
foreach (const QString &fileName, fileNames)
|
||||
loadFile(fileName);
|
||||
}
|
||||
|
||||
void MainWindow::fileOpen()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Open Executable File"),
|
||||
settings().value("FileOpen/LastDir").toString()
|
||||
// filterQString & filter = QString(),
|
||||
//QString * selectedFilter = 0, Options options = 0
|
||||
);
|
||||
settings().setValue("FileOpen/LastDir", QFileInfo(fileName).dir().dirName());
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
loadFile(fileName);
|
||||
}
|
||||
|
||||
|
||||
Editor *MainWindow::findOrCreateTextViewer(const QString &fileName)
|
||||
{
|
||||
Editor *textViewer = m_textViewerFromName.value(fileName);
|
||||
if (textViewer)
|
||||
return textViewer;
|
||||
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QString contents = file.readAll();
|
||||
|
||||
textViewer = new MyEditor(this);
|
||||
textViewer->setPlainText(contents);
|
||||
m_textViewerFromName[fileName] = textViewer;
|
||||
m_textViewers->addTab(textViewer, fileName);
|
||||
return textViewer;
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** Commercial Usage
|
||||
**
|
||||
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||
** accordance with the Qt Commercial License Agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Nokia.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, please
|
||||
** contact the sales department at http://qt.nokia.com/contact.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef TEXTEDITOR_MAINWINDOW_H
|
||||
#define TEXTEDITOR_MAINWINDOW_H
|
||||
|
||||
#include "itexteditor.h"
|
||||
|
||||
#include <QtCore/QHash>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTabWidget;
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace TextEditor { class BaseTextEditor; }
|
||||
typedef TextEditor::BaseTextEditor Editor;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow();
|
||||
~MainWindow();
|
||||
|
||||
void loadFile(const QString &fileName);
|
||||
void loadFiles(const QStringList &fileNames);
|
||||
|
||||
private slots:
|
||||
void fileOpen();
|
||||
|
||||
private:
|
||||
QTabWidget *m_textViewers;
|
||||
QHash<QString, Editor *> m_textViewerFromName;
|
||||
Editor *findOrCreateTextViewer(const QString &fileName);
|
||||
Editor *currentTextViewer();
|
||||
|
||||
QSettings &settings();
|
||||
QAction * m_fileOpenAction;
|
||||
QAction * m_quitAction;
|
||||
};
|
||||
|
||||
#endif // TEXTEDITOR_MAINWINDOW_H
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
QTCREATOR = ../../plugins
|
||||
|
||||
TARGET = ../../../bin/texteditor
|
||||
|
||||
QT += gui
|
||||
|
||||
CONFIG -= release
|
||||
CONFIG += debug
|
||||
|
||||
DEFINES += TEXTEDITOR_STANDALONE
|
||||
|
||||
INCLUDEPATH += $${QTCREATOR}
|
||||
INCLUDEPATH += $${QTCREATOR}/texteditor
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
$${QTCREATOR}/texteditor/basetextdocument.h \
|
||||
$${QTCREATOR}/texteditor/basetexteditor.h \
|
||||
$${QTCREATOR}/texteditor/storagesettings.h \
|
||||
$${QTCREATOR}/texteditor/itexteditable.h \
|
||||
$${QTCREATOR}/texteditor/itexteditor.h \
|
||||
$${QTCREATOR}/texteditor/tabsettings.h \
|
||||
$${QTCREATOR}/texteditor/displaysettings.h \
|
||||
$${QTCREATOR}/coreplugin/icontext.h \
|
||||
$${QTCREATOR}/coreplugin/ifile.h \
|
||||
$${QTCREATOR}/coreplugin/editormanager/ieditor.h \
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
$${QTCREATOR}/texteditor/basetextdocument.cpp \
|
||||
$${QTCREATOR}/texteditor/basetexteditor.cpp \
|
||||
$${QTCREATOR}/texteditor/storagesettings.cpp \
|
||||
$${QTCREATOR}/texteditor/tabsettings.cpp \
|
||||
$${QTCREATOR}/texteditor/displaysettings.cpp \
|
||||
|
||||
#RESOURCES += \
|
||||
# $${QTCREATOR}/gdbdebugger/gdbdebugger.qrc
|
||||
|
||||
unix {
|
||||
OBJECTS_DIR = .tmp
|
||||
MOC_DIR = .tmp
|
||||
RCC_DIR = .tmp
|
||||
UI_DIR = .tmp
|
||||
}
|
||||
Reference in New Issue
Block a user