📄 tableview.h
字号:
#ifndef TABLEVIEW_H
#define TABLEVIEW_H
#include <QtGui>
#include <QtSql>
#include "struct.h"
#include "tableviewfilter.h"
#include "mysqltablemodel.h"
#include "finddialog.h"
#include "datacombobox.h"
class FindDialog;
class MyDelegate: public QSqlRelationalDelegate
{
Q_OBJECT
public:
MyDelegate(QWidget *parent=0);
~MyDelegate();
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const ;
void setModelData ( QWidget * editor, QAbstractItemModel * model, const QModelIndex & index ) const;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem&,const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex &index) const;
};
class TableView : public QTableView
{
Q_OBJECT
public:
TableView(QWidget *parent = 0);
~TableView();
void enableAction(bool bEnabled);
QAction *getInsertRowAction(){return actInsertRow;}
QAction *getAppendRowAction(){return actAppendRow;}
QAction *getDeleteRowAction(){return actDeleteRow;}
QAction *getCommitAction(){return actCommit;}
QAction *getRollbackAction(){return actRollback;}
QAction *getFilterAction(){return actFilter;}
QAction *getFindAction(){return actFind;}
QAction *getCloseAction(){return actClose;}
QAction *getCopyAction(){return actCopy;}
QAction *getSaveAction(){return actSave;}
QAction *getRetrieveAllAction(){return actRetrieveAll;}
QAction *getPrintAction(){return actPrint;}
QString getSelectedText();
QString getSelectedTableText();
bool saveFile(const QString & fileName);
bool isPasswordColumn(QString columnName);
signals:
void onSum(double value);
void onCloseTable(WId);
public slots:
void setTableModel(MySqlTableModel *model);
void commit();
void deleteRow();
void rollback();
void insertRow();
void appendRow();
void setFilter();
void closeFilter();
void closeTable();
void copy();
void save();
void retrieveAll();
void print();
protected:
//QItemSelectionModel::SelectionFlags selectionCommand ( const QModelIndex & index, const QEvent * event = 0 ) const;
void setSelection ( const QRect & rect, QItemSelectionModel::SelectionFlags flags );
private slots:
void onSortIndicatorChanged ( int idx, Qt::SortOrder order);
void showFind();
void printPreview(QPrinter *printer);
private:
QAction *actInsertRow,
*actAppendRow,
*actDeleteRow,
*actCommit,
*actRollback,
*actClose,
*actFilter,
*actFind,
*actCopy,
*actSave,
*actPrint,
*actRetrieveAll;
TableViewFilter *filterDlg;
FindDialog * findDlg;
QStringList passwordColumnList;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -