feat: 添加表格页面,复制时获取最新50条

This commit is contained in:
sleepwithoutbz
2025-09-23 21:29:39 +08:00
parent c148f9ba22
commit 9e5421bd05
15 changed files with 210 additions and 299 deletions

View File

@@ -77,7 +77,7 @@ ElaWindow::ElaWindow(QWidget *parent) : QMainWindow{parent}, d_ptr(new ElaWindow
d->_focusEvent = new ElaEvent("WMWindowClicked", "onWMWindowClickedEvent", d);
d->_focusEvent->registerAndInit();
// 展开导航栏
// ADDZY: 标题栏展开导航栏按钮被点击
connect(d->_appBar, &ElaAppBar::navigationButtonClicked, d, &ElaWindowPrivate::onNavigationButtonClicked);
// 主题变更动画

View File

@@ -22,7 +22,9 @@ void ElaWindowPrivate::onNavigationButtonClicked() {
_isNavigationDisplayModeChanged = false;
_resetWindowLayout(true);
_navigationBar->setIsTransparent(false);
_navigationBar->setDisplayMode(ElaNavigationType::Maximal, false);
// ADDZY: 显示导航栏时,默认 compat 模式
// _navigationBar->setDisplayMode(ElaNavigationType::Maximal, false);
_navigationBar->setDisplayMode(ElaNavigationType::Compact, false);
_navigationBar->move(-_navigationBar->width(), _navigationBar->pos().y());
_navigationBar->resize(_navigationBar->width(), _navigationCenterStackedWidget->height() + 1);
QPropertyAnimation *navigationMoveAnimation = new QPropertyAnimation(_navigationBar, "pos");

View File

@@ -1,4 +1,4 @@
#include "CBBase.h"
#include "BasePage.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
@@ -7,7 +7,7 @@
#include "ElaText.h"
#include "ElaTheme.h"
#include "ElaToolButton.h"
CBBase::CBBase(QWidget* parent)
BasePage::BasePage(QWidget* parent)
: ElaScrollPage(parent)
{
connect(eTheme, &ElaTheme::themeModeChanged, this, [=]() {
@@ -18,18 +18,18 @@ CBBase::CBBase(QWidget* parent)
});
}
CBBase::~CBBase()
BasePage::~BasePage()
{
}
void CBBase::createCustomWidget(QString desText)
void BasePage::createCustomWidget(QString desText)
{
// 顶部元素
QWidget* customWidget = new QWidget(this);
ElaText* subTitleText = new ElaText(this);
subTitleText->setText("https://github.com/Liniyous/ElaWidgetTools");
subTitleText->setTextInteractionFlags(Qt::TextSelectableByMouse);
subTitleText->setTextPixelSize(11);
// ElaText* subTitleText = new ElaText(this);
// subTitleText->setText("https://github.com/Liniyous/ElaWidgetTools");
// subTitleText->setTextInteractionFlags(Qt::TextSelectableByMouse);
// subTitleText->setTextPixelSize(11);
ElaToolButton* documentationButton = new ElaToolButton(this);
documentationButton->setFixedHeight(35);
@@ -76,7 +76,7 @@ void CBBase::createCustomWidget(QString desText)
QVBoxLayout* topLayout = new QVBoxLayout(customWidget);
topLayout->setContentsMargins(0, 0, 0, 0);
topLayout->addWidget(subTitleText);
// topLayout->addWidget(subTitleText);
topLayout->addSpacing(5);
topLayout->addLayout(buttonLayout);
topLayout->addSpacing(5);

15
src/UI/BasePage.h Normal file
View File

@@ -0,0 +1,15 @@
#pragma once
#include <ElaScrollPage.h>
class QVBoxLayout;
class BasePage : public ElaScrollPage {
Q_OBJECT
public:
explicit BasePage(QWidget *parent = nullptr);
~BasePage() override;
protected:
void createCustomWidget(QString);
private:
};

View File

@@ -1,14 +0,0 @@
#pragma once
#include <ElaScrollPage.h>
class QVBoxLayout;
class CBBase : public ElaScrollPage
{
Q_OBJECT
public:
explicit CBBase(QWidget* parent = nullptr);
~CBBase() override;
protected:
void createCustomWidget(QString desText);
};

View File

@@ -1,230 +0,0 @@
#include "CBTable.h"
#include <QDebug>
#include <QDesktopServices>
#include <QHBoxLayout>
#include <QMouseEvent>
#include <QPainter>
#include <QVBoxLayout>
#include "ElaAcrylicUrlCard.h"
#include "ElaFlowLayout.h"
#include "ElaImageCard.h"
#include "ElaMenu.h"
#include "ElaMessageBar.h"
#include "ElaNavigationRouter.h"
#include "ElaPopularCard.h"
#include "ElaScrollArea.h"
#include "ElaText.h"
#include "ElaToolTip.h"
CBTable::CBTable(QWidget *parent) : CBBase(parent) {
// 预览窗口标题
setWindowTitle("Home");
setTitleVisible(false);
setContentsMargins(2, 2, 0, 0);
// 标题卡片区域
ElaText *desText = new ElaText("FluentUI For QWidget", this);
desText->setTextPixelSize(18);
ElaText *titleText = new ElaText("ElaWidgetTools", this);
titleText->setTextPixelSize(35);
QVBoxLayout *titleLayout = new QVBoxLayout();
titleLayout->setContentsMargins(30, 60, 0, 0);
titleLayout->addWidget(desText);
titleLayout->addWidget(titleText);
ElaImageCard *backgroundCard = new ElaImageCard(this);
backgroundCard->setBorderRadius(10);
backgroundCard->setFixedHeight(400);
backgroundCard->setMaximumAspectRatio(1.7);
backgroundCard->setCardImage(QImage(":/Resource/Image/Home_Background.png"));
ElaAcrylicUrlCard *urlCard1 = new ElaAcrylicUrlCard(this);
urlCard1->setCardPixmapSize(QSize(62, 62));
urlCard1->setFixedSize(195, 225);
urlCard1->setTitlePixelSize(17);
urlCard1->setTitleSpacing(25);
urlCard1->setSubTitleSpacing(13);
urlCard1->setUrl("https://github.com/Liniyous/ElaWidgetTools");
urlCard1->setCardPixmap(QPixmap(":/Resource/Image/github.png"));
urlCard1->setTitle("ElaTool Github");
urlCard1->setSubTitle("Use ElaWidgetTools To Create A Cool Project");
ElaToolTip *urlCard1ToolTip = new ElaToolTip(urlCard1);
urlCard1ToolTip->setToolTip("https://github.com/Liniyous/ElaWidgetTools");
ElaAcrylicUrlCard *urlCard2 = new ElaAcrylicUrlCard(this);
urlCard2->setCardPixmapSize(QSize(62, 62));
urlCard2->setFixedSize(195, 225);
urlCard2->setTitlePixelSize(17);
urlCard2->setTitleSpacing(25);
urlCard2->setSubTitleSpacing(13);
urlCard2->setUrl("https://space.bilibili.com/21256707");
urlCard2->setCardPixmap(QPixmap(":/Resource/Image/Moon.jpg"));
urlCard2->setTitle("ElaWidgetTool");
urlCard2->setSubTitle("80985@qq.com");
ElaScrollArea *cardScrollArea = new ElaScrollArea(this);
cardScrollArea->setWidgetResizable(true);
cardScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
cardScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
cardScrollArea->setIsGrabGesture(true, 0);
cardScrollArea->setIsOverShoot(Qt::Horizontal, true);
QWidget *cardScrollAreaWidget = new QWidget(this);
cardScrollAreaWidget->setStyleSheet("background-color:transparent;");
cardScrollArea->setWidget(cardScrollAreaWidget);
QHBoxLayout *urlCardLayout = new QHBoxLayout();
urlCardLayout->setSpacing(15);
urlCardLayout->setContentsMargins(30, 0, 0, 6);
urlCardLayout->addWidget(urlCard1);
urlCardLayout->addWidget(urlCard2);
urlCardLayout->addStretch();
QVBoxLayout *cardScrollAreaWidgetLayout = new QVBoxLayout(cardScrollAreaWidget);
cardScrollAreaWidgetLayout->setContentsMargins(0, 0, 0, 0);
cardScrollAreaWidgetLayout->addStretch();
cardScrollAreaWidgetLayout->addLayout(urlCardLayout);
QVBoxLayout *backgroundLayout = new QVBoxLayout(backgroundCard);
backgroundLayout->setContentsMargins(0, 0, 0, 0);
backgroundLayout->addLayout(titleLayout);
backgroundLayout->addWidget(cardScrollArea);
// 推荐卡片
ElaText *flowText = new ElaText("热门免费应用", this);
flowText->setTextPixelSize(20);
QHBoxLayout *flowTextLayout = new QHBoxLayout();
flowTextLayout->setContentsMargins(33, 0, 0, 0);
flowTextLayout->addWidget(flowText);
// ElaFlowLayout
ElaPopularCard *homeCard = new ElaPopularCard(this);
connect(homeCard, &ElaPopularCard::popularCardButtonClicked, this,
[=]() { QDesktopServices::openUrl(QUrl("https://github.com/Liniyous/ElaWidgetTools")); });
homeCard->setCardPixmap(QPixmap(":/Resource/Image/Cirno.jpg"));
homeCard->setTitle("ElaWidgetTool");
homeCard->setSubTitle("5.0⭐ 实用程序与工具");
homeCard->setInteractiveTips("免费下载");
homeCard->setDetailedText(
"ElaWidgetTools致力于为QWidget用户提供一站式的外观和实用功能解决方案,只需数十MB内存和极少CPU占用以支持高效而美观的界面开发");
homeCard->setCardFloatPixmap(QPixmap(":/Resource/Image/IARC/IARC_7+.svg.png"));
ElaPopularCard *homeCard1 = new ElaPopularCard(this);
connect(homeCard1, &ElaPopularCard::popularCardButtonClicked, this, [=]() { Q_EMIT elaScreenNavigation(); });
homeCard1->setTitle("ElaScreen");
homeCard1->setSubTitle("5.0⭐ 实用程序与工具");
homeCard1->setCardPixmap(QPixmap(":/Resource/Image/control/AutomationProperties.png"));
homeCard1->setInteractiveTips("免费使用");
homeCard1->setDetailedText("使用ElaDxgiManager获取屏幕的实时数据以QImage的形式处理数据支持切换采集设备和输出设备。");
homeCard1->setCardFloatPixmap(QPixmap(":/Resource/Image/IARC/IARC_7+.svg.png"));
ElaPopularCard *homeCard2 = new ElaPopularCard(this);
connect(homeCard2, &ElaPopularCard::popularCardButtonClicked, this, [=]() { Q_EMIT elaSceneNavigation(); });
homeCard2->setTitle("ElaScene");
homeCard2->setSubTitle("5.0⭐ 实用程序与工具");
homeCard2->setCardPixmap(QPixmap(":/Resource/Image/control/Canvas.png"));
homeCard2->setInteractiveTips("免费使用");
homeCard2->setDetailedText("使用ElaScene封装的高集成度API进行快速拓扑绘图开发对基于连接的网络拓扑特化处理。");
homeCard2->setCardFloatPixmap(QPixmap(":/Resource/Image/IARC/IARC_7+.svg.png"));
ElaPopularCard *homeCard3 = new ElaPopularCard(this);
connect(homeCard3, &ElaPopularCard::popularCardButtonClicked, this, [=]() { Q_EMIT elaBaseComponentNavigation(); });
homeCard3->setTitle("ElaBaseComponent");
homeCard3->setSubTitle("5.0⭐ 实用程序与工具");
homeCard3->setCardPixmap(QPixmap(":/Resource/Image/control/StandardUICommand.png"));
homeCard3->setInteractiveTips("免费使用");
homeCard3->setDetailedText("添加ElaBaseComponent页面中的基础组件到你的项目中以进行快捷开发使用方便结构整洁API规范");
homeCard3->setCardFloatPixmap(QPixmap(":/Resource/Image/IARC/IARC_7+.svg.png"));
ElaPopularCard *homeCard4 = new ElaPopularCard(this);
connect(homeCard4, &ElaPopularCard::popularCardButtonClicked, this, [=]() { Q_EMIT elaCardNavigation(); });
homeCard4->setTitle("ElaCard");
homeCard4->setSubTitle("5.0⭐ 实用程序与工具");
homeCard4->setCardPixmap(QPixmap(":/Resource/Image/control/FlipView.png"));
homeCard4->setInteractiveTips("免费使用");
homeCard4->setDetailedText("使用ElaCard系列组件包括促销卡片和促销卡片视窗来快速建立循环动画。");
homeCard4->setCardFloatPixmap(QPixmap(":/Resource/Image/IARC/IARC_7+.svg.png"));
ElaPopularCard *homeCard5 = new ElaPopularCard(this);
connect(homeCard5, &ElaPopularCard::popularCardButtonClicked, this, [=]() { Q_EMIT elaIconNavigation(); });
homeCard5->setTitle("ElaIcon");
homeCard5->setSubTitle("5.0⭐ 实用程序与工具");
homeCard5->setCardPixmap(QPixmap(":/Resource/Image/control/CommandBarFlyout.png"));
homeCard5->setInteractiveTips("免费使用");
homeCard5->setDetailedText("在该界面快速挑选你喜欢的图标应用到项目中,以枚举的形式使用它");
homeCard5->setCardFloatPixmap(QPixmap(":/Resource/Image/IARC/IARC_7+.svg.png"));
ElaFlowLayout *flowLayout = new ElaFlowLayout(0, 5, 5);
flowLayout->setContentsMargins(30, 0, 0, 0);
flowLayout->setIsAnimation(true);
flowLayout->addWidget(homeCard);
flowLayout->addWidget(homeCard1);
flowLayout->addWidget(homeCard2);
flowLayout->addWidget(homeCard3);
flowLayout->addWidget(homeCard4);
flowLayout->addWidget(homeCard5);
// 菜单
_homeMenu = new ElaMenu(this);
ElaMenu *checkMenu = _homeMenu->addMenu(ElaIconType::Cubes, "查看");
checkMenu->addAction("查看1");
checkMenu->addAction("查看2");
checkMenu->addAction("查看3");
checkMenu->addAction("查看4");
ElaMenu *checkMenu1 = _homeMenu->addMenu(ElaIconType::Cubes, "查看");
checkMenu1->addAction("查看1");
checkMenu1->addAction("查看2");
checkMenu1->addAction("查看3");
checkMenu1->addAction("查看4");
ElaMenu *checkMenu2 = checkMenu->addMenu(ElaIconType::Cubes, "查看");
checkMenu2->addAction("查看1");
checkMenu2->addAction("查看2");
checkMenu2->addAction("查看3");
checkMenu2->addAction("查看4");
// QKeySequence key = QKeySequence(Qt::CTRL | Qt::Key_S);
_homeMenu->addSeparator();
_homeMenu->addElaIconAction(ElaIconType::BoxCheck, "排序方式", QKeySequence::Save);
_homeMenu->addElaIconAction(ElaIconType::ArrowRotateRight, "刷新");
QAction *action = _homeMenu->addElaIconAction(ElaIconType::ArrowRotateLeft, "撤销");
connect(action, &QAction::triggered, this, [=]() { ElaNavigationRouter::getInstance()->navigationRouteBack(); });
_homeMenu->addElaIconAction(ElaIconType::Copy, "复制");
_homeMenu->addElaIconAction(ElaIconType::MagnifyingGlassPlus, "显示设置");
QWidget *centralWidget = new QWidget(this);
centralWidget->setWindowTitle("Home");
QVBoxLayout *centerVLayout = new QVBoxLayout(centralWidget);
centerVLayout->setSpacing(0);
centerVLayout->setContentsMargins(0, 0, 0, 0);
centerVLayout->addWidget(backgroundCard);
centerVLayout->addSpacing(20);
centerVLayout->addLayout(flowTextLayout);
centerVLayout->addSpacing(10);
centerVLayout->addLayout(flowLayout);
centerVLayout->addStretch();
addCentralWidget(centralWidget);
// 初始化提示
ElaMessageBar::success(ElaMessageBarType::BottomRight, "Success", "初始化成功!", 2000);
}
CBTable::~CBTable() {}
void CBTable::mouseReleaseEvent(QMouseEvent *event) {
switch (event->button()) {
case Qt::RightButton: {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
_homeMenu->popup(event->globalPosition().toPoint());
#else
_homeMenu->popup(event->globalPos());
#endif
break;
}
default: {
break;
}
}
ElaScrollPage::mouseReleaseEvent(event);
}

View File

@@ -1,23 +0,0 @@
#pragma once
#include "CBBase.h"
class ElaMenu;
class CBTable : public CBBase {
Q_OBJECT
public:
Q_INVOKABLE explicit CBTable(QWidget *parent = nullptr);
~CBTable();
Q_SIGNALS:
Q_SIGNAL void elaScreenNavigation();
Q_SIGNAL void elaBaseComponentNavigation();
Q_SIGNAL void elaSceneNavigation();
Q_SIGNAL void elaCardNavigation();
Q_SIGNAL void elaIconNavigation();
protected:
virtual void mouseReleaseEvent(QMouseEvent *event);
private:
ElaMenu *_homeMenu{nullptr};
};

60
src/UI/CBTableView.cpp Normal file
View File

@@ -0,0 +1,60 @@
#include "CBTableView.h"
#include "CBTableViewModel.h"
#include <QHBoxLayout>
#include <QHeaderView>
#include <QVBoxLayout>
#include "ElaTableView.h"
#include "ElaText.h"
CBTableView::CBTableView(QWidget *parent) : BasePage(parent) {
// [Useless] 预览窗口标题
setWindowTitle("Clipboard Histroy");
// 面包屑导航是否显示,即 centralWidget 的 Title 是否显示
setTitleVisible(false);
ElaText *tableText = new ElaText("剪贴板历史记录", this);
tableText->setTextPixelSize(18);
_tableView = new ElaTableView(this);
// ElaScrollBar* tableViewFloatScrollBar = new ElaScrollBar(_tableView->verticalScrollBar(), _tableView);
// tableViewFloatScrollBar->setIsAnimation(true);
QFont tableHeaderFont = _tableView->horizontalHeader()->font();
tableHeaderFont.setPixelSize(16);
_tableView->horizontalHeader()->setFont(tableHeaderFont);
_tableView->setModel(new CBTableViewModel(this));
_tableView->setAlternatingRowColors(true);
_tableView->setIconSize(QSize(38, 38));
_tableView->verticalHeader()->setHidden(true);
_tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
// 设置单击即可选中整行
_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
// 设置只能选择一个还是可以多选
_tableView->setSelectionMode(QAbstractItemView::SingleSelection);
_tableView->horizontalHeader()->setMinimumSectionSize(60);
_tableView->verticalHeader()->setMinimumSectionSize(46);
_tableView->setFixedHeight(520);
connect(_tableView, &ElaTableView::tableViewShow, this, [=]() {
_tableView->setColumnWidth(0, 320);
_tableView->setColumnWidth(1, 50);
_tableView->setColumnWidth(2, 50);
// _tableView->setColumnWidth(3, 150);
// _tableView->setColumnWidth(4, 60);
});
QHBoxLayout *tableViewLayout = new QHBoxLayout();
tableViewLayout->setContentsMargins(0, 0, 10, 0);
tableViewLayout->addWidget(_tableView);
QWidget *centralWidget = new QWidget(this);
centralWidget->setWindowTitle("Clipboard Histroy");
centralWidget->setWindowFlags(Qt::WindowTitleHint);
QVBoxLayout *centerVLayout = new QVBoxLayout(centralWidget);
centerVLayout->setContentsMargins(0, 0, 0, 0);
centerVLayout->addWidget(tableText);
centerVLayout->addSpacing(10);
centerVLayout->addLayout(tableViewLayout);
centerVLayout->addStretch();
addCentralWidget(centralWidget, true, false, 0);
}
CBTableView::~CBTableView() {}

14
src/UI/CBTableView.h Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include "BasePage.h"
class ElaTableView;
class CBTableView : public BasePage {
Q_OBJECT
public:
Q_INVOKABLE explicit CBTableView(QWidget *parent = nullptr);
~CBTableView();
private:
ElaTableView *_tableView{nullptr};
};

View File

@@ -0,0 +1,58 @@
#include "CBTableViewModel.h"
#include <QIcon>
CBTableViewModel::CBTableViewModel(QObject *parent) : QAbstractTableModel{parent} {
_header << "内容" << "时间";
QStringList data0;
QStringList data1;
QStringList data2;
QStringList data3;
QStringList data4;
QStringList data5;
QStringList data6;
QStringList data7;
QStringList data8;
data0 << "夜航星(Night Voyager)" << "05:03";
data1 << "玫瑰少年" << "03:55";
data2 << "Collapsing World(Original Mix)" << "03:10";
data3 << "RAIN MAN (雨人)" << "05:37";
data4 << "黑暗森林" << "05:47";
data5 << "轻(我的三体第四季主题曲)" << "01:59";
data6 << "STYX HELIX" << "04:51";
data7 << "LAST STARDUST" << "05:18";
data8 << "Running In The Dark" << "03:40";
_dataList.append(data0);
_dataList.append(data1);
_dataList.append(data2);
_dataList.append(data3);
_dataList.append(data4);
_dataList.append(data5);
_dataList.append(data6);
_dataList.append(data7);
_dataList.append(data8);
}
CBTableViewModel::~CBTableViewModel() {}
int CBTableViewModel::rowCount(const QModelIndex &parent) const { return 100; }
int CBTableViewModel::columnCount(const QModelIndex &parent) const { return _header.count(); }
QVariant CBTableViewModel::data(const QModelIndex &index, int role) const {
if (role == Qt::DisplayRole) {
return _dataList[index.row() % 9][index.column()];
} else if (role == Qt::DecorationPropertyRole) {
return Qt::AlignCenter;
} else if (role == Qt::TextAlignmentRole && index.column() == 1) {
return Qt::AlignCenter;
}
return QVariant();
}
QVariant CBTableViewModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
return _header[section];
}
return QAbstractTableModel::headerData(section, orientation, role);
}

19
src/UI/CBTableViewModel.h Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include <QAbstractTableModel>
class CBTableViewModel : public QAbstractTableModel {
Q_OBJECT
public:
explicit CBTableViewModel(QObject *parent = nullptr);
~CBTableViewModel();
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
private:
QStringList _header;
QList<QStringList> _dataList;
};

View File

@@ -1,12 +1,16 @@
#include "clipboard.h"
#include "sqlite_orm/sqlite_orm.h"
#include <qlogging.h>
// using sqlite_orm::datetime;
// using sqlite_orm::default_value;
using sqlite_orm::limit;
using sqlite_orm::make_column;
using sqlite_orm::make_storage;
using sqlite_orm::make_table;
using sqlite_orm::order_by;
using sqlite_orm::primary_key;
using sqlite_orm::where;
// 1. 直接定义静态变量
// static decltype(auto) storage = make_storage("./cbh.db", make_table("CBRows", make_column("id", &CBRow::id, primary_key().autoincrement()),
@@ -34,9 +38,10 @@ ClipboardMonitor::~ClipboardMonitor() {}
void ClipboardMonitor::onClipboardChanged() {
// 获取剪贴板对象
QClipboard *clipboard = QApplication::clipboard();
// 检查是否有文本内容
if (clipboard->mimeData()->hasText()) {
if (!clipboard->mimeData()->hasText())
return;
QString text = clipboard->text();
qDebug() << "Clipboard text changed:" << text;
storage->insert(CBRow{
@@ -44,11 +49,13 @@ void ClipboardMonitor::onClipboardChanged() {
text.toStdString(),
storage->select(datetime("now")).front(),
});
}
// 你也可以检查其他格式,如图像
// if (clipboard->mimeData()->hasImage()) {
// QPixmap pixmap = clipboard->pixmap();
// // 处理图像...
// }
refreshTableModel();
}
void ClipboardMonitor::refreshTableModel() {
auto res = storage->get_all<CBRow>(order_by(&CBRow::id).desc(), limit(5));
// TODO: 数据存入TableModel
for (auto k : res) {
qDebug() << k.id;
}
}

View File

@@ -26,4 +26,7 @@ public:
private slots:
void onClipboardChanged();
private:
void refreshTableModel();
};

View File

@@ -1,4 +1,5 @@
#include "window.h"
#include "UI/CBTableView.h"
#include <QGraphicsView>
#include <QHBoxLayout>
@@ -17,7 +18,6 @@
#include "ElaTheme.h"
#include "ElaToolBar.h"
#include "ElaToolButton.h"
#include "UI/CBTable.h"
#ifdef Q_OS_WIN
#include "ElaApplication.h"
@@ -45,12 +45,12 @@ void MainWindow::initWindow() {
// 设置窗口页面内容
// TODO: Set the subtitle of user info card
setUserInfoCardSubTitle("Nothing!");
_tablePage = new CBTable(this);
_tablePage = new CBTableView(this);
addPageNode("剪贴板历史", _tablePage, ElaIconType::TableTree);
this->setIsDefaultClosed(false);
connect(this, &MainWindow::closeButtonClicked, this, [=]() { setVisible(false); });
// this->setIsDefaultClosed(false);
// connect(this, &MainWindow::closeButtonClicked, this, [=]() { setVisible(false); });
}
void MainWindow::createActions() {

View File

@@ -1,7 +1,7 @@
#pragma once
#include "ElaWindow.h"
#include "UI/CBTable.h"
#include "UI/CBTableView.h"
#include <QMainWindow>
#include <QSystemTrayIcon>
@@ -18,7 +18,7 @@ private:
void createTrayIcon();
void setIcon();
CBTable *_tablePage{nullptr};
CBTableView *_tablePage{nullptr};
// 图标
QIcon *icon;