diff options
| author | 2008-09-25 16:06:36 +0000 | |
|---|---|---|
| committer | 2008-09-25 16:06:36 +0000 | |
| commit | 7c244abf0f785b6abada4f6fccab52dbf96efcac (patch) | |
| tree | a1e8726e39489a3f1284b339c690ab1d09e8a7f4 | |
| parent | finished porting of theme module to qt4 (diff) | |
| download | KVIrc-7c244abf0f785b6abada4f6fccab52dbf96efcac.tar.gz KVIrc-7c244abf0f785b6abada4f6fccab52dbf96efcac.tar.bz2 KVIrc-7c244abf0f785b6abada4f6fccab52dbf96efcac.zip | |
some fixes/improvements and code cleaning.
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2567 17fca916-40b9-46aa-a4ea-0a15b648b75c
| -rw-r--r-- | src/modules/aliaseditor/aliaseditor.cpp | 63 | ||||
| -rw-r--r-- | src/modules/aliaseditor/aliaseditor.h | 4 | ||||
| -rw-r--r-- | src/modules/editor/scripteditor.cpp | 35 | ||||
| -rw-r--r-- | src/modules/eventeditor/eventeditor.cpp | 108 | ||||
| -rw-r--r-- | src/modules/eventeditor/eventeditor.h | 31 | ||||
| -rw-r--r-- | src/modules/help/libkvihelp.cpp | 53 | ||||
| -rw-r--r-- | src/modules/popupeditor/popupeditor.cpp | 334 | ||||
| -rw-r--r-- | src/modules/popupeditor/popupeditor.h | 50 |
8 files changed, 329 insertions, 349 deletions
diff --git a/src/modules/aliaseditor/aliaseditor.cpp b/src/modules/aliaseditor/aliaseditor.cpp index 73fb5be5d..61e6215ef 100644 --- a/src/modules/aliaseditor/aliaseditor.cpp +++ b/src/modules/aliaseditor/aliaseditor.cpp @@ -22,8 +22,12 @@ // //============================================================================= + + #include "aliaseditor.h" + + #include "kvi_iconmanager.h" #include "kvi_options.h" #include "kvi_locale.h" @@ -34,6 +38,7 @@ #include "kvi_scripteditor.h" #include "kvi_debug.h" #include "kvi_app.h" +#include "kvi_frame.h" #include "kvi_qstring.h" #include "kvi_kvs_aliasmanager.h" #include "kvi_filedialog.h" @@ -53,6 +58,11 @@ #include <QTreeWidget> #include <QMouseEvent> #include <QList> +#include <QPainter> + +#ifdef COMPILE_PSEUDO_TRANSPARENCY + extern KVIRC_API QPixmap * g_pShadedChildGlobalDesktopBackground; +#endif extern KviAliasEditorWindow * g_pAliasEditorWindow; extern KviModule * g_pAliasEditorModule; @@ -122,7 +132,6 @@ KviAliasNamespaceTreeWidgetItem::KviAliasNamespaceTreeWidgetItem(KviAliasNamespa KviAliasNamespaceTreeWidgetItem::~KviAliasNamespaceTreeWidgetItem() { - debug("Deleting %s and pointer %d",this->text(0).toUtf8().data(),this); } KviAliasNamespaceTreeWidgetItem * KviAliasNamespaceTreeWidgetItem::findNamespaceItem(const QString &szName) @@ -215,6 +224,7 @@ KviAliasEditorTreeWidget::KviAliasEditorTreeWidget(QWidget * par) setRootIsDecorated(true); setAnimated(true); } + void KviAliasEditorTreeWidget::mousePressEvent (QMouseEvent *e) { if (e->button() == Qt::RightButton) @@ -468,18 +478,15 @@ bool KviAliasEditor::hasSelectedItems() } bool KviAliasEditor::itemExists(QTreeWidgetItem *pSearchFor) { - debug("Check if %s exists",pSearchFor->text(0).toUtf8().data()); if(!pSearchFor)return false; for (int i=0;i<m_pTreeWidget->topLevelItemCount();i++) { - debug("Check in top level %d",i); - if(m_pTreeWidget->topLevelItem(i)==pSearchFor) return true; + if(m_pTreeWidget->topLevelItem(i)==pSearchFor) return true; else { if(!((KviAliasEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i))->isAlias()) { - debug ("search into name space %s",m_pTreeWidget->topLevelItem(i)->text(0).toUtf8().data()); if (itemExistsRecursive(pSearchFor,m_pTreeWidget->topLevelItem(i))) return true; } } @@ -490,13 +497,11 @@ bool KviAliasEditor::itemExistsRecursive(QTreeWidgetItem *pSearchFor,QTreeWidget { for(int i=0;i<pSearchAt->childCount();i++) { - debug("Check into child %d with text %s and %s",i,pSearchAt->child(i)->text(0).toUtf8().data(),pSearchFor->text(0).toUtf8().data()); - if(pSearchFor == pSearchAt->child(i))return true; else { - //if(!((KviAliasEditorTreeWidgetItem *)pSearchAt->child(i))->isAlias()) - if (pSearchAt->child(i)->childCount()) { + if (pSearchAt->child(i)->childCount()) + { if (itemExistsRecursive(pSearchFor,pSearchAt->child(i))) return true; } } @@ -583,17 +588,15 @@ void KviAliasEditor::recursiveSearchReplace(const QString &szSearch,KviAliasEdit { it->child(i)->setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ALIASHIGHLIGHTED)))); if (bReplace) ((QString &)((KviAliasTreeWidgetItem *)it->child(i))->buffer()).replace(szSearch,szReplace,Qt::CaseInsensitive); - openParentItems(it); + it->setExpanded(true); } - //else - //it->child(i)->setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ALIAS)))); + else + it->child(i)->setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ALIAS)))); } else { recursiveSearchReplace(szSearch,(KviAliasEditorTreeWidgetItem *)(it->child(i)),bReplace,szReplace); } } - //} - //recursiveSearchReplace(szSearch,(KviAliasEditorTreeWidgetItem *)(it->nextSibling()),bReplace,szReplace); } @@ -623,6 +626,9 @@ void KviAliasEditor::slotFind() { m_pTreeWidget->topLevelItem(i)->setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ALIASHIGHLIGHTED)))); } + else + m_pTreeWidget->topLevelItem(i)->setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ALIAS)))); + } else { recursiveSearchReplace(szSearch,(KviAliasEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i)); @@ -702,7 +708,6 @@ void KviAliasEditor::exportSelected() void KviAliasEditor::exportSelectionInSinglesFiles(KviPointerList<KviAliasTreeWidgetItem> *l) { if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))m_szDir += KVI_PATH_SEPARATOR; - debug ("dir %s",m_szDir.toUtf8().data()); if (!l->first()) { g_pAliasEditorModule->lock(); @@ -718,8 +723,7 @@ void KviAliasEditor::exportSelectionInSinglesFiles(KviPointerList<KviAliasTreeWi } if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))m_szDir += KVI_PATH_SEPARATOR; - debug ("dir changed in %s",m_szDir.toUtf8().data()); - + bool bReplaceAll=false; for(KviAliasTreeWidgetItem * it = l->first();it;it = l->next()) @@ -998,7 +1002,6 @@ void KviAliasEditor::appendSelectedItems(KviPointerList<KviAliasEditorTreeWidget void KviAliasEditor::removeItemChildren(KviAliasEditorTreeWidgetItem *it) { - debug("Deleting"); for (int i=0;i<it->childCount();i++) { if (it->child(i)->childCount()) removeItemChildren((KviAliasEditorTreeWidgetItem *)it->child(i)); @@ -1042,7 +1045,6 @@ bool KviAliasEditor::removeItem(KviAliasEditorTreeWidgetItem *it,bool * pbYesToA m_pLastEditedItem = 0; if(it == m_pLastClickedItem) m_pLastClickedItem = 0; - debug ("Deleting"); if (it->childCount()) removeItemChildren(it); delete it; return true; @@ -1390,22 +1392,7 @@ void KviAliasEditor::renameItem() m_pEditor->getText(szCode); pntCursor = m_pEditor->getCursor(); } - - // take child items, if any -// KviPointerList<QTreeWidgetItem> lChildren; -// lChildren.setAutoDelete(false); - //appendItems(lChildren, m_pLastEditedItem->firstChild()); QList<QTreeWidgetItem*> lChildren= m_pLastEditedItem->takeChildren(); -// QTreeWidgetItem * it = m_pLastEditedItem->firstChild(); - /*while(it) - { - lChildren.append(it); - it = it->nextSibling(); - } - */ -/* for(it = lChildren.first();it;it = lChildren.next()) - m_pTreeWidget->takeItem(it); -*/ bool bYesToAll = true; removeItem(m_pLastEditedItem,&bYesToAll,true); @@ -1436,17 +1423,13 @@ void KviAliasEditor::renameItem() // the name is changed explicitly with renameItem(), when needed void KviAliasEditor::saveLastEditedItem() { - if(!m_pLastEditedItem){debug ("Nothing to save");return;} - if(!m_pEditor->isModified()){debug ("Alreary saved");return;} // nothing to save if(!itemExists(m_pLastEditedItem)){debug("Item does not exists");return;} // dead ? - debug("Check last edit item %s",m_pLastEditedItem->text(0).toUtf8().data()); ((KviAliasTreeWidgetItem *)m_pLastEditedItem)->setCursorPosition(m_pEditor->getCursor()); - if(m_pLastEditedItem->isNamespace()){debug("Is namespace");return;} + if(!m_pLastEditedItem || !m_pEditor->isModified()) return; + if(m_pLastEditedItem->isNamespace())return; QString newCode; m_pEditor->getText(newCode); - debug("Saving %s",newCode.toUtf8().data()); - ((KviAliasTreeWidgetItem *)m_pLastEditedItem)->setBuffer(newCode); } diff --git a/src/modules/aliaseditor/aliaseditor.h b/src/modules/aliaseditor/aliaseditor.h index 449516dea..6ea24cf6d 100644 --- a/src/modules/aliaseditor/aliaseditor.h +++ b/src/modules/aliaseditor/aliaseditor.h @@ -107,9 +107,9 @@ public: int m_cPos; public: const QString & buffer(){ return m_szBuffer; }; - const int & cursorPosition(){ debug ("Returing cPos %d",m_cPos);return m_cPos; }; + const int & cursorPosition(){return m_cPos; }; void setBuffer(const QString &szBuffer){ m_szBuffer = szBuffer; }; - void setCursorPosition(const int &cPos){ debug("Saving cpos %d",cPos);m_cPos = cPos; }; + void setCursorPosition(const int &cPos){ m_cPos = cPos; }; }; class KviAliasEditor : public QWidget diff --git a/src/modules/editor/scripteditor.cpp b/src/modules/editor/scripteditor.cpp index 74dca4e47..38667f329 100644 --- a/src/modules/editor/scripteditor.cpp +++ b/src/modules/editor/scripteditor.cpp @@ -255,8 +255,6 @@ void KviScriptEditorWidget::updateOptions() setPalette(p); setFont(g_fntNormal); setTextColor(g_clrNormalText); - //setTextFormat(Qt::PlainText); - // this will rehighlight everything setText(toPlainText()); // an "hack" to ensure Update all in the editor KviScriptEditorSyntaxHighlighter *h = new KviScriptEditorSyntaxHighlighter(this); @@ -331,37 +329,6 @@ void KviScriptEditorWidget::keyPressEvent(QKeyEvent * e) QRect cr = cursorRect(); cr.setWidth(m_pCompleter->popup()->sizeHintForColumn(0)+ m_pCompleter->popup()->verticalScrollBar()->sizeHint().width()); m_pCompleter->complete(cr); - /* - bool bIsShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E); // CTRL+E - - // don't process the shortcut when we have a completer - if(!m_pCompleter || !bIsShortcut)QTextEdit::keyPressEvent(e); - - const bool bCtrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier); - if(!m_pCompleter || (bCtrlOrShift && e->text().isEmpty()))return; - - // end of word - static QString szEow("~!@#$%^&*()_+{}|:\"<>?,/;'[]\\-="); - bool hasModifier = (e->modifiers() != Qt::NoModifier) && !bCtrlOrShift; - - QString szCompletionPrefix = textUnderCursor(); - debug ("completition prefix %s",szCompletionPrefix.toUtf8().data()); - if(!bIsShortcut && (hasModifier || e->text().isEmpty()|| szCompletionPrefix.length() < 3 || szEow.contains(e->text().right(1)))) - { - m_pCompleter->popup()->hide(); - return; - } - - if(szCompletionPrefix != m_pCompleter->completionPrefix()) - { - m_pCompleter->setCompletionPrefix(szCompletionPrefix); - m_pCompleter->popup()->setCurrentIndex(m_pCompleter->completionModel()->index(0, 0)); - } - - QRect cr = cursorRect(); - cr.setWidth(m_pCompleter->popup()->sizeHintForColumn(0) + m_pCompleter->popup()->verticalScrollBar()->sizeHint().width()); - m_pCompleter->complete(cr); - */ } QString KviScriptEditorWidget::textUnderCursor() const @@ -1037,8 +1004,6 @@ void KviScriptEditorImplementation::saveToFile() void KviScriptEditorImplementation::setText(const KviQCString & szText) { m_pEditor->setText(szText.data()); - //m_pEditor->setTextFormat(Qt::PlainText); - //m_pEditor->moveCursor(KviTalTextEdit::MoveEnd,false); m_pEditor->document()->setModified(false); updateRowColLabel(); } diff --git a/src/modules/eventeditor/eventeditor.cpp b/src/modules/eventeditor/eventeditor.cpp index 2f179eac8..081a3b4f3 100644 --- a/src/modules/eventeditor/eventeditor.cpp +++ b/src/modules/eventeditor/eventeditor.cpp @@ -52,32 +52,33 @@ extern KviEventEditorWindow * g_pEventEditorWindow; -KviEventListViewItem::KviEventListViewItem(QTreeWidget * par,unsigned int uEvIdx,const QString &name,const QString ¶ms) +KviEventTreeWidgetItem::KviEventTreeWidgetItem(QTreeWidget * par,unsigned int uEvIdx,const QString &name,const QString ¶ms) : QTreeWidgetItem(par), m_uEventIdx(uEvIdx), m_szParams(params) { setName(name); } -void KviEventListViewItem::setName(const QString &szName) +void KviEventTreeWidgetItem::setName(const QString &szName) { m_szName = szName; setText(0,m_szName); } -KviEventHandlerListViewItem::KviEventHandlerListViewItem(QTreeWidgetItem * par,const QString &name,const QString &buffer,bool bEnabled) +KviEventHandlerTreeWidgetItem::KviEventHandlerTreeWidgetItem(QTreeWidgetItem * par,const QString &name,const QString &buffer,bool bEnabled) : QTreeWidgetItem(par), m_szBuffer(buffer) { + m_cPos=0; setEnabled(bEnabled); //this updates the icon too setName(name); } -void KviEventHandlerListViewItem::setName(const QString &szName) +void KviEventHandlerTreeWidgetItem::setName(const QString &szName) { m_szName = szName; setText(0,m_szName); } -void KviEventHandlerListViewItem::setEnabled(const bool bEnabled) +void KviEventHandlerTreeWidgetItem::setEnabled(const bool bEnabled) { m_bEnabled = bEnabled; setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(m_bEnabled ? KVI_SMALLICON_HANDLER : KVI_SMALLICON_HANDLERDISABLED)))); @@ -95,16 +96,19 @@ KviEventEditor::KviEventEditor(QWidget * par) l->addWidget(spl,0,0); - KviTalVBox * boxi = new KviTalVBox(spl); - boxi->setSpacing(0); - boxi->setMargin(0); + KviTalVBox * vbox = new KviTalVBox(spl); + vbox->setSpacing(0); + vbox->setMargin(0); - m_pListView = new KviEventEditorListView(boxi); + m_pTreeWidget = new KviEventEditorTreeWidget(vbox); - QPushButton * pb = new QPushButton(__tr2qs("&Export All To..."),boxi); + QPushButton * pb = new QPushButton(__tr2qs("&Export All To..."),vbox); connect(pb,SIGNAL(clicked()),this,SLOT(exportAllEvents())); KviTalVBox * box = new KviTalVBox(spl); + spl->setStretchFactor (0,20); + spl->setStretchFactor (1,80); + box->setSpacing(0); box->setMargin(0); @@ -113,7 +117,6 @@ KviEventEditor::KviEventEditor(QWidget * par) m_pEditor = KviScriptEditor::createInstance(box); m_pEditor->setFocus(); - m_bOneTimeSetupDone = false; m_pLastEditedItem = 0; } @@ -128,21 +131,21 @@ void KviEventEditor::oneTimeSetup() if(m_bOneTimeSetupDone)return; m_bOneTimeSetupDone = true; - KviEventListViewItem * it; - KviEventHandlerListViewItem * ch; + KviEventTreeWidgetItem * it; + KviEventHandlerTreeWidgetItem * ch; for(unsigned int i = 0;i < KVI_KVS_NUM_APP_EVENTS;i++) { KviKvsEvent * e = KviKvsEventManager::instance()->appEvent(i); - it = new KviEventListViewItem(m_pListView,i,e->name(),e->parameterDescription()); + it = new KviEventTreeWidgetItem(m_pTreeWidget,i,e->name(),e->parameterDescription()); if(KviPointerList<KviKvsEventHandler> * l = e->handlers()) { for(KviKvsEventHandler * s = l->first();s;s = l->next()) { if(s->type() == KviKvsEventHandler::Script) { - ch = new KviEventHandlerListViewItem(it,((KviKvsScriptEventHandler *)s)->name(), + ch = new KviEventHandlerTreeWidgetItem(it,((KviKvsScriptEventHandler *)s)->name(), ((KviKvsScriptEventHandler *)s)->code(),((KviKvsScriptEventHandler *)s)->isEnabled()); } } @@ -150,15 +153,15 @@ void KviEventEditor::oneTimeSetup() it->setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(it->childCount() ? KVI_SMALLICON_EVENT : KVI_SMALLICON_EVENTNOHANDLERS)))); } - connect(m_pListView,SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),this,SLOT(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *))); - connect(m_pListView,SIGNAL(rightButtonPressed(QTreeWidgetItem *,QPoint)), + connect(m_pTreeWidget,SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),this,SLOT(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *))); + connect(m_pTreeWidget,SIGNAL(rightButtonPressed(QTreeWidgetItem *,QPoint)), this,SLOT(itemPressed(QTreeWidgetItem *,QPoint))); m_pContextPopup = new KviTalPopupMenu(this); - m_pListView->sortItems(0,Qt::AscendingOrder); + m_pTreeWidget->sortItems(0,Qt::AscendingOrder); } -KviEventEditorListView::KviEventEditorListView(QWidget * par) +KviEventEditorTreeWidget::KviEventEditorTreeWidget(QWidget * par) : QTreeWidget(par) { setColumnCount (1); @@ -169,7 +172,7 @@ KviEventEditorListView::KviEventEditorListView(QWidget * par) setAnimated(true); } -void KviEventEditorListView::mousePressEvent (QMouseEvent *e) +void KviEventEditorTreeWidget::mousePressEvent (QMouseEvent *e) { if (e->button() == Qt::RightButton) { @@ -189,7 +192,7 @@ void KviEventEditor::itemPressed(QTreeWidgetItem *it,const QPoint &pnt) if(it->parent()) { QString tmp; - if(!(((KviEventHandlerListViewItem *)it)->m_bEnabled)) + if(!(((KviEventHandlerTreeWidgetItem *)it)->m_bEnabled)) m_pContextPopup->insertItem( *(g_pIconManager->getSmallIcon(KVI_SMALLICON_HANDLER)), __tr2qs("&Enable Handler"),this,SLOT(toggleCurrentHandlerEnabled())); @@ -217,7 +220,7 @@ void KviEventEditor::itemPressed(QTreeWidgetItem *it,const QPoint &pnt) } } -void KviEventEditor::getUniqueHandlerName(KviEventListViewItem *it,QString &buffer) +void KviEventEditor::getUniqueHandlerName(KviEventTreeWidgetItem *it,QString &buffer) { __range_valid(m_bOneTimeSetupDone); @@ -232,9 +235,9 @@ void KviEventEditor::getUniqueHandlerName(KviEventListViewItem *it,QString &buff bFound = false; for(int i=0;i<it->childCount();i++) - //for(KviEventHandlerListViewItem * ch = (KviEventHandlerListViewItem *)(it->firstChild());ch;ch = (KviEventHandlerListViewItem *)ch->nextSibling()) + //for(KviEventHandlerTreeWidgetItem * ch = (KviEventHandlerTreeWidgetItem *)(it->firstChild());ch;ch = (KviEventHandlerTreeWidgetItem *)ch->nextSibling()) { - if(KviQString::equalCI(newName,((KviEventHandlerListViewItem *)it->child(i))->m_szName)) + if(KviQString::equalCI(newName,((KviEventHandlerTreeWidgetItem *)it->child(i))->m_szName)) { bFound = true; KviQString::sprintf(newName,"%Q_%d",&buffer,idx); @@ -251,9 +254,9 @@ void KviEventEditor::addHandlerForCurrentEvent() { __range_valid(m_pOneTimeSetupDone); - if(!m_pListView->selectedItems().isEmpty()) + if(!m_pTreeWidget->selectedItems().isEmpty()) { - QTreeWidgetItem * it = m_pListView->selectedItems().first(); + QTreeWidgetItem * it = m_pTreeWidget->selectedItems().first(); if(it->parent() == 0) { @@ -261,8 +264,8 @@ void KviEventEditor::addHandlerForCurrentEvent() it->setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_EVENT)))); QString buffer = __tr2qs("default"); - getUniqueHandlerName((KviEventListViewItem *)it,buffer); - QTreeWidgetItem * ch = new KviEventHandlerListViewItem(it,buffer,"",true); + getUniqueHandlerName((KviEventTreeWidgetItem *)it,buffer); + QTreeWidgetItem * ch = new KviEventHandlerTreeWidgetItem(it,buffer,"",true); it->setExpanded(true); ch->setSelected(true); } @@ -296,7 +299,7 @@ void KviEventEditor::toggleCurrentHandlerEnabled() if(m_pLastEditedItem) { m_pLastEditedItem->setEnabled(!(m_pLastEditedItem->m_bEnabled)); - m_pListView->repaint(m_pListView->visualItemRect(m_pLastEditedItem)); + m_pTreeWidget->repaint(m_pTreeWidget->visualItemRect(m_pLastEditedItem)); currentItemChanged(m_pLastEditedItem,0); } } @@ -308,31 +311,27 @@ void KviEventEditor::commit() saveLastEditedItem(); KviKvsEventManager::instance()->removeAllScriptAppHandlers(); - int count=m_pListView->topLevelItemCount(); + int count=m_pTreeWidget->topLevelItemCount(); for (int i=0;i<count;i++) - //for(QTreeWidgetItem * it = m_pListView->firstChild();it;it = it->nextSibling()) { - QTreeWidgetItem * it = m_pListView->topLevelItem(i); + QTreeWidgetItem * it = m_pTreeWidget->topLevelItem(i); int ccount = it->childCount(); if(ccount > 0) { QString szContext; for(int j=0;j<ccount;j++) - //for(QTreeWidgetItem * ch = it->firstChild();ch;ch = ch->nextSibling()) { QTreeWidgetItem * ch = it->child(j); - - KviQString::sprintf(szContext,"%Q::%Q",&(((KviEventListViewItem *)it)->m_szName),&(((KviEventHandlerListViewItem *)ch)->m_szName)); - + KviQString::sprintf(szContext,"%Q::%Q",&(((KviEventTreeWidgetItem *)it)->m_szName),&(((KviEventHandlerTreeWidgetItem *)ch)->m_szName)); KviKvsScriptEventHandler * s = KviKvsScriptEventHandler::createInstance( // msvc workaround - ((KviEventHandlerListViewItem *)ch)->m_szName, + ((KviEventHandlerTreeWidgetItem *)ch)->m_szName, szContext, - ((KviEventHandlerListViewItem *)ch)->m_szBuffer, - ((KviEventHandlerListViewItem *)ch)->m_bEnabled + ((KviEventHandlerTreeWidgetItem *)ch)->m_szBuffer, + ((KviEventHandlerTreeWidgetItem *)ch)->m_bEnabled ); - KviKvsEventManager::instance()->addAppHandler(((KviEventListViewItem *)it)->m_uEventIdx,s); + KviKvsEventManager::instance()->addAppHandler(((KviEventTreeWidgetItem *)it)->m_uEventIdx,s); } } } @@ -344,13 +343,13 @@ void KviEventEditor::saveLastEditedItem() { __range_valid(m_bOneTimeSetupDone); if(!m_pLastEditedItem)return; - + ((KviEventHandlerTreeWidgetItem *)m_pLastEditedItem)->setCursorPosition(m_pEditor->getCursor()); QString buffer = m_pNameEditor->text(); //not-so elaborate fix for #218, we'd better rework this buffer.replace(QRegExp("[^A-Za-z0-9_]"), ""); if(!KviQString::equalCI(buffer,m_pLastEditedItem->m_szName)) { - getUniqueHandlerName((KviEventListViewItem *)(m_pLastEditedItem->parent()),buffer); + getUniqueHandlerName((KviEventTreeWidgetItem *)(m_pLastEditedItem->parent()),buffer); } m_pLastEditedItem->setName(buffer); @@ -372,27 +371,30 @@ void KviEventEditor::currentItemChanged(QTreeWidgetItem * it,QTreeWidgetItem *pr m_pEditor->setEnabled(false); return; } - + if(it->parent()) { - m_pLastEditedItem = (KviEventHandlerListViewItem *)it; + m_pLastEditedItem = (KviEventHandlerTreeWidgetItem *)it; m_pNameEditor->setEnabled(true); m_pNameEditor->setText(m_pLastEditedItem->name()); m_pEditor->setEnabled(true); + m_pEditor->setFocus(); m_pEditor->setText(m_pLastEditedItem->m_szBuffer); + m_pEditor->setCursorPosition(((KviEventHandlerTreeWidgetItem *)it)->cursorPosition()); } else { m_pLastEditedItem = 0; m_pNameEditor->setEnabled(false); m_pNameEditor->setText(""); m_pEditor->setEnabled(false); - QString parms = ((KviEventListViewItem *)it)->m_szParams; + QString parms = ((KviEventTreeWidgetItem *)it)->m_szParams; if(parms.isEmpty())parms = __tr2qs("none"); KviCommandFormatter::indent(parms); KviCommandFormatter::indent(parms); QString tmp; KviQString::sprintf(tmp,__tr2qs("\n\n Event:\n %s\n\n Parameters:\n%s"), - ((KviEventListViewItem *)it)->m_szName.toUtf8().data(),parms.toUtf8().data()); + ((KviEventTreeWidgetItem *)it)->m_szName.toUtf8().data(),parms.toUtf8().data()); m_pEditor->setText(tmp); + } } @@ -402,7 +404,7 @@ void KviEventEditor::showEvent(QShowEvent *e) QWidget::showEvent(e); } -void KviEventEditor::getExportEventBuffer(QString &buffer,KviEventHandlerListViewItem * it) +void KviEventEditor::getExportEventBuffer(QString &buffer,KviEventHandlerTreeWidgetItem * it) { if(!it->parent())return; @@ -411,7 +413,7 @@ void KviEventEditor::getExportEventBuffer(QString &buffer,KviEventHandlerListVie KviCommandFormatter::blockFromBuffer(szBuf); buffer = "event("; - buffer += ((KviEventListViewItem *)(it->parent()))->m_szName; + buffer += ((KviEventTreeWidgetItem *)(it->parent()))->m_szName; buffer += ","; buffer += it->m_szName; buffer += ")\n"; @@ -422,7 +424,7 @@ void KviEventEditor::getExportEventBuffer(QString &buffer,KviEventHandlerListVie { buffer += "\n"; buffer += "eventctl -d "; - buffer += ((KviEventListViewItem *)(it->parent()))->m_szName; + buffer += ((KviEventTreeWidgetItem *)(it->parent()))->m_szName; buffer += " "; buffer += it->m_szName; } @@ -436,7 +438,7 @@ void KviEventEditor::exportCurrentHandler() QString szName = QDir::homePath(); if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))szName += KVI_PATH_SEPARATOR; - szName += ((KviEventListViewItem *)(m_pLastEditedItem->parent()))->m_szName; + szName += ((KviEventTreeWidgetItem *)(m_pLastEditedItem->parent()))->m_szName; szName += "."; szName += m_pLastEditedItem->m_szName; szName += ".kvs"; @@ -460,16 +462,16 @@ void KviEventEditor::exportAllEvents() QString out; - int count=m_pListView->topLevelItemCount(); + int count=m_pTreeWidget->topLevelItemCount(); for (int i=0;i<count;i++) { - KviEventListViewItem * it = (KviEventListViewItem *)m_pListView->topLevelItem(i); + KviEventTreeWidgetItem * it = (KviEventTreeWidgetItem *)m_pTreeWidget->topLevelItem(i); int ccount = it->childCount(); for(int j=0;j<ccount;j++) { - KviEventHandlerListViewItem * item = (KviEventHandlerListViewItem *) it->child(j); + KviEventHandlerTreeWidgetItem * item = (KviEventHandlerTreeWidgetItem *) it->child(j); QString tmp; getExportEventBuffer(tmp,item); diff --git a/src/modules/eventeditor/eventeditor.h b/src/modules/eventeditor/eventeditor.h index ff23b0d10..51c0b77fb 100644 --- a/src/modules/eventeditor/eventeditor.h +++ b/src/modules/eventeditor/eventeditor.h @@ -34,42 +34,47 @@ class KviScriptEditor; -class KviEventListViewItem : public QTreeWidgetItem +class KviEventTreeWidgetItem : public QTreeWidgetItem { public: unsigned int m_uEventIdx; QString m_szName; QString m_szParams; public: - KviEventListViewItem(QTreeWidget * par,unsigned int uEvIdx,const QString &name,const QString ¶ms); - ~KviEventListViewItem() {}; + KviEventTreeWidgetItem(QTreeWidget * par,unsigned int uEvIdx,const QString &name,const QString ¶ms); + ~KviEventTreeWidgetItem() {}; public: void setName(const QString &szName); QString name() const { return m_szName; }; }; -class KviEventHandlerListViewItem : public QTreeWidgetItem +class KviEventHandlerTreeWidgetItem : public QTreeWidgetItem { public: QString m_szName; QString m_szBuffer; bool m_bEnabled; + int m_cPos; public: - KviEventHandlerListViewItem(QTreeWidgetItem * par,const QString &name,const QString &buffer,bool bEnabled); - ~KviEventHandlerListViewItem() {}; + KviEventHandlerTreeWidgetItem(QTreeWidgetItem * par,const QString &name,const QString &buffer,bool bEnabled); + ~KviEventHandlerTreeWidgetItem() {}; public: + const int & cursorPosition(){return m_cPos; }; + void setCursorPosition(const int &cPos){debug ("set cursor to %d",cPos); m_cPos = cPos; }; + void setName(const QString &szName); QString name() const { return m_szName; }; void setEnabled(const bool bEnabled); }; -class KviEventEditorListView : public QTreeWidget +class KviEventEditorTreeWidget : public QTreeWidget { Q_OBJECT public: - KviEventEditorListView(QWidget*); - ~KviEventEditorListView(){}; + KviEventEditorTreeWidget(QWidget*); + ~KviEventEditorTreeWidget(){}; protected: + void mousePressEvent (QMouseEvent *e); signals: void rightButtonPressed(QTreeWidgetItem *,QPoint); @@ -83,16 +88,16 @@ public: ~KviEventEditor(); public: KviScriptEditor * m_pEditor; - KviEventEditorListView * m_pListView; + KviEventEditorTreeWidget * m_pTreeWidget; QLineEdit * m_pNameEditor; KviTalPopupMenu * m_pContextPopup; - KviEventHandlerListViewItem * m_pLastEditedItem; + KviEventHandlerTreeWidgetItem * m_pLastEditedItem; bool m_bOneTimeSetupDone; public: void commit(); void saveLastEditedItem(); - void getUniqueHandlerName(KviEventListViewItem *it,QString &buffer); - void getExportEventBuffer(QString &szBuffer,KviEventHandlerListViewItem * it); + void getUniqueHandlerName(KviEventTreeWidgetItem *it,QString &buffer); + void getExportEventBuffer(QString &szBuffer,KviEventHandlerTreeWidgetItem * it); protected slots: void currentItemChanged(QTreeWidgetItem *it,QTreeWidgetItem *); void itemPressed(QTreeWidgetItem *it,const QPoint &pnt); diff --git a/src/modules/help/libkvihelp.cpp b/src/modules/help/libkvihelp.cpp index 6092bdf19..7ffd979cc 100644 --- a/src/modules/help/libkvihelp.cpp +++ b/src/modules/help/libkvihelp.cpp @@ -25,8 +25,9 @@ #include "helpwidget.h" #include "helpwindow.h" #include "index.h" - +#include "kvi_locale.h" #include "kvi_module.h" +#include "kvi_fileutils.h" #include "kvi_sourcesdate.h" #include "kvi_app.h" #include "kvi_frame.h" @@ -137,36 +138,56 @@ static bool help_kvs_cmd_search(KviKvsModuleCommandCall * c) static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c) { - QString doc, szHelpDir; + QString szDoc, szHelpDir; QDir dirHelp; KVSM_PARAMETERS_BEGIN(c) - KVSM_PARAMETER("document",KVS_PT_STRING,KVS_PF_OPTIONAL,doc) + KVSM_PARAMETER("document",KVS_PT_STRING,KVS_PF_OPTIONAL,szDoc) KVSM_PARAMETERS_END(c) g_pApp->getGlobalKvircDirectory(szHelpDir,KviApp::Help); dirHelp = QDir(szHelpDir); - if(doc.isEmpty()){ - doc = dirHelp.absoluteFilePath("index.html"); - qDebug ("No file, use default at path %s",doc.toUtf8().data()); - } else qDebug("Doc set from user to %s",doc.toUtf8().data()); - - QFileInfo * f= new QFileInfo(doc); - qDebug("Path %s",doc.toUtf8().data()); + if(szDoc.isEmpty()){ + szDoc = dirHelp.absoluteFilePath("index.html"); + qDebug ("No file, use default at path %s",szDoc.toUtf8().data()); + } else qDebug("Doc set from user to %s",szDoc.toUtf8().data()); + + if (g_pDocIndex) + { + if (!g_pDocIndex->documentList().count()) + { + QString szDoclist,szDict; + g_pApp->getLocalKvircDirectory(szDoclist,KviApp::Help,"help.doclist." KVI_SOURCES_DATE); + g_pApp->getLocalKvircDirectory(szDict,KviApp::Help,"help.dict." KVI_SOURCES_DATE); + if ( KviFileUtils::fileExists(szDoclist) && KviFileUtils::fileExists( szDict )) g_pDocIndex->readDict(); + else + { + c->warning(__tr2qs("Docs database is not builded")); + return true; + } + } + int i=g_pDocIndex->titlesList().indexOf(szDoc); + if (i!=-1) + { + szDoc=QUrl::fromLocalFile(g_pDocIndex->documentList()[ i ]).path(); + if (szDoc.left(1)=="/") szDoc.remove(0,1); + } + } + QFileInfo * f= new QFileInfo(szDoc); if(f) { if(!f->exists()) { - doc = dirHelp.absoluteFilePath(doc); - qDebug("No abs path, trying relative path: %s",doc.toUtf8().data()); - f->setFile(doc); + szDoc = dirHelp.absoluteFilePath(szDoc); + qDebug("No abs path, trying relative path: %s",szDoc.toUtf8().data()); + f->setFile(szDoc); } if(!f->exists()) { - doc = dirHelp.absoluteFilePath("nohelpavailable.html"); - qDebug("No rel path, defaulting to error page: %s",doc.toUtf8().data()); - f->setFile(doc); + szDoc = dirHelp.absoluteFilePath("nohelpavailable.html"); + qDebug("No rel path, defaulting to error page: %s",szDoc.toUtf8().data()); + f->setFile(szDoc); } } diff --git a/src/modules/popupeditor/popupeditor.cpp b/src/modules/popupeditor/popupeditor.cpp index e7fdd5768..e3f79dd62 100644 --- a/src/modules/popupeditor/popupeditor.cpp +++ b/src/modules/popupeditor/popupeditor.cpp @@ -56,21 +56,21 @@ extern KviPopupEditorWindow * g_pPopupEditorWindow; //KviPopupEntryItem -KviPopupListViewItem::KviPopupListViewItem(KviTalTreeWidget * pListView,KviPopupListViewItem * after,Type t) -: KviTalTreeWidgetItem(pListView,after) +KviPopupTreeWidgetItem::KviPopupTreeWidgetItem(KviTalTreeWidget * pTreeWidget,KviPopupTreeWidgetItem * after,Type t) +: KviTalTreeWidgetItem(pTreeWidget,after) { m_type = t; init(); } -KviPopupListViewItem::KviPopupListViewItem(KviPopupListViewItem * parent,KviPopupListViewItem * after,Type t) +KviPopupTreeWidgetItem::KviPopupTreeWidgetItem(KviPopupTreeWidgetItem * parent,KviPopupTreeWidgetItem * after,Type t) : KviTalTreeWidgetItem(parent,after) { m_type = t; init(); } -void KviPopupListViewItem::init() +void KviPopupTreeWidgetItem::init() { switch(m_type) { @@ -103,7 +103,7 @@ void KviPopupListViewItem::init() } } -void KviPopupListViewItem::setItemText(const QString & szText) +void KviPopupTreeWidgetItem::setItemText(const QString & szText) { switch(m_type) { @@ -119,7 +119,7 @@ void KviPopupListViewItem::setItemText(const QString & szText) } } -void KviPopupListViewItem::setCondition(const QString & szCondition) +void KviPopupTreeWidgetItem::setCondition(const QString & szCondition) { switch(m_type) { @@ -134,7 +134,7 @@ void KviPopupListViewItem::setCondition(const QString & szCondition) } } -void KviPopupListViewItem::setCode(const QString & szCode) +void KviPopupTreeWidgetItem::setCode(const QString & szCode) { switch(m_type) { @@ -149,12 +149,12 @@ void KviPopupListViewItem::setCode(const QString & szCode) } } -void KviPopupListViewItem::setId(const QString & szId) +void KviPopupTreeWidgetItem::setId(const QString & szId) { m_szId = szId; } -void KviPopupListViewItem::setIcon(const QString & szIcon) +void KviPopupTreeWidgetItem::setIcon(const QString & szIcon) { switch(m_type) { @@ -189,6 +189,7 @@ KviSinglePopupEditor::KviSinglePopupEditor(QWidget * par) g->setMargin(0); g->setSpacing(2); + m_pNameEditor = new QLineEdit(this); m_pNameEditor->setToolTip(__tr2qs("Popup name")); @@ -201,24 +202,26 @@ KviSinglePopupEditor::KviSinglePopupEditor(QWidget * par) spl->setObjectName("popupeditor"); spl->setOpaqueResize(false); - m_pListView = new KviTalTreeWidget(spl); - m_pListView->setColumnCount(2); + m_pTreeWidget = new KviTalTreeWidget(spl); + m_pTreeWidget->setColumnCount(2); QStringList labels; labels << __tr2qs("Item") << __tr2qs("Type"); - m_pListView->setHeaderLabels(labels); - m_pListView->setSelectionMode(QAbstractItemView::SingleSelection); - m_pListView->setSelectionBehavior(QAbstractItemView::SelectRows); - m_pListView->setAllColumnsShowFocus(true); - m_pListView->setRootIsDecorated(true); - m_pListView->header()->setSortIndicatorShown(false); - m_pListView->setSortingEnabled(false); + m_pTreeWidget->setHeaderLabels(labels); + m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection); + m_pTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows); + m_pTreeWidget->setAllColumnsShowFocus(true); + m_pTreeWidget->setRootIsDecorated(true); + m_pTreeWidget->header()->setSortIndicatorShown(false); + m_pTreeWidget->setSortingEnabled(false); - connect(m_pListView,SIGNAL(itemSelectionChanged()),this,SLOT(selectionChanged())); - connect(m_pListView,SIGNAL(itemPressed(KviTalTreeWidgetItem *, int)), + connect(m_pTreeWidget,SIGNAL(itemSelectionChanged()),this,SLOT(selectionChanged())); + connect(m_pTreeWidget,SIGNAL(itemPressed(KviTalTreeWidgetItem *, int)), this,SLOT(itemPressed(KviTalTreeWidgetItem *, int))); - m_pEditor = KviScriptEditor::createInstance(spl); + + m_pEditor = KviScriptEditor::createInstance(spl); + g->addWidget(spl,1,0,1,3); QLabel * l = new QLabel(__tr2qs("Text:"),this); @@ -292,11 +295,11 @@ void KviSinglePopupEditor::testPopup() m_pTestPopup->doPopup(pnt,g_pActiveWindow,parms,true); } -KviPopupListViewItem * KviSinglePopupEditor::findMatchingItem(KviKvsPopupMenuItem * it,KviPopupListViewItem * item) +KviPopupTreeWidgetItem * KviSinglePopupEditor::findMatchingItem(KviKvsPopupMenuItem * it,KviPopupTreeWidgetItem * item) { if(it->type() != KviKvsPopupMenuItem::Item)goto not_this_one; - if(item->m_type != KviPopupListViewItem::Item)goto not_this_one; + if(item->m_type != KviPopupTreeWidgetItem::Item)goto not_this_one; if(it->name() != item->m_szId)goto not_this_one; if(it->kvsText()) { @@ -329,8 +332,8 @@ not_this_one: int count=item->childCount(); for(int i=0; i<count; i++) { - item = (KviPopupListViewItem *)item->child(i); - KviPopupListViewItem * found = findMatchingItem(it,item); + item = (KviPopupTreeWidgetItem *)item->child(i); + KviPopupTreeWidgetItem * found = findMatchingItem(it,item); if(found)return found; } @@ -342,16 +345,16 @@ void KviSinglePopupEditor::testModeMenuItemClicked(KviKvsPopupMenuItem * it) saveLastSelectedItem(); // that's the first thingie // find the matching item and set it as current - int count=m_pListView->topLevelItemCount(); + int count=m_pTreeWidget->topLevelItemCount(); for(int i=0; i<count; i++) { - KviPopupListViewItem * item = (KviPopupListViewItem *)m_pListView->topLevelItem(i); - KviPopupListViewItem * found = findMatchingItem(it,item); + KviPopupTreeWidgetItem * item = (KviPopupTreeWidgetItem *)m_pTreeWidget->topLevelItem(i); + KviPopupTreeWidgetItem * found = findMatchingItem(it,item); if(found) { // set the item as current - m_pListView->scrollToItem(found); - m_pListView->setCurrentItem(found); + m_pTreeWidget->scrollToItem(found); + m_pTreeWidget->setCurrentItem(found); found->setSelected(true); selectionChanged(); return; @@ -367,13 +370,13 @@ void KviSinglePopupEditor::itemPressed(KviTalTreeWidgetItem * it, int) m_pContextPopup->clear(); - KviPopupListViewItem * parentMenu = 0; + KviPopupTreeWidgetItem * parentMenu = 0; bool bIsMenu = false; if(it) { - parentMenu = (KviPopupListViewItem *) (((KviPopupListViewItem *)it)->parent()); - bIsMenu = ((KviPopupListViewItem *)it)->m_type == KviPopupListViewItem::Menu; + parentMenu = (KviPopupTreeWidgetItem *) (((KviPopupTreeWidgetItem *)it)->parent()); + bIsMenu = ((KviPopupTreeWidgetItem *)it)->m_type == KviPopupTreeWidgetItem::Menu; } m_pContextPopup->insertItem(__tr2qs("New Separator Below"),this,SLOT(contextNewSeparatorBelow())); @@ -477,120 +480,120 @@ void KviSinglePopupEditor::itemPressed(KviTalTreeWidgetItem * it, int) m_pContextPopup->popup(QCursor::pos()); } -void KviSinglePopupEditor::createNewItemAboveLastSelected(KviPopupListViewItem::Type t) +void KviSinglePopupEditor::createNewItemAboveLastSelected(KviPopupTreeWidgetItem::Type t) { - m_pListView->setCurrentItem(newItemAbove(m_pLastSelectedItem,t)); + m_pTreeWidget->setCurrentItem(newItemAbove(m_pLastSelectedItem,t)); } -void KviSinglePopupEditor::createNewItemBelowLastSelected(KviPopupListViewItem::Type t) +void KviSinglePopupEditor::createNewItemBelowLastSelected(KviPopupTreeWidgetItem::Type t) { - m_pListView->setCurrentItem(newItemBelow(m_pLastSelectedItem,t)); + m_pTreeWidget->setCurrentItem(newItemBelow(m_pLastSelectedItem,t)); } -void KviSinglePopupEditor::createNewItemInsideLastSelected(KviPopupListViewItem::Type t) +void KviSinglePopupEditor::createNewItemInsideLastSelected(KviPopupTreeWidgetItem::Type t) { if(m_pLastSelectedItem)m_pLastSelectedItem->setExpanded(true); - m_pListView->setCurrentItem(newItemInside(m_pLastSelectedItem,t)); + m_pTreeWidget->setCurrentItem(newItemInside(m_pLastSelectedItem,t)); } void KviSinglePopupEditor::contextNewSeparatorAbove() { - createNewItemAboveLastSelected(KviPopupListViewItem::Separator); + createNewItemAboveLastSelected(KviPopupTreeWidgetItem::Separator); } void KviSinglePopupEditor::contextNewSeparatorBelow() { - createNewItemBelowLastSelected(KviPopupListViewItem::Separator); + createNewItemBelowLastSelected(KviPopupTreeWidgetItem::Separator); } void KviSinglePopupEditor::contextNewSeparatorInside() { - createNewItemInsideLastSelected(KviPopupListViewItem::Separator); + createNewItemInsideLastSelected(KviPopupTreeWidgetItem::Separator); } void KviSinglePopupEditor::contextNewItemBelow() { - createNewItemBelowLastSelected(KviPopupListViewItem::Item); + createNewItemBelowLastSelected(KviPopupTreeWidgetItem::Item); } void KviSinglePopupEditor::contextNewItemAbove() { - createNewItemAboveLastSelected(KviPopupListViewItem::Item); + createNewItemAboveLastSelected(KviPopupTreeWidgetItem::Item); } void KviSinglePopupEditor::contextNewItemInside() { - createNewItemInsideLastSelected(KviPopupListViewItem::Item); + createNewItemInsideLastSelected(KviPopupTreeWidgetItem::Item); } void KviSinglePopupEditor::contextNewMenuBelow() { - createNewItemBelowLastSelected(KviPopupListViewItem::Menu); + createNewItemBelowLastSelected(KviPopupTreeWidgetItem::Menu); } void KviSinglePopupEditor::contextNewMenuAbove() { - createNewItemAboveLastSelected(KviPopupListViewItem::Menu); + createNewItemAboveLastSelected(KviPopupTreeWidgetItem::Menu); } void KviSinglePopupEditor::contextNewMenuInside() { - createNewItemInsideLastSelected(KviPopupListViewItem::Menu); + createNewItemInsideLastSelected(KviPopupTreeWidgetItem::Menu); } void KviSinglePopupEditor::contextNewExtMenuBelow() { - createNewItemBelowLastSelected(KviPopupListViewItem::ExtMenu); + createNewItemBelowLastSelected(KviPopupTreeWidgetItem::ExtMenu); } void KviSinglePopupEditor::contextNewExtMenuAbove() { - createNewItemAboveLastSelected(KviPopupListViewItem::ExtMenu); + createNewItemAboveLastSelected(KviPopupTreeWidgetItem::ExtMenu); } void KviSinglePopupEditor::contextNewExtMenuInside() { - createNewItemInsideLastSelected(KviPopupListViewItem::ExtMenu); + createNewItemInsideLastSelected(KviPopupTreeWidgetItem::ExtMenu); } void KviSinglePopupEditor::contextNewLabelBelow() { - createNewItemBelowLastSelected(KviPopupListViewItem::Label); + createNewItemBelowLastSelected(KviPopupTreeWidgetItem::Label); } void KviSinglePopupEditor::contextNewLabelAbove() { - createNewItemAboveLastSelected(KviPopupListViewItem::Label); + createNewItemAboveLastSelected(KviPopupTreeWidgetItem::Label); } void KviSinglePopupEditor::contextNewLabelInside() { - createNewItemInsideLastSelected(KviPopupListViewItem::Label); + createNewItemInsideLastSelected(KviPopupTreeWidgetItem::Label); } -KviPopupListViewItem * KviSinglePopupEditor::newItem(KviPopupListViewItem * par,KviPopupListViewItem * after,KviPopupListViewItem::Type t) +KviPopupTreeWidgetItem * KviSinglePopupEditor::newItem(KviPopupTreeWidgetItem * par,KviPopupTreeWidgetItem * after,KviPopupTreeWidgetItem::Type t) { - if(par)return new KviPopupListViewItem(par,after,t); - return new KviPopupListViewItem(m_pListView,after,t); + if(par)return new KviPopupTreeWidgetItem(par,after,t); + return new KviPopupTreeWidgetItem(m_pTreeWidget,after,t); } -KviPopupListViewItem * KviSinglePopupEditor::newItemBelow(KviPopupListViewItem * it,KviPopupListViewItem::Type t) +KviPopupTreeWidgetItem * KviSinglePopupEditor::newItemBelow(KviPopupTreeWidgetItem * it,KviPopupTreeWidgetItem::Type t) { if(!it)return newItem(0,0,t); - return newItem((KviPopupListViewItem *)it->parent(),it,t); + return newItem((KviPopupTreeWidgetItem *)it->parent(),it,t); } -KviPopupListViewItem * KviSinglePopupEditor::newItemAbove(KviPopupListViewItem * it,KviPopupListViewItem::Type t) +KviPopupTreeWidgetItem * KviSinglePopupEditor::newItemAbove(KviPopupTreeWidgetItem * it,KviPopupTreeWidgetItem::Type t) { if(!it)return newItem(0,0,t); - return newItem((KviPopupListViewItem *)it->parent(),(KviPopupListViewItem *)m_pListView->itemAbove(it),t); + return newItem((KviPopupTreeWidgetItem *)it->parent(),(KviPopupTreeWidgetItem *)m_pTreeWidget->itemAbove(it),t); } -KviPopupListViewItem * KviSinglePopupEditor::newItemInside(KviPopupListViewItem * it,KviPopupListViewItem::Type t) +KviPopupTreeWidgetItem * KviSinglePopupEditor::newItemInside(KviPopupTreeWidgetItem * it,KviPopupTreeWidgetItem::Type t) { if(it) { - if(it->m_type != KviPopupListViewItem::Menu) + if(it->m_type != KviPopupTreeWidgetItem::Menu) { return newItemBelow(it,t); } @@ -600,30 +603,30 @@ KviPopupListViewItem * KviSinglePopupEditor::newItemInside(KviPopupListViewItem void KviSinglePopupEditor::contextNewPrologue() { - KviPopupListViewItem * it = m_pLastSelectedItem ? (KviPopupListViewItem *)m_pLastSelectedItem->parent() : 0; + KviPopupTreeWidgetItem * it = m_pLastSelectedItem ? (KviPopupTreeWidgetItem *)m_pLastSelectedItem->parent() : 0; // if(!findPrologue(it)) // { - m_pListView->setCurrentItem(newItem(it,it,KviPopupListViewItem::Prologue)); + m_pTreeWidget->setCurrentItem(newItem(it,it,KviPopupTreeWidgetItem::Prologue)); // } } void KviSinglePopupEditor::contextNewEpilogue() { - KviPopupListViewItem * it = m_pLastSelectedItem ? (KviPopupListViewItem *)m_pLastSelectedItem->parent() : 0; + KviPopupTreeWidgetItem * it = m_pLastSelectedItem ? (KviPopupTreeWidgetItem *)m_pLastSelectedItem->parent() : 0; // if(!findEpilogue(it)) // { - KviPopupListViewItem * after = it ? (KviPopupListViewItem *)it->child(0) : (KviPopupListViewItem *)m_pListView->topLevelItem(0); + KviPopupTreeWidgetItem * after = it ? (KviPopupTreeWidgetItem *)it->child(0) : (KviPopupTreeWidgetItem *)m_pTreeWidget->topLevelItem(0); if(after) { - while(m_pListView->itemAbove(after)) + while(m_pTreeWidget->itemAbove(after)) { - if(after->parent()==m_pListView->itemAbove(after)->parent()) - after = (KviPopupListViewItem *)m_pListView->itemAbove(after); + if(after->parent()==m_pTreeWidget->itemAbove(after)->parent()) + after = (KviPopupTreeWidgetItem *)m_pTreeWidget->itemAbove(after); } } else { after = it; } - m_pListView->setCurrentItem(newItem(it,after,KviPopupListViewItem::Epilogue)); + m_pTreeWidget->setCurrentItem(newItem(it,after,KviPopupTreeWidgetItem::Epilogue)); // } } @@ -640,7 +643,7 @@ void KviSinglePopupEditor::contextCut() if(!m_pLastSelectedItem)return; contextCopy(); - KviPopupListViewItem * it = m_pLastSelectedItem; + KviPopupTreeWidgetItem * it = m_pLastSelectedItem; m_pLastSelectedItem = 0; delete it; if(!m_pLastSelectedItem)selectionChanged(); @@ -649,15 +652,15 @@ void KviSinglePopupEditor::contextCut() void KviSinglePopupEditor::contextPasteBelow() { if(!m_pClipboard)return; - KviPopupListViewItem * par = m_pLastSelectedItem ? (KviPopupListViewItem *)m_pLastSelectedItem->parent() : 0; + KviPopupTreeWidgetItem * par = m_pLastSelectedItem ? (KviPopupTreeWidgetItem *)m_pLastSelectedItem->parent() : 0; populateMenu(m_pClipboard,par,m_pLastSelectedItem); } void KviSinglePopupEditor::contextPasteAbove() { if(!m_pClipboard)return; - KviPopupListViewItem * par = m_pLastSelectedItem ? (KviPopupListViewItem *)m_pLastSelectedItem->parent() : 0; - KviPopupListViewItem * above = m_pLastSelectedItem ? (KviPopupListViewItem *)m_pListView->itemAbove(m_pLastSelectedItem) : 0; + KviPopupTreeWidgetItem * par = m_pLastSelectedItem ? (KviPopupTreeWidgetItem *)m_pLastSelectedItem->parent() : 0; + KviPopupTreeWidgetItem * above = m_pLastSelectedItem ? (KviPopupTreeWidgetItem *)m_pTreeWidget->itemAbove(m_pLastSelectedItem) : 0; populateMenu(m_pClipboard,par,above); } @@ -667,7 +670,7 @@ void KviSinglePopupEditor::contextPasteInside() if(!m_pClipboard)return; if(m_pLastSelectedItem) { - if(m_pLastSelectedItem->m_type != KviPopupListViewItem::Menu) + if(m_pLastSelectedItem->m_type != KviPopupTreeWidgetItem::Menu) { contextPasteBelow(); return; @@ -685,9 +688,9 @@ void KviSinglePopupEditor::saveLastSelectedItem() switch(m_pLastSelectedItem->m_type) { - case KviPopupListViewItem::Prologue: - case KviPopupListViewItem::Epilogue: - case KviPopupListViewItem::Item: + case KviPopupTreeWidgetItem::Prologue: + case KviPopupTreeWidgetItem::Epilogue: + case KviPopupTreeWidgetItem::Item: { QString tmpx; m_pEditor->getText(tmpx); @@ -702,9 +705,9 @@ void KviSinglePopupEditor::saveLastSelectedItem() switch(m_pLastSelectedItem->m_type) { - case KviPopupListViewItem::Menu: - case KviPopupListViewItem::ExtMenu: - case KviPopupListViewItem::Item: + case KviPopupTreeWidgetItem::Menu: + case KviPopupTreeWidgetItem::ExtMenu: + case KviPopupTreeWidgetItem::Item: m_pLastSelectedItem->setIcon(m_pIconEditor->text()); break; default: @@ -713,10 +716,10 @@ void KviSinglePopupEditor::saveLastSelectedItem() switch(m_pLastSelectedItem->m_type) { - case KviPopupListViewItem::Menu: - case KviPopupListViewItem::Item: - case KviPopupListViewItem::Label: - case KviPopupListViewItem::ExtMenu: + case KviPopupTreeWidgetItem::Menu: + case KviPopupTreeWidgetItem::Item: + case KviPopupTreeWidgetItem::Label: + case KviPopupTreeWidgetItem::ExtMenu: m_pLastSelectedItem->setItemText(m_pTextEditor->text()); m_pLastSelectedItem->setCondition(m_pConditionEditor->text()); break; @@ -724,50 +727,50 @@ void KviSinglePopupEditor::saveLastSelectedItem() break; } - if(m_pLastSelectedItem->m_type == KviPopupListViewItem::ExtMenu) + if(m_pLastSelectedItem->m_type == KviPopupTreeWidgetItem::ExtMenu) { m_pLastSelectedItem->setCode(m_pExtNameEditor->text()); } } -void KviSinglePopupEditor::addItemToMenu(KviKvsPopupMenu * p,KviPopupListViewItem *it) +void KviSinglePopupEditor::addItemToMenu(KviKvsPopupMenu * p,KviPopupTreeWidgetItem *it) { it->m_szId.trimmed(); switch(it->m_type) { - case KviPopupListViewItem::Prologue: + case KviPopupTreeWidgetItem::Prologue: it->m_szCode.trimmed(); p->addPrologue(it->m_szId,it->m_szCode); break; - case KviPopupListViewItem::Epilogue: + case KviPopupTreeWidgetItem::Epilogue: it->m_szCode.trimmed(); p->addEpilogue(it->m_szId,it->m_szCode); break; - case KviPopupListViewItem::Separator: + case KviPopupTreeWidgetItem::Separator: it->m_szCondition.trimmed(); p->addSeparator(it->m_szId,it->m_szCondition); break; - case KviPopupListViewItem::Label: + case KviPopupTreeWidgetItem::Label: it->m_szText.trimmed(); it->m_szCondition.trimmed(); it->m_szIcon.trimmed(); p->addLabel(it->m_szId,it->m_szText,it->m_szIcon,it->m_szCondition); break; - case KviPopupListViewItem::Item: + case KviPopupTreeWidgetItem::Item: it->m_szText.trimmed(); it->m_szIcon.trimmed(); it->m_szCondition.trimmed(); it->m_szCode.trimmed(); p->addItem(it->m_szId,it->m_szCode,it->m_szText,it->m_szIcon,it->m_szCondition); break; - case KviPopupListViewItem::ExtMenu: + case KviPopupTreeWidgetItem::ExtMenu: it->m_szText.trimmed(); it->m_szIcon.trimmed(); it->m_szCondition.trimmed(); it->m_szCode.trimmed();// <-- this is the ext name in fact p->addExtPopup(it->m_szId,it->m_szCode,it->m_szText,it->m_szIcon,it->m_szCondition); break; - case KviPopupListViewItem::Menu: + case KviPopupTreeWidgetItem::Menu: { it->m_szText.trimmed(); it->m_szIcon.trimmed(); @@ -776,7 +779,7 @@ void KviSinglePopupEditor::addItemToMenu(KviKvsPopupMenu * p,KviPopupListViewIte int count= it->childCount(); for(int i=0; i<count; i++) { - addItemToMenu(menu,(KviPopupListViewItem *)it->child(i)); + addItemToMenu(menu,(KviPopupTreeWidgetItem *)it->child(i)); } } break; @@ -794,10 +797,10 @@ KviKvsPopupMenu * KviSinglePopupEditor::getMenu() KviKvsPopupMenu * p = new KviKvsPopupMenu(tmp); - int count= m_pListView->topLevelItemCount(); + int count= m_pTreeWidget->topLevelItemCount(); for(int i=0; i<count; i++) { - addItemToMenu(p,(KviPopupListViewItem *)m_pListView->topLevelItem(i)); + addItemToMenu(p,(KviPopupTreeWidgetItem *)m_pTreeWidget->topLevelItem(i)); } return p; } @@ -814,64 +817,64 @@ void KviSinglePopupEditor::selectionChanged() KviTalTreeWidgetItem * it; - if(m_pListView->selectedItems().empty()) + if(m_pTreeWidget->selectedItems().empty()) { it=0; } else { - it= (KviTalTreeWidgetItem*)m_pListView->selectedItems().first(); + it= (KviTalTreeWidgetItem*)m_pTreeWidget->selectedItems().first(); } if(it) { - m_pIdEditor->setText(((KviPopupListViewItem *)it)->m_szId); + m_pIdEditor->setText(((KviPopupTreeWidgetItem *)it)->m_szId); - switch(((KviPopupListViewItem *)it)->m_type) + switch(((KviPopupTreeWidgetItem *)it)->m_type) { - case KviPopupListViewItem::Prologue: - case KviPopupListViewItem::Epilogue: - case KviPopupListViewItem::Item: - m_pEditor->setText(((KviPopupListViewItem *)it)->m_szCode); + case KviPopupTreeWidgetItem::Prologue: + case KviPopupTreeWidgetItem::Epilogue: + case KviPopupTreeWidgetItem::Item: + m_pEditor->setText(((KviPopupTreeWidgetItem *)it)->m_szCode); bEditorEnabled = true; break; default: break; } - switch(((KviPopupListViewItem *)it)->m_type) + switch(((KviPopupTreeWidgetItem *)it)->m_type) { - case KviPopupListViewItem::Menu: - case KviPopupListViewItem::Item: - case KviPopupListViewItem::Label: - case KviPopupListViewItem::ExtMenu: - m_pIconEditor->setText(((KviPopupListViewItem *)it)->m_szIcon); + case KviPopupTreeWidgetItem::Menu: + case KviPopupTreeWidgetItem::Item: + case KviPopupTreeWidgetItem::Label: + case KviPopupTreeWidgetItem::ExtMenu: + m_pIconEditor->setText(((KviPopupTreeWidgetItem *)it)->m_szIcon); bIconEditorEnabled = true; break; default: break; } - switch(((KviPopupListViewItem *)it)->m_type) + switch(((KviPopupTreeWidgetItem *)it)->m_type) { - case KviPopupListViewItem::Menu: - case KviPopupListViewItem::Item: - case KviPopupListViewItem::Label: - case KviPopupListViewItem::ExtMenu: - m_pConditionEditor->setText(((KviPopupListViewItem *)it)->m_szCondition); + case KviPopupTreeWidgetItem::Menu: + case KviPopupTreeWidgetItem::Item: + case KviPopupTreeWidgetItem::Label: + case KviPopupTreeWidgetItem::ExtMenu: + m_pConditionEditor->setText(((KviPopupTreeWidgetItem *)it)->m_szCondition); bConditionEditorEnabled = true; - m_pTextEditor->setText(((KviPopupListViewItem *)it)->m_szText); + m_pTextEditor->setText(((KviPopupTreeWidgetItem *)it)->m_szText); bTextEditorEnabled = true; break; default: break; } - if(((KviPopupListViewItem *)it)->m_type == KviPopupListViewItem::ExtMenu) + if(((KviPopupTreeWidgetItem *)it)->m_type == KviPopupTreeWidgetItem::ExtMenu) { - m_pExtNameEditor->setText(((KviPopupListViewItem *)it)->m_szCode); + m_pExtNameEditor->setText(((KviPopupTreeWidgetItem *)it)->m_szCode); bNameEditorEnabled =true; } } - m_pLastSelectedItem = (KviPopupListViewItem *)it; + m_pLastSelectedItem = (KviPopupTreeWidgetItem *)it; if(!bEditorEnabled)m_pEditor->setText(""); m_pEditor->setEnabled(bEditorEnabled); @@ -887,14 +890,14 @@ void KviSinglePopupEditor::selectionChanged() m_pIdEditor->setEnabled(it); } -void KviSinglePopupEditor::populateMenu(KviKvsPopupMenu * pop,KviPopupListViewItem * par,KviPopupListViewItem * theItem) +void KviSinglePopupEditor::populateMenu(KviKvsPopupMenu * pop,KviPopupTreeWidgetItem * par,KviPopupTreeWidgetItem * theItem) { if(!pop)return; for(KviKvsScript * sp = pop->prologues()->first();sp;sp = pop->prologues()->next()) { - if(par)theItem = new KviPopupListViewItem(par,theItem,KviPopupListViewItem::Prologue); - else theItem = new KviPopupListViewItem(m_pListView,theItem,KviPopupListViewItem::Prologue); + if(par)theItem = new KviPopupTreeWidgetItem(par,theItem,KviPopupTreeWidgetItem::Prologue); + else theItem = new KviPopupTreeWidgetItem(m_pTreeWidget,theItem,KviPopupTreeWidgetItem::Prologue); theItem->setCode(sp->code()); theItem->setId(sp->name()); } @@ -904,8 +907,8 @@ void KviSinglePopupEditor::populateMenu(KviKvsPopupMenu * pop,KviPopupListViewIt switch(item->type()) { case KviKvsPopupMenuItem::Item: - if(par)theItem = new KviPopupListViewItem(par,theItem,KviPopupListViewItem::Item); - else theItem = new KviPopupListViewItem(m_pListView,theItem,KviPopupListViewItem::Item); + if(par)theItem = new KviPopupTreeWidgetItem(par,theItem,KviPopupTreeWidgetItem::Item); + else theItem = new KviPopupTreeWidgetItem(m_pTreeWidget,theItem,KviPopupTreeWidgetItem::Item); theItem->setIcon(item->kvsIcon() ? item->kvsIcon()->code() : QString::null); theItem->setItemText(item->kvsText() ? item->kvsText()->code() : QString::null); theItem->setCondition(item->kvsCondition() ? item->kvsCondition()->code() : QString::null); @@ -913,8 +916,8 @@ void KviSinglePopupEditor::populateMenu(KviKvsPopupMenu * pop,KviPopupListViewIt theItem->setId(item->name()); break; case KviKvsPopupMenuItem::ExtMenu: - if(par)theItem = new KviPopupListViewItem(par,theItem,KviPopupListViewItem::ExtMenu); - else theItem = new KviPopupListViewItem(m_pListView,theItem,KviPopupListViewItem::ExtMenu); + if(par)theItem = new KviPopupTreeWidgetItem(par,theItem,KviPopupTreeWidgetItem::ExtMenu); + else theItem = new KviPopupTreeWidgetItem(m_pTreeWidget,theItem,KviPopupTreeWidgetItem::ExtMenu); theItem->setIcon(item->kvsIcon() ? item->kvsIcon()->code() : QString::null); theItem->setItemText(item->kvsText() ? item->kvsText()->code() : QString::null); theItem->setCondition(item->kvsCondition() ? item->kvsCondition()->code() : QString::null); @@ -922,21 +925,21 @@ void KviSinglePopupEditor::populateMenu(KviKvsPopupMenu * pop,KviPopupListViewIt theItem->setId(item->name()); break; case KviKvsPopupMenuItem::Label: - if(par)theItem = new KviPopupListViewItem(par,theItem,KviPopupListViewItem::Label); - else theItem = new KviPopupListViewItem(m_pListView,theItem,KviPopupListViewItem::Label); + if(par)theItem = new KviPopupTreeWidgetItem(par,theItem,KviPopupTreeWidgetItem::Label); + else theItem = new KviPopupTreeWidgetItem(m_pTreeWidget,theItem,KviPopupTreeWidgetItem::Label); theItem->setIcon(item->kvsIcon() ? item->kvsIcon()->code() : QString::null); theItem->setItemText(item->kvsText() ? item->kvsText()->code() : QString::null); theItem->setCondition(item->kvsCondition() ? item->kvsCondition()->code() : QString::null); theItem->setId(item->name()); break; case KviKvsPopupMenuItem::Separator: - if(par)theItem = new KviPopupListViewItem(par,theItem,KviPopupListViewItem::Separator); - else theItem = new KviPopupListViewItem(m_pListView,theItem,KviPopupListViewItem::Separator); + if(par)theItem = new KviPopupTreeWidgetItem(par,theItem,KviPopupTreeWidgetItem::Separator); + else theItem = new KviPopupTreeWidgetItem(m_pTreeWidget,theItem,KviPopupTreeWidgetItem::Separator); theItem->setId(item->name()); break; case KviKvsPopupMenuItem::Menu: - if(par)theItem = new KviPopupListViewItem(par,theItem,KviPopupListViewItem::Menu); - else theItem = new KviPopupListViewItem(m_pListView,theItem,KviPopupListViewItem::Menu); + if(par)theItem = new KviPopupTreeWidgetItem(par,theItem,KviPopupTreeWidgetItem::Menu); + else theItem = new KviPopupTreeWidgetItem(m_pTreeWidget,theItem,KviPopupTreeWidgetItem::Menu); theItem->setIcon(item->kvsIcon() ? item->kvsIcon()->code() : QString::null); theItem->setItemText(item->kvsText() ? item->kvsText()->code() : QString::null); theItem->setCondition(item->kvsCondition() ? item->kvsCondition()->code() : QString::null); @@ -950,31 +953,29 @@ void KviSinglePopupEditor::populateMenu(KviKvsPopupMenu * pop,KviPopupListViewIt for(KviKvsScript * se = pop->epilogues()->first();se;se = pop->epilogues()->next()) { - if(par)theItem = new KviPopupListViewItem(par,theItem,KviPopupListViewItem::Epilogue); - else theItem = new KviPopupListViewItem(m_pListView,theItem,KviPopupListViewItem::Epilogue); + if(par)theItem = new KviPopupTreeWidgetItem(par,theItem,KviPopupTreeWidgetItem::Epilogue); + else theItem = new KviPopupTreeWidgetItem(m_pTreeWidget,theItem,KviPopupTreeWidgetItem::Epilogue); theItem->setCode(se->code()); theItem->setId(se->name()); } - m_pListView->resizeColumnToContents(0); + m_pTreeWidget->resizeColumnToContents(0); } -void KviSinglePopupEditor::edit(KviMenuListViewItem * it) +void KviSinglePopupEditor::edit(KviMenuTreeWidgetItem * it) { saveLastSelectedItem(); m_pLastSelectedItem = 0; - m_pListView->clear(); + m_pTreeWidget->clear(); selectionChanged(); if(it) { m_pNameEditor->setText(it->m_pPopup->popupName()); - populateMenu(it->m_pPopup,0,0); - } else { m_pIconEditor->setText(""); m_pIconEditor->setEnabled(false); @@ -990,14 +991,14 @@ void KviSinglePopupEditor::edit(KviMenuListViewItem * it) m_pExtNameEditor->setText(""); m_pExtNameEditor->setEnabled(false); } - m_pListView->setEnabled(it); + m_pTreeWidget->setEnabled(it); m_pNameEditor->setEnabled(it); m_pMenuButton->setEnabled(it); } -KviMenuListViewItem::KviMenuListViewItem(KviTalTreeWidget * par,KviKvsPopupMenu * popup) +KviMenuTreeWidgetItem::KviMenuTreeWidgetItem(KviTalTreeWidget * par,KviKvsPopupMenu * popup) : KviTalTreeWidgetItem(par) { setIcon(0,*(g_pIconManager->getSmallIcon(KVI_SMALLICON_POPUP))); @@ -1005,12 +1006,12 @@ KviMenuListViewItem::KviMenuListViewItem(KviTalTreeWidget * par,KviKvsPopupMenu m_pPopup = popup; } -KviMenuListViewItem::~KviMenuListViewItem() +KviMenuTreeWidgetItem::~KviMenuTreeWidgetItem() { delete m_pPopup; } -void KviMenuListViewItem::replacePopup(KviKvsPopupMenu * popup) +void KviMenuTreeWidgetItem::replacePopup(KviKvsPopupMenu * popup) { delete m_pPopup; m_pPopup = popup; @@ -1027,10 +1028,10 @@ KviPopupEditor::KviPopupEditor(QWidget * par) KviTalVBox * box = new KviTalVBox(spl); - m_pListView = new KviTalTreeWidget(box); - m_pListView->addColumn(__tr2qs("Popup")); - m_pListView->setSelectionMode(QAbstractItemView::ExtendedSelection); - m_pListView->header()->setSortIndicatorShown(true); + m_pTreeWidget = new KviTalTreeWidget(box); + m_pTreeWidget->addColumn(__tr2qs("Popup")); + m_pTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); + m_pTreeWidget->header()->setSortIndicatorShown(true); QPushButton * pb = new QPushButton(__tr2qs("&Export All To..."),box); connect(pb,SIGNAL(clicked()),this,SLOT(exportAll())); @@ -1043,6 +1044,9 @@ KviPopupEditor::KviPopupEditor(QWidget * par) m_pLastEditedItem = 0; m_pContextPopup = new KviTalPopupMenu(this); + + spl->setStretchFactor (0,20); + spl->setStretchFactor (1,80); currentItemChanged(0,0); } @@ -1061,19 +1065,19 @@ void KviPopupEditor::oneTimeSetup() KviPointerHashTableIterator<QString,KviKvsPopupMenu> it(*a); - KviMenuListViewItem * item; + KviMenuTreeWidgetItem * item; while(it.current()) { KviKvsPopupMenu * popup = it.current(); KviKvsPopupMenu * copy = new KviKvsPopupMenu(popup->popupName()); copy->copyFrom(popup); - item = new KviMenuListViewItem(m_pListView,copy); + item = new KviMenuTreeWidgetItem(m_pTreeWidget,copy); ++it; } - connect(m_pListView,SIGNAL(currentItemChanged(KviTalTreeWidgetItem *,KviTalTreeWidgetItem *)),this,SLOT(currentItemChanged(KviTalTreeWidgetItem *,KviTalTreeWidgetItem *))); - connect(m_pListView,SIGNAL(itemPressed(KviTalTreeWidgetItem *, int)), + connect(m_pTreeWidget,SIGNAL(currentItemChanged(KviTalTreeWidgetItem *,KviTalTreeWidgetItem *)),this,SLOT(currentItemChanged(KviTalTreeWidgetItem *,KviTalTreeWidgetItem *))); + connect(m_pTreeWidget,SIGNAL(itemPressed(KviTalTreeWidgetItem *, int)), this,SLOT(itemPressed(KviTalTreeWidgetItem *, int))); } @@ -1149,11 +1153,11 @@ void KviPopupEditor::exportPopups(bool bSelectedOnly) saveLastEditedItem(); QString out; - int count=0, topcount=m_pListView->topLevelItemCount(); + int count=0, topcount=m_pTreeWidget->topLevelItemCount(); for(int i=0; i<topcount;i++) { - KviMenuListViewItem * it = (KviMenuListViewItem *)m_pListView->topLevelItem(i); + KviMenuTreeWidgetItem * it = (KviMenuTreeWidgetItem *)m_pTreeWidget->topLevelItem(i); if ( (it->isSelected()) || (bSelectedOnly == true) ) { count++; @@ -1183,7 +1187,7 @@ void KviPopupEditor::removeCurrentPopup() { if(m_pLastEditedItem) { - KviMenuListViewItem * it = m_pLastEditedItem; + KviMenuTreeWidgetItem * it = m_pLastEditedItem; m_pLastEditedItem = 0; delete it; if(!m_pLastEditedItem)currentItemChanged(0,0); @@ -1194,8 +1198,8 @@ void KviPopupEditor::newPopup() { QString newName; getUniquePopupName(0,newName); - KviMenuListViewItem * it = new KviMenuListViewItem(m_pListView,new KviKvsPopupMenu(newName)); - m_pListView->setCurrentItem(it); + KviMenuTreeWidgetItem * it = new KviMenuTreeWidgetItem(m_pTreeWidget,new KviKvsPopupMenu(newName)); + m_pTreeWidget->setCurrentItem(it); } void KviPopupEditor::saveLastEditedItem() @@ -1219,7 +1223,7 @@ void KviPopupEditor::currentItemChanged(KviTalTreeWidgetItem *it,KviTalTreeWidge { saveLastEditedItem(); - m_pLastEditedItem = (KviMenuListViewItem *)it; + m_pLastEditedItem = (KviMenuTreeWidgetItem *)it; m_pEditor->edit(m_pLastEditedItem); } @@ -1238,7 +1242,7 @@ void KviPopupEditor::commit() //KviKvsPopupManager::instance()->clear(); - int count=0, topcount=m_pListView->topLevelItemCount(); + int count=0, topcount=m_pTreeWidget->topLevelItemCount(); // Copy the original popup dict KviPointerHashTable<QString,KviKvsPopupMenu> copy(*(KviKvsPopupManager::instance()->popupDict())); @@ -1246,7 +1250,7 @@ void KviPopupEditor::commit() for(int i=0; i<topcount;i++) { - KviMenuListViewItem * it = (KviMenuListViewItem *)m_pListView->topLevelItem(i); + KviMenuTreeWidgetItem * it = (KviMenuTreeWidgetItem *)m_pTreeWidget->topLevelItem(i); KviKvsPopupMenu * p = KviKvsPopupManager::instance()->get(it->m_pPopup->popupName()); p->doClear(); p->copyFrom(it->m_pPopup); @@ -1268,7 +1272,7 @@ void KviPopupEditor::commit() g_pApp->savePopups(); } -void KviPopupEditor::getUniquePopupName(KviMenuListViewItem *item,QString &buffer) +void KviPopupEditor::getUniquePopupName(KviMenuTreeWidgetItem *item,QString &buffer) { __range_valid(m_bOneTimeSetupDone); @@ -1277,7 +1281,7 @@ void KviPopupEditor::getUniquePopupName(KviMenuListViewItem *item,QString &buffe bool bFound = true; int idx = 1; - int topcount=m_pListView->topLevelItemCount(); + int topcount=m_pTreeWidget->topLevelItemCount(); while(bFound) { @@ -1285,7 +1289,7 @@ void KviPopupEditor::getUniquePopupName(KviMenuListViewItem *item,QString &buffe for(int i=0; i<topcount;i++) { - KviMenuListViewItem * ch = (KviMenuListViewItem *)m_pListView->topLevelItem(i); + KviMenuTreeWidgetItem * ch = (KviMenuTreeWidgetItem *)m_pTreeWidget->topLevelItem(i); if(KviQString::equalCI(newName,ch->m_pPopup->popupName()) && (ch != item)) { diff --git a/src/modules/popupeditor/popupeditor.h b/src/modules/popupeditor/popupeditor.h index 5b3ce16b6..1aa8285b0 100644 --- a/src/modules/popupeditor/popupeditor.h +++ b/src/modules/popupeditor/popupeditor.h @@ -36,16 +36,16 @@ class KviKvsPopupMenu; class KviKvsPopupMenuItem; class KviScriptEditor; -class KviMenuListViewItem; +class KviMenuTreeWidgetItem; -// KviPopupListViewItem -class KviPopupListViewItem : public KviTalTreeWidgetItem +// KviPopupTreeWidgetItem +class KviPopupTreeWidgetItem : public KviTalTreeWidgetItem { public: enum Type { Item , Menu , Separator , Label , Epilogue , Prologue , ExtMenu }; public: - KviPopupListViewItem(KviTalTreeWidget * pListView,KviPopupListViewItem * after,Type t); - KviPopupListViewItem(KviPopupListViewItem * parent,KviPopupListViewItem * after,Type t); + KviPopupTreeWidgetItem(KviTalTreeWidget * pTreeWidget,KviPopupTreeWidgetItem * after,Type t); + KviPopupTreeWidgetItem(KviPopupTreeWidgetItem * parent,KviPopupTreeWidgetItem * after,Type t); public: Type m_type; QString m_szText; @@ -74,8 +74,8 @@ protected: QPushButton * m_pMenuButton; KviKvsPopupMenu * m_pClipboard; KviKvsPopupMenu * m_pTestPopup; - KviPopupListViewItem * m_pLastSelectedItem; - KviTalTreeWidget * m_pListView; + KviPopupTreeWidgetItem * m_pLastSelectedItem; + KviTalTreeWidget * m_pTreeWidget; QLineEdit * m_pNameEditor; KviScriptEditor * m_pEditor; QLineEdit * m_pTextEditor; @@ -85,21 +85,21 @@ protected: QLineEdit * m_pExtNameEditor; KviTalPopupMenu * m_pContextPopup; public: - void edit(KviMenuListViewItem * it); + void edit(KviMenuTreeWidgetItem * it); KviKvsPopupMenu * getMenu(); protected: // theItem is the item above the first item that has to be inserted - void populateMenu(KviKvsPopupMenu * pop,KviPopupListViewItem * par,KviPopupListViewItem * theItem = 0); + void populateMenu(KviKvsPopupMenu * pop,KviPopupTreeWidgetItem * par,KviPopupTreeWidgetItem * theItem = 0); void saveLastSelectedItem(); - void addItemToMenu(KviKvsPopupMenu * pop,KviPopupListViewItem * par); - KviPopupListViewItem * newItem(KviPopupListViewItem * par,KviPopupListViewItem * after,KviPopupListViewItem::Type t); - KviPopupListViewItem * newItemBelow(KviPopupListViewItem * it,KviPopupListViewItem::Type t); - KviPopupListViewItem * newItemAbove(KviPopupListViewItem * it,KviPopupListViewItem::Type t); - KviPopupListViewItem * newItemInside(KviPopupListViewItem * it,KviPopupListViewItem::Type t); - void createNewItemAboveLastSelected(KviPopupListViewItem::Type t); - void createNewItemBelowLastSelected(KviPopupListViewItem::Type t); - void createNewItemInsideLastSelected(KviPopupListViewItem::Type t); - KviPopupListViewItem * findMatchingItem(KviKvsPopupMenuItem * it,KviPopupListViewItem * item); + void addItemToMenu(KviKvsPopupMenu * pop,KviPopupTreeWidgetItem * par); + KviPopupTreeWidgetItem * newItem(KviPopupTreeWidgetItem * par,KviPopupTreeWidgetItem * after,KviPopupTreeWidgetItem::Type t); + KviPopupTreeWidgetItem * newItemBelow(KviPopupTreeWidgetItem * it,KviPopupTreeWidgetItem::Type t); + KviPopupTreeWidgetItem * newItemAbove(KviPopupTreeWidgetItem * it,KviPopupTreeWidgetItem::Type t); + KviPopupTreeWidgetItem * newItemInside(KviPopupTreeWidgetItem * it,KviPopupTreeWidgetItem::Type t); + void createNewItemAboveLastSelected(KviPopupTreeWidgetItem::Type t); + void createNewItemBelowLastSelected(KviPopupTreeWidgetItem::Type t); + void createNewItemInsideLastSelected(KviPopupTreeWidgetItem::Type t); + KviPopupTreeWidgetItem * findMatchingItem(KviKvsPopupMenuItem * it,KviPopupTreeWidgetItem * item); protected slots: void contextCut(); void contextCopy(); @@ -131,11 +131,11 @@ protected slots: -class KviMenuListViewItem : public KviTalTreeWidgetItem +class KviMenuTreeWidgetItem : public KviTalTreeWidgetItem { public: - KviMenuListViewItem(KviTalTreeWidget * par,KviKvsPopupMenu * popup); - ~KviMenuListViewItem(); + KviMenuTreeWidgetItem(KviTalTreeWidget * par,KviKvsPopupMenu * popup); + ~KviMenuTreeWidgetItem(); public: KviKvsPopupMenu * m_pPopup; public: @@ -153,8 +153,8 @@ public: ~KviPopupEditor(); public: KviSinglePopupEditor * m_pEditor; - KviTalTreeWidget * m_pListView; - KviMenuListViewItem * m_pLastEditedItem; + KviTalTreeWidget * m_pTreeWidget; + KviMenuTreeWidgetItem * m_pLastEditedItem; bool m_bOneTimeSetupDone; KviTalPopupMenu * m_pContextPopup; public: @@ -170,11 +170,11 @@ protected slots: void itemPressed(KviTalTreeWidgetItem * item, int column); protected: void showEvent(QShowEvent *e); - void getExportPopupBuffer(QString &buffer,KviMenuListViewItem * it); + void getExportPopupBuffer(QString &buffer,KviMenuTreeWidgetItem * it); private: void oneTimeSetup(); void saveLastEditedItem(); - void getUniquePopupName(KviMenuListViewItem * it,QString &buffer); + void getUniquePopupName(KviMenuTreeWidgetItem * it,QString &buffer); }; |
