From 2b0188908788e9319e141c68f7b046e38b0852e8 Mon Sep 17 00:00:00 2001 From: WS <2422523675@qq.com> Date: Sat, 14 Aug 2021 23:22:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=81=E9=9D=A2=E9=87=87=E7=94=A8=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E5=AD=98=E5=82=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbunit.cpp | 2 +- mainwindow.cpp | 18 +++++++++--------- mainwindow.h | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dbunit.cpp b/dbunit.cpp index df563b5..04d4a11 100644 --- a/dbunit.cpp +++ b/dbunit.cpp @@ -55,7 +55,7 @@ DBUnit::init_basic_tables(QSqlDatabase& db_ins) q.prepare("create table if not exists books_information(" "book_id integer auto_increment primary key,isbn text not null," "name text not null,publishing integer not null,author integer not null," - "author2 integer not null,language text,time text,abstract text,image blob," + "author2 integer not null,language text,time text,abstract text,image text," "constraint fk_bi0 foreign key (publishing) references publishing_information on delete cascade on update cascade," "constraint fk_bi1 foreign key (author) references authors_information on delete cascade on update cascade," "constraint fk_bi1 foreign key (author2) references authors_information on delete cascade on update cascade)"); diff --git a/mainwindow.cpp b/mainwindow.cpp index 7add43d..e409038 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -42,7 +42,7 @@ MainWindow::MainWindow(QWidget* parent) init_groups_list(groups_list); init_groups_list(items_list); - items_view->setItemDelegate(new ListIconDelegate()); + items_view->setItemDelegate(new ItemDisplayDelegate()); items_view->setViewMode(QListView::IconMode); items_view->setResizeMode(QListView::Adjust); items_view->setSelectionRectVisible(true); @@ -166,11 +166,11 @@ GroupDisplayDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelI return QSize(400, 145); } -ListIconDelegate::ListIconDelegate() +ItemDisplayDelegate::ItemDisplayDelegate() { } -ListIconDelegate::~ListIconDelegate() +ItemDisplayDelegate::~ItemDisplayDelegate() { } @@ -181,7 +181,7 @@ auto }; void -ListIconDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const +ItemDisplayDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { painter->save(); painter->setRenderHint(QPainter::Antialiasing); @@ -215,31 +215,31 @@ ListIconDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, c } QSize -ListIconDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const +ItemDisplayDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { return QSize(135, 195); } QWidget* -ListIconDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const +ItemDisplayDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const { return new QLineEdit(parent); } void -ListIconDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const +ItemDisplayDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { static_cast(editor)->setText(index.data().toString()); } void -ListIconDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const +ItemDisplayDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { model->setData(index, static_cast(editor)->text()); } void -ListIconDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const +ItemDisplayDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const { editor->setGeometry(calc_textrect2(option.rect, option.fontMetrics.height() * 1.3)); } diff --git a/mainwindow.h b/mainwindow.h index 93dade8..8248ced 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -22,10 +22,10 @@ public: virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; }; -class ListIconDelegate : public QItemDelegate { +class ItemDisplayDelegate : public QItemDelegate { public: - ListIconDelegate(); - virtual ~ListIconDelegate() override; + ItemDisplayDelegate(); + virtual ~ItemDisplayDelegate() override; // QAbstractItemDelegate interface public: