2010 -> 2011

明天开始,我就迈向了公元2011年。

首先要感谢祖国和人民,然后要感谢生我养我的父母,再者要感谢陪伴我度过日日夜夜的亲爱的老婆,还要感谢每一个认识我的人……没有你们,我不可能走到今天。

过去的一年。

还清商业贷款。经过我和老婆的努力奋斗,房子的商业贷款终于提前还清了,剩下的公积金贷款,每个月自动扣公积金就好了,也不用着急了。这个算是我过去一年最大的收获,今后的压力会相对小很多。

技术提升。学到了J2EE的很多知识。J2EE是在是博大精深,我只是接触了几多月,还没有达到精通,就被迫做Andorid开发了。对于J2EE,只能说是熟练。但是,对于做项目来说,基本够用了,能够在公司里接触J2EE的开发,我还是比较满足的。学到了Android开发的很多知识。我以前一直以来都是做Java的嵌入式开发的,所以,对于新介入的Android领域,除了API需要熟悉以外,开发起来还是游刃有余的。

过去的一年,也有好多需要反省的地方。一个是,运动少了,身体明显不如以前了,总是感觉很疲劳,去医院越来越频繁,这个让我很担心。一个是,目前的公司是做产品的,没有我想要进入的技术领域。还有就是最令我头痛的英语,因为没有环境,感觉学习的速度小于遗忘的速度,恐怕将来英语会把我堵在好多外企的门外。

未来的一年。

身体最重要,身体是革命的本钱。平时一定多注意,多保养,多运动。

努力去寻找一个技术领域。做管理,在哪里都一样,可是这不是我的目标。做技术,我觉得最好能够找到一个技术领域去专研,这是我的目标。

多读书,少看电视。

英语,还要补。

