Changed: #1193 Polish sheet id view plugin code.
parent
364f7fddff
commit
cf39fcd06c
@ -1,55 +0,0 @@
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include <stdio.h>
|
||||
#include "bin_reader.h"
|
||||
#include <QTableWidget>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QByteArray>
|
||||
#include <QVector>
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/sheet_id.h"
|
||||
#include <vector>
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
class CPred
|
||||
{
|
||||
public:
|
||||
bool operator()(const CSheetId &a, const CSheetId &b)
|
||||
{
|
||||
return a.toString()<b.toString();
|
||||
}
|
||||
};
|
||||
|
||||
BinReader::BinReader(QString dir)
|
||||
{
|
||||
QByteArray dirChar = dir.toLatin1();
|
||||
char* dirCharRef = dirChar.data();
|
||||
// NLMISC::CApplicationContext appContext;
|
||||
CPath::addSearchPath(dirCharRef);
|
||||
CSheetId::init(false);
|
||||
CSheetId::buildIdVector(this->SheetList);
|
||||
CPred Pred;
|
||||
sort(this->SheetList.begin(), this->SheetList.end(), Pred);
|
||||
// this->SheetList.fromStdVector(sheets);
|
||||
}
|
||||
int BinReader::count()
|
||||
{
|
||||
return this->SheetList.size();
|
||||
}
|
||||
std::vector<CSheetId> BinReader::getVector() const
|
||||
{
|
||||
return this->SheetList;
|
||||
}
|
||||
void BinReader::pushToTable(QTableWidget*& table)
|
||||
{
|
||||
table->clear();
|
||||
table->setRowCount(this->SheetList.size());
|
||||
table->setColumnCount(2);
|
||||
for (int i = 0; i < this->SheetList.size(); i++)
|
||||
{
|
||||
QTableWidgetItem* item1 = new QTableWidgetItem(QString(this->SheetList[i].toString().c_str()));
|
||||
QTableWidgetItem* item2 = new QTableWidgetItem(QString("%1").arg(this->SheetList[i].asInt()));
|
||||
table->setItem(i,1,item1);
|
||||
table->setItem(i,2,item2);
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include <stdio.h>
|
||||
#include <QTableWidget>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QByteArray>
|
||||
#include <QVector>
|
||||
#include "nel/misc/path.h"
|
||||
#include "nel/misc/sheet_id.h"
|
||||
#include <vector>
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
class BinReader
|
||||
{
|
||||
public:
|
||||
BinReader(QString dir);
|
||||
int count();
|
||||
void pushToTable(QTableWidget*& table);
|
||||
std::vector<CSheetId> getVector() const;
|
||||
private:
|
||||
std::vector<CSheetId> SheetList;
|
||||
};
|
@ -1,47 +0,0 @@
|
||||
#include "dialog.h"
|
||||
#include "ui_dialog.h"
|
||||
#include "bin_reader.h"
|
||||
|
||||
#include "QMessageBox"
|
||||
#include "QSettings"
|
||||
|
||||
Dialog::Dialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::Dialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QSettings settings("ovqt_sheet_builder.ini", QSettings::IniFormat);
|
||||
dir = settings.value("PathToSheetId", "").toString();
|
||||
connect(ui->reloadButton,SIGNAL(clicked()),this,SLOT(reloadTable()));
|
||||
connect(ui->browseButton,SIGNAL(clicked()),this,SLOT(getDir()));
|
||||
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
void Dialog::reloadTable()
|
||||
{
|
||||
QFile file(dir + QString("./sheet_id.bin"));
|
||||
if(file.exists() == true)
|
||||
{
|
||||
QSettings settings("ovqt_sheet_builder.ini", QSettings::IniFormat);
|
||||
settings.setValue("PathToSheetId", dir);
|
||||
BinReader reader(this->dir);
|
||||
reader.pushToTable(ui->table);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox errorBox;
|
||||
errorBox.setText(QString("File sheet_id.bin doesn't exist in direcotry: \n") + this->dir);
|
||||
errorBox.exec();
|
||||
}
|
||||
}
|
||||
void Dialog::getDir()
|
||||
{
|
||||
QFileDialog fileDialog(this);
|
||||
fileDialog.setFileMode(QFileDialog::DirectoryOnly);
|
||||
this->dir = fileDialog.getExistingDirectory();
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFileDialog>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class Dialog;
|
||||
}
|
||||
|
||||
class Dialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Dialog(QWidget *parent = 0);
|
||||
~Dialog();
|
||||
public Q_SLOTS:
|
||||
void reloadTable();
|
||||
void getDir();
|
||||
|
||||
private:
|
||||
QString dir;
|
||||
Ui::Dialog *ui;
|
||||
};
|
||||
|
||||
#endif // DIALOG_H
|
@ -0,0 +1,75 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "sheet_id_view.h"
|
||||
#include "ui_dialog.h"
|
||||
|
||||
#include "nel/misc/path.h"
|
||||
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QApplication>
|
||||
|
||||
class CPred
|
||||
{
|
||||
public:
|
||||
bool operator()(const NLMISC::CSheetId &a, const NLMISC::CSheetId &b)
|
||||
{
|
||||
return a.toString()<b.toString();
|
||||
}
|
||||
};
|
||||
|
||||
SheetIdView::SheetIdView(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
connect(m_ui.reloadButton, SIGNAL(clicked()), this, SLOT(pushToTable()));
|
||||
}
|
||||
|
||||
SheetIdView::~SheetIdView()
|
||||
{
|
||||
}
|
||||
|
||||
void SheetIdView::pushToTable()
|
||||
{
|
||||
// Check sheet_id.bin
|
||||
try
|
||||
{
|
||||
NLMISC::CPath::lookup("sheet_id.bin");
|
||||
}
|
||||
catch (NLMISC::Exception &e)
|
||||
{
|
||||
QMessageBox::critical(this, e.what(), tr("Path not found for sheet_id.bin. Add in the settings search path to the file"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
// Load sheet_id.bin file
|
||||
NLMISC::CSheetId::init(false);
|
||||
NLMISC::CSheetId::buildIdVector(m_sheetList);
|
||||
CPred Pred;
|
||||
sort(m_sheetList.begin(), m_sheetList.end(), Pred);
|
||||
|
||||
// Fill table
|
||||
m_ui.table->clear();
|
||||
m_ui.table->setRowCount(m_sheetList.size());
|
||||
m_ui.table->setColumnCount(2);
|
||||
for (size_t i = 0; i < m_sheetList.size(); i++)
|
||||
{
|
||||
QApplication::processEvents();
|
||||
QTableWidgetItem* item1 = new QTableWidgetItem(QString(m_sheetList[i].toString().c_str()));
|
||||
QTableWidgetItem* item2 = new QTableWidgetItem(QString("%1").arg(m_sheetList[i].asInt()));
|
||||
m_ui.table->setItem(i,1,item1);
|
||||
m_ui.table->setItem(i,2,item2);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef SHEET_ID_VIEW_H
|
||||
#define SHEET_ID_VIEW_H
|
||||
|
||||
#include "ui_sheet_id_view.h"
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/sheet_id.h"
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
|
||||
class SheetIdView : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SheetIdView(QWidget *parent = 0);
|
||||
~SheetIdView();
|
||||
|
||||
public Q_SLOTS:
|
||||
void pushToTable();
|
||||
|
||||
private:
|
||||
std::vector<NLMISC::CSheetId> m_sheetList;
|
||||
Ui::SheetIdView m_ui;
|
||||
};
|
||||
|
||||
#endif // SHEET_ID_VIEW_H
|
Loading…
Reference in New Issue