封面采用路径存储方式
This commit is contained in:
parent
1d59429613
commit
2b01889087
|
@ -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)");
|
||||
|
|
|
@ -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<QLineEdit*>(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<QLineEdit*>(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));
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue