aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/raweditor
diff options
context:
space:
mode:
authorGravatar Alexey Sokolov2016-04-29 23:57:30 +0100
committerGravatar Alexey Sokolov2016-04-29 23:57:48 +0100
commit690dd7a33ddc90678367d73adf313533536e10f2 (patch)
tree2276fe7c384ebbc222b40a19c536d5c3c5606ce8 /src/modules/raweditor
parentAdd config for clang-format. (diff)
downloadKVIrc-690dd7a33ddc90678367d73adf313533536e10f2.tar.gz
KVIrc-690dd7a33ddc90678367d73adf313533536e10f2.tar.bz2
KVIrc-690dd7a33ddc90678367d73adf313533536e10f2.zip
Apply clang-format
Diffstat (limited to 'src/modules/raweditor')
-rw-r--r--src/modules/raweditor/RawEditorWindow.cpp252
-rw-r--r--src/modules/raweditor/RawEditorWindow.h73
-rw-r--r--src/modules/raweditor/libkviraweditor.cpp23
3 files changed, 184 insertions, 164 deletions
diff --git a/src/modules/raweditor/RawEditorWindow.cpp b/src/modules/raweditor/RawEditorWindow.cpp
index 2a8e1fa1d..ba40666ad 100644
--- a/src/modules/raweditor/RawEditorWindow.cpp
+++ b/src/modules/raweditor/RawEditorWindow.cpp
@@ -51,58 +51,55 @@
extern RawEditorWindow * g_pRawEditorWindow;
-
-RawTreeWidgetItem::RawTreeWidgetItem(QTreeWidget *par,int idx,bool bEnabled)
-: QTreeWidgetItem(par)
+RawTreeWidgetItem::RawTreeWidgetItem(QTreeWidget * par, int idx, bool bEnabled)
+ : QTreeWidgetItem(par)
{
m_iIdx = idx;
- QString szName;
+ QString szName;
szName.sprintf("%03d", idx);
- setText(0,szName);
+ setText(0, szName);
setEnabled(bEnabled);
}
-void RawHandlerTreeWidgetItem::setName(const QString &szName)
+void RawHandlerTreeWidgetItem::setName(const QString & szName)
{
- setText(0,szName);
+ setText(0, szName);
}
RawEditorWidget::RawEditorWidget(QWidget * par)
-: QWidget(par)
+ : QWidget(par)
{
setObjectName("raw_event_editor");
QGridLayout * l = new QGridLayout(this);
- QSplitter * spl = new QSplitter(Qt::Horizontal,this);
+ QSplitter * spl = new QSplitter(Qt::Horizontal, this);
spl->setObjectName("raweditor_splitter");
spl->setChildrenCollapsible(false);
- l->addWidget(spl,0,0);
+ l->addWidget(spl, 0, 0);
KviTalVBox * boxi = new KviTalVBox(spl);
boxi->setMaximumWidth(200);
m_pTreeWidget = new RawTreeWidget(boxi);
-
-
m_pTreeWidget->setColumnCount(1);
- m_pTreeWidget->setHeaderLabel(__tr2qs_ctx("RAW Event","editor"));
+ m_pTreeWidget->setHeaderLabel(__tr2qs_ctx("RAW Event", "editor"));
-// m_pTreeWidget->setMultiSelection(false);
+ // m_pTreeWidget->setMultiSelection(false);
m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
-// m_pTreeWidget->setShowSortIndicator(true);
+ // m_pTreeWidget->setShowSortIndicator(true);
m_pTreeWidget->setRootIsDecorated(true);
m_pContextPopup = new QMenu(this);
m_pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(m_pTreeWidget,SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),this,SLOT(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)));
+ connect(m_pTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
- connect(m_pTreeWidget,SIGNAL(customContextMenuRequested(const QPoint &)),this,SLOT(customContextMenuRequested(const QPoint &)));
+ connect(m_pTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenuRequested(const QPoint &)));
- QPushButton * pb = new QPushButton(__tr2qs_ctx("&Export All to...","editor"),boxi);
- connect(pb,SIGNAL(clicked()),this,SLOT(exportAllEvents()));
+ QPushButton * pb = new QPushButton(__tr2qs_ctx("&Export All to...", "editor"), boxi);
+ connect(pb, SIGNAL(clicked()), this, SLOT(exportAllEvents()));
KviTalVBox * box = new KviTalVBox(spl);
m_pNameEditor = new QLineEdit(box);
- m_pNameEditor->setToolTip(__tr2qs_ctx("Edit the RAW event handler name.","editor"));
+ m_pNameEditor->setToolTip(__tr2qs_ctx("Edit the RAW event handler name.", "editor"));
m_pEditor = KviScriptEditor::createInstance(box);
m_bOneTimeSetupDone = false;
@@ -116,23 +113,24 @@ RawEditorWidget::~RawEditorWidget()
void RawEditorWidget::oneTimeSetup()
{
- if(m_bOneTimeSetupDone)return;
+ if(m_bOneTimeSetupDone)
+ return;
m_bOneTimeSetupDone = true;
RawTreeWidgetItem * it;
- for(unsigned int i = 0;i < 999;i++)
+ for(unsigned int i = 0; i < 999; i++)
{
KviPointerList<KviKvsEventHandler> * l = KviKvsEventManager::instance()->rawHandlers(i);
if(l)
{
- it = new RawTreeWidgetItem(m_pTreeWidget,i,true);
- for(KviKvsEventHandler * s = l->first();s;s = l->next())
+ it = new RawTreeWidgetItem(m_pTreeWidget, i, true);
+ for(KviKvsEventHandler * s = l->first(); s; s = l->next())
{
if(s->type() == KviKvsEventHandler::Script)
{
- new RawHandlerTreeWidgetItem(it,((KviKvsScriptEventHandler *)s)->name(),
- ((KviKvsScriptEventHandler *)s)->code(),((KviKvsScriptEventHandler *)s)->isEnabled());
+ new RawHandlerTreeWidgetItem(it, ((KviKvsScriptEventHandler *)s)->name(),
+ ((KviKvsScriptEventHandler *)s)->code(), ((KviKvsScriptEventHandler *)s)->isEnabled());
}
}
it->setExpanded(true);
@@ -140,10 +138,10 @@ void RawEditorWidget::oneTimeSetup()
}
}
-void RawEditorWidget::customContextMenuRequested(const QPoint &pos)
+void RawEditorWidget::customContextMenuRequested(const QPoint & pos)
{
- QTreeWidgetItem *it;
- it=(QTreeWidgetItem *)m_pTreeWidget->itemAt(pos);
+ QTreeWidgetItem * it;
+ it = (QTreeWidgetItem *)m_pTreeWidget->itemAt(pos);
KVI_ASSERT(m_bOneTimeSetupDone);
m_pContextPopup->clear();
if(it)
@@ -152,43 +150,46 @@ void RawEditorWidget::customContextMenuRequested(const QPoint &pos)
{
if(!(((RawHandlerTreeWidgetItem *)it)->m_bEnabled))
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Handler)),
- __tr2qs_ctx("&Enable Handler","editor"),this,SLOT(toggleCurrentHandlerEnabled()));
+ *(g_pIconManager->getSmallIcon(KviIconManager::Handler)),
+ __tr2qs_ctx("&Enable Handler", "editor"), this, SLOT(toggleCurrentHandlerEnabled()));
else
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::HandlerDisabled)),
- __tr2qs_ctx("&Disable Handler","editor"),this,SLOT(toggleCurrentHandlerEnabled()));
+ *(g_pIconManager->getSmallIcon(KviIconManager::HandlerDisabled)),
+ __tr2qs_ctx("&Disable Handler", "editor"), this, SLOT(toggleCurrentHandlerEnabled()));
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Discard)),
- __tr2qs_ctx("Re&move Handler","editor"),
- this,SLOT(removeCurrentHandler()));
+ *(g_pIconManager->getSmallIcon(KviIconManager::Discard)),
+ __tr2qs_ctx("Re&move Handler", "editor"),
+ this, SLOT(removeCurrentHandler()));
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Save)),
- __tr2qs_ctx("&Export Handler to...","editor"),
- this,SLOT(exportCurrentHandler()));
- } else {
+ *(g_pIconManager->getSmallIcon(KviIconManager::Save)),
+ __tr2qs_ctx("&Export Handler to...", "editor"),
+ this, SLOT(exportCurrentHandler()));
+ }
+ else
+ {
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Handler)),
- __tr2qs_ctx("&New Handler","editor"),
- this,SLOT(addHandlerForCurrentRaw()));
+ *(g_pIconManager->getSmallIcon(KviIconManager::Handler)),
+ __tr2qs_ctx("&New Handler", "editor"),
+ this, SLOT(addHandlerForCurrentRaw()));
}
}
m_pContextPopup->addSeparator();
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::RawEvent)),
- __tr2qs_ctx("&Add RAW Event...","editor"),
- this,SLOT(addRaw()));
- m_pContextPopup->popup(mapToGlobal(QPoint(pos.x()+15,pos.y())));
+ *(g_pIconManager->getSmallIcon(KviIconManager::RawEvent)),
+ __tr2qs_ctx("&Add RAW Event...", "editor"),
+ this, SLOT(addRaw()));
+ m_pContextPopup->popup(mapToGlobal(QPoint(pos.x() + 15, pos.y())));
}
-void RawEditorWidget::getUniqueHandlerName(RawTreeWidgetItem *it,QString &buffer)
+void RawEditorWidget::getUniqueHandlerName(RawTreeWidgetItem * it, QString & buffer)
{
KVI_ASSERT(m_bOneTimeSetupDone);
QString newName = buffer;
- if(newName.isEmpty())newName = __tr2qs_ctx("unnamed","editor");
+ if(newName.isEmpty())
+ newName = __tr2qs_ctx("unnamed", "editor");
bool bFound = true;
int idx = 1;
@@ -197,10 +198,10 @@ void RawEditorWidget::getUniqueHandlerName(RawTreeWidgetItem *it,QString &buffer
{
bFound = false;
- for (int i=0;i<it->childCount();i++)
+ for(int i = 0; i < it->childCount(); i++)
{
- RawHandlerTreeWidgetItem * ch =(RawHandlerTreeWidgetItem *) it->child(i);
- if(KviQString::equalCI(newName,ch->text(0)))
+ RawHandlerTreeWidgetItem * ch = (RawHandlerTreeWidgetItem *)it->child(i);
+ if(KviQString::equalCI(newName, ch->text(0)))
{
bFound = true;
newName = QString("%1_%2").arg(buffer).arg(idx);
@@ -208,7 +209,6 @@ void RawEditorWidget::getUniqueHandlerName(RawTreeWidgetItem *it,QString &buffer
break;
}
}
-
}
buffer = newName;
@@ -218,14 +218,15 @@ void RawEditorWidget::addRaw()
{
bool bOk = false;
- int iIdx = QInputDialog::getInt(this,__tr2qs_ctx("New RAW Event","editor"),__tr2qs_ctx("Enter the numeric code of the message (0-999)","editor"),0,0,999,1,&bOk);
+ int iIdx = QInputDialog::getInt(this, __tr2qs_ctx("New RAW Event", "editor"), __tr2qs_ctx("Enter the numeric code of the message (0-999)", "editor"), 0, 0, 999, 1, &bOk);
- if(!bOk)return;
+ if(!bOk)
+ return;
RawTreeWidgetItem * it;
- for (int i=0;i<m_pTreeWidget->topLevelItemCount();i++)
+ for(int i = 0; i < m_pTreeWidget->topLevelItemCount(); i++)
{
- it=(RawTreeWidgetItem *)m_pTreeWidget->topLevelItem(i);
+ it = (RawTreeWidgetItem *)m_pTreeWidget->topLevelItem(i);
if(((RawTreeWidgetItem *)it)->m_iIdx == iIdx)
{
m_pTreeWidget->setCurrentItem(it);
@@ -235,28 +236,27 @@ void RawEditorWidget::addRaw()
}
}
- it = new RawTreeWidgetItem(m_pTreeWidget,iIdx,true);
+ it = new RawTreeWidgetItem(m_pTreeWidget, iIdx, true);
m_pTreeWidget->setCurrentItem(it);
m_pTreeWidget->clearSelection();
it->setSelected(true);
add_handler:
addHandlerForCurrentRaw();
-
}
void RawEditorWidget::addHandlerForCurrentRaw()
{
KVI_ASSERT(m_bOneTimeSetupDone);
- RawTreeWidgetItem * it = (RawTreeWidgetItem *) m_pTreeWidget->currentItem();
+ RawTreeWidgetItem * it = (RawTreeWidgetItem *)m_pTreeWidget->currentItem();
if(it)
{
if(it->parent() == 0)
{
- QString buffer = __tr2qs_ctx("default","editor");
- getUniqueHandlerName((RawTreeWidgetItem *)it,buffer);
- QTreeWidgetItem * ch = new RawHandlerTreeWidgetItem(it,buffer,"",true);
+ QString buffer = __tr2qs_ctx("default", "editor");
+ getUniqueHandlerName((RawTreeWidgetItem *)it, buffer);
+ QTreeWidgetItem * ch = new RawHandlerTreeWidgetItem(it, buffer, "", true);
it->setEnabled(true);
it->setExpanded(true);
m_pTreeWidget->setCurrentItem(ch);
@@ -272,12 +272,13 @@ void RawEditorWidget::removeCurrentHandler()
if(m_pLastEditedItem)
{
QTreeWidgetItem * it = m_pLastEditedItem;
- RawTreeWidgetItem * parent=(RawTreeWidgetItem *)it->parent();
+ RawTreeWidgetItem * parent = (RawTreeWidgetItem *)it->parent();
m_pLastEditedItem = 0;
delete it;
m_pEditor->setEnabled(false);
m_pNameEditor->setEnabled(false);
- if (!parent->childCount()) parent->setEnabled(false);
+ if(!parent->childCount())
+ parent->setEnabled(false);
}
}
@@ -288,38 +289,38 @@ void RawEditorWidget::toggleCurrentHandlerEnabled()
{
m_pLastEditedItem->m_bEnabled = !(m_pLastEditedItem->m_bEnabled);
m_pLastEditedItem->setEnabled(m_pLastEditedItem->m_bEnabled);
- currentItemChanged(m_pLastEditedItem,m_pLastEditedItem);
+ currentItemChanged(m_pLastEditedItem, m_pLastEditedItem);
}
}
void RawEditorWidget::commit()
{
- if(!m_bOneTimeSetupDone)return; // nothing to commit
+ if(!m_bOneTimeSetupDone)
+ return; // nothing to commit
saveLastEditedItem();
KviKvsEventManager::instance()->removeAllScriptRawHandlers();
QTreeWidgetItem * it;
- for(int i=0;i<m_pTreeWidget->topLevelItemCount();i++)
+ for(int i = 0; i < m_pTreeWidget->topLevelItemCount(); i++)
{
- it=(QTreeWidgetItem *)m_pTreeWidget->topLevelItem(i);
+ it = (QTreeWidgetItem *)m_pTreeWidget->topLevelItem(i);
if(it->childCount())
{
QString szContext;
QTreeWidgetItem * ch;
- for (int j=0;j<it->childCount();j++)
+ for(int j = 0; j < it->childCount(); j++)
{
- ch=(QTreeWidgetItem *)it->child(j);
- qDebug("Commit handler %s",((RawHandlerTreeWidgetItem *)ch)->text(0).toUtf8().data());
+ ch = (QTreeWidgetItem *)it->child(j);
+ qDebug("Commit handler %s", ((RawHandlerTreeWidgetItem *)ch)->text(0).toUtf8().data());
//int a=(RawTreeWidgetItem *)it)->m_iIdx;
szContext = QString("RawEvent%1::%2").arg(((RawTreeWidgetItem *)it)->m_iIdx).arg(((RawHandlerTreeWidgetItem *)ch)->text(0));
KviKvsScriptEventHandler * s = new KviKvsScriptEventHandler(
- ((RawHandlerTreeWidgetItem *)ch)->text(0),
- szContext,
- ((RawHandlerTreeWidgetItem *)ch)->m_szBuffer,
- ((RawHandlerTreeWidgetItem *)ch)->m_bEnabled
- );
+ ((RawHandlerTreeWidgetItem *)ch)->text(0),
+ szContext,
+ ((RawHandlerTreeWidgetItem *)ch)->m_szBuffer,
+ ((RawHandlerTreeWidgetItem *)ch)->m_bEnabled);
- KviKvsEventManager::instance()->addRawHandler(((RawTreeWidgetItem *)it)->m_iIdx,s);
+ KviKvsEventManager::instance()->addRawHandler(((RawTreeWidgetItem *)it)->m_iIdx, s);
}
}
}
@@ -330,14 +331,15 @@ void RawEditorWidget::commit()
void RawEditorWidget::saveLastEditedItem()
{
KVI_ASSERT(m_bOneTimeSetupDone);
- if(!m_pLastEditedItem)return;
+ if(!m_pLastEditedItem)
+ return;
QString buffer = m_pNameEditor->text();
- qDebug("Check lineedit name %s and internal %s",buffer.toUtf8().data(),m_pLastEditedItem->text(0).toUtf8().data());
- if(!KviQString::equalCI(buffer,m_pLastEditedItem->text(0)))
+ qDebug("Check lineedit name %s and internal %s", buffer.toUtf8().data(), m_pLastEditedItem->text(0).toUtf8().data());
+ if(!KviQString::equalCI(buffer, m_pLastEditedItem->text(0)))
{
- getUniqueHandlerName((RawTreeWidgetItem *)(m_pLastEditedItem->parent()),buffer);
- qDebug("Change name %s",buffer.toUtf8().data());
+ getUniqueHandlerName((RawTreeWidgetItem *)(m_pLastEditedItem->parent()), buffer);
+ qDebug("Change name %s", buffer.toUtf8().data());
}
m_pLastEditedItem->setName(buffer);
@@ -347,7 +349,7 @@ void RawEditorWidget::saveLastEditedItem()
m_pLastEditedItem->m_szBuffer = tmp;
}
-void RawEditorWidget::currentItemChanged(QTreeWidgetItem * it,QTreeWidgetItem *)
+void RawEditorWidget::currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *)
{
KVI_ASSERT(m_bOneTimeSetupDone);
saveLastEditedItem();
@@ -358,25 +360,28 @@ void RawEditorWidget::currentItemChanged(QTreeWidgetItem * it,QTreeWidgetItem *)
m_pNameEditor->setText(it->text(0));
m_pEditor->setEnabled(true);
m_pEditor->setText(((RawHandlerTreeWidgetItem *)it)->m_szBuffer);
- } else {
+ }
+ else
+ {
m_pLastEditedItem = 0;
m_pNameEditor->setEnabled(false);
m_pNameEditor->setText("");
m_pEditor->setEnabled(false);
- QString szTmp = QString(__tr2qs_ctx("\n\nRAW Event:\n%1","editor")).arg(((RawHandlerTreeWidgetItem *)it)->text(0));
+ QString szTmp = QString(__tr2qs_ctx("\n\nRAW Event:\n%1", "editor")).arg(((RawHandlerTreeWidgetItem *)it)->text(0));
m_pEditor->setText(szTmp);
}
}
-void RawEditorWidget::showEvent(QShowEvent *e)
+void RawEditorWidget::showEvent(QShowEvent * e)
{
oneTimeSetup();
QWidget::showEvent(e);
}
-void RawEditorWidget::getExportEventBuffer(QString &buffer,RawHandlerTreeWidgetItem * it)
+void RawEditorWidget::getExportEventBuffer(QString & buffer, RawHandlerTreeWidgetItem * it)
{
- if(!it->parent())return;
+ if(!it->parent())
+ return;
QString szBuf = it->m_szBuffer;
@@ -402,12 +407,15 @@ void RawEditorWidget::getExportEventBuffer(QString &buffer,RawHandlerTreeWidgetI
void RawEditorWidget::exportCurrentHandler()
{
- if(!m_pLastEditedItem)return;
+ if(!m_pLastEditedItem)
+ return;
saveLastEditedItem();
- if(!m_pLastEditedItem)return;
+ if(!m_pLastEditedItem)
+ return;
QString szName = QDir::homePath();
- if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))szName += KVI_PATH_SEPARATOR;
+ if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))
+ szName += KVI_PATH_SEPARATOR;
szName += "raw";
szName += ((RawTreeWidgetItem *)(m_pLastEditedItem->parent()))->text(0);
szName += ".";
@@ -416,14 +424,15 @@ void RawEditorWidget::exportCurrentHandler()
QString szFile;
- if(!KviFileDialog::askForSaveFileName(szFile,__tr2qs_ctx("Choose a Filename - KVIrc","editor"),szName,KVI_FILTER_SCRIPT,true,true,true,this))return;
+ if(!KviFileDialog::askForSaveFileName(szFile, __tr2qs_ctx("Choose a Filename - KVIrc", "editor"), szName, KVI_FILTER_SCRIPT, true, true, true, this))
+ return;
QString szOut;
- getExportEventBuffer(szOut,m_pLastEditedItem);
+ getExportEventBuffer(szOut, m_pLastEditedItem);
- if(!KviFileUtils::writeFile(szFile,szOut))
+ if(!KviFileUtils::writeFile(szFile, szOut))
{
- QMessageBox::warning(this,__tr2qs_ctx("Writing to File Failed - KVIrc","editor"),__tr2qs_ctx("Unable to write to the RAW events file.","editor"),__tr2qs_ctx("&OK","editor"));
+ QMessageBox::warning(this, __tr2qs_ctx("Writing to File Failed - KVIrc", "editor"), __tr2qs_ctx("Unable to write to the RAW events file.", "editor"), __tr2qs_ctx("&OK", "editor"));
}
}
@@ -434,62 +443,63 @@ void RawEditorWidget::exportAllEvents()
RawTreeWidgetItem * it;
QString out;
- for (int i=0;i<m_pTreeWidget->topLevelItemCount();i++)
+ for(int i = 0; i < m_pTreeWidget->topLevelItemCount(); i++)
{
- it=(RawTreeWidgetItem *)m_pTreeWidget->topLevelItem(i);
+ it = (RawTreeWidgetItem *)m_pTreeWidget->topLevelItem(i);
RawHandlerTreeWidgetItem * item;
- for (int j=0;j<it->childCount();j++)
+ for(int j = 0; j < it->childCount(); j++)
{
QString tmp;
- item=(RawHandlerTreeWidgetItem *)it->child(j);
- getExportEventBuffer(tmp,item);
+ item = (RawHandlerTreeWidgetItem *)it->child(j);
+ getExportEventBuffer(tmp, item);
out += tmp;
out += "\n";
}
}
QString szName = QDir::homePath();
- if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))szName += KVI_PATH_SEPARATOR;
+ if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))
+ szName += KVI_PATH_SEPARATOR;
szName += "rawevents.kvs";
QString szFile;
- if(!KviFileDialog::askForSaveFileName(szFile,__tr2qs_ctx("Choose a Filename - KVIrc","editor"),szName,KVI_FILTER_SCRIPT,true,true,true,this))return;
+ if(!KviFileDialog::askForSaveFileName(szFile, __tr2qs_ctx("Choose a Filename - KVIrc", "editor"), szName, KVI_FILTER_SCRIPT, true, true, true, this))
+ return;
- if(!KviFileUtils::writeFile(szFile,out))
+ if(!KviFileUtils::writeFile(szFile, out))
{
- QMessageBox::warning(this,__tr2qs_ctx("Writing to File Failed - KVIrc","editor"),__tr2qs_ctx("Unable to write to the RAW events file.","editor"),__tr2qs_ctx("OK","editor"));
+ QMessageBox::warning(this, __tr2qs_ctx("Writing to File Failed - KVIrc", "editor"), __tr2qs_ctx("Unable to write to the RAW events file.", "editor"), __tr2qs_ctx("OK", "editor"));
}
}
-
RawEditorWindow::RawEditorWindow()
-: KviWindow(KviWindow::ScriptEditor,"raweditor",0)
+ : KviWindow(KviWindow::ScriptEditor, "raweditor", 0)
{
g_pRawEditorWindow = this;
QGridLayout * g = new QGridLayout();
m_pEditor = new RawEditorWidget(this);
- g->addWidget(m_pEditor,0,0,1,4);
+ g->addWidget(m_pEditor, 0, 0, 1, 4);
- QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK","editor"),this);
- connect(btn,SIGNAL(clicked()),this,SLOT(okClicked()));
+ QPushButton * btn = new QPushButton(__tr2qs_ctx("&OK", "editor"), this);
+ connect(btn, SIGNAL(clicked()), this, SLOT(okClicked()));
btn->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)));
- g->addWidget(btn,1,1);
+ g->addWidget(btn, 1, 1);
- btn = new QPushButton(__tr2qs_ctx("&Apply","editor"),this);
- connect(btn,SIGNAL(clicked()),this,SLOT(applyClicked()));
+ btn = new QPushButton(__tr2qs_ctx("&Apply", "editor"), this);
+ connect(btn, SIGNAL(clicked()), this, SLOT(applyClicked()));
btn->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)));
- g->addWidget(btn,1,2);
+ g->addWidget(btn, 1, 2);
- btn = new QPushButton(__tr2qs_ctx("Cancel","editor"),this);
- connect(btn,SIGNAL(clicked()),this,SLOT(cancelClicked()));
+ btn = new QPushButton(__tr2qs_ctx("Cancel", "editor"), this);
+ connect(btn, SIGNAL(clicked()), this, SLOT(cancelClicked()));
btn->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)));
- g->addWidget(btn,1,3);
+ g->addWidget(btn, 1, 3);
- g->setRowStretch(0,1);
- g->setColumnStretch(0,1);
+ g->setRowStretch(0, 1);
+ g->setColumnStretch(0, 1);
setLayout(g);
}
@@ -521,10 +531,10 @@ QPixmap * RawEditorWindow::myIconPtr()
void RawEditorWindow::fillCaptionBuffers()
{
- m_szPlainTextCaption = __tr2qs_ctx("RAW Editor","editor");
+ m_szPlainTextCaption = __tr2qs_ctx("RAW Editor", "editor");
}
-void RawEditorWindow::getConfigGroupName(QString &szName)
+void RawEditorWindow::getConfigGroupName(QString & szName)
{
szName = "raweditor";
}
diff --git a/src/modules/raweditor/RawEditorWindow.h b/src/modules/raweditor/RawEditorWindow.h
index 9de743b31..7cbfa407d 100644
--- a/src/modules/raweditor/RawEditorWindow.h
+++ b/src/modules/raweditor/RawEditorWindow.h
@@ -37,52 +37,59 @@ class QMenu;
class RawTreeWidget : public QTreeWidget
{
- public:
- RawTreeWidget(QWidget *par)
- : QTreeWidget(par){};
- void updateItem(QTreeWidgetItem *item)
+public:
+ RawTreeWidget(QWidget * par)
+ : QTreeWidget(par){};
+ void updateItem(QTreeWidgetItem * item)
{
- update(indexFromItem(item,0));
+ update(indexFromItem(item, 0));
};
- ~RawTreeWidget() {};
+ ~RawTreeWidget(){};
};
class RawTreeWidgetItem : public QTreeWidgetItem
{
public:
int m_iIdx;
+
public:
- RawTreeWidgetItem(QTreeWidget * par,int idx,bool bEnabled);
- ~RawTreeWidgetItem() {};
+ RawTreeWidgetItem(QTreeWidget * par, int idx, bool bEnabled);
+ ~RawTreeWidgetItem(){};
+
public:
void setEnabled(bool bEnabled)
{
- if (bEnabled) setIcon(0,QIcon(*g_pIconManager->getSmallIcon(KviIconManager::RawEvent)));
- else setIcon(0,QIcon(*g_pIconManager->getSmallIcon(KviIconManager::RawEventNoHandlers)));
- ((RawTreeWidget*)treeWidget())->updateItem(this);
+ if(bEnabled)
+ setIcon(0, QIcon(*g_pIconManager->getSmallIcon(KviIconManager::RawEvent)));
+ else
+ setIcon(0, QIcon(*g_pIconManager->getSmallIcon(KviIconManager::RawEventNoHandlers)));
+ ((RawTreeWidget *)treeWidget())->updateItem(this);
};
};
class RawHandlerTreeWidgetItem : public QTreeWidgetItem
{
public:
- RawHandlerTreeWidgetItem(QTreeWidgetItem * par,const QString & name,const QString & buffer,bool bEnabled)
- : QTreeWidgetItem(par), m_szBuffer(buffer), m_bEnabled(bEnabled)
+ RawHandlerTreeWidgetItem(QTreeWidgetItem * par, const QString & name, const QString & buffer, bool bEnabled)
+ : QTreeWidgetItem(par), m_szBuffer(buffer), m_bEnabled(bEnabled)
{
- setText(0,name);
+ setText(0, name);
setEnabled(bEnabled);
};
- ~RawHandlerTreeWidgetItem() {};
+ ~RawHandlerTreeWidgetItem(){};
+
public:
void setEnabled(bool bEnabled)
{
- if (bEnabled) setIcon(0,QIcon(*g_pIconManager->getSmallIcon(KviIconManager::Handler)));
- else setIcon(0,QIcon(*g_pIconManager->getSmallIcon(KviIconManager::HandlerDisabled)));
- ((RawTreeWidget*)treeWidget())->updateItem(this);
+ if(bEnabled)
+ setIcon(0, QIcon(*g_pIconManager->getSmallIcon(KviIconManager::Handler)));
+ else
+ setIcon(0, QIcon(*g_pIconManager->getSmallIcon(KviIconManager::HandlerDisabled)));
+ ((RawTreeWidget *)treeWidget())->updateItem(this);
};
QString m_szBuffer;
- bool m_bEnabled;
- void setName(const QString &szName);
+ bool m_bEnabled;
+ void setName(const QString & szName);
};
class RawEditorWidget : public QWidget
@@ -91,29 +98,33 @@ class RawEditorWidget : public QWidget
public:
RawEditorWidget(QWidget * par);
~RawEditorWidget();
+
public:
KviScriptEditor * m_pEditor;
- RawTreeWidget * m_pTreeWidget;
- QLineEdit * m_pNameEditor;
- QMenu * m_pContextPopup;
+ RawTreeWidget * m_pTreeWidget;
+ QLineEdit * m_pNameEditor;
+ QMenu * m_pContextPopup;
RawHandlerTreeWidgetItem * m_pLastEditedItem;
- bool m_bOneTimeSetupDone;
+ bool m_bOneTimeSetupDone;
+
public:
void commit();
void saveLastEditedItem();
- void getUniqueHandlerName(RawTreeWidgetItem *it,QString &buffer);
- void getExportEventBuffer(QString &szBuffer,RawHandlerTreeWidgetItem * it);
+ void getUniqueHandlerName(RawTreeWidgetItem * it, QString & buffer);
+ void getExportEventBuffer(QString & szBuffer, RawHandlerTreeWidgetItem * it);
protected slots:
- void currentItemChanged(QTreeWidgetItem *it,QTreeWidgetItem *);
- void customContextMenuRequested(const QPoint &pnt);
+ void currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *);
+ void customContextMenuRequested(const QPoint & pnt);
void toggleCurrentHandlerEnabled();
void removeCurrentHandler();
void addHandlerForCurrentRaw();
void addRaw();
void exportAllEvents();
void exportCurrentHandler();
+
protected:
- void showEvent(QShowEvent *e);
+ void showEvent(QShowEvent * e);
+
private:
void oneTimeSetup();
};
@@ -124,12 +135,14 @@ class RawEditorWindow : public KviWindow
public:
RawEditorWindow();
~RawEditorWindow();
+
protected:
RawEditorWidget * m_pEditor;
+
protected:
virtual QPixmap * myIconPtr();
virtual void fillCaptionBuffers();
- virtual void getConfigGroupName(QString &szName);
+ virtual void getConfigGroupName(QString & szName);
virtual void saveProperties(KviConfigurationFile *);
virtual void loadProperties(KviConfigurationFile *);
protected slots:
diff --git a/src/modules/raweditor/libkviraweditor.cpp b/src/modules/raweditor/libkviraweditor.cpp
index 06a9060ca..acfc7ea86 100644
--- a/src/modules/raweditor/libkviraweditor.cpp
+++ b/src/modules/raweditor/libkviraweditor.cpp
@@ -28,10 +28,8 @@
#include "KviLocale.h"
#include "KviMainWindow.h"
-
RawEditorWindow * g_pRawEditorWindow = 0;
-
/*
@doc: raweditor.open
@type:
@@ -59,7 +57,7 @@ static bool raweditor_kvs_cmd_open(KviKvsModuleCommandCall *)
static bool raweditor_module_init(KviModule * m)
{
- KVSM_REGISTER_SIMPLE_COMMAND(m,"open",raweditor_kvs_cmd_open);
+ KVSM_REGISTER_SIMPLE_COMMAND(m, "open", raweditor_kvs_cmd_open);
g_pRawEditorWindow = 0;
return true;
}
@@ -78,13 +76,12 @@ static bool raweditor_module_cleanup(KviModule *)
}
KVIRC_MODULE(
- "RawEditor", // module name
- "4.0.0", // module version
- "Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)", // author & (C)
- "Editor for the script RAW events",
- raweditor_module_init,
- raweditor_module_can_unload,
- 0,
- raweditor_module_cleanup,
- "editor"
-)
+ "RawEditor", // module name
+ "4.0.0", // module version
+ "Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)", // author & (C)
+ "Editor for the script RAW events",
+ raweditor_module_init,
+ raweditor_module_can_unload,
+ 0,
+ raweditor_module_cleanup,
+ "editor")