diff options
| author | 2008-04-08 23:46:37 +0000 | |
|---|---|---|
| committer | 2008-04-08 23:46:37 +0000 | |
| commit | 86fc13a3dabbc218896247605a75f0c847af7839 (patch) | |
| tree | ec82ccf45e579411219600493b4b3c03fea16f74 /src/modules/options/optw_texticons.cpp | |
| parent | TODO-cmake update (diff) | |
| download | KVIrc-86fc13a3dabbc218896247605a75f0c847af7839.tar.gz KVIrc-86fc13a3dabbc218896247605a75f0c847af7839.tar.bz2 KVIrc-86fc13a3dabbc218896247605a75f0c847af7839.zip | |
more code clean
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1440 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/options/optw_texticons.cpp')
| -rw-r--r-- | src/modules/options/optw_texticons.cpp | 246 |
1 files changed, 0 insertions, 246 deletions
diff --git a/src/modules/options/optw_texticons.cpp b/src/modules/options/optw_texticons.cpp deleted file mode 100644 index 4a85c5c20..000000000 --- a/src/modules/options/optw_texticons.cpp +++ /dev/null @@ -1,246 +0,0 @@ -// -// File : optw_texticons.cpp -// Creation date : Fri May 24 2002 00:16:13 CEST by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net) -// -// This program is FREE software. You can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your opinion) any later version. -// -// 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// - -#include "optw_texticons.h" - -#include "kvi_iconmanager.h" -#include "kvi_texticonmanager.h" -#include "kvi_locale.h" -#include "kvi_filedialog.h" - -#include <qlayout.h> -#include <qcursor.h> -#include "kvi_tal_hbox.h" - - -KviTextIconEditor::KviTextIconEditor(QWidget * par,KviTextIcon * icon,KviTextIconTableItem* item) -: KviTalHBox(par),m_pTableItem(item) -{ - m_pIconButton=new QToolButton(this); - m_pBrowseButton=new QToolButton(this); - m_pBrowseButton->setSizePolicy(QSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum)); - m_pBrowseButton->setText("..."); - m_pIcon = icon; - m_pPopup = 0; - updateIcon(); - connect(m_pIconButton,SIGNAL(clicked()),this,SLOT(doPopup())); - connect(m_pBrowseButton,SIGNAL(clicked()),this,SLOT(chooseFromFile())); -} - - -KviTextIconEditor::~KviTextIconEditor() -{ - -} - -void KviTextIconEditor::doPopup() -{ - if(!m_pPopup) - { - m_pPopup = new KviTalPopupMenu(this); - KviIconWidget * iw = new KviIconWidget(m_pPopup); - connect(iw,SIGNAL(selected(int)),this,SLOT(iconSelected(int))); - m_pPopup->insertItem(iw); - } - m_pPopup->popup(QCursor::pos()); -} - -void KviTextIconEditor::iconSelected(int id) -{ - m_pIcon->setId(id); - updateIcon(); -} - -void KviTextIconEditor::chooseFromFile() -{ - QString szFile; - KviFileDialog::askForOpenFileName(szFile,"Choose icon filename",QString::null,"*.png","options"); - if(!szFile.isEmpty()) - { - if(g_pIconManager->getPixmap(szFile)) - { - m_pIcon->setFilename(szFile); -// debug("%s %s %i |%s| %p",__FILE__,__FUNCTION__,__LINE__,m_pIcon->filename().utf8().data(),m_pIcon); - updateIcon(); - } - } -} - -void KviTextIconEditor::updateIcon() -{ - if(m_pIcon) - { - QPixmap* pix=m_pIcon->pixmap(); - if(pix) - m_pIconButton->setPixmap(*pix); - } -} - -KviTextIconTableItem::KviTextIconTableItem(KviTalTable * t,KviTextIcon * icon) -: KviTalTableItem(t,KviTalTableItem::WhenCurrent,QString::null) -{ - if(icon) - m_pIcon=icon; - else - m_pIcon=new KviTextIcon(0); - QPixmap* pix=m_pIcon->pixmap(); - if(pix) - setPixmap(*pix); -} - -KviTextIconTableItem::~KviTextIconTableItem() -{ - delete m_pIcon; -} - -void KviTextIconTableItem::setId(int id) -{ - m_pIcon->setId(id); - QPixmap* pix=m_pIcon->pixmap(); - if(pix) - setPixmap(*pix); -} - -QWidget * KviTextIconTableItem::createEditor() const -{ - return new KviTextIconEditor(table()->viewport(),m_pIcon,(KviTextIconTableItem*)this); -} - - -void KviTextIconTableItem::setContentFromEditor(QWidget * w) -{ - if(w->inherits("KviTextIconEditor")) - { - QPixmap* pix=m_pIcon->pixmap(); - if(pix) - setPixmap(*pix); - } -} - -KviTextIconsOptionsWidget::KviTextIconsOptionsWidget(QWidget * parent) -: KviOptionsWidget(parent,"texticons_options_widget") -{ - createLayout(2,2); - - KviPointerHashTableIterator<QString,KviTextIcon> it(*(g_pTextIconManager->textIconDict())); - - m_pTable = new KviTalTable(g_pTextIconManager->textIconDict()->count(),2,this); - -#ifdef COMPILE_INFO_TIPS - mergeTip(m_pTable->viewport(),__tr2qs_ctx("This table contains the text icon associations.<br>" \ - "KVirc will use them to display the CTRL+I escape sequences and eventually the " \ - "emoticons.","options")); -#endif - - int idx = 0; - while(KviTextIcon * i = it.current()) - { - m_pTable->setText(idx,0,it.currentKey()); - m_pTable->setItem(idx,1,new KviTextIconTableItem(m_pTable,new KviTextIcon(i))); - ++idx; - ++it; - } - - layout()->addMultiCellWidget(m_pTable,0,0,0,1); - - m_pAdd = new QPushButton(__tr2qs_ctx("Add","options"),this); - layout()->addWidget(m_pAdd,1,0); - connect(m_pAdd,SIGNAL(clicked()),this,SLOT(addClicked())); - - m_pDel = new QPushButton(__tr2qs_ctx("Delete","options"),this); - layout()->addWidget(m_pDel,1,1); - connect(m_pDel,SIGNAL(clicked()),this,SLOT(delClicked())); - - m_pDel->setEnabled(false); - - connect(m_pTable,SIGNAL(selectionChanged()),this,SLOT(selectionChanged())); -} - -KviTextIconsOptionsWidget::~KviTextIconsOptionsWidget() -{ -} - -void KviTextIconsOptionsWidget::selectionChanged() -{ - int i = m_pTable->currentRow(); - m_pDel->setEnabled(i >= 0 && i < m_pTable->numRows()); -} - -void KviTextIconsOptionsWidget::addClicked() -{ - m_pTable->setNumRows(m_pTable->numRows() + 1); - m_pTable->setText(m_pTable->numRows() - 1,0,__tr2qs_ctx("unnamed","options")); - m_pTable->setItem(m_pTable->numRows() - 1,1,new KviTextIconTableItem(m_pTable,0)); - m_pDel->setEnabled(true); -} - -void KviTextIconsOptionsWidget::delClicked() -{ - int i = m_pTable->currentRow(); - - if((i > -1) && (i < m_pTable->numRows())) - { - // remove row i - m_pTable->clearCell(i,0); - m_pTable->clearCell(i,1); - m_pTable->clearCell(i,2); - - for(;i < (m_pTable->numRows() - 1);i++) - { - m_pTable->swapRows(i,i+1); - } - - m_pTable->setNumRows(m_pTable->numRows() - 1); - if(m_pTable->numRows() == 0)m_pDel->setEnabled(false); - } -} - -void KviTextIconsOptionsWidget::commit() -{ - - KviOptionsWidget::commit(); - g_pTextIconManager->clear(); - int n = m_pTable->numRows(); - for(int i=0;i < n;i++) - { - QString szVal = m_pTable->text(i,0); - if(!szVal.isEmpty()) - { - KviTextIconTableItem * it = (KviTextIconTableItem *)m_pTable->item(i,1); - if(it) - { - g_pTextIconManager->insert(szVal,*(it->icon())); - } - } - } - g_pTextIconManager->checkDefaultAssociations(); - - for(int i=0; i<n; i++) - for (int j=0; j<m_pTable->numCols(); j++) - if (m_pTable->item(i,j)) - m_pTable->clearCell(i,j); - -} - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES -#include "m_optw_texticons.moc" -#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES |
