Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
viper committed Apr 22, 2016
0 parents commit 55f0a07
Show file tree
Hide file tree
Showing 58 changed files with 5,781 additions and 0 deletions.
68 changes: 68 additions & 0 deletions BitRestMapEditor.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
QT += core gui sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = bitRestMapEditor
TEMPLATE = app

RC_FILE = BitRestMapEditor.rc

SOURCES += \
main.cpp \
mainwindow.cpp \
rmapobject.cpp \
rmapobjectmodel.cpp \
rtable.cpp \
rtablemodel.cpp \
rsection.cpp \
rsectionmodel.cpp \
rgridwidget.cpp \
newmapdialog.cpp \
rmapobjectmovepolicy.cpp \
rmapobjectbehaviourpolicy.cpp \
rmapobjectresizepolicy.cpp \
rmapobjectfactory.cpp \
rcompositemapobject.cpp \
rmapobjecttreewidgetitem.cpp \
rmapobjecttableviewdelegate.cpp \
rmapobjectfocusholder.cpp \
connectiondialog.cpp \
rfontselectordialog.cpp \
rpictureselectordialog.cpp \
rfontdescriptor.cpp \
rimagedescriptor.cpp \
rcompositemapobjectmodel.cpp \
rmapregistry.cpp \
rrefsdescriptor.cpp \
aboutdialog.cpp

HEADERS += \
mainwindow.h \
rmapobject.h \
rmapobjectmodel.h \
rtable.h \
rtablemodel.h \
rsection.h \
rsectionmodel.h \
rgridwidget.h \
newmapdialog.h \
rmapobjectbehaviourpolicy.h \
rmapobjectmovepolicy.h \
rmapobjectresizepolicy.h \
rmapobjectfactory.h \
rcompositemapobject.h \
rmapobjecttreewidgetitem.h \
rmapobjecttableviewdelegate.h \
rmapobjectfocusholder.h \
connectiondialog.h \
rfontselectordialog.h \
rpictureselectordialog.h \
rfontdescriptor.h \
rimagedescriptor.h \
rcompositemapobjectmodel.h \
rmapregistry.h \
rrefsdescriptor.h \
aboutdialog.h

OTHER_FILES += \
BitRestMapEditor.rc
1 change: 1 addition & 0 deletions BitRestMapEditor.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "editor.ico"
10 changes: 10 additions & 0 deletions aboutdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "aboutdialog.h"

