Changed: #1307 Added editor for worksheet files.
--HG-- branch : gsoc2011-translationovqt
This commit is contained in:
parent
32c07d0b62
commit
ed92fd2a78
3 changed files with 183 additions and 30 deletions
|
@ -18,6 +18,9 @@
|
|||
#include "translation_manager_main_window.h"
|
||||
// Project system includes
|
||||
#include "../core/icore.h"
|
||||
#include "../core/core_constants.h"
|
||||
#include "../core/imenu_manager.h"
|
||||
#include "../../extension_system/iplugin_spec.h"
|
||||
// Qt includes
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QMessageBox>
|
||||
|
@ -27,10 +30,14 @@
|
|||
#include <QtGui/QErrorMessage>
|
||||
#include <QtCore/QSignalMapper>
|
||||
#include <QtGui/QTableWidget>
|
||||
#include <QtGui/QTableWidgetItem>
|
||||
#include <QtGui/QListWidget>
|
||||
#include <QtGui/QDockWidget>
|
||||
#include <QtCore/QSize>
|
||||
#include <QtGui/QGridLayout>
|
||||
#include <QtGui/QMdiSubWindow>
|
||||
#include <QtGui/QFileDialog>
|
||||
|
||||
struct TEntryInfo
|
||||
{
|
||||
string SheetName;
|
||||
|
@ -48,19 +55,97 @@ CMainWindow::CMainWindow(QWidget *parent)
|
|||
{
|
||||
_ui.setupUi(this);
|
||||
|
||||
_toolMenu = new QMenu(tr("Primitives"), _ui.toolBar);
|
||||
_ui.toolBar->addAction(_toolMenu->menuAction());
|
||||
|
||||
QAction *extractBotNames = _toolMenu->addAction(tr("Extract bot names"));
|
||||
extractBotNames->setStatusTip(tr("Extract bot names from primitives"));
|
||||
connect(extractBotNames, SIGNAL(triggered()), this, SLOT(extractBotNames()));
|
||||
|
||||
|
||||
|
||||
readSettings();
|
||||
createToolbar();
|
||||
m_undoStack = new QUndoStack(this);
|
||||
}
|
||||
|
||||
void CMainWindow::createToolbar()
|
||||
{
|
||||
// Tools menu
|
||||
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||
QMenu *translationManagerMenu = new QMenu("Translation Manager");
|
||||
QAction *extractBotNamesAct = translationManagerMenu->addAction("Extract bot names");
|
||||
extractBotNamesAct->setStatusTip(tr("Extract bot names from primitives"));
|
||||
QMenu *toolMenu = menuManager->menu(Core::Constants::M_TOOLS);
|
||||
toolMenu->addMenu(translationManagerMenu);
|
||||
|
||||
|
||||
// File menu
|
||||
//QAction *action = menuManager->action(Core::Constants::NEW);
|
||||
//_ui.toolBar->addAction(action);
|
||||
openAct = menuManager->action(Core::Constants::OPEN);
|
||||
_ui.toolBar->addAction(openAct);
|
||||
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
||||
|
||||
saveAct = menuManager->action(Core::Constants::SAVE);
|
||||
_ui.toolBar->addAction(saveAct);
|
||||
connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
|
||||
//action = menuManager->action(Core::Constants::SAVE_AS);
|
||||
//_ui.toolBar->addAction(action);
|
||||
|
||||
}
|
||||
|
||||
void CMainWindow::open()
|
||||
{
|
||||
QString file_name = QFileDialog::getOpenFileName(this);
|
||||
if (!file_name.isEmpty())
|
||||
{
|
||||
STRING_MANAGER::TWorksheet wk_file;
|
||||
if(loadExcelSheet(file_name.toStdString(), wk_file, true) == true)
|
||||
{
|
||||
QTableWidget *wk_table = new QTableWidget();
|
||||
wk_table->setToolTip(file_name);
|
||||
wk_table->setWindowFilePath(file_name);
|
||||
wk_table->setColumnCount(wk_file.ColCount);
|
||||
wk_table->setRowCount(wk_file.size() - 1);
|
||||
// read columns name
|
||||
for(unsigned int i = 0; i < wk_file.ColCount; i++)
|
||||
{
|
||||
QTableWidgetItem *col = new QTableWidgetItem();
|
||||
ucstring col_name = wk_file.getData(0, i);
|
||||
col->setText(tr(col_name.toString().c_str()));
|
||||
|
||||
wk_table->setHorizontalHeaderItem(i, col);
|
||||
}
|
||||
// read rows
|
||||
for(unsigned int i = 1; i < wk_file.size(); i++)
|
||||
{
|
||||
for(unsigned int j = 0; j < wk_file.ColCount; j++)
|
||||
{
|
||||
QTableWidgetItem *row = new QTableWidgetItem();
|
||||
ucstring row_value = wk_file.getData(i, j);
|
||||
row->setText(tr(row_value.toString().c_str()));
|
||||
|
||||
wk_table->setItem(i - 1, j, row);
|
||||
}
|
||||
}
|
||||
QMdiSubWindow *sub_window = new QMdiSubWindow(_ui.mdiArea);
|
||||
sub_window->setWidget(wk_table);
|
||||
wk_table->resizeColumnsToContents();
|
||||
wk_table->resizeRowsToContents();
|
||||
wk_table->showMaximized();
|
||||
sub_window->activateWindow();
|
||||
//_ui.mdiArea->addSubWindow(sub_window);
|
||||
// set editor signals
|
||||
connect(wk_table, SIGNAL(cellChanged(int,int) ), this, SLOT(sheetEditorChanged(int,int)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CMainWindow::sheetEditorChanged(int, int)
|
||||
{
|
||||
saveAct->setEnabled(true);
|
||||
}
|
||||
|
||||
void CMainWindow::save()
|
||||
{
|
||||
QMdiSubWindow *current_window = _ui.mdiArea->currentSubWindow();
|
||||
|
||||
}
|
||||
|
||||
void CMainWindow::readSettings()
|
||||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
|
@ -87,28 +172,7 @@ void CMainWindow::extractBotNames()
|
|||
{
|
||||
if(verifySettings() == true)
|
||||
{
|
||||
// int extract_bot_names = extractBotNamesAll(config_paths, ligo_path, translation_path, work_path);
|
||||
|
||||
QGridLayout* mainLayout = new QGridLayout();
|
||||
|
||||
|
||||
|
||||
//contentsWindow->setAllowedAreas(Qt::LeftDockWidgetArea);
|
||||
|
||||
|
||||
QListWidget *listWidget = new QListWidget(this);
|
||||
|
||||
mainLayout->addWidget(QListWidget);
|
||||
|
||||
|
||||
|
||||
QTableWidget *tableWidget = new QTableWidget(this);
|
||||
|
||||
tableWidget->setRowCount(10);
|
||||
tableWidget->setColumnCount(5);
|
||||
|
||||
mainLayout->addWidget(QTableWidget);
|
||||
setCentralWidget(tableWidget);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,12 @@
|
|||
// Project includes
|
||||
#include "../core/icore_listener.h"
|
||||
|
||||
// Nel includes
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/sheet_id.h"
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/diff_tool.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QUndoStack>
|
||||
|
@ -29,6 +35,8 @@
|
|||
#include <QtGui/QGridLayout>
|
||||
#include <QtGui/QTabWidget>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QMdiSubWindow>
|
||||
|
||||
|
||||
#include "ui_translation_manager_main_window.h"
|
||||
#include <set>
|
||||
|
@ -49,7 +57,10 @@ public:
|
|||
QUndoStack *m_undoStack;
|
||||
private:
|
||||
Ui::CMainWindow _ui;
|
||||
QMenu *_toolMenu;
|
||||
// actions
|
||||
QAction *openAct;
|
||||
QAction *saveAct;
|
||||
// config
|
||||
map<string, list<string> > config_paths;
|
||||
list<string> languages;
|
||||
string ligo_path;
|
||||
|
@ -57,12 +68,18 @@ private:
|
|||
string work_path;
|
||||
private Q_SLOTS:
|
||||
void extractBotNames();
|
||||
void open();
|
||||
void save();
|
||||
void sheetEditorChanged(int, int);
|
||||
private:
|
||||
void compareBotNames();
|
||||
bool verifySettings();
|
||||
void readSettings();
|
||||
void createMenus();
|
||||
void createToolbar();
|
||||
list<string> convertQStringList(QStringList listq);
|
||||
|
||||
|
||||
};
|
||||
|
||||
class CCoreListener : public Core::ICoreListener
|
||||
|
@ -75,6 +92,21 @@ public:
|
|||
virtual bool closeMainWindow() const;
|
||||
};
|
||||
|
||||
class CMdiSubWindow : public QMdiSubWindow
|
||||
{
|
||||
private:
|
||||
int window_type;
|
||||
public:
|
||||
int getWType()
|
||||
{
|
||||
return window_type;
|
||||
}
|
||||
void setWType(int nType)
|
||||
{
|
||||
window_type = nType;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Plugin
|
||||
|
||||
#endif // SIMPLE_VIEWER_H
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CMainWindow</class>
|
||||
<widget class="QMainWindow" name="CMainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>883</width>
|
||||
<height>576</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QMdiArea" name="mdiArea">
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="sheetEditor">
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in a new issue