图头框架优化,支持居中显示,上下拖拉放大范围
This commit is contained in:
parent
8dcd7dd211
commit
cf80a84c9e
167
WellLogUI/include/CStringType.h
Normal file
167
WellLogUI/include/CStringType.h
Normal file
|
|
@ -0,0 +1,167 @@
|
||||||
|
/**
|
||||||
|
* @file CStringTyle.h
|
||||||
|
* @brief CString数据自定义、井以及井次结构体
|
||||||
|
* @date 2014-10-10
|
||||||
|
* @author: ZhouWenfei
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PAI_FRAME_CSTRING_H__
|
||||||
|
#define PAI_FRAME_CSTRING_H__
|
||||||
|
#pragma once
|
||||||
|
#include <iostream>
|
||||||
|
#include <QString>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#pragma execution_character_set("utf-8")
|
||||||
|
#pragma warning( push ,0)
|
||||||
|
//#include "BaseFunExport.h"
|
||||||
|
#pragma warning( pop )
|
||||||
|
//#ifdef MessageBox
|
||||||
|
//#define MessageBox MessageBox
|
||||||
|
//#endif
|
||||||
|
#define MAX_PATH 1024
|
||||||
|
//#define _MAX_PATH 1024
|
||||||
|
#define MaxCurve 1024
|
||||||
|
#define curve_name_len 256
|
||||||
|
#define curve_unit_len 256
|
||||||
|
#define MIN_RANK rank_char
|
||||||
|
#define MAX_RANK rank_longlong
|
||||||
|
|
||||||
|
#define INTMAX_RANK rank_longlong
|
||||||
|
#define SIZE_T_RANK rank_long
|
||||||
|
#define PTRDIFF_T_RANK rank_long
|
||||||
|
#define MB_OK QMessageBox::Ok
|
||||||
|
typedef unsigned short WORD;
|
||||||
|
#ifdef WIN32
|
||||||
|
typedef unsigned long DWORD;
|
||||||
|
typedef DWORD *LPDWORD;
|
||||||
|
typedef void *HANDLE;
|
||||||
|
#else
|
||||||
|
typedef unsigned int DWORD;
|
||||||
|
typedef DWORD *LPDWORD;
|
||||||
|
typedef void *HANDLE;
|
||||||
|
#endif
|
||||||
|
typedef unsigned char BYTE;
|
||||||
|
typedef char* LPSTR;
|
||||||
|
typedef void* LPVOID;
|
||||||
|
|
||||||
|
class CString;
|
||||||
|
typedef QList<CString> CStringList;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#define REPR_INT 1
|
||||||
|
//#define REPR_SHORT 2
|
||||||
|
//#define REPR_LONG 3
|
||||||
|
//#define REPR_FLOAT 4
|
||||||
|
//#define REPR_DOUBLE 5
|
||||||
|
//#define REPR_STRING 6
|
||||||
|
//#define REPR_CHAR 7
|
||||||
|
//#define REPR_UCHAR 8
|
||||||
|
//#define REPR_USHORT 9
|
||||||
|
//#define REPR_UINT 10
|
||||||
|
//#define REPR_ULONG 11
|
||||||
|
//class BASEFUN_EXPORT CString;
|
||||||
|
|
||||||
|
//构建CString
|
||||||
|
class CString
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CString(const char *str = nullptr);
|
||||||
|
CString(const QString str);
|
||||||
|
CString(const CString &other);
|
||||||
|
~CString();
|
||||||
|
|
||||||
|
int GetLength()const;
|
||||||
|
int Find(char *str);
|
||||||
|
int Find(char str);
|
||||||
|
int Find(CString &another);
|
||||||
|
int Find(char str[],int start);
|
||||||
|
int ReverseFind(char ch);
|
||||||
|
int Insert(int pos ,const CString Sctr);
|
||||||
|
int Replace(const char *Src,const char *Dest);
|
||||||
|
CString & TrimLeft();
|
||||||
|
CString & MakeUpper();
|
||||||
|
CString& MakeLower();
|
||||||
|
CString & TrimRight();
|
||||||
|
bool operator==(const char* other );
|
||||||
|
bool operator!=(const char* other );
|
||||||
|
bool operator==(const CString& other );
|
||||||
|
bool operator!=(const CString& other );
|
||||||
|
char operator[](int i);
|
||||||
|
CString Right(int count)const;
|
||||||
|
CString Left(int count)const;
|
||||||
|
// CString operator = (const QString& SrcStr) ;
|
||||||
|
CString operator + (const CString& SrcStr) ;
|
||||||
|
CString operator += (CString& SrcStr) ;
|
||||||
|
CString operator += (const CString& SrcStr) ;
|
||||||
|
char* GetString()const;
|
||||||
|
char GetChar(int n);
|
||||||
|
char GetAt(int n);
|
||||||
|
CString Mid(int pos,int count)const;
|
||||||
|
CString Mid(int pos)const;
|
||||||
|
void Format(const char *format,...);
|
||||||
|
void Delete(int fromIndex,int length);
|
||||||
|
// const char *m_temp;
|
||||||
|
void Alloc(int len);
|
||||||
|
void Empty();
|
||||||
|
private:
|
||||||
|
QString m_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum flags {
|
||||||
|
FL_SPLAT0 = 0x00,/* Drop the value, do not assign */
|
||||||
|
|
||||||
|
FL_SPLAT = 0x01,/* Drop the value, do not assign */
|
||||||
|
FL_INV = 0x02,/* Character-set with inverse */
|
||||||
|
FL_WIDTH = 0x04,/* Field width specified */
|
||||||
|
FL_MINUS = 0x08,/* Negative number */
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ranks {
|
||||||
|
|
||||||
|
rank_char = -2,
|
||||||
|
rank_short = -1,
|
||||||
|
rank_int = 0,
|
||||||
|
rank_long = 1,
|
||||||
|
rank_longlong = 2,
|
||||||
|
rank_ptr = INT_MAX/* Special value used for pointers */
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum bail {
|
||||||
|
|
||||||
|
bail_none = 0,/* No error condition */
|
||||||
|
bail_eof,/* Hit EOF */
|
||||||
|
bail_err/* Conversion mismatch */
|
||||||
|
|
||||||
|
};
|
||||||
|
int AfxMessageBox(CString str);
|
||||||
|
int MessageBox(QWidget *parent,char lpText[128],char*lpCaption, int UINTuType);
|
||||||
|
void ShowMessage(QString mess);
|
||||||
|
|
||||||
|
//构建AfxMessageBox()函数
|
||||||
|
//extern int BASEFUN_EXPORT AfxMessageBox(CString str);
|
||||||
|
//extern int BASEFUN_EXPORT MessageBox(QWidget *parent,char lpText[128],char*lpCaption, int UINTuType);
|
||||||
|
// using namespace pai::graphics;
|
||||||
|
#endif
|
||||||
|
|
||||||
192
WellLogUI/include/PaiTableWidget.h
Normal file
192
WellLogUI/include/PaiTableWidget.h
Normal file
|
|
@ -0,0 +1,192 @@
|
||||||
|
|
||||||
|
#ifndef PAI_FRAME_ICONSOLE_PAITABLEWIDGET_H
|
||||||
|
#define PAI_FRAME_ICONSOLE_PAITABLEWIDGET_H
|
||||||
|
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QContextMenuEvent>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QCheckBox>
|
||||||
|
namespace pai
|
||||||
|
{
|
||||||
|
namespace gui
|
||||||
|
{
|
||||||
|
|
||||||
|
//class PaiCheckBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class PaiTableWidget
|
||||||
|
* @brief PaiTableWidget 是P.A.I系统定制发布的表格控件
|
||||||
|
*/
|
||||||
|
class PaiTableWidget : public QTableWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
PaiTableWidget(QWidget* pParent = NULL);
|
||||||
|
virtual ~PaiTableWidget();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 表格高度自增加,不会出现滚动条
|
||||||
|
* @param[in] ok 是否自动增加
|
||||||
|
* @param[in] maxRowCount 当行数超过该数字时高度不再增加,出现滚动条
|
||||||
|
*/
|
||||||
|
void SetAutoHeight(const bool ok, const int maxRowCount = 10);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 删除多行
|
||||||
|
* @param[in] rowIndex 从该行开始删除
|
||||||
|
* @param[in] count 删除的行数, 如果越界将到最大行时终止
|
||||||
|
*/
|
||||||
|
void RemoveRows(const int rowIndex, const int count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 删除所有行
|
||||||
|
*/
|
||||||
|
void RemoveRows();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置是否显示单元格边框
|
||||||
|
* @param[in] hor 水平方向线
|
||||||
|
* @param[in] ver 垂直方向线
|
||||||
|
*/
|
||||||
|
void setShowGrid(bool hor, bool ver);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置当表格内容为空时要显示的提示字符串
|
||||||
|
* @param msg 提示信息
|
||||||
|
*/
|
||||||
|
void ShowPromptMessage(const QString &msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置当表格内容为空时要显示的提示字符串
|
||||||
|
* @param str 字符串
|
||||||
|
*/
|
||||||
|
void SetFilterEmptyMessage(const QString &str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置是否可以在表格上可以有选择行的显示某些列的功能
|
||||||
|
* @param[in] selectable 是否打开该功能
|
||||||
|
*/
|
||||||
|
void SetColumnVisibleSelectable(bool selectable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置不可以被隐藏的列
|
||||||
|
* @param[in] columnList 不可以被隐藏的列的名字列表
|
||||||
|
*/
|
||||||
|
void SetUnselectableColumns(const QStringList& columnList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@brief 恢复记录的非隐藏表头
|
||||||
|
*/
|
||||||
|
void RecallMemberedSections();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置是否可选中列,如果可选中则会在指定列的左侧添加一个CheckBox.(只可作用于水平表头)
|
||||||
|
* @param[in] logicalIndex 目标列的逻辑索引
|
||||||
|
* @param[in] checkable 是否可选中
|
||||||
|
* @param[in] pCheckBox 需要添加的CheckBox,如果checkable为false,则可不传递此参数。
|
||||||
|
*/
|
||||||
|
void SetColumnCheckable(const int logicalIndex, const bool checkable, QCheckBox *pCheckBox = NULL);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* @brief 根据关键字搜索
|
||||||
|
* @param[in] keyword 搜索的关键字
|
||||||
|
* @param[in] col 要搜索的列
|
||||||
|
*/
|
||||||
|
void Filter(const QString & keyword, int col = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 根据关键字搜索
|
||||||
|
* @param[in] keyword 搜索的关键字
|
||||||
|
* @param[in] cols 要搜索的列
|
||||||
|
*/
|
||||||
|
void Filter(const QString & keyword, QList<int> cols);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 重写添加列函数,使及时调整HeaderView的CheckBox
|
||||||
|
* @param[in] column 要插入的列位置
|
||||||
|
*/
|
||||||
|
void insertColumn(int column);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 重写移除列函数,使及时调整HeaderView的CheckBox
|
||||||
|
* @prama[in] column 要删除的位置
|
||||||
|
*/
|
||||||
|
void removeColumn(int column);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
*@brief 记录非隐藏表头
|
||||||
|
*/
|
||||||
|
void RememberCurrentSections();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 按照上一次的过滤规则,对某一行惊醒过滤
|
||||||
|
* @param[in] rowIndex 要过滤的行索引
|
||||||
|
* @return 是否通过过滤
|
||||||
|
*/
|
||||||
|
virtual bool Filter(int rowIndex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 实现该函数用来写字符串
|
||||||
|
*/
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 实现鼠标右键菜单
|
||||||
|
*/
|
||||||
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 实现快捷键功能
|
||||||
|
*/
|
||||||
|
void keyPressEvent(QKeyEvent *event);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
/**
|
||||||
|
* @brief 重新设置高度以适应自动变化
|
||||||
|
*/
|
||||||
|
void ResetTableHeight();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 行数发生变化
|
||||||
|
*/
|
||||||
|
void RowCountChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置剪切板内容
|
||||||
|
*/
|
||||||
|
void setClipboard();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 当单元格的数据发送改变室的槽函数
|
||||||
|
* @param[in] pItem 对应的单元格
|
||||||
|
*/
|
||||||
|
void TableItemChanged(QTableWidgetItem *pItem);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_AutoHeight;
|
||||||
|
bool m_ShowFilterEmptyMsg;
|
||||||
|
int m_AutoHeightMaxRowCount;
|
||||||
|
QString m_MsgWhileFilterEmpty;
|
||||||
|
QString m_PromptMsg;
|
||||||
|
|
||||||
|
QList<int> m_FilterCols; // 最近一次过滤的的列
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString m_FilterKeyword; // 最近一次过滤的关键字
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* @brief 行数发生变化
|
||||||
|
* @param count 变化后的行数
|
||||||
|
*/
|
||||||
|
void RowCountChanged(const int count);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* PAITABLEWIDGET_H_ */
|
||||||
71
WellLogUI/include/assetcopy.h
Normal file
71
WellLogUI/include/assetcopy.h
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
#ifndef ASSETCOPY_H
|
||||||
|
#define ASSETCOPY_H
|
||||||
|
#include <QObject>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QTableWidgetSelectionRange>
|
||||||
|
#include <QCache>
|
||||||
|
// #include "ObjWellLogWavefile.h"
|
||||||
|
#include "ObjWellLog.h"
|
||||||
|
#include "adapter_defs.h"
|
||||||
|
|
||||||
|
class AssetCopy : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AssetCopy(QObject *parent=NULL);
|
||||||
|
~AssetCopy();
|
||||||
|
void initPopMenu(QTableWidget *pTable, QMenu *pmenu = NULL);
|
||||||
|
void setDataType(DType type);
|
||||||
|
void reqCustomComtextMenu(const QPoint &pos);
|
||||||
|
QString itemParseText(int row,int col);
|
||||||
|
void setVerScrollValue(int value);
|
||||||
|
void setHorScrollValue(int value);
|
||||||
|
void restParse();
|
||||||
|
bool isParse();
|
||||||
|
void SetWellLogs(DType type1,QList<CObjWellLog*>&pWellLogs);
|
||||||
|
public slots:
|
||||||
|
void onCopyData();
|
||||||
|
void onParseData();
|
||||||
|
void onCopyLinesData();
|
||||||
|
void onCopyColnumsData();
|
||||||
|
signals:
|
||||||
|
void signalReqCustomContextMenu(const QPoint& point);
|
||||||
|
void signalParseData(const QTableWidgetSelectionRange &parseRange);
|
||||||
|
|
||||||
|
void saveToTempModel();
|
||||||
|
|
||||||
|
void needANewLine(int);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onCustomContextMenuRequested(const QPoint& pos);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString itemText(int row,int col);
|
||||||
|
void changeCacheRowCol(int orgRow,int orgCol,int movRow,int movCol);
|
||||||
|
private:
|
||||||
|
//////////////////<2F>鸴<EFBFBD><E9B8B4>/ճ<><D5B3>//////////////////
|
||||||
|
QByteArray seriseSelectRange(const QTableWidgetSelectionRange& selectRange);
|
||||||
|
QTableWidgetSelectionRange deseriseSelectRange( QByteArray& selectByte);
|
||||||
|
//ճ<><D5B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
void parseData(const QTableWidgetSelectionRange& parse);
|
||||||
|
void cacheGridData(const QTableWidgetSelectionRange& m_selectionRange);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
///////////////////<2F><><EFBFBD><EFBFBD>/ճ<><D5B3>////////////
|
||||||
|
QMenu* m_menu;
|
||||||
|
static AssetCopy *p_assCopy;
|
||||||
|
|
||||||
|
QMap<int,QMap<int,QString> > m_cacheData;
|
||||||
|
QMap<int,QMap<int,QString> > m_parseCacheData;
|
||||||
|
bool m_isParse;
|
||||||
|
int m_verScrolValue;
|
||||||
|
int m_horScrolValue;
|
||||||
|
QList<CObjWellLog*>m_pWellLogs;
|
||||||
|
DType type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ASSETCOPY_H
|
||||||
334
WellLogUI/include/griddataadapter.h
Normal file
334
WellLogUI/include/griddataadapter.h
Normal file
|
|
@ -0,0 +1,334 @@
|
||||||
|
#ifndef GRIDDATAADAPTER_H
|
||||||
|
#define GRIDDATAADAPTER_H
|
||||||
|
#include "CStringType.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QList>
|
||||||
|
#include <QPair>
|
||||||
|
#include <QAbstractTableModel>
|
||||||
|
#include <QMultiMap>
|
||||||
|
#include <QRunnable>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QPaintEvent>
|
||||||
|
#include <QFutureWatcher>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <PaiTableWidget.h>
|
||||||
|
#include <QTableWidgetSelectionRange>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QApplication>
|
||||||
|
#include "BaseFun.h"
|
||||||
|
// #include "ObjCoreImage.h"
|
||||||
|
#include "GeometryUtils.h"
|
||||||
|
// #include "ObjWellLogWavefile.h"
|
||||||
|
#include "ObjWelllog.h"
|
||||||
|
#include "LogIO.h"
|
||||||
|
// #include "CurveLineLog.h"
|
||||||
|
// #include "ObjWelllogTABLE.h"
|
||||||
|
// #include "ObjWelllogTDT.h"
|
||||||
|
// #include "ObjWelllogFMT.h"
|
||||||
|
#include "DepthProgress.h"
|
||||||
|
#include "adapter_defs.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file GridDataAdapter.h
|
||||||
|
* @date 2020/03/02
|
||||||
|
* @auto luol add
|
||||||
|
* 局部刷新填充数据 编辑时实保存 导出 导入
|
||||||
|
*/
|
||||||
|
|
||||||
|
using namespace pai::datamodel;
|
||||||
|
using namespace pai::gui;
|
||||||
|
|
||||||
|
|
||||||
|
class QTableWidgetItem;
|
||||||
|
class CDataManagger;
|
||||||
|
class TipPop;
|
||||||
|
class AssetCopy;
|
||||||
|
|
||||||
|
class WellLogHeaderView:public QHeaderView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
WellLogHeaderView(Qt::Orientation orientation=Qt::Horizontal, QWidget *parent = 0);
|
||||||
|
~WellLogHeaderView();
|
||||||
|
signals:
|
||||||
|
void signalClickedSectionLogicalIndex(int logincalIndex);
|
||||||
|
//void setSelectionChecked(const QModelIndex &index);
|
||||||
|
protected:
|
||||||
|
void mouseReleaseEvent(QMouseEvent *evt);
|
||||||
|
|
||||||
|
void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;
|
||||||
|
void paintEvent(QPaintEvent *pevt);
|
||||||
|
private:
|
||||||
|
int m_logicalIndex;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class TableModel : public QAbstractTableModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TableModel(QObject* parent=NULL);
|
||||||
|
|
||||||
|
// QAbstractItemModel interface
|
||||||
|
public:
|
||||||
|
int rowCount(const QModelIndex &parent) const;
|
||||||
|
int columnCount(const QModelIndex &parent) const;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
|
||||||
|
QStringList tableHeaderData();
|
||||||
|
|
||||||
|
void setModelData(const QList< QList<DataPair> > &model );
|
||||||
|
void setTableHeaderData(const QStringList &headerLst);
|
||||||
|
void clearBuffer();
|
||||||
|
void clearHeader();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList< QList<DataPair> > m_dataBuffer;
|
||||||
|
QStringList m_headerData;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GridDataAdapter : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef void (GridDataAdapter::*pChangeComplete)();
|
||||||
|
GridDataAdapter(QTableWidget* table,QScrollBar *horizontalScrollBar,QScrollBar *verticalScrollBar,QObject* parent=NULL);
|
||||||
|
~GridDataAdapter();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setModelData(const QList< QList<DataPair> > &model);
|
||||||
|
void setTableHeaderData(const QStringList &headerLst);
|
||||||
|
//清空缓存
|
||||||
|
void clearBuffer();
|
||||||
|
//设置总行数
|
||||||
|
void setRowCount(int rowCount);
|
||||||
|
//设置总列数
|
||||||
|
void setColCount(int colCount);
|
||||||
|
//绑定数据并初始数据
|
||||||
|
void bindData();
|
||||||
|
|
||||||
|
void initWellData(DType type,CObjWell* pwell);
|
||||||
|
void updateWellData();
|
||||||
|
|
||||||
|
void initWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
||||||
|
void updatetWellLogData();
|
||||||
|
|
||||||
|
void initMultWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
||||||
|
void initFMTWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
||||||
|
void initTDTWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
||||||
|
void updatetMultWellLogData();
|
||||||
|
void updatetTDTWellLogData();
|
||||||
|
void updatetFMTWellLogData();
|
||||||
|
|
||||||
|
void initTableWellLogData(DType type,QList<CObjWellLog*> WellLogs);
|
||||||
|
void updatetTableWellLogData();
|
||||||
|
|
||||||
|
void addActonMenu(int type);
|
||||||
|
|
||||||
|
void ReFreshWindow(int type);
|
||||||
|
|
||||||
|
int dataRowCount();
|
||||||
|
int dataColCount();
|
||||||
|
|
||||||
|
void CommitToSave();
|
||||||
|
//导出数据
|
||||||
|
bool tableToCSVFile();
|
||||||
|
bool dataInfoHeader(CLogIO *logio,QStringList &fieldList,QString &wellName,int &rowCount);
|
||||||
|
//导入数据
|
||||||
|
bool importToFile();
|
||||||
|
|
||||||
|
void switchLogView(bool isSwitch);
|
||||||
|
void reqCustomComtextMenu(const QPoint &pos);
|
||||||
|
|
||||||
|
void ReFreshDisplayCurve();
|
||||||
|
|
||||||
|
int getRecordCount();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool eventFilter(QObject *pSender, QEvent * pEvent) override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DType m_dtype;
|
||||||
|
int m_middleWidth;
|
||||||
|
int m_gridWidth;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void signalCommitToSave();
|
||||||
|
void signalReqCustomContextMenu(const QPoint &pos);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onDeleteLinesData();
|
||||||
|
void addALine_SLOT();
|
||||||
|
void addALine_SLOT(int);
|
||||||
|
void sortSequence_SLOT();
|
||||||
|
void sortCompute_SLOT();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotVerScrollValueChange(int value);
|
||||||
|
void slotHorScrollValueChange(int value);
|
||||||
|
|
||||||
|
void slotScrollChangeComplete();
|
||||||
|
void slotCellDoubleClicked(int row,int col);
|
||||||
|
void slotCellClicked(int row,int col);
|
||||||
|
//保存
|
||||||
|
void slotCommitToSave();
|
||||||
|
//void slotModelDataComplete(DType type,const QList< QList<DataPair> >& dataBuffer);
|
||||||
|
void slotVerScrollBarPressed();
|
||||||
|
void slotVerScrollBarReleased();
|
||||||
|
void slotHorScrollBarPressed();
|
||||||
|
void slotHorScrollBarReleased();
|
||||||
|
//
|
||||||
|
void slotSectionClicked(int logincIndex);
|
||||||
|
void onParseData(const QTableWidgetSelectionRange &parseRange);
|
||||||
|
|
||||||
|
void refreshTempModel_SLOT();
|
||||||
|
void itemChange_SLOT(int, int);
|
||||||
|
private:
|
||||||
|
bool VerScrollUp;
|
||||||
|
bool VerScrollChanged;
|
||||||
|
|
||||||
|
int DefRowHeight;
|
||||||
|
int DefColWidth;
|
||||||
|
void initColWH();
|
||||||
|
bool haveDoubleClicked;
|
||||||
|
|
||||||
|
void buildItemList();
|
||||||
|
bool isCellChanged();
|
||||||
|
//更新缓存数据并刷新视图
|
||||||
|
void updateTableView();
|
||||||
|
//滚动刷新
|
||||||
|
void valueChange();
|
||||||
|
//计算行列
|
||||||
|
void calcuPageRowsCols();
|
||||||
|
//重置编辑范围
|
||||||
|
void resetEditRange();
|
||||||
|
//更新pagerow
|
||||||
|
void calNewPageRow();
|
||||||
|
//保存井数据 数据行
|
||||||
|
void saveWellData(QList<QList<double> > data,QList<int> modifyRows);
|
||||||
|
//提取井数据
|
||||||
|
void extractWellData(QList<QList<double> > &editData,QList<int> &modifyRows ,bool &isScuccess);
|
||||||
|
void getWellData(int row,int col,QList<double>& wellXYZ,bool& covSuccss);
|
||||||
|
//保存曲线数据
|
||||||
|
void saveWellLogData(QList<QList<float> > depthList);
|
||||||
|
|
||||||
|
void fillDefaultTitle(QStringList& fields,int pageCol);
|
||||||
|
//提取曲线数据
|
||||||
|
void extractWellLogData(QList<QList<float> > &editData ,bool &isScuccess);
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
//保存波列数据
|
||||||
|
void saveMultWellLogData(bool &isScuccess);
|
||||||
|
//提取波列数据
|
||||||
|
//void extractMultWellLogData(int &row,int &col,float &value,bool &isScuccess);
|
||||||
|
void extractMultWellLogData(QList<QList<float> > &editData,bool &isScuccess);
|
||||||
|
//////////////////////////////////////////////////
|
||||||
|
//保存表
|
||||||
|
void saveTableWellLogData(bool &isScuccess);
|
||||||
|
//导入表格数据
|
||||||
|
void importTableWellLogData(QFile &importFile);
|
||||||
|
|
||||||
|
//导出井眼轨迹数据
|
||||||
|
void exportWellData(FILE *fp, DepthProgress& process);
|
||||||
|
//导出曲线数据
|
||||||
|
void exportWellLogData(FILE *fp, DepthProgress& process);
|
||||||
|
//导入曲线数据
|
||||||
|
void importWellLogData(QFile &importFile, DepthProgress& process);
|
||||||
|
|
||||||
|
//导出多维数据
|
||||||
|
void exportMultWellLogData(FILE *fp, DepthProgress& process);
|
||||||
|
//导出表格数据
|
||||||
|
void exportTableWellLogData(FILE *fp, DepthProgress& process);
|
||||||
|
//获取头信息行列
|
||||||
|
bool getRowsColumnsByHeader(QFile &importFile,int &rows,int &columns,QString &contentLine);
|
||||||
|
float getData(int repCode,char *buffer);
|
||||||
|
void setData(int repCode,char *buffer,double yy);
|
||||||
|
|
||||||
|
//附加曲线统计、属性编辑、计算视图
|
||||||
|
void attachWellLogView();
|
||||||
|
void hideWellLogView();
|
||||||
|
void bindWellLogData(int wellLogIndex);
|
||||||
|
|
||||||
|
//更新临时存储
|
||||||
|
void refreshTempModel();
|
||||||
|
|
||||||
|
//插入一行
|
||||||
|
void addALine(int);
|
||||||
|
private:
|
||||||
|
int m_pageRow;
|
||||||
|
int m_pageCol;
|
||||||
|
int m_dataRowCount;
|
||||||
|
int m_dataColCount;
|
||||||
|
int *itemWidth;//单元格宽度
|
||||||
|
bool ifItemWidth;
|
||||||
|
|
||||||
|
int m_verScrolValue;
|
||||||
|
int m_horScrolValue;
|
||||||
|
QScrollBar *m_verScrolBar;
|
||||||
|
QScrollBar *m_horScrolBar;
|
||||||
|
PFLOATPROPERTY *m_MutiVM;
|
||||||
|
// CObjWellLogWavefile *m_pWave;
|
||||||
|
// CObjWellLogTDT *m_pTDT;
|
||||||
|
// CObjWellLogFMT *m_pFMT;
|
||||||
|
QList<QTableWidgetItem*> m_pageItems;
|
||||||
|
QTableWidget* m_table;
|
||||||
|
TableModel* m_tmodel;
|
||||||
|
//////////////initWellData///////////////////////////
|
||||||
|
CObjWell* m_pWell;
|
||||||
|
//////////////initWellLogData///////////////////////////
|
||||||
|
QStringList m_TitleField;
|
||||||
|
QList<CObjWellLog*> m_pWellLogs;
|
||||||
|
|
||||||
|
PFLOATPROPERTY **vP;
|
||||||
|
////////////////////initTableWellLogData////////////////////////////////
|
||||||
|
int recordcount;
|
||||||
|
//修改后的行列值
|
||||||
|
QMultiMap<int ,int> modifyRowCols;
|
||||||
|
private:
|
||||||
|
QString fileName;
|
||||||
|
QString curveName;
|
||||||
|
int StartDepth;
|
||||||
|
int EndDepth;
|
||||||
|
int StartDim;
|
||||||
|
int EndDim;
|
||||||
|
///
|
||||||
|
int DepLevel;
|
||||||
|
|
||||||
|
float m_SDep;
|
||||||
|
float m_EDep;
|
||||||
|
float m_Rlev;
|
||||||
|
int m_nSamples;
|
||||||
|
int m_flRlev2;
|
||||||
|
int m_PointNum;
|
||||||
|
int m_RepCode;
|
||||||
|
int m_CodeLen;
|
||||||
|
int m_SamplePoint;
|
||||||
|
private:
|
||||||
|
|
||||||
|
QFutureWatcher<void> watcher;
|
||||||
|
QMutex m_mutex;
|
||||||
|
pChangeComplete m_pComplete;
|
||||||
|
//记录编辑选中范围
|
||||||
|
QTableWidgetSelectionRange m_editRange;
|
||||||
|
//用于比较是否修改判定字符
|
||||||
|
QString m_cellText;
|
||||||
|
CDataManagger *m_mgr;
|
||||||
|
TipPop *m_popTip;
|
||||||
|
bool m_switch;
|
||||||
|
int m_nVerScrollValue;
|
||||||
|
AssetCopy* m_pAssetCopy;
|
||||||
|
QMenu *m_menu;
|
||||||
|
|
||||||
|
bool canLoadFromSLF;
|
||||||
|
FLOATPROPERTY tempdata;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRIDDATAADAPTER_H
|
||||||
324
WellLogUI/src/CStringType.cpp
Normal file
324
WellLogUI/src/CStringType.cpp
Normal file
|
|
@ -0,0 +1,324 @@
|
||||||
|
#include "CStringType.h"
|
||||||
|
#include <QLabel>
|
||||||
|
char *m_temp=NULL;
|
||||||
|
CString::CString(const char *str)
|
||||||
|
{
|
||||||
|
m_temp=NULL;
|
||||||
|
if(str==NULL)
|
||||||
|
m_data ="";
|
||||||
|
else
|
||||||
|
m_data=QString::fromLocal8Bit(str);
|
||||||
|
}
|
||||||
|
CString::CString(const QString str)
|
||||||
|
{
|
||||||
|
m_temp=NULL;
|
||||||
|
if(str==NULL)
|
||||||
|
m_data ="";
|
||||||
|
else
|
||||||
|
m_data=str;
|
||||||
|
}
|
||||||
|
|
||||||
|
CString::~CString()
|
||||||
|
{
|
||||||
|
if(m_temp) delete m_temp;
|
||||||
|
m_temp=NULL;
|
||||||
|
};
|
||||||
|
void CString::Empty()
|
||||||
|
{
|
||||||
|
m_data ="";
|
||||||
|
}
|
||||||
|
|
||||||
|
CString::CString(const CString &other)
|
||||||
|
{
|
||||||
|
m_temp=NULL;
|
||||||
|
m_data=other.m_data;
|
||||||
|
}
|
||||||
|
int CString::GetLength()const
|
||||||
|
{
|
||||||
|
return m_data.length();
|
||||||
|
}
|
||||||
|
int CString::Find(char *str)
|
||||||
|
{
|
||||||
|
std::string dataStr=m_data.toStdString();
|
||||||
|
return dataStr.find(str);
|
||||||
|
}
|
||||||
|
int CString::Find(CString &another)
|
||||||
|
{
|
||||||
|
return m_data.toStdString().find(another.m_data.toStdString());
|
||||||
|
}
|
||||||
|
int CString::Find(char str)
|
||||||
|
{
|
||||||
|
std::string dataStr=m_data.toStdString();
|
||||||
|
return dataStr.find(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CString::Find(char str[],int start)
|
||||||
|
{
|
||||||
|
std::string dataStr=m_data.toStdString();
|
||||||
|
int npos=dataStr.find(str);
|
||||||
|
if(npos==-1)
|
||||||
|
return -1;
|
||||||
|
if(npos<start)
|
||||||
|
return -1;
|
||||||
|
return dataStr.find(str);
|
||||||
|
}
|
||||||
|
int CString::ReverseFind(char ch)
|
||||||
|
{
|
||||||
|
int index=m_data.lastIndexOf(ch);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CString::Insert(int pos ,const CString Sctr)
|
||||||
|
{
|
||||||
|
m_data.insert(pos,Sctr.m_data);
|
||||||
|
return m_data.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CString::Replace(const char *Src,const char *Dest)
|
||||||
|
{
|
||||||
|
int length=((std::string)Src).length();
|
||||||
|
QString srcStr=QString::fromLocal8Bit(Src);
|
||||||
|
QString destStr=QString::fromLocal8Bit(Dest);
|
||||||
|
m_data.replace(srcStr,destStr);
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
void CString::Delete(int fromIndex,int length)
|
||||||
|
{
|
||||||
|
m_data=m_data.remove(fromIndex,length);
|
||||||
|
}
|
||||||
|
CString & CString::TrimLeft()
|
||||||
|
{
|
||||||
|
std::string findStr=" ";
|
||||||
|
std::string tempstr=m_data.toStdString();
|
||||||
|
QString temp=m_data;
|
||||||
|
vector<char>StrVector;
|
||||||
|
int left=0;
|
||||||
|
for (int i=0;i<tempstr.length();i++)
|
||||||
|
{
|
||||||
|
if(tempstr.at(i)==findStr.at(0)) {
|
||||||
|
left++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
m_data=temp.mid(left);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
CString & CString::MakeUpper()
|
||||||
|
{
|
||||||
|
m_data=m_data.toUpper();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
CString& CString::MakeLower()
|
||||||
|
{
|
||||||
|
m_data=m_data.toLower();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
CString & CString::TrimRight()
|
||||||
|
{
|
||||||
|
std::string findStr=" ";
|
||||||
|
std::string tempstr=m_data.toStdString();
|
||||||
|
QString temp=m_data;
|
||||||
|
int flag=0;
|
||||||
|
for (int i=tempstr.length()-1;i>-1;i--)
|
||||||
|
{
|
||||||
|
if(tempstr[i]==findStr.at(0)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
flag=i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_data=temp.left(flag+1);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
bool CString::operator==(const char* other )
|
||||||
|
{
|
||||||
|
QString srcStr=QString::fromLocal8Bit(other);
|
||||||
|
if(this->m_data==srcStr)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool CString::operator!=(const char* other )
|
||||||
|
{
|
||||||
|
QString srcStr=QString::fromLocal8Bit(other);
|
||||||
|
if(this->m_data!=srcStr)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
char CString::operator[](int i)
|
||||||
|
{
|
||||||
|
char ch=GetChar(i);
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
CString CString::Right(int count)const
|
||||||
|
{
|
||||||
|
if (count<0)
|
||||||
|
{
|
||||||
|
count=0;
|
||||||
|
}
|
||||||
|
if (count>m_data.length())
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
int length=m_data.length();
|
||||||
|
QString temp=m_data;
|
||||||
|
QString lastdata=temp.remove(0,length-count);
|
||||||
|
CString RightStr(lastdata);
|
||||||
|
return RightStr;
|
||||||
|
}
|
||||||
|
CString CString::Mid(int pos,int count)const
|
||||||
|
{
|
||||||
|
if (count<0)
|
||||||
|
{
|
||||||
|
count=0;
|
||||||
|
}
|
||||||
|
QString temp=m_data.mid(pos,count);
|
||||||
|
CString mstr(temp);
|
||||||
|
return mstr;
|
||||||
|
}
|
||||||
|
CString CString::Mid(int pos)const
|
||||||
|
{
|
||||||
|
QString temp=m_data.mid(pos);
|
||||||
|
CString mstr(temp);
|
||||||
|
return mstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CString CString::Left(int count)const
|
||||||
|
{
|
||||||
|
if (count<0)
|
||||||
|
{
|
||||||
|
count=0;
|
||||||
|
}
|
||||||
|
if (count>m_data.length())
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
int length=m_data.length();
|
||||||
|
QString temp=m_data;
|
||||||
|
QString lastdata=temp.remove(count,length-count);
|
||||||
|
CString leftStr(lastdata);
|
||||||
|
return leftStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CString CString::operator + (const CString& SrcStr)
|
||||||
|
{
|
||||||
|
CString str;
|
||||||
|
str.m_data=m_data+SrcStr.m_data;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
CString CString::operator = (const QString& SrcStr)
|
||||||
|
{
|
||||||
|
CString str;
|
||||||
|
str.m_data=SrcStr;
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
CString CString::operator += (CString& SrcStr)
|
||||||
|
{
|
||||||
|
m_data = m_data+SrcStr.m_data ;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
CString CString::operator += (const CString& SrcStr)
|
||||||
|
{
|
||||||
|
m_data = m_data+SrcStr.m_data ;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
bool CString::operator!=(const CString& other )
|
||||||
|
{
|
||||||
|
return m_data!=other.m_data;
|
||||||
|
}
|
||||||
|
bool CString::operator==(const CString& other )
|
||||||
|
{
|
||||||
|
return m_data==other.m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CString::Alloc(int len)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
char* CString::GetString() const
|
||||||
|
{
|
||||||
|
int length=((string)(m_data.toLocal8Bit().data())).length();
|
||||||
|
if(m_temp) delete m_temp;
|
||||||
|
m_temp=new char[length+1];
|
||||||
|
// Alloc(length);
|
||||||
|
strcpy(m_temp,m_data.toLocal8Bit().data());
|
||||||
|
return m_temp;
|
||||||
|
}
|
||||||
|
char CString::GetChar(int n)
|
||||||
|
{
|
||||||
|
return GetString()[n];
|
||||||
|
}
|
||||||
|
char CString::GetAt(int n)
|
||||||
|
{
|
||||||
|
return GetChar(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CString::Format(const char *format,...)
|
||||||
|
{
|
||||||
|
//char *str=GetString();
|
||||||
|
va_list args;
|
||||||
|
va_start(args,format);
|
||||||
|
m_data.vsprintf(format,args);
|
||||||
|
char *buf=new char[2*strlen(m_data.toStdString().c_str())+1];
|
||||||
|
vsprintf(buf,format,args);
|
||||||
|
m_data=buf;
|
||||||
|
delete buf;
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
void ShowMessage(QString mess)
|
||||||
|
{
|
||||||
|
QDialog dialog(NULL);
|
||||||
|
dialog.setModal(false);
|
||||||
|
Qt::WindowFlags flags = dialog.windowFlags();
|
||||||
|
flags |= Qt::WindowStaysOnTopHint;
|
||||||
|
flags &= ~Qt::WindowContextHelpButtonHint;
|
||||||
|
dialog.setWindowFlags(flags);
|
||||||
|
dialog.setWindowTitle("提示");
|
||||||
|
QFormLayout form(&dialog);
|
||||||
|
QLabel edit(&dialog);
|
||||||
|
form.addRow(&edit);
|
||||||
|
edit.setText(mess);
|
||||||
|
// QDialogButtonBox buttonBox(QDialogButtonBox::Yes,Qt::Horizontal, &dialog);
|
||||||
|
// form.addRow(&buttonBox);
|
||||||
|
// if(buttonBox.button(QDialogButtonBox::Yes)) buttonBox.button(QDialogButtonBox::Yes)->setText("退出");
|
||||||
|
// QObject::connect(buttonBox.button(QDialogButtonBox::Yes), SIGNAL(clicked()), NULL, SLOT(reject()));
|
||||||
|
dialog.show();
|
||||||
|
dialog.exec();
|
||||||
|
}
|
||||||
|
int AfxMessageBox(CString str)
|
||||||
|
{
|
||||||
|
QDialog dialog(NULL);
|
||||||
|
dialog.setModal(false);
|
||||||
|
Qt::WindowFlags flags = dialog.windowFlags();
|
||||||
|
flags |= Qt::WindowStaysOnTopHint;
|
||||||
|
flags &= ~Qt::WindowContextHelpButtonHint;
|
||||||
|
dialog.setWindowFlags(flags);
|
||||||
|
dialog.setWindowTitle("提示");
|
||||||
|
QFormLayout form(&dialog);
|
||||||
|
form.addWidget(new QLabel(str.GetString()));
|
||||||
|
// dialog.show();
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
// Do something here
|
||||||
|
}
|
||||||
|
// return MessageBox(NULL,"提示",str.GetString(),NULL );
|
||||||
|
// QString cstr=str.GetString();
|
||||||
|
// QMessageBox msgBox;
|
||||||
|
// msgBox.setText(cstr);
|
||||||
|
// return msgBox.exec();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MessageBox(QWidget *parent,char lpText[128],char*lpCaption, int UINTuType)
|
||||||
|
{
|
||||||
|
if (!parent)
|
||||||
|
{
|
||||||
|
char *tempName=lpCaption;
|
||||||
|
QString addStr=QString::fromLocal8Bit(tempName);
|
||||||
|
return QMessageBox::information(NULL,lpText,addStr,QMessageBox::Ok);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
109
WellLogUI/src/TipPop.cpp
Normal file
109
WellLogUI/src/TipPop.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
#include "TipPop.h"
|
||||||
|
#include <QRegion>
|
||||||
|
#include <QPolygon>
|
||||||
|
#include <QRect>
|
||||||
|
#include <QLine>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPainterPath>
|
||||||
|
#include <QCursor>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QSpacerItem>
|
||||||
|
|
||||||
|
|
||||||
|
#define TIP_WIDTH 110
|
||||||
|
#define TIP_HEIGHT 45
|
||||||
|
#define TIP_CONTENTWIDTH 80
|
||||||
|
#define TIP_BORDER 2
|
||||||
|
|
||||||
|
#define TIP_LINECOUNT 5
|
||||||
|
#define TIP_RIGHTMARGIN 2
|
||||||
|
|
||||||
|
|
||||||
|
TipPop::TipPop(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
this->setFixedSize(TIP_WIDTH,TIP_HEIGHT);
|
||||||
|
m_Lst=new QLine[TIP_LINECOUNT];
|
||||||
|
init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TipPop::~TipPop()
|
||||||
|
{
|
||||||
|
delete []m_Lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TipPop::init()
|
||||||
|
{
|
||||||
|
|
||||||
|
QPolygon polygon;
|
||||||
|
int offset=TIP_WIDTH-TIP_CONTENTWIDTH;
|
||||||
|
QRect newRect=this->rect().adjusted(0,0,-offset,0);
|
||||||
|
QPoint centerP=QPoint(TIP_WIDTH,newRect.center().y());
|
||||||
|
|
||||||
|
m_Lst[0]=QLine(newRect.topLeft(),newRect.bottomLeft());
|
||||||
|
m_Lst[1]=QLine(newRect.bottomLeft(),newRect.bottomRight());
|
||||||
|
m_Lst[2]=QLine(newRect.topRight(),centerP);
|
||||||
|
m_Lst[3]=QLine(centerP,newRect.bottomRight());
|
||||||
|
m_Lst[4]=QLine(newRect.topRight(),newRect.topLeft());
|
||||||
|
|
||||||
|
|
||||||
|
QLine line;
|
||||||
|
|
||||||
|
for(int i=0;i<TIP_LINECOUNT;i++)
|
||||||
|
{
|
||||||
|
line=m_Lst[i];
|
||||||
|
polygon<<line.p1()<<line.p2();
|
||||||
|
}
|
||||||
|
QRegion region(polygon);
|
||||||
|
this->setMask(region);
|
||||||
|
QLabel *lbl=new QLabel(this);
|
||||||
|
lbl->setObjectName("deplbl");
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(9);
|
||||||
|
font.setBold(true);
|
||||||
|
lbl->setFont(font);
|
||||||
|
lbl->setStyleSheet("color:white");
|
||||||
|
|
||||||
|
lbl->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
|
||||||
|
QHBoxLayout *vLayout=new QHBoxLayout(this);
|
||||||
|
vLayout->addWidget(lbl);
|
||||||
|
QSpacerItem *item=new QSpacerItem(1,1,QSizePolicy::Expanding);
|
||||||
|
vLayout->addSpacerItem(item);
|
||||||
|
vLayout->setContentsMargins(0,0,0,0);
|
||||||
|
}
|
||||||
|
void TipPopdrawBorder()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void TipPop::moveCursorPoint(const float &dept)
|
||||||
|
{
|
||||||
|
QPoint point= QCursor::pos();
|
||||||
|
int posX=point.x()-width()-TIP_RIGHTMARGIN;
|
||||||
|
int posY=point.y()-height()/2.0;
|
||||||
|
this->setGeometry(QRect(posX,posY,width(),height()));
|
||||||
|
m_dept=dept;
|
||||||
|
QLabel* lbl=this->findChild<QLabel*>("deplbl");
|
||||||
|
lbl->setText(QString(" MD:%1").arg(m_dept));
|
||||||
|
QFont ft( "Microsoft YaHei", 9, 75);
|
||||||
|
lbl->setFont(ft);
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TipPop::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter paint;
|
||||||
|
paint.begin(this);
|
||||||
|
int val=TIP_BORDER;
|
||||||
|
paint.save();
|
||||||
|
paint.setPen(Qt::NoPen);
|
||||||
|
|
||||||
|
paint.setBrush(QColor(75,75,75,100));/*Qt::lightGray*/
|
||||||
|
paint.drawRect(rect());
|
||||||
|
paint.restore();
|
||||||
|
paint.end();
|
||||||
|
|
||||||
|
}
|
||||||
29
WellLogUI/src/TipPop.h
Normal file
29
WellLogUI/src/TipPop.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef TIPPOP_H
|
||||||
|
#define TIPPOP_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class TipPop : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TipPop(QWidget *parent=NULL);
|
||||||
|
~TipPop();
|
||||||
|
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
void init();
|
||||||
|
void moveCursorPoint(const float &dept);
|
||||||
|
void drawBorder();
|
||||||
|
private:
|
||||||
|
float m_deptValue;
|
||||||
|
float m_value;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLine *m_Lst;
|
||||||
|
float m_dept;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TIPPOP_H
|
||||||
51
WellLogUI/src/adapter_defs.h
Normal file
51
WellLogUI/src/adapter_defs.h
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
#ifndef ADAPTER_DEFS_H
|
||||||
|
#define ADAPTER_DEFS_H
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
struct DataPair
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DataPair()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
DataPair(QVariant val,Qt::ItemFlag flg=Qt::NoItemFlags)
|
||||||
|
{
|
||||||
|
value=val;
|
||||||
|
itemflag=flg;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataPair(const DataPair& pair)
|
||||||
|
{
|
||||||
|
itemflag=pair.itemflag;
|
||||||
|
value=pair.value;
|
||||||
|
}
|
||||||
|
Qt::ItemFlag itemflag;
|
||||||
|
QVariant value;
|
||||||
|
DataPair operator =(const DataPair& pair )
|
||||||
|
{
|
||||||
|
|
||||||
|
itemflag=pair.itemflag;
|
||||||
|
value=pair.value;
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(DataPair)
|
||||||
|
|
||||||
|
enum DType
|
||||||
|
{
|
||||||
|
D_WellData=0,
|
||||||
|
D_WellLogData,
|
||||||
|
D_MultWellLogData,
|
||||||
|
D_TableWellLogData,
|
||||||
|
D_TDTWellLogData,
|
||||||
|
D_FMTWellLogData,
|
||||||
|
D_NONE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
705
WellLogUI/src/assetcopy.cpp
Normal file
705
WellLogUI/src/assetcopy.cpp
Normal file
|
|
@ -0,0 +1,705 @@
|
||||||
|
#include "assetcopy.h"
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <qtablewidget.h>
|
||||||
|
// #include "ObjWellLogTABLE.h"
|
||||||
|
// #include "ObjDiscreteWellLog.h"
|
||||||
|
// #include "BaseDialog.h"
|
||||||
|
#include "DepthProgress.h"
|
||||||
|
#define DECIMALPLACESNUM 8
|
||||||
|
|
||||||
|
//定义表格的行高
|
||||||
|
#define DefRowHeight 20
|
||||||
|
//列宽
|
||||||
|
#define DefColWidth 180
|
||||||
|
|
||||||
|
AssetCopy* AssetCopy::p_assCopy =NULL;
|
||||||
|
|
||||||
|
AssetCopy::AssetCopy(QObject *parent)
|
||||||
|
: QObject(parent),m_menu(NULL)
|
||||||
|
{
|
||||||
|
m_isParse=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetCopy::~AssetCopy()
|
||||||
|
{
|
||||||
|
if(NULL != m_menu)
|
||||||
|
{
|
||||||
|
m_menu=NULL;
|
||||||
|
}
|
||||||
|
if(NULL !=p_assCopy)
|
||||||
|
{
|
||||||
|
p_assCopy=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void AssetCopy::SetWellLogs(DType type1,QList<CObjWellLog*>&pWellLogs)
|
||||||
|
{
|
||||||
|
type=type1;
|
||||||
|
m_pWellLogs=pWellLogs;
|
||||||
|
}
|
||||||
|
void AssetCopy::onCustomContextMenuRequested(const QPoint &pos)
|
||||||
|
{
|
||||||
|
if(NULL != m_menu)
|
||||||
|
{
|
||||||
|
m_menu->exec(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssetCopy::onCopyData()
|
||||||
|
{
|
||||||
|
m_isParse=false;
|
||||||
|
if(NULL == m_menu || NULL == m_menu->parent())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
||||||
|
if(NULL == m_table)
|
||||||
|
return;
|
||||||
|
//if(m_table->isVisible())
|
||||||
|
|
||||||
|
QList<QTableWidgetItem*> selItems=m_table->selectedItems();
|
||||||
|
QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
|
||||||
|
if(selItems.size()>0)
|
||||||
|
{
|
||||||
|
QTableWidgetSelectionRange copyRange=selRanges.value(0);
|
||||||
|
|
||||||
|
int top = copyRange.topRow();
|
||||||
|
int bottom = copyRange.bottomRow();
|
||||||
|
int left = copyRange.leftColumn();
|
||||||
|
int right = copyRange.rightColumn();
|
||||||
|
|
||||||
|
QString szClipText;
|
||||||
|
for(int nRow = top;nRow <=bottom;nRow++)
|
||||||
|
{
|
||||||
|
for(int nCol = left;nCol <=right;nCol++)
|
||||||
|
{
|
||||||
|
QString szTmp;
|
||||||
|
auto pItem = m_table->item(nRow,nCol);
|
||||||
|
if(pItem)
|
||||||
|
szTmp = pItem->text();
|
||||||
|
szClipText.append(szTmp);
|
||||||
|
szClipText.append("\t");
|
||||||
|
}
|
||||||
|
szClipText.chop(1);
|
||||||
|
szClipText.append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
QClipboard* clip=QApplication::clipboard();
|
||||||
|
clip->setText(szClipText);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void AssetCopy::onCopyLinesData()
|
||||||
|
{
|
||||||
|
// if(!m_pWellLogs.size()) return;
|
||||||
|
// m_isParse=false;
|
||||||
|
// if(NULL == m_menu || NULL == m_menu->parent()) return;
|
||||||
|
// QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
||||||
|
// if(NULL == m_table)
|
||||||
|
// return;
|
||||||
|
// //if(m_table->isVisible())
|
||||||
|
|
||||||
|
// QList<QTableWidgetItem*> selItems=m_table->selectedItems();
|
||||||
|
// QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
|
||||||
|
|
||||||
|
// CObjWellLogWavefile *pWaveValue=NULL;
|
||||||
|
// pWaveValue=dynamic_cast<CObjWellLogWavefile *>(m_pWellLogs[0]);
|
||||||
|
// CObjWellLogTABLE *pTableValue=NULL;
|
||||||
|
// pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
|
||||||
|
// if(selItems.size()>0)
|
||||||
|
// {
|
||||||
|
// QTableWidgetSelectionRange copyRange=selRanges.value(0);
|
||||||
|
|
||||||
|
// int top = m_verScrolValue+copyRange.topRow();
|
||||||
|
// int bottom = m_verScrolValue+copyRange.bottomRow();
|
||||||
|
// int left = 0;//copyRange.leftColumn();
|
||||||
|
// int right = m_horScrolValue+m_table->columnCount();
|
||||||
|
|
||||||
|
// if(pWaveValue) right =pWaveValue->waveinfo.TimeSamples;
|
||||||
|
// else if(!pTableValue) right=m_pWellLogs.size();
|
||||||
|
// char buffer[200];
|
||||||
|
// QString szClipText;
|
||||||
|
// float stdep=999999;
|
||||||
|
// for(int i = 0; i < m_pWellLogs.size(); i++) {
|
||||||
|
// if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep)
|
||||||
|
// stdep = m_pWellLogs[i]->acurveinfo.StartDepth;
|
||||||
|
// }
|
||||||
|
// double dep=0;
|
||||||
|
// int nCurrentRow = m_table->currentRow();
|
||||||
|
|
||||||
|
// for(int nRow = top;nRow <= bottom; nRow++)
|
||||||
|
// {
|
||||||
|
// if(!pTableValue)
|
||||||
|
// dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel;
|
||||||
|
|
||||||
|
// for(int nCol = left;nCol < right; nCol++)
|
||||||
|
// {
|
||||||
|
// QString szTmp;
|
||||||
|
// if(nCol==0||pTableValue) {
|
||||||
|
// auto pItem = m_table->item(nRow,nCol);
|
||||||
|
// if(pItem)
|
||||||
|
// szTmp = pItem->text();
|
||||||
|
// else
|
||||||
|
// szTmp=toString(dep,'f',5,0);
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// if(pWaveValue) szTmp=toString(pWaveValue->GetData((float)dep,nCol-1,buffer),'f',DECIMALPLACESNUM,0);
|
||||||
|
// else szTmp=toString(m_pWellLogs[nCol-1]->GetData((float)dep),'f',DECIMALPLACESNUM,0);
|
||||||
|
// }
|
||||||
|
// szClipText.append(szTmp);
|
||||||
|
// szClipText.append("\t");
|
||||||
|
// }
|
||||||
|
// szClipText.chop(1);
|
||||||
|
// szClipText.append("\n");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// QClipboard* clip=QApplication::clipboard();
|
||||||
|
// clip->setText(szClipText);
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
void AssetCopy::onCopyColnumsData()
|
||||||
|
{
|
||||||
|
// if(!m_pWellLogs.size()) return;
|
||||||
|
// m_isParse=false;
|
||||||
|
// if(NULL == m_menu || NULL == m_menu->parent())
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
||||||
|
// if(NULL == m_table)
|
||||||
|
// return;
|
||||||
|
// //if(m_table->isVisible())
|
||||||
|
|
||||||
|
// CObjWellLogWavefile *pWaveValue=NULL;
|
||||||
|
// pWaveValue=dynamic_cast<CObjWellLogWavefile *>(m_pWellLogs[0]);
|
||||||
|
// CObjWellLogTABLE *pTableValue=NULL;
|
||||||
|
// CObjDiscreteWellLog *pTableValue1=NULL;
|
||||||
|
// pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
|
||||||
|
// pTableValue1=dynamic_cast<CObjDiscreteWellLog *>(m_pWellLogs[0]);
|
||||||
|
// QList<QTableWidgetItem*> selItems=m_table->selectedItems();
|
||||||
|
// QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
|
||||||
|
// float stdep=999999;
|
||||||
|
// for(int i=0;i<m_pWellLogs.size();i++) {
|
||||||
|
// if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep) stdep=m_pWellLogs[i]->acurveinfo.StartDepth;
|
||||||
|
// }
|
||||||
|
// if(selItems.size()>0)
|
||||||
|
// {
|
||||||
|
// QTableWidgetSelectionRange copyRange=selRanges.value(0);
|
||||||
|
|
||||||
|
// int top = 0;//copyRange.topRow();
|
||||||
|
// int bottom = m_table->rowCount();//copyRange.bottomRow();
|
||||||
|
// int left = m_horScrolValue+copyRange.leftColumn();
|
||||||
|
// int right =m_horScrolValue+copyRange.rightColumn();
|
||||||
|
|
||||||
|
// if(!pTableValue&&!pTableValue1&&!pWaveValue)
|
||||||
|
// {
|
||||||
|
// bottom=(m_pWellLogs[0]->acurveinfo.EndDepth-m_pWellLogs[0]->acurveinfo.StartDepth)/m_pWellLogs[0]->acurveinfo.DepLevel+0.5;
|
||||||
|
// }
|
||||||
|
// else if(pWaveValue) {
|
||||||
|
// bottom=(pWaveValue->waveinfo.EndDepth-pWaveValue->waveinfo.StartDepth)/pWaveValue->waveinfo.DepLevel+0.5;
|
||||||
|
// }
|
||||||
|
// QString szClipText;
|
||||||
|
// char buffer[200];
|
||||||
|
// QString szTmp;
|
||||||
|
// float dep=0;
|
||||||
|
// for(int nRow = top;nRow <=bottom;nRow++)
|
||||||
|
// {
|
||||||
|
// if(!pTableValue&&!pTableValue1)dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel;
|
||||||
|
// for(int nCol = left;nCol <=right;nCol++)
|
||||||
|
// {
|
||||||
|
// if(nCol==0||pTableValue||pTableValue1) {
|
||||||
|
// auto pItem = m_table->item(nRow,nCol);
|
||||||
|
// if(pItem)
|
||||||
|
// szTmp = pItem->text();
|
||||||
|
// else if(nCol==0) {
|
||||||
|
// float val=szTmp.toFloat();
|
||||||
|
// sprintf(buffer,"%8.3f",val+m_pWellLogs[0]->acurveinfo.DepLevel);
|
||||||
|
// szTmp =buffer ;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// if(pWaveValue) szTmp=toString(pWaveValue->GetData(dep,nCol-1,buffer),'f',0);
|
||||||
|
// else szTmp=toString(m_pWellLogs[nCol-1]->GetData(dep),'f',DECIMALPLACESNUM,0);
|
||||||
|
// }
|
||||||
|
// szClipText.append(szTmp);
|
||||||
|
// szClipText.append("\t");
|
||||||
|
// }
|
||||||
|
// szClipText.chop(1);
|
||||||
|
// szClipText.append("\n");
|
||||||
|
// }
|
||||||
|
// QClipboard* clip=QApplication::clipboard();
|
||||||
|
// clip->setText(szClipText);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssetCopy::cacheGridData(const QTableWidgetSelectionRange& m_selectionRange)
|
||||||
|
{
|
||||||
|
if(m_selectionRange.columnCount() ==0
|
||||||
|
|| m_selectionRange.rowCount() == 0
|
||||||
|
|| NULL == m_menu
|
||||||
|
|| NULL== m_menu->parent())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QTableWidget *p_table=qobject_cast<QTableWidget*>( m_menu->parent());
|
||||||
|
if(NULL == p_table)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_cacheData.clear();
|
||||||
|
QTableWidgetItem *item=NULL;
|
||||||
|
|
||||||
|
int sRow= m_selectionRange.topRow();
|
||||||
|
int sCol= m_selectionRange.leftColumn();
|
||||||
|
int eRow=m_selectionRange.bottomRow();
|
||||||
|
int eCol=m_selectionRange.rightColumn();
|
||||||
|
int costCols=m_selectionRange.columnCount();
|
||||||
|
int costRows=m_selectionRange.rowCount();
|
||||||
|
|
||||||
|
QString value;
|
||||||
|
for(int r=sRow;r<=eRow;r++)
|
||||||
|
{
|
||||||
|
QMap<int,QString> colCache;
|
||||||
|
for(int c=sCol;c<=eCol;c++)
|
||||||
|
{
|
||||||
|
item=p_table->item(r,c);
|
||||||
|
if(NULL != item)
|
||||||
|
{
|
||||||
|
value=item->text();
|
||||||
|
colCache.insert(c,value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_cacheData.insert(r,colCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AssetCopy::itemText(int row,int col)
|
||||||
|
{
|
||||||
|
QString result="";
|
||||||
|
if( 0== m_cacheData.count())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<int,QString> colMap;
|
||||||
|
if(m_cacheData.contains(row) )
|
||||||
|
{
|
||||||
|
colMap=m_cacheData.value(row);
|
||||||
|
if(colMap.contains(col))
|
||||||
|
{
|
||||||
|
result=colMap.value(col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
QString AssetCopy::itemParseText(int row,int col)
|
||||||
|
{
|
||||||
|
QString result="";
|
||||||
|
if( 0== m_parseCacheData.count())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<int,QString> colMap;
|
||||||
|
if(m_parseCacheData.contains(row) )
|
||||||
|
{
|
||||||
|
colMap=m_parseCacheData.value(row);
|
||||||
|
if(colMap.contains(col))
|
||||||
|
{
|
||||||
|
result=colMap.value(col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
//////////////复制、粘贴////////////////////////////////////////////////////
|
||||||
|
QByteArray AssetCopy::seriseSelectRange(const QTableWidgetSelectionRange& selectRange)
|
||||||
|
{
|
||||||
|
QByteArray barr;
|
||||||
|
QDataStream ds(&barr,QIODevice::WriteOnly);
|
||||||
|
ds.setByteOrder(QDataStream::BigEndian);
|
||||||
|
ds<<selectRange.topRow()
|
||||||
|
<<selectRange.leftColumn()
|
||||||
|
<<selectRange.bottomRow()
|
||||||
|
<<selectRange.rightColumn();
|
||||||
|
|
||||||
|
return barr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableWidgetSelectionRange AssetCopy::deseriseSelectRange( QByteArray& selectByte)
|
||||||
|
{
|
||||||
|
QDataStream ds(&selectByte,QIODevice::ReadOnly);
|
||||||
|
ds.setByteOrder(QDataStream::BigEndian);
|
||||||
|
int top,left,bottom,right;
|
||||||
|
ds>>top>>left>>bottom>>right;
|
||||||
|
|
||||||
|
return QTableWidgetSelectionRange(top,left,bottom,right);
|
||||||
|
}
|
||||||
|
void AssetCopy::setVerScrollValue(int value)
|
||||||
|
{
|
||||||
|
m_verScrolValue=value;
|
||||||
|
|
||||||
|
}
|
||||||
|
void AssetCopy::setHorScrollValue(int value)
|
||||||
|
{
|
||||||
|
m_horScrolValue=value;
|
||||||
|
}
|
||||||
|
void AssetCopy::parseData(const QTableWidgetSelectionRange& parse)
|
||||||
|
{
|
||||||
|
if(NULL == m_menu || NULL == m_menu->parent())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
||||||
|
if(NULL == m_table)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QList<QTableWidgetSelectionRange> rangeLst=m_table->selectedRanges();
|
||||||
|
if(rangeLst.size()==0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableWidgetSelectionRange selRange=rangeLst.value(0);
|
||||||
|
|
||||||
|
int tableRowCount=m_table->rowCount();
|
||||||
|
int tbaleColCount=m_table->columnCount();
|
||||||
|
int top,left,bottom,right;
|
||||||
|
int selRows=selRange.rowCount();
|
||||||
|
int selCols=selRange.columnCount();
|
||||||
|
//选择一格自动填充
|
||||||
|
if(selRows==selCols && selRows==1)
|
||||||
|
{
|
||||||
|
top=selRange.topRow();
|
||||||
|
left=selRange.leftColumn();
|
||||||
|
|
||||||
|
int parRows=parse.rowCount();
|
||||||
|
int parCols=parse.columnCount();
|
||||||
|
|
||||||
|
bottom=top+parRows-1;
|
||||||
|
right=left+parCols-1;
|
||||||
|
|
||||||
|
//裁剪区域大小总行
|
||||||
|
if(parRows+top>tableRowCount)
|
||||||
|
{
|
||||||
|
bottom=tableRowCount-1;
|
||||||
|
}
|
||||||
|
//大于总列
|
||||||
|
if(parCols+left>tbaleColCount)
|
||||||
|
{
|
||||||
|
right=tbaleColCount-1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}else //选择方式
|
||||||
|
{
|
||||||
|
|
||||||
|
top=selRange.topRow();
|
||||||
|
left=selRange.leftColumn();
|
||||||
|
|
||||||
|
|
||||||
|
int scCount= selRange.columnCount();
|
||||||
|
int srCount=selRange.rowCount();
|
||||||
|
int pcCount=parse.columnCount();
|
||||||
|
int prcCount=parse.rowCount();
|
||||||
|
//选中区域大于粘贴区域
|
||||||
|
if(scCount>pcCount && srCount>prcCount)
|
||||||
|
{
|
||||||
|
bottom=top+prcCount-1;
|
||||||
|
right=left+pcCount-1;
|
||||||
|
//选中区域列大于粘贴区域
|
||||||
|
}else if( scCount>pcCount && srCount<prcCount)
|
||||||
|
{
|
||||||
|
bottom=selRange.bottomRow();
|
||||||
|
right=left+pcCount-1;
|
||||||
|
//选中区域行大于粘贴区域
|
||||||
|
}else if(scCount<pcCount && srCount>prcCount)
|
||||||
|
{
|
||||||
|
bottom=top+prcCount-1;
|
||||||
|
right=selRange.rightColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int begRow=parse.topRow();
|
||||||
|
int endRow=begRow+bottom-top;
|
||||||
|
int begCol=parse.leftColumn();
|
||||||
|
int endCol=begCol+right-left;
|
||||||
|
|
||||||
|
int moveRows=top- begRow;
|
||||||
|
int moveCols=left-begCol;
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
int row,col;
|
||||||
|
m_parseCacheData.clear();
|
||||||
|
//取原数据粘贴数据
|
||||||
|
for(int i=begRow;i<=endRow;i++)
|
||||||
|
{
|
||||||
|
QMap<int,QString> colMap;
|
||||||
|
row=i+moveRows;
|
||||||
|
for(int j=begCol;j<=endCol;j++)
|
||||||
|
{
|
||||||
|
text=itemText(i,j);//m_table->item(i,j)->text();
|
||||||
|
|
||||||
|
col=j+moveCols;
|
||||||
|
colMap.insert(col,text);
|
||||||
|
m_table->item(row,col)->setText(text);
|
||||||
|
|
||||||
|
}
|
||||||
|
m_parseCacheData.insert(row,colMap);
|
||||||
|
}
|
||||||
|
//int top=begRow+moveRows+m_verScrolValue;
|
||||||
|
//int bottom=endRow+moveRows+m_verScrolValue;
|
||||||
|
//int left=begCol+moveCols+m_horScrolValue;
|
||||||
|
//int right=endCol+moveCols+m_horScrolValue;
|
||||||
|
|
||||||
|
int topRow=begRow+moveRows;
|
||||||
|
int bottomRow=endRow+moveRows;
|
||||||
|
int leftCol=begCol+moveCols;
|
||||||
|
int rightCol=endCol+moveCols;
|
||||||
|
|
||||||
|
|
||||||
|
QTableWidgetSelectionRange parselRange(topRow,leftCol,bottomRow,rightCol);
|
||||||
|
m_isParse=true;
|
||||||
|
emit signalParseData(parselRange);
|
||||||
|
}
|
||||||
|
void AssetCopy::restParse()
|
||||||
|
{
|
||||||
|
m_isParse=false;
|
||||||
|
}
|
||||||
|
bool AssetCopy::isParse()
|
||||||
|
{
|
||||||
|
return m_isParse;
|
||||||
|
}
|
||||||
|
void AssetCopy::changeCacheRowCol(int orgRow,int orgCol,int movRow,int movCol)
|
||||||
|
{
|
||||||
|
QMap<int,QMap<int,QString> >::iterator mItor=m_cacheData.begin();
|
||||||
|
QMap<int,QString>::iterator itor;
|
||||||
|
QMap<int,QString> mapValue;
|
||||||
|
QString value;
|
||||||
|
|
||||||
|
for(;mItor!=m_cacheData.end();mItor++)
|
||||||
|
{
|
||||||
|
if(mItor.key()==orgRow)
|
||||||
|
{
|
||||||
|
mapValue=mItor.value();
|
||||||
|
m_cacheData.erase(mItor);
|
||||||
|
m_cacheData.insert(movRow,mapValue);
|
||||||
|
mItor=m_cacheData.begin();
|
||||||
|
}
|
||||||
|
itor=mItor->begin();
|
||||||
|
for(;itor!=mItor->end();itor++)
|
||||||
|
{
|
||||||
|
if(itor.key()==orgCol)
|
||||||
|
{
|
||||||
|
value=itor.value();
|
||||||
|
mItor->erase(itor);
|
||||||
|
mItor->insert(movCol,value);
|
||||||
|
itor=mItor->begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssetCopy::reqCustomComtextMenu(const QPoint &pos)
|
||||||
|
{
|
||||||
|
emit signalReqCustomContextMenu(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssetCopy::onParseData()
|
||||||
|
{
|
||||||
|
// if(type == D_MultWellLogData)
|
||||||
|
// {
|
||||||
|
// int choose = QMessageBox::question(NULL, tr("提示"),
|
||||||
|
// QString(tr("该数据格式下,粘贴后将直接存储,是否粘贴?")),
|
||||||
|
// QMessageBox::Yes | QMessageBox::No);
|
||||||
|
// if(choose == QMessageBox::No)
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// if(!m_pWellLogs.size()) return;
|
||||||
|
// if(NULL == m_menu || NULL == m_menu->parent())
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
|
||||||
|
// if(NULL == m_table)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// QClipboard* pClip = QApplication::clipboard();
|
||||||
|
// QString szText = pClip->text();
|
||||||
|
|
||||||
|
// if(szText.isEmpty())
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// int nSpace = 0;
|
||||||
|
// int nDou=0;
|
||||||
|
// int nTab =0;
|
||||||
|
|
||||||
|
// DepthProgress MyDepthProgress2;
|
||||||
|
// MyDepthProgress2.CreatProgress(0, szText.size(), "粘贴内容检查中...");
|
||||||
|
|
||||||
|
// for(int nIndex =0;nIndex<szText.size();++nIndex)
|
||||||
|
// {
|
||||||
|
// if(szText[nIndex]=='\t')
|
||||||
|
// {
|
||||||
|
// nTab++;
|
||||||
|
// }
|
||||||
|
// else if(szText[nIndex]==' ')
|
||||||
|
// {
|
||||||
|
// nSpace++;
|
||||||
|
// }
|
||||||
|
// else if(szText[nIndex]==',')
|
||||||
|
// {
|
||||||
|
// nDou++;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// MyDepthProgress2.SetDepth(nIndex);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// int nMax = nSpace>nDou ? nSpace : nDou;
|
||||||
|
// nMax = nMax>nTab ? nMax : nTab;
|
||||||
|
|
||||||
|
// char rFlag;
|
||||||
|
// if(nMax==nTab)
|
||||||
|
// {
|
||||||
|
// rFlag ='\t';
|
||||||
|
// }
|
||||||
|
// else if(nMax==nSpace)
|
||||||
|
// {
|
||||||
|
// rFlag =' ';
|
||||||
|
// }
|
||||||
|
// else if(nMax==nDou)
|
||||||
|
// {
|
||||||
|
// rFlag =',';
|
||||||
|
// }
|
||||||
|
// m_table->clearSelection();
|
||||||
|
// QStringList rSplitList = szText.split('\n');
|
||||||
|
// if(rSplitList.size()&&rSplitList[rSplitList.size()-1]=="") rSplitList.removeAt(rSplitList.size()-1);
|
||||||
|
// CObjWellLogWavefile *pWaveValue=NULL;
|
||||||
|
// pWaveValue=dynamic_cast<CObjWellLogWavefile *>(m_pWellLogs[0]);
|
||||||
|
// CObjWellLogTABLE *pTableValue=NULL;
|
||||||
|
// pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
|
||||||
|
// CObjDiscreteWellLog *pTableValue1=NULL;
|
||||||
|
// pTableValue1=dynamic_cast<CObjDiscreteWellLog *>(m_pWellLogs[0]);
|
||||||
|
// float stdep=999999;
|
||||||
|
|
||||||
|
// for(int i=0;i<m_pWellLogs.size();i++) {
|
||||||
|
// if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep) stdep=m_pWellLogs[i]->acurveinfo.StartDepth;
|
||||||
|
// }
|
||||||
|
// float dep=0;
|
||||||
|
|
||||||
|
// //起始行
|
||||||
|
// int nCurrentRow = m_table->currentRow();
|
||||||
|
|
||||||
|
// //纵向扩充表格
|
||||||
|
// MyDepthProgress2.CreatProgress(0, rSplitList.size(), "表格建设中...");
|
||||||
|
// MyDepthProgress2.SetDepth(0);
|
||||||
|
// for(int cTemp = nCurrentRow; cTemp < (nCurrentRow + rSplitList.size()); cTemp++){
|
||||||
|
// if(cTemp >= m_table->rowCount())
|
||||||
|
// needANewLine(cTemp);
|
||||||
|
|
||||||
|
// MyDepthProgress2.SetDepth(cTemp - nCurrentRow);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //进度条
|
||||||
|
// int curprogre = 0;
|
||||||
|
// MyDepthProgress2.CreatProgress(0, rSplitList.size(), "数据归位...");
|
||||||
|
// MyDepthProgress2.SetDepth(0);
|
||||||
|
|
||||||
|
// for(int nRow = 0; nRow < rSplitList.size(); ++nRow)
|
||||||
|
// {
|
||||||
|
// if(!pTableValue)
|
||||||
|
// dep = stdep + (m_verScrolValue + nCurrentRow) * m_pWellLogs[0]->acurveinfo.DepLevel;
|
||||||
|
|
||||||
|
// //起始列
|
||||||
|
// int nCurrentColumn = m_table->currentColumn();
|
||||||
|
|
||||||
|
// QStringList rColumnList = rSplitList[nRow].split(rFlag);
|
||||||
|
|
||||||
|
// for(int nCol = 0; nCol < rColumnList.size(); nCol++)
|
||||||
|
// {
|
||||||
|
// if(pTableValue||pTableValue1) {
|
||||||
|
// //空替换
|
||||||
|
// if(rColumnList[nCol].isEmpty() ) rColumnList[nCol] = "";
|
||||||
|
// auto pItem = m_table->item(nCurrentRow, nCurrentColumn);
|
||||||
|
|
||||||
|
// //写值
|
||||||
|
// if(pItem)
|
||||||
|
// pItem->setText(rColumnList[nCol]);
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// QTableWidgetItem* pItem = new QTableWidgetItem;
|
||||||
|
// pItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
|
||||||
|
// pItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);//对齐
|
||||||
|
// if(nCurrentColumn == 0) pItem->setFlags(pItem->flags() & (~Qt::ItemIsEditable));
|
||||||
|
// pItem->setFont(QFont("Times",10));
|
||||||
|
|
||||||
|
// m_table->setItem(nCurrentRow, nCurrentColumn, pItem);
|
||||||
|
|
||||||
|
// pItem->setText(rColumnList[nCol]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else if(nCurrentColumn){
|
||||||
|
// float val=rColumnList[nCol].toFloat();
|
||||||
|
// if(pWaveValue) pWaveValue->SetData(dep,m_horScrolValue+nCurrentColumn-1,&val);
|
||||||
|
// else m_pWellLogs[m_horScrolValue+nCurrentColumn-1]->SetData(dep,&val);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// nCurrentColumn++;
|
||||||
|
|
||||||
|
// MyDepthProgress2.SetDepth(++curprogre);
|
||||||
|
// }
|
||||||
|
// nCurrentRow++;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// if(!pTableValue)
|
||||||
|
// for(int i=0;i<m_pWellLogs.size();i++)
|
||||||
|
// {
|
||||||
|
// m_pWellLogs[i]->SetModify(true);
|
||||||
|
// m_pWellLogs[i]->SaveToSLF();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// emit saveToTempModel();
|
||||||
|
|
||||||
|
/*
|
||||||
|
CBaseDialog *pTableDialog=(CBaseDialog*)(m_table->parent());
|
||||||
|
if(pTableDialog) {
|
||||||
|
//粘贴操作不直接保存,刷新操作会重新读表格数据
|
||||||
|
//pTableDialog->ReFreshWindow(type);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssetCopy::initPopMenu(QTableWidget *pTable, QMenu *pmenu)
|
||||||
|
{
|
||||||
|
if(pmenu == NULL)
|
||||||
|
m_menu = new QMenu(pTable);
|
||||||
|
else
|
||||||
|
m_menu = pmenu;
|
||||||
|
|
||||||
|
QIcon icon = QIcon(::GetImagePath() + "/UIMake/fuzhi.png");
|
||||||
|
QAction* action = m_menu->addAction(icon, "复制选中数据");
|
||||||
|
connect(action,SIGNAL(triggered()),this,SLOT(onCopyData()));
|
||||||
|
|
||||||
|
icon = QIcon(::GetImagePath() + "/UIMake/Hfuzhi.png");
|
||||||
|
action = m_menu->addAction(icon, "复制选中行数据");
|
||||||
|
connect(action,SIGNAL(triggered()),this,SLOT(onCopyLinesData()));
|
||||||
|
|
||||||
|
icon = QIcon(::GetImagePath() + "/UIMake/Vfuzhi.png");
|
||||||
|
action = m_menu->addAction(icon, "复制选中列数据");
|
||||||
|
connect(action,SIGNAL(triggered()),this,SLOT(onCopyColnumsData()));
|
||||||
|
|
||||||
|
icon = QIcon(::GetImagePath() + "/UIMake/pas.png");
|
||||||
|
action = m_menu->addAction(icon, "粘贴");
|
||||||
|
connect(action,SIGNAL(triggered()),this,SLOT(onParseData()));
|
||||||
|
|
||||||
|
connect(this,SIGNAL(signalReqCustomContextMenu(QPoint)),this,SLOT(onCustomContextMenuRequested(QPoint)),Qt::UniqueConnection);
|
||||||
|
}
|
||||||
3576
WellLogUI/src/griddataadapter.cpp
Normal file
3576
WellLogUI/src/griddataadapter.cpp
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -1,7 +1,9 @@
|
||||||
#include "formhead.h"
|
#include "formhead.h"
|
||||||
#include "ui_formhead.h"
|
#include "ui_formhead.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QDebug>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QClipboard>
|
||||||
#include "CallManage.h"
|
#include "CallManage.h"
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
@ -26,15 +28,27 @@ FormHead::FormHead(QWidget *parent, int indexID) :
|
||||||
QTableView::item {border-right: 0px solid black;} \
|
QTableView::item {border-right: 0px solid black;} \
|
||||||
QTableView::item:selected {border-right: 0px solid black;}");
|
QTableView::item:selected {border-right: 0px solid black;}");
|
||||||
|
|
||||||
//使能右键菜单功能
|
//
|
||||||
|
//ui->tableWidget->verticalHeader()->hide(); //行
|
||||||
|
//ui->tableWidget->horizontalHeader()->hide(); //列
|
||||||
|
ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
|
||||||
|
ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度
|
||||||
|
//ui->tableWidget->setColumnCount(1); //动态设置列数
|
||||||
|
//ui->tableWidget->horizontalHeader()->setStretchLastSection(true);//最后一列铺满最后
|
||||||
|
//标题
|
||||||
|
// QTableWidgetItem *headerItem = new QTableWidgetItem("");
|
||||||
|
// ui->tableWidget->setHorizontalHeaderItem(0, headerItem);
|
||||||
|
//我们让一列也可以滑动
|
||||||
|
ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
|
ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
|
// 设置右键菜单策略
|
||||||
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
|
||||||
|
// 在窗口构造函数中
|
||||||
|
//ui->tableWidget->installEventFilter(this);
|
||||||
|
|
||||||
// 连接信号和槽
|
// 连接信号和槽
|
||||||
|
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
|
||||||
// 创建并设置定时器
|
|
||||||
// m_timer = new QTimer(this);
|
|
||||||
// connect(m_timer, &QTimer::timeout, this, &FormHead::resizeWindow);
|
|
||||||
// m_timer->start(5); // 设置定时器为5毫秒
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FormHead::~FormHead()
|
FormHead::~FormHead()
|
||||||
|
|
@ -48,13 +62,12 @@ void FormHead::resizeWindow()
|
||||||
//调整大小
|
//调整大小
|
||||||
if(rect.width()>m_iCols*g_iColsWidth)
|
if(rect.width()>m_iCols*g_iColsWidth)
|
||||||
{
|
{
|
||||||
ui->tableWidget->setGeometry((rect.width()-(m_iCols*g_iColsWidth+1))/2, 0, m_iCols*(g_iColsWidth+1), m_iRows*(g_iRowsHight+2));
|
ui->tableWidget->setGeometry((rect.width()-(m_iCols*g_iColsWidth+1))/2, 0, m_iCols*(g_iColsWidth+1)+4, m_iRows*(g_iRowsHight+2)+4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->tableWidget->setGeometry(0, 0, m_iCols*(g_iColsWidth+1), m_iRows*(g_iRowsHight+2));
|
ui->tableWidget->setGeometry(0, 0, m_iCols*(g_iColsWidth+1)+4, m_iRows*(g_iRowsHight+2)+4);
|
||||||
}
|
}
|
||||||
//m_timer->stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormHead::resizeEvent(QResizeEvent *event)
|
void FormHead::resizeEvent(QResizeEvent *event)
|
||||||
|
|
@ -69,8 +82,8 @@ void FormHead::Init(int iRows, int iCols, int iWidth)
|
||||||
|
|
||||||
//清空
|
//清空
|
||||||
ui->tableWidget->clearContents();
|
ui->tableWidget->clearContents();
|
||||||
ui->tableWidget->verticalHeader()->hide();//隐藏左侧系统序号栏
|
//ui->tableWidget->verticalHeader()->hide();//隐藏左侧系统序号栏
|
||||||
ui->tableWidget->horizontalHeader()->hide();//隐藏上方系统序号栏
|
//ui->tableWidget->horizontalHeader()->hide();//隐藏上方系统序号栏
|
||||||
//ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
|
//ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
|
||||||
//ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度
|
//ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度
|
||||||
|
|
||||||
|
|
@ -95,3 +108,257 @@ void FormHead::Init(int iRows, int iCols, int iWidth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormHead::slotContextMenu(QPoint pos)
|
||||||
|
{
|
||||||
|
QMenu menu(ui->tableWidget);
|
||||||
|
QAction *mergeAction = menu.addAction("合并表格");
|
||||||
|
QAction *refreshAction = menu.addAction("拆分表格");
|
||||||
|
QAction *deleteAction = menu.addAction("删除行");
|
||||||
|
QAction *addAction = menu.addAction("添加行");
|
||||||
|
|
||||||
|
// 弹出菜单
|
||||||
|
QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
|
||||||
|
|
||||||
|
if (selectedAction == mergeAction) {
|
||||||
|
qDebug() << "合并表格";
|
||||||
|
slotMerge();
|
||||||
|
} else if (selectedAction == deleteAction) {
|
||||||
|
//删除1行
|
||||||
|
int row = ui->tableWidget->currentRow();
|
||||||
|
ui->tableWidget->removeRow(row);
|
||||||
|
} else if (selectedAction == refreshAction) {
|
||||||
|
qDebug() << "拆分表格";
|
||||||
|
slotSplit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//合并
|
||||||
|
void FormHead::slotMerge()
|
||||||
|
{
|
||||||
|
QModelIndexList list = ui->tableWidget->selectionModel()->selectedIndexes();
|
||||||
|
if (list.size() < 2)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "单元格合并", "所选中单元格中为单个单元格,无法合并", "确定");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int topRow = 0;
|
||||||
|
int leftCol = 0;
|
||||||
|
int bottomRow = 0;
|
||||||
|
int rightCol = 0;
|
||||||
|
|
||||||
|
QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
|
||||||
|
|
||||||
|
if (selectRanges.size() > 0)
|
||||||
|
{
|
||||||
|
topRow = selectRanges[0].topRow();
|
||||||
|
leftCol = selectRanges[0].leftColumn();
|
||||||
|
bottomRow = selectRanges[0].bottomRow();
|
||||||
|
rightCol = selectRanges[0].rightColumn();
|
||||||
|
}
|
||||||
|
for(auto range:selectRanges)
|
||||||
|
{
|
||||||
|
if(range.topRow()<topRow)
|
||||||
|
topRow=range.topRow();
|
||||||
|
if(range.leftColumn()<leftCol)
|
||||||
|
leftCol=range.leftColumn();
|
||||||
|
if(range.bottomRow()> bottomRow)
|
||||||
|
bottomRow=range.bottomRow();
|
||||||
|
if(range.rightColumn()>rightCol)
|
||||||
|
rightCol=range.rightColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
int rowSpan = (bottomRow - topRow) + 1;
|
||||||
|
int colSpan = (rightCol - leftCol) + 1;
|
||||||
|
ui->tableWidget->setSpan(topRow, leftCol, rowSpan, colSpan);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//拆分
|
||||||
|
void FormHead::slotSplit()
|
||||||
|
{
|
||||||
|
int row,col;
|
||||||
|
QList<QTableWidgetSelectionRange> selectRanges = ui->tableWidget->selectedRanges();
|
||||||
|
if (selectRanges.size() < 2)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "拆分表格失败", "单元格已是最小单位,不能再进行拆分", "确定");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QList<QTableWidgetItem*> selectItems = ui->tableWidget->selectedItems();
|
||||||
|
if(selectItems.size()==0)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "拆分表格失败", "请先为表格设置元素item", "确定");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(selectItems.size()>1)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, "拆分表格失败", "非法选择", "确定");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(auto item:selectItems)
|
||||||
|
{
|
||||||
|
row= item->row();
|
||||||
|
col=item->column();
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->tableWidget->setSpan(row, col, 1, 1); // 设置跨度为1
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FormHead::eventFilter(QObject* obj, QEvent* event)
|
||||||
|
{
|
||||||
|
if (obj == ui->tableWidget && event->type() == QEvent::KeyPress) {
|
||||||
|
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||||
|
if (keyEvent->matches(QKeySequence::Paste)) {
|
||||||
|
onPasteExcelData();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QWidget::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//复制粘贴事件
|
||||||
|
void FormHead::keyPressEvent(QKeyEvent * event)
|
||||||
|
{
|
||||||
|
//excel 行分是 "\n" ; 列分是 "\t"
|
||||||
|
if (event->matches(QKeySequence::Copy))
|
||||||
|
{
|
||||||
|
copy();
|
||||||
|
}
|
||||||
|
else if (event->matches(QKeySequence::Paste))
|
||||||
|
{
|
||||||
|
Paste();
|
||||||
|
}
|
||||||
|
else if (event->matches(QKeySequence::SelectAll))
|
||||||
|
{
|
||||||
|
ui->tableWidget->selectAll();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormHead::copy()
|
||||||
|
{
|
||||||
|
QMap<int, QList<int>> selMap;//行,列
|
||||||
|
QList<QTableWidgetItem*> list = ui->tableWidget->selectedItems();
|
||||||
|
if (list.count() <= 0)
|
||||||
|
return;
|
||||||
|
for (QTableWidgetItem* item : list)
|
||||||
|
{
|
||||||
|
int rowN = ui->tableWidget->row(item);
|
||||||
|
int colN = ui->tableWidget->column(item);
|
||||||
|
selMap[rowN].append(colN);
|
||||||
|
}
|
||||||
|
QString cpStr;
|
||||||
|
QMap<int, QList<int>>::iterator it = selMap.begin();
|
||||||
|
while (it != selMap.end())
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (*it).count(); i++)
|
||||||
|
{
|
||||||
|
QTableWidgetItem* item = ui->tableWidget->item(it.key(), (*it).at(i));
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
cpStr.append(item->text().trimmed());
|
||||||
|
}
|
||||||
|
if (i != (*it).count() - 1)
|
||||||
|
cpStr.append("\t");
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
if (it != selMap.end())
|
||||||
|
{
|
||||||
|
cpStr.append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QApplication::clipboard()->setText(cpStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormHead::Paste()
|
||||||
|
{
|
||||||
|
QString pastText = QApplication::clipboard()->text();
|
||||||
|
QStringList rowList = pastText.split("\n", QString::KeepEmptyParts);
|
||||||
|
if(rowList.size()==0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(rowList.at(rowList.size()-1)=="")
|
||||||
|
{
|
||||||
|
rowList.removeAt(rowList.size()-1);
|
||||||
|
}
|
||||||
|
QTableWidgetItem* crtItem = ui->tableWidget->currentItem();
|
||||||
|
int rowN, colN;
|
||||||
|
if (!crtItem)
|
||||||
|
{
|
||||||
|
rowN = ui->tableWidget->currentRow();
|
||||||
|
colN = ui->tableWidget->currentColumn();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rowN = ui->tableWidget->row(crtItem);
|
||||||
|
colN = ui->tableWidget->column(crtItem);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < (ui->tableWidget->rowCount() - rowN) && (i < rowList.length()); i++)
|
||||||
|
{
|
||||||
|
QStringList rowDataList = rowList.at(i).split("\t", QString::KeepEmptyParts);
|
||||||
|
for (int j = 0; j < (ui->tableWidget->columnCount() - colN) && (j < rowDataList.length()); j++)
|
||||||
|
{
|
||||||
|
int x = i + rowN;
|
||||||
|
int y = j + colN;
|
||||||
|
|
||||||
|
QTableWidgetItem* item = ui->tableWidget->item(x, y);
|
||||||
|
if (item)
|
||||||
|
{
|
||||||
|
item->setText(rowDataList.at(j));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->tableWidget->setItem(x, y, new QTableWidgetItem(rowDataList.at(j)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormHead::onPasteExcelData()
|
||||||
|
{
|
||||||
|
// QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
// const QString clipData = clipboard->text();
|
||||||
|
|
||||||
|
// if (clipData.isEmpty()) return;
|
||||||
|
|
||||||
|
// QList<QStringList> rowsData;
|
||||||
|
// const QStringList rows = clipData.split('\n', QString::SkipEmptyParts);
|
||||||
|
// for (const QString row:rows) {
|
||||||
|
// rowsData << row.split('\t', QString::SkipEmptyParts);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// QTableWidget* table = ui->tableWidget;
|
||||||
|
// const QModelIndex currentIndex = table->currentIndex();
|
||||||
|
// const int startRow = currentIndex.isValid() ? currentIndex.row() : 0;
|
||||||
|
// const int startCol = currentIndex.isValid() ? currentIndex.column() : 0;
|
||||||
|
|
||||||
|
// table->setUpdatesEnabled(false);
|
||||||
|
// table->setRowCount(std::max(table->rowCount(), startRow + rowsData.size()));
|
||||||
|
// table->setColumnCount(std::max(table->columnCount(), startCol + rowsData[0].size()));
|
||||||
|
// //更新行数,列数
|
||||||
|
// m_iRows = table->rowCount();
|
||||||
|
// m_iCols = table->columnCount();
|
||||||
|
|
||||||
|
// for (int i = 0; i < rowsData.size(); ++i) {
|
||||||
|
// for (int j = 0; j < rowsData[i].size(); ++j) {
|
||||||
|
// if (startRow + i >= table->rowCount()) break;
|
||||||
|
// if (startCol + j >= table->columnCount()) break;
|
||||||
|
|
||||||
|
// QTableWidgetItem* item = table->item(startRow + i, startCol + j);
|
||||||
|
// if (!item) {
|
||||||
|
// item = new QTableWidgetItem();
|
||||||
|
// table->setItem(startRow + i, startCol + j, item);
|
||||||
|
// }
|
||||||
|
// item->setText(rowsData[i][j]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// table->setUpdatesEnabled(true);
|
||||||
|
// //改变大小
|
||||||
|
// resizeWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,19 @@ public:
|
||||||
private:
|
private:
|
||||||
Ui::FormHead *ui;
|
Ui::FormHead *ui;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//支持复制粘贴,暂时还未实现
|
||||||
|
void keyPressEvent(QKeyEvent * e);
|
||||||
|
|
||||||
|
public:
|
||||||
|
//图头
|
||||||
|
bool eventFilter(QObject* obj, QEvent* event);
|
||||||
|
void onPasteExcelData();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int m_indexID;
|
int m_indexID;
|
||||||
int m_iRows;
|
int m_iRows;
|
||||||
int m_iCols;
|
int m_iCols;
|
||||||
QTimer *m_timer;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Init(int iRows, int iCols, int iWidth);
|
void Init(int iRows, int iCols, int iWidth);
|
||||||
|
|
@ -34,6 +42,13 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void resizeWindow();
|
void resizeWindow();
|
||||||
|
|
||||||
|
//图头右键菜单响应函数
|
||||||
|
void slotContextMenu(QPoint pos);
|
||||||
|
void slotMerge();//合并
|
||||||
|
void slotSplit();//拆分
|
||||||
|
//图头
|
||||||
|
void copy();
|
||||||
|
void Paste();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FORMHEAD_H
|
#endif // FORMHEAD_H
|
||||||
|
|
|
||||||
172
logPlus/formmultiheads.cpp
Normal file
172
logPlus/formmultiheads.cpp
Normal file
|
|
@ -0,0 +1,172 @@
|
||||||
|
#include "formmultiheads.h"
|
||||||
|
#include "ui_formmultiheads.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMenu>
|
||||||
|
#include "newheaddialog.h"
|
||||||
|
#include "formhead.h"
|
||||||
|
|
||||||
|
extern int g_iRows;
|
||||||
|
extern int g_iCols;
|
||||||
|
extern int g_iColsWidth;
|
||||||
|
extern int g_iRowsHight;
|
||||||
|
|
||||||
|
FormMultiHeads::FormMultiHeads(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::FormMultiHeads)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
//-------------------------------------
|
||||||
|
//ui->tableWidget->hide();
|
||||||
|
//隐藏网格线
|
||||||
|
ui->tableWidget->setShowGrid(false);
|
||||||
|
//设置样式表,不显示竖直边框
|
||||||
|
ui->tableWidget->setStyleSheet( "QTableView::item {border-left: 0px solid black;} \
|
||||||
|
QTableView::item:selected {border-left: 0px solid black;}\
|
||||||
|
QTableView::item {border-right: 0px solid black;} \
|
||||||
|
QTableView::item:selected {border-right: 0px solid black;}");
|
||||||
|
//
|
||||||
|
//ui->tableWidget->verticalHeader()->hide(); //行
|
||||||
|
//ui->tableWidget->horizontalHeader()->hide(); //列
|
||||||
|
ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
|
||||||
|
ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度
|
||||||
|
ui->tableWidget->setColumnCount(1); //动态设置列数
|
||||||
|
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);//最后一列铺满最后
|
||||||
|
//标题
|
||||||
|
QTableWidgetItem *headerItem = new QTableWidgetItem("");
|
||||||
|
ui->tableWidget->setHorizontalHeaderItem(0, headerItem);
|
||||||
|
//我们让一列也可以滑动
|
||||||
|
ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
|
ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
|
// 设置右键菜单策略
|
||||||
|
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
|
||||||
|
// 在窗口构造函数中
|
||||||
|
//ui->tableWidget->installEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
FormMultiHeads::~FormMultiHeads()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormMultiHeads::slotContextMenu(QPoint pos)
|
||||||
|
{
|
||||||
|
QMenu menu(ui->tableWidget);
|
||||||
|
QAction *newAction = menu.addAction("新建图头");
|
||||||
|
// 弹出菜单
|
||||||
|
QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
|
||||||
|
if (selectedAction == newAction) {
|
||||||
|
NewHeadDialog *dlg = new NewHeadDialog(this);
|
||||||
|
//
|
||||||
|
dlg->setAttribute(Qt::WA_DeleteOnClose);//关闭时,自动删除窗口对象
|
||||||
|
int result = dlg->exec();//模态对话框
|
||||||
|
if (result == QDialog::Accepted) {
|
||||||
|
// 处理用户点击了确定按钮的逻辑
|
||||||
|
qDebug() << "Accepted=";
|
||||||
|
|
||||||
|
int rowcount = ui->tableWidget->rowCount(); //总行数
|
||||||
|
//增加1行
|
||||||
|
ui->tableWidget->setRowCount(rowcount+1);
|
||||||
|
//行标题
|
||||||
|
QTableWidgetItem *headerItem = new QTableWidgetItem("");
|
||||||
|
ui->tableWidget->setVerticalHeaderItem(rowcount, headerItem);
|
||||||
|
|
||||||
|
int iWidth=0;
|
||||||
|
//设置行高度
|
||||||
|
ui->tableWidget->setRowHeight(rowcount, g_iRows*(g_iRowsHight+2)+1);
|
||||||
|
if(rowcount==0)
|
||||||
|
{
|
||||||
|
iWidth=g_iCols*g_iColsWidth;
|
||||||
|
//设置列宽
|
||||||
|
ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iWidth=ui->tableWidget->columnWidth(0);
|
||||||
|
if(iWidth<g_iCols*g_iColsWidth)//列宽变大
|
||||||
|
{
|
||||||
|
iWidth=g_iCols*g_iColsWidth;
|
||||||
|
//设置列宽
|
||||||
|
ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
FormHead *widgetHead = new FormHead(this, 1);
|
||||||
|
widgetHead->Init(g_iRows, g_iCols, iWidth);
|
||||||
|
ui->tableWidget->setCellWidget(rowcount, 0, widgetHead);
|
||||||
|
}
|
||||||
|
else if (result == QDialog::Rejected) {
|
||||||
|
// 处理用户点击了取消按钮的逻辑
|
||||||
|
qDebug() << "Rejected=";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 处理其他情况的逻辑
|
||||||
|
qDebug() << "other=";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if(ui->tableWidget->rowCount()==0 && ui->tableWidget->rowCount()==0)
|
||||||
|
// {
|
||||||
|
// QMenu menu(ui->tableWidget);
|
||||||
|
// QAction *newAction = menu.addAction("新建图头");
|
||||||
|
// // 弹出菜单
|
||||||
|
// QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
|
||||||
|
// if (selectedAction == newAction) {
|
||||||
|
// NewHeadDialog *dlg = new NewHeadDialog(this);
|
||||||
|
// //
|
||||||
|
// dlg->setAttribute(Qt::WA_DeleteOnClose);//关闭时,自动删除窗口对象
|
||||||
|
// int result = dlg->exec();//模态对话框
|
||||||
|
// if (result == QDialog::Accepted) {
|
||||||
|
// // 处理用户点击了确定按钮的逻辑
|
||||||
|
// qDebug() << "Accepted=";
|
||||||
|
// //
|
||||||
|
// ui->tableWidget->clear();
|
||||||
|
// //
|
||||||
|
// ui->tableWidget->setColumnCount(g_iCols);
|
||||||
|
// ui->tableWidget->setRowCount(g_iRows); //动态设置行数
|
||||||
|
// for(int i=0; i<g_iRows; i++)
|
||||||
|
// {
|
||||||
|
// for(int j=0; j<g_iCols; j++)
|
||||||
|
// {
|
||||||
|
// QTableWidgetItem* item = new QTableWidgetItem("");
|
||||||
|
// ui->tableWidget->setItem(i, j, item);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else if (result == QDialog::Rejected) {
|
||||||
|
// // 处理用户点击了取消按钮的逻辑
|
||||||
|
// qDebug() << "Rejected=";
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// // 处理其他情况的逻辑
|
||||||
|
// qDebug() << "other=";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// QMenu menu(ui->tableWidget);
|
||||||
|
// QAction *mergeAction = menu.addAction("合并表格");
|
||||||
|
// QAction *refreshAction = menu.addAction("拆分表格");
|
||||||
|
// QAction *deleteAction = menu.addAction("删除行");
|
||||||
|
// QAction *addAction = menu.addAction("添加行");
|
||||||
|
|
||||||
|
// // 弹出菜单
|
||||||
|
// QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
|
||||||
|
|
||||||
|
// if (selectedAction == mergeAction) {
|
||||||
|
// qDebug() << "合并表格";
|
||||||
|
// slotMerge();
|
||||||
|
// } else if (selectedAction == deleteAction) {
|
||||||
|
// //删除1行
|
||||||
|
// int row = ui->tableWidget->currentRow();
|
||||||
|
// ui->tableWidget->removeRow(row);
|
||||||
|
// } else if (selectedAction == refreshAction) {
|
||||||
|
// qDebug() << "拆分表格";
|
||||||
|
// slotSplit();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
29
logPlus/formmultiheads.h
Normal file
29
logPlus/formmultiheads.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef FORMMULTIHEADS_H
|
||||||
|
#define FORMMULTIHEADS_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class FormMultiHeads;
|
||||||
|
}
|
||||||
|
|
||||||
|
class FormMultiHeads : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit FormMultiHeads(QWidget *parent = nullptr);
|
||||||
|
~FormMultiHeads();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::FormMultiHeads *ui;
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
//图头右键菜单响应函数
|
||||||
|
void slotContextMenu(QPoint pos);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FORMMULTIHEADS_H
|
||||||
36
logPlus/formmultiheads.ui
Normal file
36
logPlus/formmultiheads.ui
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>FormMultiHeads</class>
|
||||||
|
<widget class="QWidget" name="FormMultiHeads">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>18</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>18</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTableWidget" name="tableWidget"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
|
|
@ -40,6 +40,7 @@ SOURCES += \
|
||||||
formhead.cpp \
|
formhead.cpp \
|
||||||
forminfo.cpp \
|
forminfo.cpp \
|
||||||
formline.cpp \
|
formline.cpp \
|
||||||
|
formmultiheads.cpp \
|
||||||
formtrack.cpp \
|
formtrack.cpp \
|
||||||
formwell.cpp \
|
formwell.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
|
|
@ -72,6 +73,7 @@ HEADERS += \
|
||||||
formhead.h \
|
formhead.h \
|
||||||
forminfo.h \
|
forminfo.h \
|
||||||
formline.h \
|
formline.h \
|
||||||
|
formmultiheads.h \
|
||||||
formtrack.h \
|
formtrack.h \
|
||||||
formwell.h \
|
formwell.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
|
|
@ -93,6 +95,7 @@ FORMS += \
|
||||||
formhead.ui \
|
formhead.ui \
|
||||||
forminfo.ui \
|
forminfo.ui \
|
||||||
formline.ui \
|
formline.ui \
|
||||||
|
formmultiheads.ui \
|
||||||
formtrack.ui \
|
formtrack.ui \
|
||||||
formwell.ui \
|
formwell.ui \
|
||||||
interfaceWidget.ui \
|
interfaceWidget.ui \
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "qtprojectwidgets.h"
|
#include "qtprojectwidgets.h"
|
||||||
#include "qtcenterwidgets.h"
|
#include "qtcenterwidgets.h"
|
||||||
#include "mainwindownew.h"
|
|
||||||
#include "mainwindowcurve.h"
|
#include "mainwindowcurve.h"
|
||||||
#include "customtabwidget.h"
|
#include "customtabwidget.h"
|
||||||
#include "ConsoleOutputWidget.h"
|
#include "ConsoleOutputWidget.h"
|
||||||
|
|
@ -47,10 +46,10 @@ public:
|
||||||
|
|
||||||
//停靠栏
|
//停靠栏
|
||||||
QStackedWidget *m_stackedWidget_Center = nullptr;//中间工作区stack
|
QStackedWidget *m_stackedWidget_Center = nullptr;//中间工作区stack
|
||||||
QDockWidget *m_projectView = nullptr; //左侧工程区
|
//QDockWidget *m_projectView = nullptr; //左侧工程区
|
||||||
QDockWidget *m_propertyView = nullptr; //右侧属性区
|
//QDockWidget *m_propertyView = nullptr; //属性区
|
||||||
QDockWidget *m_logView = nullptr; //下方日志区
|
//QDockWidget *m_logView = nullptr; //日志区
|
||||||
QDockWidget *m_gdbView = nullptr; //下方调试区
|
//QDockWidget *m_gdbView = nullptr; //调试区
|
||||||
|
|
||||||
//子页面
|
//子页面
|
||||||
QtProjectWidgets *m_projectWidgets; //左侧工程区
|
QtProjectWidgets *m_projectWidgets; //左侧工程区
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
#include "newheaddialog.h"
|
#include "newheaddialog.h"
|
||||||
#include "formhead.h"
|
#include "formhead.h"
|
||||||
#include "qmytablewidget.h"
|
//#include "qmytablewidget.h"
|
||||||
|
|
||||||
extern int g_iOneWidth; //道宽
|
extern int g_iOneWidth; //道宽
|
||||||
extern QString g_prjname;
|
extern QString g_prjname;
|
||||||
|
|
@ -45,31 +45,31 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
ui->tableWidget->hide();
|
ui->tableWidget->hide();
|
||||||
//隐藏网格线
|
// //隐藏网格线
|
||||||
ui->tableWidget->setShowGrid(false);
|
// ui->tableWidget->setShowGrid(false);
|
||||||
//设置样式表,不显示竖直边框
|
// //设置样式表,不显示竖直边框
|
||||||
ui->tableWidget->setStyleSheet( "QTableView::item {border-left: 0px solid black;} \
|
// ui->tableWidget->setStyleSheet( "QTableView::item {border-left: 0px solid black;} \
|
||||||
QTableView::item:selected {border-left: 0px solid black;}\
|
// QTableView::item:selected {border-left: 0px solid black;}\
|
||||||
QTableView::item {border-right: 0px solid black;} \
|
// QTableView::item {border-right: 0px solid black;} \
|
||||||
QTableView::item:selected {border-right: 0px solid black;}");
|
// QTableView::item:selected {border-right: 0px solid black;}");
|
||||||
//
|
// //
|
||||||
ui->tableWidget->verticalHeader()->hide(); //行
|
// ui->tableWidget->verticalHeader()->hide(); //行
|
||||||
ui->tableWidget->horizontalHeader()->hide(); //列
|
// ui->tableWidget->horizontalHeader()->hide(); //列
|
||||||
//ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
|
// //ui->tableWidget->verticalHeader()->setFixedWidth(3);//标题栏宽度
|
||||||
//ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度
|
// //ui->tableWidget->horizontalHeader()->setFixedHeight(3);//标题栏高度
|
||||||
ui->tableWidget->setColumnCount(1); //动态设置列数
|
// ui->tableWidget->setColumnCount(1); //动态设置列数
|
||||||
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);//最后一列铺满最后
|
// ui->tableWidget->horizontalHeader()->setStretchLastSection(true);//最后一列铺满最后
|
||||||
//标题
|
// //标题
|
||||||
QTableWidgetItem *headerItem = new QTableWidgetItem("");
|
// QTableWidgetItem *headerItem = new QTableWidgetItem("");
|
||||||
ui->tableWidget->setHorizontalHeaderItem(0, headerItem);
|
// ui->tableWidget->setHorizontalHeaderItem(0, headerItem);
|
||||||
//我们让一列也可以滑动
|
// //我们让一列也可以滑动
|
||||||
ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
// ui->tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
// ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
// 设置右键菜单策略
|
// // 设置右键菜单策略
|
||||||
ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
// ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
|
// connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenu(QPoint)));
|
||||||
// 在窗口构造函数中
|
// // 在窗口构造函数中
|
||||||
//ui->tableWidget->installEventFilter(this);
|
// //ui->tableWidget->installEventFilter(this);
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
//ui->tableWidget_2->setFrameShape(QFrame::NoFrame); //设置无边框
|
//ui->tableWidget_2->setFrameShape(QFrame::NoFrame); //设置无边框
|
||||||
|
|
@ -91,11 +91,6 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
||||||
ui->tableWidget_2->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
ui->tableWidget_2->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
ui->tableWidget_2->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
ui->tableWidget_2->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
|
|
||||||
// //表头
|
|
||||||
// QStringList list;
|
|
||||||
// list << "" << "" << "" << "";
|
|
||||||
// ui->tableWidget->setHorizontalHeaderLabels(list);
|
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
ui->tableWidget_3->hide();
|
ui->tableWidget_3->hide();
|
||||||
ui->tableWidget_3->verticalHeader()->hide();
|
ui->tableWidget_3->verticalHeader()->hide();
|
||||||
|
|
@ -106,6 +101,26 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
||||||
connect(this, SIGNAL(sig_NewWell(QString)), this, SLOT(s_NewWell(QString)));
|
connect(this, SIGNAL(sig_NewWell(QString)), this, SLOT(s_NewWell(QString)));
|
||||||
|
|
||||||
connect(CallManage::getInstance(), SIGNAL(sig_mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
connect(CallManage::getInstance(), SIGNAL(sig_mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
|
||||||
|
|
||||||
|
//数据组织与管理树
|
||||||
|
m_dock1=new QDockWidget(tr(""),this);
|
||||||
|
m_dock1->setFeatures(QDockWidget::NoDockWidgetFeatures);//QDockWidget::DockWidgetMovable
|
||||||
|
//dock1->setAllowedAreas(Qt::TopDockWidgetArea);
|
||||||
|
//
|
||||||
|
m_formMultiHeads = new FormMultiHeads(this);
|
||||||
|
m_dock1->setWidget(m_formMultiHeads);
|
||||||
|
addDockWidget(Qt::TopDockWidgetArea,m_dock1);
|
||||||
|
//移除标题栏
|
||||||
|
QWidget* lTitleBar = m_dock1->titleBarWidget();
|
||||||
|
QWidget* lEmptyWidget = new QWidget();
|
||||||
|
m_dock1->setTitleBarWidget(lEmptyWidget);
|
||||||
|
delete lTitleBar;
|
||||||
|
|
||||||
|
//属性编辑器
|
||||||
|
// m_propertyWidget = PropertyService();
|
||||||
|
// m_propertyWidget->setWindowTitle("属性编辑器");
|
||||||
|
// m_propertyWidget->setParent(this);
|
||||||
|
// addDockWidget( Qt::TopDockWidgetArea, m_propertyWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindowCurve::~MainWindowCurve()
|
MainWindowCurve::~MainWindowCurve()
|
||||||
|
|
@ -295,14 +310,22 @@ void MainWindowCurve::s_Save()
|
||||||
//显示/隐藏图头
|
//显示/隐藏图头
|
||||||
void MainWindowCurve::s_showHeadTable()
|
void MainWindowCurve::s_showHeadTable()
|
||||||
{
|
{
|
||||||
if(ui->tableWidget->isVisible())
|
if(m_dock1->isVisible())
|
||||||
{
|
{
|
||||||
ui->tableWidget->hide();
|
m_dock1->hide();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->tableWidget->show();
|
m_dock1->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if(ui->tableWidget->isVisible())
|
||||||
|
// {
|
||||||
|
// ui->tableWidget->hide();
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// ui->tableWidget->show();
|
||||||
|
// }
|
||||||
|
|
||||||
// QTableWidget *tableWidget = new QTableWidget();
|
// QTableWidget *tableWidget = new QTableWidget();
|
||||||
|
|
||||||
// tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
// tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||||
|
|
@ -603,59 +626,60 @@ void MainWindowCurve::dropEvent(QDropEvent* event)
|
||||||
|
|
||||||
void MainWindowCurve::slotContextMenu(QPoint pos)
|
void MainWindowCurve::slotContextMenu(QPoint pos)
|
||||||
{
|
{
|
||||||
QMenu menu(ui->tableWidget);
|
// QMenu menu(ui->tableWidget);
|
||||||
QAction *newAction = menu.addAction("新建图头");
|
// QAction *newAction = menu.addAction("新建图头");
|
||||||
// 弹出菜单
|
// // 弹出菜单
|
||||||
QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
|
// QAction *selectedAction = menu.exec(ui->tableWidget->mapToGlobal(pos));
|
||||||
if (selectedAction == newAction) {
|
// if (selectedAction == newAction) {
|
||||||
NewHeadDialog *dlg = new NewHeadDialog(this);
|
// NewHeadDialog *dlg = new NewHeadDialog(this);
|
||||||
//
|
// //
|
||||||
dlg->setAttribute(Qt::WA_DeleteOnClose);//关闭时,自动删除窗口对象
|
// dlg->setAttribute(Qt::WA_DeleteOnClose);//关闭时,自动删除窗口对象
|
||||||
int result = dlg->exec();//模态对话框
|
// int result = dlg->exec();//模态对话框
|
||||||
if (result == QDialog::Accepted) {
|
// if (result == QDialog::Accepted) {
|
||||||
// 处理用户点击了确定按钮的逻辑
|
// // 处理用户点击了确定按钮的逻辑
|
||||||
qDebug() << "Accepted=";
|
// qDebug() << "Accepted=";
|
||||||
|
|
||||||
int rowcount = ui->tableWidget->rowCount(); //总行数
|
// int rowcount = ui->tableWidget->rowCount(); //总行数
|
||||||
//增加1行
|
// //增加1行
|
||||||
ui->tableWidget->setRowCount(rowcount+1);
|
// ui->tableWidget->setRowCount(rowcount+1);
|
||||||
//行标题
|
// //行标题
|
||||||
QTableWidgetItem *headerItem = new QTableWidgetItem("");
|
// QTableWidgetItem *headerItem = new QTableWidgetItem("");
|
||||||
ui->tableWidget->setVerticalHeaderItem(rowcount, headerItem);
|
// ui->tableWidget->setVerticalHeaderItem(rowcount, headerItem);
|
||||||
|
|
||||||
|
// int iWidth=0;
|
||||||
|
// //设置行高度
|
||||||
|
// ui->tableWidget->setRowHeight(rowcount, g_iRows*(g_iRowsHight+2)+1);
|
||||||
|
// if(rowcount==0)
|
||||||
|
// {
|
||||||
|
// iWidth=g_iCols*g_iColsWidth;
|
||||||
|
// //设置列宽
|
||||||
|
// ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// iWidth=ui->tableWidget->columnWidth(0);
|
||||||
|
// if(iWidth<g_iCols*g_iColsWidth)//列宽变大
|
||||||
|
// {
|
||||||
|
// iWidth=g_iCols*g_iColsWidth;
|
||||||
|
// //设置列宽
|
||||||
|
// ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// //
|
||||||
|
// FormHead *widgetHead = new FormHead(this, 1);
|
||||||
|
// widgetHead->Init(g_iRows, g_iCols, iWidth);
|
||||||
|
// ui->tableWidget->setCellWidget(rowcount, 0, widgetHead);
|
||||||
|
// }
|
||||||
|
// else if (result == QDialog::Rejected) {
|
||||||
|
// // 处理用户点击了取消按钮的逻辑
|
||||||
|
// qDebug() << "Rejected=";
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// // 处理其他情况的逻辑
|
||||||
|
// qDebug() << "other=";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
int iWidth=0;
|
|
||||||
//设置行高度
|
|
||||||
ui->tableWidget->setRowHeight(rowcount, g_iRows*(g_iRowsHight+2)+1);
|
|
||||||
if(rowcount==0)
|
|
||||||
{
|
|
||||||
iWidth=g_iCols*g_iColsWidth;
|
|
||||||
//设置列宽
|
|
||||||
ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iWidth=ui->tableWidget->columnWidth(0);
|
|
||||||
if(iWidth<g_iCols*g_iColsWidth)//列宽变大
|
|
||||||
{
|
|
||||||
iWidth=g_iCols*g_iColsWidth;
|
|
||||||
//设置列宽
|
|
||||||
ui->tableWidget->setColumnWidth(0, g_iCols*(g_iColsWidth+1)+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
FormHead *widgetHead = new FormHead(this, 1);
|
|
||||||
widgetHead->Init(g_iRows, g_iCols, iWidth);
|
|
||||||
ui->tableWidget->setCellWidget(rowcount, 0, widgetHead);
|
|
||||||
}
|
|
||||||
else if (result == QDialog::Rejected) {
|
|
||||||
// 处理用户点击了取消按钮的逻辑
|
|
||||||
qDebug() << "Rejected=";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// 处理其他情况的逻辑
|
|
||||||
qDebug() << "other=";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if(ui->tableWidget->rowCount()==0 && ui->tableWidget->rowCount()==0)
|
// if(ui->tableWidget->rowCount()==0 && ui->tableWidget->rowCount()==0)
|
||||||
// {
|
// {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include "formwell.h"
|
#include "formwell.h"
|
||||||
#include "geometryutils.h"
|
#include "geometryutils.h"
|
||||||
|
#include "formmultiheads.h"
|
||||||
|
|
||||||
#pragma execution_character_set("utf-8")
|
#pragma execution_character_set("utf-8")
|
||||||
|
|
||||||
|
|
@ -41,10 +42,15 @@ public slots:
|
||||||
|
|
||||||
//鼠标滚动,通知可视解释窗口
|
//鼠标滚动,通知可视解释窗口
|
||||||
void s_mouseWheel(QWheelEvent *event);
|
void s_mouseWheel(QWheelEvent *event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString m_strUuid;
|
QString m_strUuid;
|
||||||
QStringList m_listWell;
|
QStringList m_listWell;
|
||||||
|
|
||||||
|
FormMultiHeads *m_formMultiHeads; //左侧工程区
|
||||||
|
|
||||||
|
QDockWidget *m_dock1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//展示所有井
|
//展示所有井
|
||||||
void DisplayWells(QJsonArray wellsArray);
|
void DisplayWells(QJsonArray wellsArray);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user