Skip to content

Commit

Permalink
GUI: удобства.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmpas committed Apr 10, 2018
1 parent 3cf8a43 commit 151a178
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 9 deletions.
24 changes: 23 additions & 1 deletion src/gtool1cd/BlobViewer/blob_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "../models/stream_device.h"
#include <Table.h>
#include <QDebug>
#include <QShortcut>

BlobViewer::BlobViewer(QWidget *parent) :
QWidget(parent),
Expand All @@ -17,6 +18,13 @@ BlobViewer::BlobViewer(QWidget *parent) :
font.setStyleHint(QFont::TypeWriter);
font.setFamily("Monospace");
ui->plainTextEdit->setFont(font);
ui->plainTextEdit->setTabStopWidth( ui->plainTextEdit->fontMetrics().width(" ") );

auto prevTabShortCut = new QShortcut(QKeySequence("Ctrl+PgUp"), this);
connect(prevTabShortCut, SIGNAL(activated()), this, SLOT(prevTabActivated()));

auto nextTabShortCut = new QShortcut(QKeySequence("Ctrl+PgDown"), this);
connect(nextTabShortCut, SIGNAL(activated()), this, SLOT(nextTabActivated()));

}

Expand All @@ -43,8 +51,8 @@ void BlobViewer::setText(const QString &textData, bool do_not_hide_tabs)
auto t = parse_1Ctext(textData.toStdString(), "");
if (t != nullptr) {
ui->treeView->setModel(new SkobkaTreeModel( std::move(t) ));
ui->treeView->expandAll();
ui->tabWidget->addTab(ui->parsedDataTab, tr("Дерево"));
ui->tabWidget->setCurrentWidget(ui->parsedDataTab);
}
} catch (...) {
}
Expand Down Expand Up @@ -139,3 +147,17 @@ void BlobViewer::on_treeView_doubleClicked(const QModelIndex &index)
new_window->show();
}
}

void BlobViewer::prevTabActivated()
{
auto w = ui->tabWidget;
int i = (w->currentIndex() - 1 + w->count()) % w->count();
w->setCurrentIndex(i);
}

void BlobViewer::nextTabActivated()
{
auto w = ui->tabWidget;
int i = (w->currentIndex() + 1 + w->count()) % w->count();
w->setCurrentIndex(i);
}
2 changes: 2 additions & 0 deletions src/gtool1cd/BlobViewer/blob_viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class BlobViewer : public QWidget

private slots:
void on_treeView_doubleClicked(const QModelIndex &index);
void prevTabActivated();
void nextTabActivated();

private:
QString rootName;
Expand Down
5 changes: 5 additions & 0 deletions src/gtool1cd/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ void MainWindow::on_configurationsButton_clicked()
configurationsWindow->show();
configurationsWindow->activateWindow();
}

void MainWindow::on_tableListView_activated(const QModelIndex &index)
{
emit ui->tableListView->doubleClicked(index);
}
2 changes: 2 additions & 0 deletions src/gtool1cd/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ private slots:

void on_configurationsButton_clicked();

void on_tableListView_activated(const QModelIndex &index);

private:
Ui::MainWindow *ui;
T_1CD *db;
Expand Down
13 changes: 11 additions & 2 deletions src/gtool1cd/models/skobka_tree_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,17 @@ QVariant SkobkaTreeModel::data(const QModelIndex &index, int role) const
}

if (role == Qt::EditRole) {
if (qp.startsWith("#base64:")) {
qp = qp.right(qp.size() - QString("#base64:").size());
auto item_type = item->get_type();
if (item_type == node_type::nd_binary
|| item_type == node_type::nd_binary2
|| item_type == node_type::nd_binary_d) {

if (qp.startsWith("#base64")) {
qp = qp.right(qp.size() - QString("#base64:").size());
} else if (qp.startsWith("#data")) {
qp = qp.right(qp.size() - QString("#data:").size());
}

auto byteArray = QByteArray::fromBase64(qp.toUtf8());
TMemoryStream *mems = new TMemoryStream();
mems->WriteBuffer(byteArray.data(), byteArray.size());
Expand Down
7 changes: 7 additions & 0 deletions src/gtool1cd/table_data_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ TableDataWindow::TableDataWindow(QWidget *parent, Table *table)

connect(ui->dataView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(dataView_selection_changed(QItemSelection)));

if (indexes.size() > 1) {
ui->indexChooseBox->setCurrentIndex(1);
emit ui->indexChooseBox->activated(1);
}

ui->dataView->setFocus();
}

TableDataWindow::~TableDataWindow()
Expand Down
39 changes: 33 additions & 6 deletions src/gtool1cd/table_data_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="fieldsButton">
<property name="text">
Expand Down Expand Up @@ -73,23 +88,35 @@
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTableView" name="dataView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
Expand Down

0 comments on commit 151a178

Please sign in to comment.