加上注释,不要分隔/**************************************************************************** ** ** This file is part of the LibreCAD project, a 2D CAD program ** ** Copyright (C) 2010-2011 R. van Twisk (librecad@rvt.dds.nl) ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. ** ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file gpl-2.0.txt included in the ** packaging of this file. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ** ** This copyright notice MUST APPEAR in all copies of the script! ** **********************************************************************/ #include "qg_blockwidget.h" #include <QToolTip> #include <QToolButton> #include <QMenu> #include <QBoxLayout> #include <QLabel> /** * Constructor. */ QG_BlockWidget::QG_BlockWidget(QG_ActionHandler* ah, QWidget* parent, const char* name, Qt::WFlags f) : QWidget(parent, name, f), pxmVisible(":/ui/visibleblock.png"), pxmHidden(":/ui/hiddenblock.png"), pxmAdd(":/ui/blockadd.png"), pxmRemove(":/ui/blockremove.png"), pxmAttributes(":/ui/blockattributes.png"), pxmEdit(":/ui/blockedit.png"), pxmInsert(":/ui/blockinsert.png"), pxmDefreezeAll(":/ui/visibleblock.png"), pxmFreezeAll(":/ui/hiddenblock.png") { actionHandler = ah; blockList = NULL; lastBlock = NULL; listBox = new Q3ListBox(this, "blockbox"); listBox->setDragSelect(false); listBox->setMultiSelection(false); listBox->setSmoothScrolling(true); listBox->setFocusPolicy(Qt::NoFocus); QVBoxLayout* lay = new QVBoxLayout(this); lay->setSpacing ( 0 ); /* QLabel* caption = new QLabel(tr("Block List"), this, "caption"); caption->setAlignment(Qt::AlignCenter); caption->setPaletteBackgroundColor(black); caption->setPaletteForegroundColor(white); */ QHBoxLayout* layButtons = new QHBoxLayout(); QHBoxLayout* layButtons2 = new QHBoxLayout(); QToolButton* but; // show all blocks: but = new QToolButton(this); but->setPixmap(pxmDefreezeAll); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Show all blocks")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksDefreezeAll())); layButtons->addWidget(but); // hide all blocks: but = new QToolButton(this); but->setPixmap(pxmFreezeAll); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Hide all blocks")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksFreezeAll())); layButtons->addWidget(but); // add block: but = new QToolButton(this); but->setPixmap(pxmAdd); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Add a block")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksAdd())); layButtons->addWidget(but); // remove block: but = new QToolButton(this); but->setPixmap(pxmRemove); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Remove the active block")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksRemove())); layButtons->addWidget(but); // edit attributes: but = new QToolButton(this); but->setPixmap(pxmAttributes); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Rename the active block")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksAttributes())); layButtons->addWidget(but); // edit block: but = new QToolButton(this); but->setPixmap(pxmEdit); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Edit the active block\n" "in a separate window")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksEdit())); layButtons2->addWidget(but); // insert block: but = new QToolButton(this); but->setPixmap(pxmInsert); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Insert the active block")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksInsert())); layButtons2->addWidget(but); //lay->addWidget(caption); lay->addLayout(layButtons); lay->addLayout(layButtons2); lay->addWidget(listBox); //connect(listBox, SIGNAL(doubleClicked(QListBoxItem*)), // actionHandler, SLOT(slotBlocksToggleView())); connect(listBox, SIGNAL(highlighted(const QString&)), this, SLOT(slotActivated(const QString&))); connect(listBox, SIGNAL(mouseButtonClicked(int, Q3ListBoxItem*, const QPoint&)), this, SLOT(slotMouseButtonClicked(int, Q3ListBoxItem*, const QPoint&))); //boxLayout()->addWidget(listBox); } /** * Destructor */ QG_BlockWidget::~QG_BlockWidget() { delete listBox; } /** * Updates the block box from the blocks in the graphic. */ void QG_BlockWidget::update() { RS_DEBUG->print("QG_BlockWidget::update()"); int yPos = listBox->contentsY(); RS_Block* activeBlock; if (blockList!=NULL) { activeBlock = blockList->getActive(); } else { activeBlock = NULL; } listBox->clear(); if (blockList==NULL) { RS_DEBUG->print("QG_BlockWidget::update(): blockList is NULL"); return; } for (uint i=0; i<blockList->count(); ++i) { RS_Block* blk = blockList->at(i); if (!blk->isFrozen()) { listBox->insertItem(pxmVisible, blk->getName()); } else { listBox->insertItem(pxmHidden, blk->getName()); } } listBox->sort(); RS_Block* b = lastBlock; highlightBlock(activeBlock); lastBlock = b; listBox->setContentsPos(0, yPos); //highlightBlock(blockList->getActiveBlock()); //listBox->setContentsPos(0, yPos); RS_DEBUG->print("QG_BlockWidget::update() done"); } /** * Highlights (activates) the given block and makes it * the active block in the blocklist. */ void QG_BlockWidget::highlightBlock(RS_Block* block) { RS_DEBUG->print("QG_BlockWidget::highlightBlock()"); if (block==NULL || listBox==NULL) { return; } blockList->activate(block); QString name = block->getName(); for (int i=0; i<(int)listBox->count(); ++i) { if (listBox->text(i)==name) { listBox->setCurrentItem(i); break; } } } /** * Toggles the view of the given block. This is usually called when * an item is double clicked. */ /* void QG_BlockWidget::slotToggleView(QListBoxItem* item) { RS_DEBUG->print("QG_BlockWidget::slotToggleView()"); if (item==NULL || blockList==NULL) { return; } int index = listBox->index(item); RS_Block* block = blockList->find(item->text()); if (block!=NULL) { blockList->toggleBlock(item->text()); if (!block->isFrozen()) { listBox->changeItem(pxmVisible, item->text(), index); } else { listBox->changeItem(*pxmHidden, item->text(), index); } } } */ /** * Called when the user activates (highlights) a block. */ void QG_BlockWidget::slotActivated(const QString& blockName) { RS_DEBUG->print("QG_BlockWidget::slotActivated(): %s", blockName.latin1()); if (blockList==NULL) { return; } lastBlock = blockList->getActive(); blockList->activate(blockName); } /** * Called for every mouse click. */ void QG_BlockWidget::slotMouseButtonClicked(int /*button*/, Q3ListBoxItem* item, const QPoint& pos) { QPoint p = mapFromGlobal(pos); RS_Block* b = lastBlock; if (p.x()<23) { actionHandler->slotBlocksToggleView(); highlightBlock(b); } else { if (item!=NULL && blockList!=NULL) { lastBlock = blockList->find(item->text()); } } } /** * Shows a context menu for the block widget. Launched with a right click. */ void QG_BlockWidget::contextMenuEvent(QContextMenuEvent *e) { //QListBoxItem* item = listBox->selectedItem(); QMenu* contextMenu = new QMenu(this); QLabel* caption = new QLabel(tr("Block Menu"), this); caption->setPaletteBackgroundColor(RS_Color(0,0,0)); caption->setPaletteForegroundColor(RS_Color(255,255,255)); caption->setAlignment( Qt::AlignCenter ); // RVT_PORT contextMenu->insertItem( caption ); contextMenu->insertItem( tr("&Defreeze all Blocks"), actionHandler, SLOT(slotBlocksDefreezeAll()), 0); contextMenu->insertItem( tr("&Freeze all Blocks"), actionHandler, SLOT(slotBlocksFreezeAll()), 0); contextMenu->insertItem( tr("&Add Block"), actionHandler, SLOT(slotBlocksAdd()), 0); contextMenu->insertItem( tr("&Remove Block"), actionHandler, SLOT(slotBlocksRemove()), 0); contextMenu->insertItem( tr("&Rename Block"), actionHandler, SLOT(slotBlocksAttributes()), 0); contextMenu->insertItem( tr("&Edit Block"), actionHandler, SLOT(slotBlocksEdit()), 0); contextMenu->insertItem( tr("&Insert Block"), actionHandler, SLOT(slotBlocksInsert()), 0); contextMenu->insertItem( tr("&Toggle Visibility"), actionHandler, SLOT(slotBlocksToggleView()), 0); contextMenu->insertItem( tr("&Create New Block"), actionHandler, SLOT(slotBlocksCreate()), 0); contextMenu->exec(QCursor::pos()); delete contextMenu; e->accept(); } /** * Escape releases focus. */ void QG_BlockWidget::keyPressEvent(QKeyEvent* e) { switch (e->key()) { case Qt::Key_Escape: emit escape(); break; default: QWidget::keyPressEvent(e); break; } }
07-04
以下是你提供的 `QG_BlockWidget.cpp` 文件的**完整带注释版本**,使用 Markdown 格式展示: ```cpp /**************************************************************************** ** ** This file is part of the LibreCAD project, a 2D CAD program ** ** Copyright (C) 2010-2011 R. van Twisk (librecad@rvt.dds.nl) ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. ** ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file gpl-2.0.txt included in the ** packaging of this file. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ** ** This copyright notice MUST APPEAR in all copies of the script! ** **********************************************************************/ // 引入头文件 #include "qg_blockwidget.h" #include <QToolTip> // 工具提示(鼠标悬停显示信息) #include <QToolButton> // 工具按钮控件 #include <QMenu> // 右键菜单支持 #include <QBoxLayout> // 布局管理器 #include <QLabel> // 文本标签控件 /** * 构造函数。创建图块列表控件。 * * @param ah 动作处理器,处理用户操作逻辑 * @param parent 父控件 * @param name 控件名称 * @param f 控件窗口标志位 */ QG_BlockWidget::QG_BlockWidget(QG_ActionHandler* ah, QWidget* parent, const char* name, Qt::WFlags f) : QWidget(parent, name, f), pxmVisible(":/ui/visibleblock.png"), // 图块可见图标 pxmHidden(":/ui/hiddenblock.png"), // 图块隐藏图标 pxmAdd(":/ui/blockadd.png"), // 添加图块图标 pxmRemove(":/ui/blockremove.png"), // 删除图块图标 pxmAttributes(":/ui/blockattributes.png"),// 图块属性图标 pxmEdit(":/ui/blockedit.png"), // 编辑图块图标 pxmInsert(":/ui/blockinsert.png"), // 插入图块图标 pxmDefreezeAll(":/ui/visibleblock.png"), // 解冻所有图标 pxmFreezeAll(":/ui/hiddenblock.png") // 冻结所有图标 { actionHandler = ah; blockList = NULL; lastBlock = NULL; // 创建图块列表控件(Qt3 兼容类) listBox = new Q3ListBox(this, "blockbox"); listBox->setDragSelect(false); // 禁止拖动选择 listBox->setMultiSelection(false); // 不允许多选 listBox->setSmoothScrolling(true); // 启用平滑滚动 listBox->setFocusPolicy(Qt::NoFocus); // 不接收键盘焦点 // 创建主布局 QVBoxLayout* lay = new QVBoxLayout(this); lay->setSpacing(0); // 创建按钮布局 QHBoxLayout* layButtons = new QHBoxLayout(); QHBoxLayout* layButtons2 = new QHBoxLayout(); QToolButton* but; // 显示所有图块按钮 but = new QToolButton(this); but->setPixmap(pxmDefreezeAll); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Show all blocks")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksDefreezeAll())); layButtons->addWidget(but); // 隐藏所有图块按钮 but = new QToolButton(this); but->setPixmap(pxmFreezeAll); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Hide all blocks")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksFreezeAll())); layButtons->addWidget(but); // 添加图块按钮 but = new QToolButton(this); but->setPixmap(pxmAdd); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Add a block")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksAdd())); layButtons->addWidget(but); // 删除图块按钮 but = new QToolButton(this); but->setPixmap(pxmRemove); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Remove the active block")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksRemove())); layButtons->addWidget(but); // 编辑属性按钮 but = new QToolButton(this); but->setPixmap(pxmAttributes); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Rename the active block")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksAttributes())); layButtons->addWidget(but); // 编辑图块按钮 but = new QToolButton(this); but->setPixmap(pxmEdit); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Edit the active block\nin a separate window")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksEdit())); layButtons2->addWidget(but); // 插入图块按钮 but = new QToolButton(this); but->setPixmap(pxmInsert); but->setMinimumSize(QSize(22,22)); QToolTip::add(but, tr("Insert the active block")); connect(but, SIGNAL(clicked()), actionHandler, SLOT(slotBlocksInsert())); layButtons2->addWidget(but); // 设置布局:按钮 + 列表 lay->addLayout(layButtons); lay->addLayout(layButtons2); lay->addWidget(listBox); // 连接信号与槽:当列表项被高亮时触发动作 connect(listBox, SIGNAL(highlighted(const QString&)), this, SLOT(slotActivated(const QString&))); // 鼠标点击事件处理 connect(listBox, SIGNAL(mouseButtonClicked(int, Q3ListBoxItem*, const QPoint&)), this, SLOT(slotMouseButtonClicked(int, Q3ListBoxItem*, const QPoint&))); } /** * 析构函数。释放资源。 */ QG_BlockWidget::~QG_BlockWidget() { delete listBox; } /** * 更新界面中的图块列表,反映当前文档的图块状态。 */ void QG_BlockWidget::update() { RS_DEBUG->print("QG_BlockWidget::update()"); int yPos = listBox->contentsY(); // 保存当前滚动位置 RS_Block* activeBlock; if (blockList != NULL) { activeBlock = blockList->getActive(); // 获取当前激活的图块 } else { activeBlock = NULL; } listBox->clear(); // 清空现有内容 if (blockList == NULL) { RS_DEBUG->print("QG_BlockWidget::update(): blockList is NULL"); return; } // 遍历图块列表并插入到界面中 for (uint i = 0; i < blockList->count(); ++i) { RS_Block* blk = blockList->at(i); if (!blk->isFrozen()) { listBox->insertItem(pxmVisible, blk->getName()); } else { listBox->insertItem(pxmHidden, blk->getName()); } } listBox->sort(); // 按名称排序 RS_Block* b = lastBlock; highlightBlock(activeBlock); // 高亮当前图块 lastBlock = b; listBox->setContentsPos(0, yPos); // 恢复滚动位置 RS_DEBUG->print("QG_BlockWidget::update() done"); } /** * 高亮指定图块,并将其设置为当前活动图块。 * * @param block 要高亮的图块对象 */ void QG_BlockWidget::highlightBlock(RS_Block* block) { RS_DEBUG->print("QG_BlockWidget::highlightBlock()"); if (block == NULL || listBox == NULL) { return; } blockList->activate(block); // 设置为当前活动图块 QString name = block->getName(); // 获取图块名称 // 在列表框中找到该图块并设为当前选中项 for (int i=0; i<(int)listBox->count(); ++i) { if (listBox->text(i)==name) { listBox->setCurrentItem(i); break; } } } /** * 当用户在界面上激活一个图块时调用(例如点击或高亮)。 * * @param blockName 激活的图块名称 */ void QG_BlockWidget::slotActivated(const QString& blockName) { RS_DEBUG->print("QG_BlockWidget::slotActivated(): %s", blockName.latin1()); if (blockList == NULL) { return; } lastBlock = blockList->getActive(); // 保存上一次激活的图块 blockList->activate(blockName); // 设置新图块为当前激活图块 } /** * 鼠标点击事件处理。 * * 如果点击的是左侧小图标区域,则切换图块可见性; * 否则更新当前选中的图块。 */ void QG_BlockWidget::slotMouseButtonClicked(int /*button*/, Q3ListBoxItem* item, const QPoint& pos) { QPoint p = mapFromGlobal(pos); // 将全局坐标转为本地坐标 RS_Block* b = lastBlock; if (p.x() < 23) { actionHandler->slotBlocksToggleView(); // 点击图标区域 -> 切换图块可见性 highlightBlock(b); // 重新高亮 } else { if (item != NULL && blockList != NULL) { lastBlock = blockList->find(item->text()); // 找到对应的图块对象 } } } /** * 右键点击时弹出上下文菜单。 */ void QG_BlockWidget::contextMenuEvent(QContextMenuEvent *e) { QMenu* contextMenu = new QMenu(this); // 添加标题 QLabel* caption = new QLabel(tr("Block Menu"), this); caption->setPaletteBackgroundColor(RS_Color(0,0,0)); // 黑色背景 caption->setPaletteForegroundColor(RS_Color(255,255,255)); // 白色字体 caption->setAlignment(Qt::AlignCenter); // 居中对齐 contextMenu->insertItem(caption); // 添加标题(已注释掉,可启用) // 添加菜单项及其对应的动作 contextMenu->insertItem(tr("&Defreeze all Blocks"), actionHandler, SLOT(slotBlocksDefreezeAll()), 0); contextMenu->insertItem(tr("&Freeze all Blocks"), actionHandler, SLOT(slotBlocksFreezeAll()), 0); contextMenu->insertItem(tr("&Add Block"), actionHandler, SLOT(slotBlocksAdd()), 0); contextMenu->insertItem(tr("&Remove Block"), actionHandler, SLOT(slotBlocksRemove()), 0); contextMenu->insertItem(tr("&Rename Block"), actionHandler, SLOT(slotBlocksAttributes()), 0); contextMenu->insertItem(tr("&Edit Block"), actionHandler, SLOT(slotBlocksEdit()), 0); contextMenu->insertItem(tr("&Insert Block"), actionHandler, SLOT(slotBlocksInsert()), 0); contextMenu->insertItem(tr("&Toggle Visibility"), actionHandler, SLOT(slotBlocksToggleView()), 0); contextMenu->insertItem(tr("&Create New Block"), actionHandler, SLOT(slotBlocksCreate()), 0); // 显示菜单并释放资源 contextMenu->exec(QCursor::pos()); delete contextMenu; e->accept(); // 接受事件 } /** * 键盘按键事件处理。按下 ESC 键时发出 escape 信号。 */ void QG_BlockWidget::keyPressEvent(QKeyEvent* e) { switch (e->key()) { case Qt::Key_Escape: // 按下 ESC 键 emit escape(); // 发送信号通知主窗口获取焦点 break; default: QWidget::keyPressEvent(e); // 默认处理其他按键 break; } } ``` --- ## 📚 补充知识点说明(每个知识点不超过 50 字) | 知识点 | 说明 | |--------|------| | **Q3ListBox** | 使用 Qt3 的兼容控件,用于向后兼容和简单图块列表显示 | | **信号与槽机制** | 使用 `connect()` 绑定 UI 事件与动作处理器方法 | | **右键菜单实现 (`contextMenuEvent`) **( | 提供图块操作快捷入口,如添加、删除、编辑等 | --- 如果你还需要其他模块(如 `RS_BlockList`, `QG_ActionHandler`)的深入解析,请继续告诉我!我可以为你定制详细的讲解 😊
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值