diff --git a/pip b/pip index f662a92..4910631 160000 --- a/pip +++ b/pip @@ -1 +1 @@ -Subproject commit f662a92380b01637341ef13e8311152495e9b9aa +Subproject commit 4910631ce8daaf7ef5dad6eae4ce0e1d6b7cb83d diff --git a/qad/CMakeLists.txt b/qad/CMakeLists.txt index 085c00d..8a8e8cb 100644 --- a/qad/CMakeLists.txt +++ b/qad/CMakeLists.txt @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.0) cmake_policy(SET CMP0017 NEW) # need include() with .cmake project(qad) set(_QAD_MAJOR 1) -set(_QAD_MINOR 3) -set(_QAD_REVISION 2) -set(_QAD_SUFFIX beta) +set(_QAD_MINOR 4) +set(_QAD_REVISION 0) +set(_QAD_SUFFIX alpha) set(_QAD_COMPANY SHS) set(_QAD_DOMAIN org.SHS) diff --git a/qad/application/lang/qad_application_en.ts b/qad/application/lang/qad_application_en.ts index 0027b17..824e696 100644 --- a/qad/application/lang/qad_application_en.ts +++ b/qad/application/lang/qad_application_en.ts @@ -35,6 +35,7 @@ + About @@ -43,53 +44,58 @@ EMainWindow + Clear recent list + + Show all + + Hide all - + Toolbars - + Docks - + Select file to open - + Select files to open - + Save changes%1? - + in - + Select file to save @@ -97,9 +103,28 @@ HistoryView - + + History cleared + + LogView + + + Category: + + + + + Clear + + + + + All + + + diff --git a/qad/application/lang/qad_application_ru.ts b/qad/application/lang/qad_application_ru.ts index eaa3765..c4d9101 100644 --- a/qad/application/lang/qad_application_ru.ts +++ b/qad/application/lang/qad_application_ru.ts @@ -35,6 +35,7 @@ + About О программе @@ -43,53 +44,58 @@ EMainWindow + Clear recent list Очистить список недавних + + Show all Показать все + + Hide all Скрыть все - + Toolbars Панели инструментов - + Docks Окна - + Select file to open Выбрать файл для открытия - + Select files to open Выберите файлы для открытия - + Save changes%1? Сохранить изменения%1? - + in в - + Select file to save Выберите файл для сохранения @@ -97,9 +103,28 @@ HistoryView - + + History cleared История очищена + + LogView + + + Category: + Категория: + + + + Clear + Очистить + + + + All + Все + + diff --git a/qad/application/logview.cpp b/qad/application/logview.cpp new file mode 100644 index 0000000..eb39473 --- /dev/null +++ b/qad/application/logview.cpp @@ -0,0 +1,183 @@ +#include "logview.h" +#include "ui_logview.h" +#include "qad_types.h" +#include "ecombobox.h" +#include +#include +#include +#include +#include +#include +#include + + +LogView::Category::Category() { + bold = false; +} + + +void LogView::Category::makeIcon(QSize size, QSize size_icon) { + icon_image = QImage(); + if (!image.isNull()) + icon_image = image.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + QPixmap px = QPixmap::fromImage(image.scaled(size_icon, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + icon.addPixmap(px, QIcon::Active); + icon.addPixmap(px, QIcon::Disabled); + icon.addPixmap(px, QIcon::Normal); + icon.addPixmap(px, QIcon::Selected); +} + + + + +LogView::LogView(QWidget * parent): QWidget(parent) { + ui = new Ui::LogView(); + ui->setupUi(this); + ui->buttonClear->setDefaultAction(ui->actionClear); + ui->labelIconSearch->setFixedSize(preferredIconSize(1.2, this)); + ui->comboCategory->addItem(tr("All")); + ui->textEdit->document()->setUndoRedoEnabled(false); + setLinesLimit(10000); + QTextCursor tc(ui->textEdit->document()); + def_cf = tc.charFormat(); +} + + +LogView::~LogView() { + delete ui; +} + + +const QTextEdit * LogView::textEdit() const { + return ui->textEdit; +} + + +void LogView::setLogFont(QFont f) { + ui->textEdit->document()->setDefaultFont(f); + QTextCursor tc(ui->textEdit->document()); + def_cf = tc.charFormat(); +} + + +QFont LogView::logFont() const { + return ui->textEdit->document()->defaultFont(); +} + + +bool LogView::isFilterVisible() const { + return !ui->widgetToolbar->isHidden(); +} + + +int LogView::linesLimit() const { + return ui->textEdit->document()->maximumBlockCount(); +} + + +void LogView::registerCategory(const QString & label, QString keyword, const QImage & icon, QColor color, bool bold) { + if (keyword.isEmpty()) keyword = label; + if (keyword.isEmpty()) return; + Category & c(categories[keyword]); + c.label = label; + c.keyword = keyword; + c.image = icon; + c.color = color; + c.bold = bold; + c.makeIcon(iconImageSize(), preferredIconSize(1., this)); + ui->comboCategory->addItem(c.icon, label, keyword); +} + + +void LogView::addText(const QString & text, bool insert_newline) { + QTextCursor tc(ui->textEdit->document()); + QStringList sl = text.split("\n"); + tc.movePosition(QTextCursor::End); + QScrollBar * bar = ui->textEdit->verticalScrollBar(); + bool at_end = (bar->value() == bar->maximum()); + for (int i = 0; i < sl.size(); ++i) { + tc.insertText(sl[i]); + if ((i < sl.size() - 1) || insert_newline) + newLine(); + } + if (at_end) + bar->setValue(bar->maximum()); + filter(); +} + + +void LogView::changeEvent(QEvent * e) { + if (e->type() == QEvent::Polish) { + ui->labelIconSearch->setFixedSize(preferredIconSize(1.2, this)); + QSize is = iconImageSize(), is_i = preferredIconSize(1., this); + QMutableMapIterator it(categories); + while (it.hasNext()) + it.next().value().makeIcon(is, is_i); + } +} + + +void LogView::newLine() { + QTextCursor tc(ui->textEdit->document()); + tc.movePosition(QTextCursor::End); + tc.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); + QString line = tc.selectedText(); + QImage icon; + QMapIterator it(categories); + while (it.hasNext()) { + it.next(); + if (line.contains(it.key(), Qt::CaseInsensitive)) { + QTextCharFormat cf = def_cf; + cf.setForeground(it.value().color); + if (it.value().bold) + cf.setFontWeight(QFont::Bold); + tc.setCharFormat(cf); + icon = it.value().icon_image; + break; + } + } + if (!icon.isNull()) { + tc.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor); + tc.insertImage(icon); + } + tc.movePosition(QTextCursor::End); + tc.setCharFormat(def_cf); + tc.insertBlock(); +} + + +QSize LogView::iconImageSize() { + int hei = QFontMetrics(ui->textEdit->document()->defaultFont()).height() / 1.25; + return QSize(hei, hei); +} + + +void LogView::setFilterVisible(bool yes) { + ui->widgetToolbar->setHidden(!yes); +} + + +void LogView::setLinesLimit(int l) { + ui->textEdit->document()->setMaximumBlockCount(l); +} + + +void LogView::clear() { + ui->textEdit->clear(); +} + + +void LogView::filter() { + QTextDocument * doc = ui->textEdit->document(); + int bc = doc->blockCount(); + QString fs[2] = {ui->comboCategory->currentData().toString(), ui->lineEdit->text()}; + QTextBlock bl; + for (int i = 0; i < bc; ++i) { + bl = doc->findBlockByNumber(i); + bool vis = true; + if (!fs[0].isEmpty()) vis = vis && bl.text().contains(fs[0], Qt::CaseInsensitive); + if (!fs[1].isEmpty()) vis = vis && bl.text().contains(fs[1], Qt::CaseInsensitive); + bl.setVisible(vis); + } + doc->markContentsDirty(0, bl.position() + bl.length()); +} diff --git a/qad/application/logview.h b/qad/application/logview.h new file mode 100644 index 0000000..8212056 --- /dev/null +++ b/qad/application/logview.h @@ -0,0 +1,94 @@ +/* + QAD - Qt ADvanced + + Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ + +#ifndef LOGVIEW_H +#define LOGVIEW_H + +#include +#include +#include +#include +#include +#include "qad_export.h" + +class QTextEdit; + +namespace Ui { + class LogView; +} + +class QAD_EXPORT LogView: public QWidget +{ + Q_OBJECT + Q_PROPERTY(bool filterVisible READ isFilterVisible WRITE setFilterVisible) + Q_PROPERTY(int linesLimit READ linesLimit WRITE setLinesLimit) + Q_PROPERTY(QFont logFont READ logFont WRITE setLogFont) +public: + explicit LogView(QWidget * parent = 0); + ~LogView(); + + const QTextEdit * textEdit() const; + void setLogFont(QFont f); + QFont logFont() const; + + bool isFilterVisible() const; + int linesLimit() const; + + void registerCategory(const QString & label, + QString keyword = QString(), + const QImage & icon = QImage(), + QColor color = QColor(), + bool bold = false); + + void addText(const QString & text, bool insert_newline = true); + +private: + struct Category { + Category(); + void makeIcon(QSize size, QSize size_icon); + QString label; + QString keyword; + QImage image, icon_image; + QIcon icon; + QColor color; + bool bold; + }; + + void changeEvent(QEvent * e); + void newLine(); + QSize iconImageSize(); + + Ui::LogView * ui; + QMap categories; // by keyword + QTextCharFormat def_cf; + +public slots: + void setFilterVisible(bool yes); + void setLinesLimit(int l); + void clear(); + +private slots: + void filter(); + +signals: + +}; + + +#endif // LOGVIEW_H diff --git a/qad/application/logview.ui b/qad/application/logview.ui new file mode 100644 index 0000000..46eba44 --- /dev/null +++ b/qad/application/logview.ui @@ -0,0 +1,192 @@ + + + LogView + + + + 0 + 0 + 724 + 502 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + + + 0 + + + 0 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 20 + 1 + + + + + + + + :/icons/edit-find.png + + + true + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 20 + 1 + + + + + + + + Category: + + + + + + + + + + + + + false + + + true + + + + + + + + :/icons/edit-clear.png:/icons/edit-clear.png + + + Clear + + + + + + CLineEdit + QLineEdit +
clineedit.h
+
+ + EComboBox + QComboBox +
ecombobox.h
+
+
+ + + + + + actionClear + triggered() + LogView + clear() + + + -1 + -1 + + + 361 + 250 + + + + + lineEdit + textChanged(QString) + LogView + filter() + + + 544 + 138 + + + 728 + 90 + + + + + comboCategory + currentIndexChanged(int) + LogView + filter() + + + 675 + 134 + + + 728 + 76 + + + + + + clear() + filter() + +
diff --git a/qad/application/plugin/logviewplugin.cpp b/qad/application/plugin/logviewplugin.cpp new file mode 100644 index 0000000..add48ea --- /dev/null +++ b/qad/application/plugin/logviewplugin.cpp @@ -0,0 +1,69 @@ +#include "logview.h" +#include "logviewplugin.h" +#include + + +LogViewPlugin::LogViewPlugin(QObject * parent): QObject(parent) { + m_initialized = false; +} + + +void LogViewPlugin::initialize(QDesignerFormEditorInterface * /* core */) { + if (m_initialized) + return; + + // Add extension registrations, etc. here + + m_initialized = true; +} + + +bool LogViewPlugin::isInitialized() const { + return m_initialized; +} + + +QWidget * LogViewPlugin::createWidget(QWidget * parent) { + return new LogView(parent); +} + + +QString LogViewPlugin::name() const { + return QLatin1String("LogView"); +} + + +QString LogViewPlugin::group() const { + return QLatin1String("Display Widgets"); +} + + +QIcon LogViewPlugin::icon() const { + return QIcon(":/icons/logview.png"); +} + + +QString LogViewPlugin::toolTip() const { + return QLatin1String(""); +} + + +QString LogViewPlugin::whatsThis() const { + return QLatin1String(""); +} + + +bool LogViewPlugin::isContainer() const { + return true; +} + + +QString LogViewPlugin::domXml() const { + return QLatin1String("\n\n"); +} + + +QString LogViewPlugin::includeFile() const { + return QLatin1String("logview.h"); +} + diff --git a/qad/application/plugin/logviewplugin.h b/qad/application/plugin/logviewplugin.h new file mode 100644 index 0000000..fc680bc --- /dev/null +++ b/qad/application/plugin/logviewplugin.h @@ -0,0 +1,36 @@ +#ifndef LOGVIEWPLUGIN_H +#define LOGVIEWPLUGIN_H + +#include +#if QT_VERSION >= 0x050000 +# include +#else +# include +#endif + +class LogViewPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + LogViewPlugin(QObject * parent = 0); + + bool isContainer() const; + bool isInitialized() const; + QIcon icon() const; + QString domXml() const; + QString group() const; + QString includeFile() const; + QString name() const; + QString toolTip() const; + QString whatsThis() const; + QWidget * createWidget(QWidget * parent); + void initialize(QDesignerFormEditorInterface * core); + +private: + bool m_initialized; + +}; + +#endif // LOGVIEWPLUGIN_H diff --git a/qad/application/plugin/qad_application.cpp b/qad/application/plugin/qad_application.cpp index 61d1067..18b0093 100644 --- a/qad/application/plugin/qad_application.cpp +++ b/qad/application/plugin/qad_application.cpp @@ -2,12 +2,14 @@ #include "edockwidgetplugin.h" #include "emainwindowplugin.h" #include "historyviewplugin.h" +#include "logviewplugin.h" QADApplication::QADApplication(QObject * parent): QObject(parent) { //m_widgets.append(new EDockWidgetPlugin(this)); m_widgets.append(new EMainWindowPlugin(this)); m_widgets.append(new HistoryViewPlugin(this)); + m_widgets.append(new LogViewPlugin(this)); } @@ -17,5 +19,5 @@ QList QADApplication::customWidgets() const { #if QT_VERSION < 0x050000 -Q_EXPORT_PLUGIN2(qad_graphic_plugin, QADApplication) +Q_EXPORT_PLUGIN2(qad_application_plugin, QADApplication) #endif diff --git a/qad/application/qad_application.qrc b/qad/application/qad_application.qrc index aafad3d..794f52d 100644 --- a/qad/application/qad_application.qrc +++ b/qad/application/qad_application.qrc @@ -27,6 +27,7 @@ ../icons/clear-history.png ../icons/layer-visible-off.png ../icons/layer-visible-on.png + ../icons/logview.png ../icons/qt.png diff --git a/qad/icons/logview.png b/qad/icons/logview.png new file mode 100644 index 0000000..3ce84f2 Binary files /dev/null and b/qad/icons/logview.png differ diff --git a/qad/widgets/matrixedit.cpp b/qad/widgets/matrixedit.cpp index da8e502..f88c8dc 100644 --- a/qad/widgets/matrixedit.cpp +++ b/qad/widgets/matrixedit.cpp @@ -6,6 +6,9 @@ MatrixEdit::MatrixEdit(QWidget * parent): QWidget(parent) { ui = new Ui::MatrixEdit(); ui->setupUi(this); +#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + ui->table->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); +#endif connect(ui->table, SIGNAL(cellChanged(int,int)), this, SIGNAL(changed())); ro = false; } diff --git a/qad/widgets/matrixedit.ui b/qad/widgets/matrixedit.ui index d70c8ad..edcd2fc 100644 --- a/qad/widgets/matrixedit.ui +++ b/qad/widgets/matrixedit.ui @@ -100,9 +100,6 @@ - - QAbstractScrollArea::AdjustToContents - QAbstractItemView::ScrollPerPixel