//--------------------------------------------------------------------------------------
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent)
{
setModal(true);
setWindowTitle(tr("О программе"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
12 changes: 12 additions & 0 deletions aboutdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H

#include <QDialog>

class AboutDialog : public QDialog {
Q_OBJECT
public:
explicit AboutDialog(QWidget *parent = 0);
};

#endif // ABOUTDIALOG_H
141 changes: 141 additions & 0 deletions connectiondialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#include "connectiondialog.h"

#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QtSql>
#include <QDebug>
#include <QMessageBox>

//--------------------------------------------------------------------------------------
ConnectionDialog::ConnectionDialog(QWidget *parent) :
QDialog(parent)
{
setModal(true);
setWindowTitle(tr("Настройки соединения"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

buttonOk = new QPushButton(tr("Ok"));
buttonCancel = new QPushButton(tr("Отмена"));
buttonCheckConnection = new QPushButton(tr("Проверить соединение"));

hostLabel = new QLabel(tr("Хост:"));
portLabel = new QLabel(tr("Порт:"));
dbnameLabel = new QLabel(tr("База данных:"));
userLabel = new QLabel(tr("Логин:"));
passwordLabel = new QLabel(tr("Пароль:"));

hostEdit = new QLineEdit;
portEdit = new QLineEdit;
dbnameEdit = new QLineEdit;
userEdit = new QLineEdit;
passwordEdit = new QLineEdit;

QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
buttonBox->addButton(buttonOk, QDialogButtonBox::ActionRole);
buttonBox->addButton(buttonCancel, QDialogButtonBox::ActionRole);

QGridLayout *gridLayout = new QGridLayout;

gridLayout->addWidget(hostLabel, 0, 0);
gridLayout->addWidget(hostEdit, 0, 1);

gridLayout->addWidget(portLabel, 1, 0);
gridLayout->addWidget(portEdit, 1, 1);

gridLayout->addWidget(dbnameLabel, 2, 0);
gridLayout->addWidget(dbnameEdit, 2, 1);

gridLayout->addWidget(userLabel, 3, 0);
gridLayout->addWidget(userEdit, 3, 1);

gridLayout->addWidget(passwordLabel, 4, 0);
gridLayout->addWidget(passwordEdit, 4, 1);

gridLayout->addWidget(buttonCheckConnection, 5, 0, 1, 5, Qt::AlignCenter);

QGridLayout *mainLayout = new QGridLayout;
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
mainLayout->addLayout(gridLayout, 1, 0, Qt::AlignCenter);
mainLayout->addWidget(buttonBox, 2, 0, Qt::AlignCenter);

setLayout(mainLayout);

connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(buttonCheckConnection, SIGNAL(clicked()), this, SLOT(checkConnection()));

buttonOk->setDefault(true);
}

//--------------------------------------------------------------------------------------
void ConnectionDialog::checkConnection()
{
setEnabled(false);
repaint();

QSqlDatabase db = QSqlDatabase::database();
db.setHostName(host());
db.setPort(port());
db.setDatabaseName(dbname());
db.setUserName(user());
db.setPassword(password());

QMessageBox msg(this);

if (db.open()) {
msg.setText(tr("Соединение с бд успешно установлено."));
msg.setIcon(QMessageBox::Information);
} else {
msg.setText(QString(tr("Ошибка установления соединения с бд.\nПричина:\n%1")).arg(db.lastError().text()));
msg.setIcon(QMessageBox::Critical);
}

msg.exec();
db.close();

setEnabled(true);
repaint();
}

//--------------------------------------------------------------------------------------
const QString ConnectionDialog::host() const
{ return hostEdit->text(); }

//--------------------------------------------------------------------------------------
int ConnectionDialog::port() const
{ return portEdit->text().toInt(); }

//--------------------------------------------------------------------------------------
const QString ConnectionDialog::dbname() const
{ return dbnameEdit->text(); }

//--------------------------------------------------------------------------------------
const QString ConnectionDialog::user() const
{ return userEdit->text(); }

//--------------------------------------------------------------------------------------
const QString ConnectionDialog::password() const
{ return passwordEdit->text(); }

//--------------------------------------------------------------------------------------
void ConnectionDialog::setHost(const QString &str)
{ hostEdit->setText(str); }

//--------------------------------------------------------------------------------------
void ConnectionDialog::setPort(int port)
{ portEdit->setText(QString().number(port)); }

//--------------------------------------------------------------------------------------
void ConnectionDialog::setDBName(const QString &str)
{ dbnameEdit->setText(str); }

//--------------------------------------------------------------------------------------
void ConnectionDialog::setUser(const QString &str)
{ userEdit->setText(str); }

//--------------------------------------------------------------------------------------
void ConnectionDialog::setPassword(const QString &str)
{ passwordEdit->setText(str); }
48 changes: 48 additions & 0 deletions connectiondialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef CONNECTIONDIALOG_H
#define CONNECTIONDIALOG_H

#include <QDialog>

class QPushButton;
class QLabel;
class QLineEdit;

class ConnectionDialog : public QDialog {
Q_OBJECT
public:
explicit ConnectionDialog(QWidget *parent = 0);

const QString host() const;
int port() const;
const QString dbname() const;
const QString user() const;
const QString password() const;

void setHost(const QString &str);
void setPort(int port);
void setDBName(const QString &str);
void setUser(const QString &str);
void setPassword(const QString &str);

private slots:
void checkConnection();

private:
QPushButton *buttonOk;
QPushButton *buttonCancel;
QPushButton *buttonCheckConnection;

QLabel *hostLabel;
QLabel *portLabel;
QLabel *dbnameLabel;
QLabel *userLabel;
QLabel *passwordLabel;

QLineEdit *hostEdit;
QLineEdit *portEdit;
QLineEdit *dbnameEdit;
QLineEdit *userEdit;
QLineEdit *passwordEdit;
};

#endif // CONNECTIONDIALOG_H
Binary file added editor.ico
Binary file not shown.
19 changes: 19 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <QtGui/QApplication>
#include <QTextCodec>
#include "mainwindow.h"
#include <QtSql>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.addLibraryPath("./");
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QSqlDatabase::addDatabase("QDB2");

QCoreApplication::setOrganizationName("TwoByte");
QCoreApplication::setApplicationName("BitRestMapEditor");

MainWindow wnd;
wnd.show();
return a.exec();
}
Loading

0 comments on commit 55f0a07

Please sign in to comment.