HGGitLab

Commit 81171da7 authored by luoliangyi's avatar luoliangyi

完善缩略图

parent b54a7a51
......@@ -34,10 +34,10 @@ MainWindow::MainWindow(QWidget *parent)
ui->toolBar->addSeparator();
ui->toolBar->addAction(ui->act_help);
//m_view->move(0, 100);
//m_view->resize(400, height() - 150);
m_thumb->move(00, 100);
m_thumb->resize(800, height() - 150);
m_view->move(0, 100);
m_view->resize(400, height() - 150);
m_thumb->move(450, 100);
m_thumb->resize(200, height() - 150);
HGImage img = NULL;
HGImgFmt_LoadImage("D:\\1.jpg", 0, NULL, HGBASE_IMGTYPE_RGB, HGBASE_IMGORIGIN_TOP, &img);
......@@ -46,7 +46,7 @@ MainWindow::MainWindow(QWidget *parent)
QImage img2("D:\\image.png");
m_thumb->setDefItemImage(&img2);
m_thumb->setType(ThumbType_Grid);
m_thumb->setType(ThumbType_Vert);
for (int i = 0; i < 1000; ++i)
{
......
This diff is collapsed.
......@@ -33,8 +33,11 @@ struct HGImgThumbItem
~HGImgThumbItem()
{
delete image;
image = NULL;
if (NULL != image)
{
delete image;
image = NULL;
}
}
QString fileName;
......@@ -49,10 +52,17 @@ public:
HGImgThumb(QWidget* parent = nullptr);
virtual ~HGImgThumb();
enum MoveStauts
{
MoveStatus_Null = 0,
MoveStatus_HRoll = 1,
MoveStatus_VRoll = 2
};
HGResult setType(ThumbType type);
HGResult setGap(int width);
HGResult zoomIn(const HGPoint *pCenter);
HGResult zoomOut(const HGPoint *pCenter);
HGResult zoomIn();
HGResult zoomOut();
HGResult setDefItemImage(const QImage *image);
HGResult getItemCount(int *count);
......@@ -68,10 +78,10 @@ public:
HGResult updateItem(int index, const QString &fileName);
HGResult refreshItem(int index);
HGResult refreshAllItems();
HGResult locateItem(int index);
signals:
void currentItemChanged(int index);
void itemClicked(int index);
void itemDoubleClicked(int index);
void itemCountChanged(int count);
void itemSelectingChanged();
......@@ -100,13 +110,27 @@ private slots:
private:
static QImage* createItemImage(const QImage *srcImage, int itemSize);
static QImage* createItemImage(HGImage srcImage, int itemSize);
void updateShowRect();
bool wnd2ShowRect(QPoint &pt);
bool showRect2Wnd(QPoint &pt);
bool getItemLoc(int index, QPoint &pt, int &row, int &col);
static void calcShowSize(int wndWidth, int wndHeight, int rollWidth, ThumbType type, int itemSize, int gapWidth, int itemCount,
int &showWidth, int &showHeight, bool &hRoll, bool &vRoll);
static void recalcShowRect(int wndWidth, int wndHeight, int rollWidth, ThumbType type, bool hRoll, bool vRoll, bool showThumb, HGRect &showRect);
void locateItemEx(int index);
QPoint getItemLoc(int index);
int getItemRow(int index);
int getItemCol(int index);
int getTotalRows();
int getTotalCols();
int getItem(const QPoint &pt);
int getInsertPos(const QPoint &pt);
int findIndex(const QString &fileName);
QRect getHRollPos();
QRect getHRollLeftPos();
QRect getHRollRightPos();
QRect getVRollPos();
QRect getVRollTopPos();
QRect getVRollBottomPos();
QRect getHRollSliderPos();
QRect getVRollSliderPos();
QRect getNullRollPos();
void Show();
static void ThreadFunc(HGThread thread, HGPointer param);
......@@ -125,12 +149,17 @@ private:
int m_signItemIndex;
bool m_stopThread;
HGThread m_thread;
std::vector<HGImgThumbItem> m_frontItems;
std::vector<HGImgThumbItem *> m_frontItems;
std::list<QString> m_backList;
bool m_hRoll;
bool m_vRoll;
bool m_showThumb;
HGRect m_showRect;
int m_mousePosX;
int m_mousePosY;
MoveStauts m_moveStatus;
int m_beginX;
int m_beginY;
};
#endif /* __HGIMGTHUMB_HPP__ */
......@@ -28,6 +28,8 @@ HGImgView::~HGImgView()
HGBase_DestroyImage(m_image);
m_image = NULL;
}
qDebug("~HGImgView");
}
HGResult HGImgView::addImage(HGImage image)
......@@ -376,6 +378,11 @@ HGResult HGImgView::showColorInfo(bool show)
void HGImgView::mousePressEvent(QMouseEvent* e)
{
if (e->button() != Qt::LeftButton)
{
return;
}
assert(0 == m_operate);
if (NULL == m_image || !m_showImage)
{
......@@ -479,7 +486,10 @@ void HGImgView::mouseMoveEvent(QMouseEvent* e)
void HGImgView::mouseReleaseEvent(QMouseEvent* e)
{
Q_UNUSED(e);
if (e->button() != Qt::LeftButton)
{
return;
}
m_operate = 0;
m_beginX = -1;
......@@ -489,11 +499,12 @@ void HGImgView::mouseReleaseEvent(QMouseEvent* e)
void HGImgView::enterEvent(QEvent *e)
{
Q_UNUSED(e);
}
void HGImgView::leaveEvent(QEvent *e)
{
Q_UNUSED(e);
m_mousePosX = -1;
m_mousePosY = -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment