aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/aliaseditor/AliasEditorWindow.cpp
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/aliaseditor/AliasEditorWindow.cpp
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/aliaseditor/AliasEditorWindow.cpp')
-rw-r--r--src/modules/aliaseditor/AliasEditorWindow.cpp819
1 files changed, 433 insertions, 386 deletions
diff --git a/src/modules/aliaseditor/AliasEditorWindow.cpp b/src/modules/aliaseditor/AliasEditorWindow.cpp
index 71addacb5..665a0ed62 100644
--- a/src/modules/aliaseditor/AliasEditorWindow.cpp
+++ b/src/modules/aliaseditor/AliasEditorWindow.cpp
@@ -22,7 +22,6 @@
//
//=============================================================================
-
#include "AliasEditorWindow.h"
#include "KviIconManager.h"
@@ -60,43 +59,48 @@
extern AliasEditorWindow * g_pAliasEditorWindow;
extern KviModule * g_pAliasEditorModule;
-
-AliasEditorTreeWidgetItem::AliasEditorTreeWidgetItem(QTreeWidget * pTreeWidget,Type eType,const QString &szName)
-: QTreeWidgetItem(pTreeWidget), KviHeapObject(), m_eType(eType), m_pParentItem(0)
+AliasEditorTreeWidgetItem::AliasEditorTreeWidgetItem(QTreeWidget * pTreeWidget, Type eType, const QString & szName)
+ : QTreeWidgetItem(pTreeWidget), KviHeapObject(), m_eType(eType), m_pParentItem(0)
{
setName(szName);
- m_cPos=0;
- if(eType==AliasEditorTreeWidgetItem::Namespace) setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NameSpace))));
- else setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Alias))));
+ m_cPos = 0;
+ if(eType == AliasEditorTreeWidgetItem::Namespace)
+ setIcon(0, QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NameSpace))));
+ else
+ setIcon(0, QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Alias))));
}
-AliasEditorTreeWidgetItem::AliasEditorTreeWidgetItem(AliasEditorTreeWidgetItem * pParentItem,Type eType,const QString &szName)
-: QTreeWidgetItem(pParentItem), m_eType(eType), m_pParentItem(pParentItem)
+AliasEditorTreeWidgetItem::AliasEditorTreeWidgetItem(AliasEditorTreeWidgetItem * pParentItem, Type eType, const QString & szName)
+ : QTreeWidgetItem(pParentItem), m_eType(eType), m_pParentItem(pParentItem)
{
setName(szName);
- m_cPos=0;
- setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
- if(eType==AliasEditorTreeWidgetItem::Namespace) setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NameSpace))));
- else setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Alias))));
+ m_cPos = 0;
+ setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
+ if(eType == AliasEditorTreeWidgetItem::Namespace)
+ setIcon(0, QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NameSpace))));
+ else
+ setIcon(0, QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Alias))));
}
-void AliasEditorTreeWidgetItem::setName(const QString &szName)
+void AliasEditorTreeWidgetItem::setName(const QString & szName)
{
m_szName = szName;
- setText(0,m_szName);
+ setText(0, m_szName);
}
void AliasEditorTreeWidgetItem::setType(Type t)
{
- m_eType=t;
- if(t==AliasEditorTreeWidgetItem::Namespace) setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NameSpace))));
- else setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Alias))));
+ m_eType = t;
+ if(t == AliasEditorTreeWidgetItem::Namespace)
+ setIcon(0, QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NameSpace))));
+ else
+ setIcon(0, QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Alias))));
}
AliasEditorTreeWidget::AliasEditorTreeWidget(QWidget * par)
-: QTreeWidget(par)
+ : QTreeWidget(par)
{
- setColumnCount (1);
- setHeaderLabel(__tr2qs_ctx("Alias","editor"));
+ setColumnCount(1);
+ setHeaderLabel(__tr2qs_ctx("Alias", "editor"));
setSelectionMode(QAbstractItemView::ExtendedSelection);
setSortingEnabled(true);
setRootIsDecorated(true);
@@ -109,11 +113,10 @@ AliasEditorTreeWidget::~AliasEditorTreeWidget()
clear();
}
-
AliasEditorWidget::AliasEditorWidget(QWidget * par)
-: QWidget(par)
+ : QWidget(par)
{
- m_pAliases=new KviPointerList<AliasEditorTreeWidgetItem>;
+ m_pAliases = new KviPointerList<AliasEditorTreeWidgetItem>;
m_pAliases->setAutoDelete(false);
m_bSaving = false;
@@ -123,9 +126,9 @@ AliasEditorWidget::AliasEditorWidget(QWidget * par)
QGridLayout * l = new QGridLayout(this);
- m_pSplitter = new QSplitter(Qt::Horizontal,this);
+ m_pSplitter = new QSplitter(Qt::Horizontal, this);
m_pSplitter->setChildrenCollapsible(false);
- l->addWidget(m_pSplitter,0,0);
+ l->addWidget(m_pSplitter, 0, 0);
KviTalVBox * box = new KviTalVBox(m_pSplitter);
box->setSpacing(0);
@@ -137,23 +140,23 @@ AliasEditorWidget::AliasEditorWidget(QWidget * par)
KviTalHBox * hbox = new KviTalHBox(box);
hbox->setSpacing(0);
hbox->setMargin(0);
- m_pNameLabel = new QLabel(__tr2qs_ctx("No item selected","editor"),hbox);
- m_pRenameButton = new QPushButton(__tr2qs_ctx("Rename","editor"),hbox);
+ m_pNameLabel = new QLabel(__tr2qs_ctx("No item selected", "editor"), hbox);
+ m_pRenameButton = new QPushButton(__tr2qs_ctx("Rename", "editor"), hbox);
m_pRenameButton->setEnabled(false);
- connect(m_pRenameButton,SIGNAL(clicked()),this,SLOT(renameItem()));
- hbox->setStretchFactor(m_pNameLabel,2);
- m_pRenameButton->setToolTip(__tr2qs_ctx("Edit the alias or namespace name","editor"));
+ connect(m_pRenameButton, SIGNAL(clicked()), this, SLOT(renameItem()));
+ hbox->setStretchFactor(m_pNameLabel, 2);
+ m_pRenameButton->setToolTip(__tr2qs_ctx("Edit the alias or namespace name", "editor"));
m_pEditor = KviScriptEditor::createInstance(box);
m_pEditor->setFocus();
- connect(m_pEditor,SIGNAL(find(const QString &)),this,SLOT(slotFindWord(const QString &)));
- connect(m_pEditor,SIGNAL(replaceAll(const QString &,const QString &)),this,SLOT(slotReplaceAll(const QString &,const QString &)));
+ connect(m_pEditor, SIGNAL(find(const QString &)), this, SLOT(slotFindWord(const QString &)));
+ connect(m_pEditor, SIGNAL(replaceAll(const QString &, const QString &)), this, SLOT(slotReplaceAll(const QString &, const QString &)));
- m_pContextPopup = new QMenu(this);
+ m_pContextPopup = new QMenu(this);
oneTimeSetup();
- currentItemChanged(0,0);
+ currentItemChanged(0, 0);
}
AliasEditorWidget::~AliasEditorWidget()
@@ -162,10 +165,12 @@ AliasEditorWidget::~AliasEditorWidget()
delete m_pAliases;
}
-void AliasEditorWidget::buildFullItemPath(AliasEditorTreeWidgetItem * it,QString &szBuffer)
+void AliasEditorWidget::buildFullItemPath(AliasEditorTreeWidgetItem * it, QString & szBuffer)
{
- if (it->isAlias()) it=it->parentItem();
- if (!it) return;
+ if(it->isAlias())
+ it = it->parentItem();
+ if(!it)
+ return;
while(it)
{
QString tmp = it->name();
@@ -180,7 +185,8 @@ void AliasEditorWidget::buildFullItemPath(AliasEditorTreeWidgetItem * it,QString
QString AliasEditorWidget::buildFullItemName(AliasEditorTreeWidgetItem * it)
{
- if(!it) return QString();
+ if(!it)
+ return QString();
QString szName = it->name();
AliasEditorTreeWidgetItem * nit = it->parentItem();
@@ -198,79 +204,84 @@ QString AliasEditorWidget::buildFullItemName(AliasEditorTreeWidgetItem * it)
}
//FIXME this should be called something like "findNamespace"
-AliasEditorTreeWidgetItem * AliasEditorWidget::findTopLevelItem(const QString &szName)
+AliasEditorTreeWidgetItem * AliasEditorWidget::findTopLevelItem(const QString & szName)
{
- AliasEditorTreeWidgetItem *pItem =0;
- for(int i=0;i<m_pTreeWidget->topLevelItemCount();i++)
+ AliasEditorTreeWidgetItem * pItem = 0;
+ for(int i = 0; i < m_pTreeWidget->topLevelItemCount(); i++)
{
- pItem = (AliasEditorTreeWidgetItem*) m_pTreeWidget->topLevelItem(i);
- if (pItem->text(0)==szName && pItem->isNamespace())
- return (AliasEditorTreeWidgetItem*)m_pTreeWidget->topLevelItem(i);
+ pItem = (AliasEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i);
+ if(pItem->text(0) == szName && pItem->isNamespace())
+ return (AliasEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i);
}
return 0;
}
-AliasEditorTreeWidgetItem * AliasEditorWidget::findItem(const QString &szFullName)
+AliasEditorTreeWidgetItem * AliasEditorWidget::findItem(const QString & szFullName)
{
- QStringList lNamespaces=szFullName.split("::");
- if(!lNamespaces.count()) return 0;
- AliasEditorTreeWidgetItem *pItem=findTopLevelItem(lNamespaces.at(0));
- if (!pItem) return 0;
+ QStringList lNamespaces = szFullName.split("::");
+ if(!lNamespaces.count())
+ return 0;
+ AliasEditorTreeWidgetItem * pItem = findTopLevelItem(lNamespaces.at(0));
+ if(!pItem)
+ return 0;
bool bFound;
int i;
int j;
- for(i=1;i<lNamespaces.count();i++)
+ for(i = 1; i < lNamespaces.count(); i++)
{
- bFound=false;
- for(j=0;j<pItem->childCount();j++)
+ bFound = false;
+ for(j = 0; j < pItem->childCount(); j++)
{
- if (KviQString::equalCI(pItem->child(j)->text(0),lNamespaces.at(i)))
+ if(KviQString::equalCI(pItem->child(j)->text(0), lNamespaces.at(i)))
{
- pItem=( AliasEditorTreeWidgetItem *)pItem->child(j);
- bFound=true;
+ pItem = (AliasEditorTreeWidgetItem *)pItem->child(j);
+ bFound = true;
break;
}
}
- if (!bFound) return 0;
+ if(!bFound)
+ return 0;
}
return (AliasEditorTreeWidgetItem *)pItem;
}
-
-AliasEditorTreeWidgetItem * AliasEditorWidget::createFullItem(const QString &szFullName)
+AliasEditorTreeWidgetItem * AliasEditorWidget::createFullItem(const QString & szFullName)
{
- QStringList lNamespaces=szFullName.split("::");
- if(!lNamespaces.count()) return 0;
- if (lNamespaces.count()==1) return new AliasEditorTreeWidgetItem(m_pTreeWidget,AliasEditorTreeWidgetItem::Alias,lNamespaces.at(0));
- AliasEditorTreeWidgetItem *pItem=findTopLevelItem(lNamespaces.at(0));
- if (!pItem) pItem=new AliasEditorTreeWidgetItem(m_pTreeWidget,AliasEditorTreeWidgetItem::Namespace,lNamespaces.at(0));
+ QStringList lNamespaces = szFullName.split("::");
+ if(!lNamespaces.count())
+ return 0;
+ if(lNamespaces.count() == 1)
+ return new AliasEditorTreeWidgetItem(m_pTreeWidget, AliasEditorTreeWidgetItem::Alias, lNamespaces.at(0));
+ AliasEditorTreeWidgetItem * pItem = findTopLevelItem(lNamespaces.at(0));
+ if(!pItem)
+ pItem = new AliasEditorTreeWidgetItem(m_pTreeWidget, AliasEditorTreeWidgetItem::Namespace, lNamespaces.at(0));
bool bFound;
int i;
- for(i=1;i<lNamespaces.count()-1;i++)
+ for(i = 1; i < lNamespaces.count() - 1; i++)
{
- bFound=false;
- for(int j=0;j<pItem->childCount();j++)
+ bFound = false;
+ for(int j = 0; j < pItem->childCount(); j++)
{
- if (KviQString::equalCI(pItem->child(j)->text(0),lNamespaces.at(i)))
+ if(KviQString::equalCI(pItem->child(j)->text(0), lNamespaces.at(i)))
{
- pItem=( AliasEditorTreeWidgetItem *)pItem->child(j);
- bFound=true;
+ pItem = (AliasEditorTreeWidgetItem *)pItem->child(j);
+ bFound = true;
break;
}
}
- if (!bFound)
- pItem=new AliasEditorTreeWidgetItem(pItem,AliasEditorTreeWidgetItem::Namespace,lNamespaces.at(i));
+ if(!bFound)
+ pItem = new AliasEditorTreeWidgetItem(pItem, AliasEditorTreeWidgetItem::Namespace, lNamespaces.at(i));
}
- return new AliasEditorTreeWidgetItem(pItem,AliasEditorTreeWidgetItem::Alias,lNamespaces.at(i));
+ return new AliasEditorTreeWidgetItem(pItem, AliasEditorTreeWidgetItem::Alias, lNamespaces.at(i));
}
-
void AliasEditorWidget::oneTimeSetup()
{
- KviPointerHashTable<QString,KviKvsScript> * a = KviKvsAliasManager::instance()->aliasDict();
- if(!a)return;
+ KviPointerHashTable<QString, KviKvsScript> * a = KviKvsAliasManager::instance()->aliasDict();
+ if(!a)
+ return;
- KviPointerHashTableIterator<QString,KviKvsScript> it(*a);
+ KviPointerHashTableIterator<QString, KviKvsScript> it(*a);
AliasEditorTreeWidgetItem * item;
while(it.current())
@@ -282,30 +293,30 @@ void AliasEditorWidget::oneTimeSetup()
++it;
}
- connect(m_pTreeWidget,SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),this,SLOT(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)));
+ connect(m_pTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
m_pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(m_pTreeWidget,SIGNAL(customContextMenuRequested(const QPoint &)),this,SLOT(customContextMenuRequested(const QPoint &)));
- connect(m_pTreeWidget,SIGNAL(itemChanged(QTreeWidgetItem *,int)),this,SLOT(itemRenamed(QTreeWidgetItem *,int)));
- connect(KviKvsAliasManager::instance(),SIGNAL(aliasRefresh(const QString &)),this,SLOT(aliasRefresh(const QString &)));
- m_pTreeWidget->sortItems(0,Qt::AscendingOrder);
+ connect(m_pTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenuRequested(const QPoint &)));
+ connect(m_pTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(itemRenamed(QTreeWidgetItem *, int)));
+ connect(KviKvsAliasManager::instance(), SIGNAL(aliasRefresh(const QString &)), this, SLOT(aliasRefresh(const QString &)));
+ m_pTreeWidget->sortItems(0, Qt::AscendingOrder);
}
-void AliasEditorWidget::aliasRefresh(const QString &szName)
+void AliasEditorWidget::aliasRefresh(const QString & szName)
{
if(m_bSaving)
return;
- AliasEditorTreeWidgetItem * item=0;
+ AliasEditorTreeWidgetItem * item = 0;
KviKvsScript * alias = KviKvsAliasManager::instance()->aliasDict()->find(szName);
// search for old alias with same name
KviPointerList<AliasEditorTreeWidgetItem> l;
l.setAutoDelete(false);
- appendAllItems(&l,AliasEditorTreeWidgetItem::Alias);
- for(AliasEditorTreeWidgetItem * it = l.first();it;it = l.next())
+ appendAllItems(&l, AliasEditorTreeWidgetItem::Alias);
+ for(AliasEditorTreeWidgetItem * it = l.first(); it; it = l.next())
{
- if (KviQString::equalCI(buildFullItemName(it),szName))
+ if(KviQString::equalCI(buildFullItemName(it), szName))
{
- item=it;
+ item = it;
break;
}
}
@@ -315,85 +326,91 @@ void AliasEditorWidget::aliasRefresh(const QString &szName)
m_pAliases->append(item);
}
- if(item!=m_pLastEditedItem)
+ if(item != m_pLastEditedItem)
{
item->setBuffer(alias->code());
return;
}
if(
- QMessageBox::warning(0,__tr2qs_ctx("Confirm Overwriting Current - KVIrc","editor"),
- __tr2qs_ctx("An external script has changed the alias you are currently editing. Do you want to accept the external changes?","editor"),
- QMessageBox::Yes,QMessageBox::No|QMessageBox::Default|QMessageBox::Escape) != QMessageBox::Yes
- )
+ QMessageBox::warning(0, __tr2qs_ctx("Confirm Overwriting Current - KVIrc", "editor"),
+ __tr2qs_ctx("An external script has changed the alias you are currently editing. Do you want to accept the external changes?", "editor"),
+ QMessageBox::Yes, QMessageBox::No | QMessageBox::Default | QMessageBox::Escape)
+ != QMessageBox::Yes)
return;
item->setBuffer(alias->code());
m_pEditor->setText(alias->code());
}
-void AliasEditorWidget::itemRenamed(QTreeWidgetItem *it,int col)
+void AliasEditorWidget::itemRenamed(QTreeWidgetItem * it, int col)
{
- if(it!=m_pLastEditedItem) return;
+ if(it != m_pLastEditedItem)
+ return;
((AliasEditorTreeWidgetItem *)it)->setName(it->text(col));
QString szNam = buildFullItemName((AliasEditorTreeWidgetItem *)it);
QString szLabelText;
if(((AliasEditorTreeWidgetItem *)it)->isNamespace())
- szLabelText = __tr2qs_ctx("Namespace","editor");
+ szLabelText = __tr2qs_ctx("Namespace", "editor");
else
- szLabelText = __tr2qs_ctx("Alias","editor");
+ szLabelText = __tr2qs_ctx("Alias", "editor");
szLabelText += ": <b>";
szLabelText += szNam;
szLabelText += "</b>";
m_pNameLabel->setText(szLabelText);
}
-
-
bool AliasEditorWidget::hasSelectedItems()
- {
- return m_pTreeWidget->selectedItems().count()?1:0;
+{
+ return m_pTreeWidget->selectedItems().count() ? 1 : 0;
}
-bool AliasEditorWidget::itemExists(QTreeWidgetItem *pSearchFor)
+bool AliasEditorWidget::itemExists(QTreeWidgetItem * pSearchFor)
{
- if(!pSearchFor)return false;
- if (m_pAliases->findRef((AliasEditorTreeWidgetItem*) pSearchFor)!=-1) return true;
- else return false;
+ if(!pSearchFor)
+ return false;
+ if(m_pAliases->findRef((AliasEditorTreeWidgetItem *)pSearchFor) != -1)
+ return true;
+ else
+ return false;
}
-void AliasEditorWidget::appendAllItems(KviPointerList<AliasEditorTreeWidgetItem> * l,AliasEditorTreeWidgetItem::Type eType)
+void AliasEditorWidget::appendAllItems(KviPointerList<AliasEditorTreeWidgetItem> * l, AliasEditorTreeWidgetItem::Type eType)
{
- for (int i=0;i<m_pTreeWidget->topLevelItemCount();i++)
+ for(int i = 0; i < m_pTreeWidget->topLevelItemCount(); i++)
{
- if (((AliasEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i))->type()==eType)
+ if(((AliasEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i))->type() == eType)
{
l->append(((AliasEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i)));
- } else {
- appendAllItemsRecursive(l,m_pTreeWidget->topLevelItem(i),eType);
+ }
+ else
+ {
+ appendAllItemsRecursive(l, m_pTreeWidget->topLevelItem(i), eType);
}
}
}
-void AliasEditorWidget::appendAllItemsRecursive(KviPointerList<AliasEditorTreeWidgetItem> * l,QTreeWidgetItem * pStartFrom,AliasEditorTreeWidgetItem::Type eType)
+void AliasEditorWidget::appendAllItemsRecursive(KviPointerList<AliasEditorTreeWidgetItem> * l, QTreeWidgetItem * pStartFrom, AliasEditorTreeWidgetItem::Type eType)
{
- for (int i=0;i<pStartFrom->childCount();i++)
+ for(int i = 0; i < pStartFrom->childCount(); i++)
{
- if (((AliasEditorTreeWidgetItem *)pStartFrom->child(i))->type()==eType)
+ if(((AliasEditorTreeWidgetItem *)pStartFrom->child(i))->type() == eType)
{
l->append((AliasEditorTreeWidgetItem *)pStartFrom->child(i));
- } else {
- appendAllItemsRecursive(l,pStartFrom->child(i),eType);
+ }
+ else
+ {
+ appendAllItemsRecursive(l, pStartFrom->child(i), eType);
}
}
}
-bool AliasEditorWidget::aliasExists(QString &szFullItemName)
+bool AliasEditorWidget::aliasExists(QString & szFullItemName)
{
KviPointerList<AliasEditorTreeWidgetItem> l;
l.setAutoDelete(false);
- appendAllItems(&l,AliasEditorTreeWidgetItem::Alias);
- for(AliasEditorTreeWidgetItem * it = l.first();it;it = l.next())
+ appendAllItems(&l, AliasEditorTreeWidgetItem::Alias);
+ for(AliasEditorTreeWidgetItem * it = l.first(); it; it = l.next())
{
- if (KviQString::equalCI(buildFullItemName(it),szFullItemName))
+ if(KviQString::equalCI(buildFullItemName(it), szFullItemName))
{
return true;
}
@@ -401,15 +418,15 @@ bool AliasEditorWidget::aliasExists(QString &szFullItemName)
return false;
}
-bool AliasEditorWidget::namespaceExists(QString &szFullItemName)
+bool AliasEditorWidget::namespaceExists(QString & szFullItemName)
{
KviPointerList<AliasEditorTreeWidgetItem> l;
l.setAutoDelete(false);
- appendAllItems(&l,AliasEditorTreeWidgetItem::Namespace);
- for(AliasEditorTreeWidgetItem * it = l.first();it;it = l.next())
+ appendAllItems(&l, AliasEditorTreeWidgetItem::Namespace);
+ for(AliasEditorTreeWidgetItem * it = l.first(); it; it = l.next())
{
- if (KviQString::equalCI(buildFullItemName(it),szFullItemName))
+ if(KviQString::equalCI(buildFullItemName(it), szFullItemName))
{
return true;
}
@@ -418,7 +435,8 @@ bool AliasEditorWidget::namespaceExists(QString &szFullItemName)
}
void AliasEditorWidget::renameItem()
{
- if(!m_pLastEditedItem)return;
+ if(!m_pLastEditedItem)
+ return;
//if(itemExists(m_pLastEditedItem))return; // dead ?
QString szName = buildFullItemName(m_pLastEditedItem);
QString szNewName;
@@ -426,35 +444,39 @@ void AliasEditorWidget::renameItem()
bool bAlias = m_pLastEditedItem->isAlias();
if(bAlias)
- szNewName = askForAliasName(__tr2qs_ctx("Enter a New Name - KVIrc","editor"),__tr2qs_ctx("Please enter the new name for the alias.","editor"),szName);
+ szNewName = askForAliasName(__tr2qs_ctx("Enter a New Name - KVIrc", "editor"), __tr2qs_ctx("Please enter the new name for the alias.", "editor"), szName);
else
- szNewName = askForNamespaceName(__tr2qs_ctx("Enter a New Name - KVIrc","editor"),__tr2qs_ctx("Please enter the new name for the namespace.","editor"),szName);
- if(szNewName.isEmpty())return;
+ szNewName = askForNamespaceName(__tr2qs_ctx("Enter a New Name - KVIrc", "editor"), __tr2qs_ctx("Please enter the new name for the namespace.", "editor"), szName);
+ if(szNewName.isEmpty())
+ return;
- if(szName == szNewName)return;
+ if(szName == szNewName)
+ return;
// check if there is already an alias with this name
- if (bAlias)
+ if(bAlias)
{
- if (aliasExists(szNewName))
+ if(aliasExists(szNewName))
{
g_pAliasEditorModule->lock();
QMessageBox::information(this,
- __tr2qs_ctx("Name Already Exists - KVIrc","editor"),
- __tr2qs_ctx("This name is already in use. Please choose another one.","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Name Already Exists - KVIrc", "editor"),
+ __tr2qs_ctx("This name is already in use. Please choose another one.", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
return;
}
- } else {
- // check if there is already a namespace with this name
- if (namespaceExists(szNewName))
+ }
+ else
+ {
+ // check if there is already a namespace with this name
+ if(namespaceExists(szNewName))
{
g_pAliasEditorModule->lock();
QMessageBox::information(this,
- __tr2qs_ctx("Name Already Exists - KVIrc","editor"),
- __tr2qs_ctx("This name is already in use. Please choose another one.","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Name Already Exists - KVIrc", "editor"),
+ __tr2qs_ctx("This name is already in use. Please choose another one.", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
return;
}
@@ -467,25 +489,25 @@ void AliasEditorWidget::renameItem()
m_pEditor->getText(szCode);
pntCursor = m_pEditor->getCursor();
}
- QList<QTreeWidgetItem*> lChildren= m_pLastEditedItem->takeChildren();
+ QList<QTreeWidgetItem *> lChildren = m_pLastEditedItem->takeChildren();
bool bYesToAll = true;
- removeItem(m_pLastEditedItem,&bYesToAll,true);
+ removeItem(m_pLastEditedItem, &bYesToAll, true);
- m_pLastEditedItem = 0; // make sure it's true (but it already should be because of removeItem())
+ m_pLastEditedItem = 0; // make sure it's true (but it already should be because of removeItem())
m_pLastClickedItem = 0; // make sure it's true (but it already should be because of removeItem())
AliasEditorTreeWidgetItem * pItem = createFullItem(szNewName);
if(bAlias)
{
pItem->setBuffer(szCode);
pItem->setCursorPosition(pntCursor);
-
- } else {
- for(int i=0;i<lChildren.count();i++)
+ }
+ else
+ {
+ for(int i = 0; i < lChildren.count(); i++)
{
- ((AliasEditorTreeWidgetItem*)lChildren.at(i))->setParentItem(pItem);
- pItem->insertChild(pItem->childCount(),lChildren.at(i));
+ ((AliasEditorTreeWidgetItem *)lChildren.at(i))->setParentItem(pItem);
+ pItem->insertChild(pItem->childCount(), lChildren.at(i));
}
-
}
activateItem(pItem);
m_pAliases->append(pItem);
@@ -506,14 +528,14 @@ void AliasEditorWidget::saveLastEditedItem()
((AliasEditorTreeWidgetItem *)m_pLastEditedItem)->setBuffer(newCode);
}
-void AliasEditorWidget::currentItemChanged(QTreeWidgetItem *it,QTreeWidgetItem *)
+void AliasEditorWidget::currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *)
{
saveLastEditedItem();
m_pLastEditedItem = (AliasEditorTreeWidgetItem *)it;
if(!m_pLastEditedItem)
{
- m_pNameLabel->setText(__tr2qs_ctx("No item selected","editor"));
+ m_pNameLabel->setText(__tr2qs_ctx("No item selected", "editor"));
m_pRenameButton->setEnabled(false);
m_pEditor->setText("");
m_pEditor->setEnabled(false);
@@ -523,7 +545,7 @@ void AliasEditorWidget::currentItemChanged(QTreeWidgetItem *it,QTreeWidgetItem *
QString szNam = buildFullItemName(m_pLastEditedItem);
if(m_pLastEditedItem->isNamespace())
{
- QString szLabelText = __tr2qs_ctx("Namespace","editor");
+ QString szLabelText = __tr2qs_ctx("Namespace", "editor");
szLabelText += ": <b>";
szLabelText += szNam;
szLabelText += "</b>";
@@ -535,7 +557,7 @@ void AliasEditorWidget::currentItemChanged(QTreeWidgetItem *it,QTreeWidgetItem *
return;
}
- QString szLabelText = __tr2qs_ctx("Alias","editor");
+ QString szLabelText = __tr2qs_ctx("Alias", "editor");
szLabelText += ": <b>";
szLabelText += szNam;
szLabelText += "</b>";
@@ -548,81 +570,83 @@ void AliasEditorWidget::currentItemChanged(QTreeWidgetItem *it,QTreeWidgetItem *
m_pEditor->setEnabled(true);
}
-
void AliasEditorWidget::customContextMenuRequested(const QPoint pnt)
{
m_pContextPopup->clear();
m_pLastClickedItem = (AliasEditorTreeWidgetItem *)m_pTreeWidget->itemAt(pnt);
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Alias)),
- __tr2qs_ctx("Add Alias","editor"),
- this,SLOT(newAlias()));
+ *(g_pIconManager->getSmallIcon(KviIconManager::Alias)),
+ __tr2qs_ctx("Add Alias", "editor"),
+ this, SLOT(newAlias()));
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::NameSpace)),
- __tr2qs_ctx("Add Namespace","editor"),
- this,SLOT(newNamespace()));
+ *(g_pIconManager->getSmallIcon(KviIconManager::NameSpace)),
+ __tr2qs_ctx("Add Namespace", "editor"),
+ this, SLOT(newNamespace()));
bool bHasItems = m_pTreeWidget->topLevelItemCount();
bool bHasSelected = hasSelectedItems();
- m_pContextPopup->addSeparator();
+ m_pContextPopup->addSeparator();
- QAction *pAction = m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Discard)),
- __tr2qs_ctx("Remove Selected","editor"),
- this,SLOT(removeSelectedItems()));
- pAction->setEnabled(bHasSelected);
+ QAction * pAction = m_pContextPopup->addAction(
+ *(g_pIconManager->getSmallIcon(KviIconManager::Discard)),
+ __tr2qs_ctx("Remove Selected", "editor"),
+ this, SLOT(removeSelectedItems()));
+ pAction->setEnabled(bHasSelected);
- m_pContextPopup->addSeparator();
+ m_pContextPopup->addSeparator();
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Save)),
- __tr2qs_ctx("Export Selected...","editor"),
- this,SLOT(exportSelected()))
- ->setEnabled(bHasSelected);
+ *(g_pIconManager->getSmallIcon(KviIconManager::Save)),
+ __tr2qs_ctx("Export Selected...", "editor"),
+ this, SLOT(exportSelected()))
+ ->setEnabled(bHasSelected);
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Save)),
- __tr2qs_ctx("Export Selected into Single Files...","editor"),
- this,SLOT(exportSelectedSepFiles()))
- ->setEnabled(bHasSelected);
+ *(g_pIconManager->getSmallIcon(KviIconManager::Save)),
+ __tr2qs_ctx("Export Selected into Single Files...", "editor"),
+ this, SLOT(exportSelectedSepFiles()))
+ ->setEnabled(bHasSelected);
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Save)),
- __tr2qs_ctx("Export All...","editor"),
- this,SLOT(exportAll()))
- ->setEnabled(bHasItems);
+ *(g_pIconManager->getSmallIcon(KviIconManager::Save)),
+ __tr2qs_ctx("Export All...", "editor"),
+ this, SLOT(exportAll()))
+ ->setEnabled(bHasItems);
- m_pContextPopup->addSeparator();
+ m_pContextPopup->addSeparator();
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::Search)),
- __tr2qs_ctx("Find in Aliases...","editor"),
- this,SLOT(slotFind()))
- ->setEnabled(bHasItems);
+ *(g_pIconManager->getSmallIcon(KviIconManager::Search)),
+ __tr2qs_ctx("Find in Aliases...", "editor"),
+ this, SLOT(slotFind()))
+ ->setEnabled(bHasItems);
m_pContextPopup->addAction(
- *(g_pIconManager->getSmallIcon(KviIconManager::NameSpace)),
- __tr2qs_ctx("Collapse All Namespaces","editor"),
- this,SLOT(slotCollapseNamespaces()))
- ->setEnabled(bHasItems);
- m_pContextPopup->popup( m_pTreeWidget->mapToGlobal(pnt));
+ *(g_pIconManager->getSmallIcon(KviIconManager::NameSpace)),
+ __tr2qs_ctx("Collapse All Namespaces", "editor"),
+ this, SLOT(slotCollapseNamespaces()))
+ ->setEnabled(bHasItems);
+ m_pContextPopup->popup(m_pTreeWidget->mapToGlobal(pnt));
}
-void AliasEditorWidget::searchReplace(const QString &szSearch,bool bReplace,const QString &szReplace)
+void AliasEditorWidget::searchReplace(const QString & szSearch, bool bReplace, const QString & szReplace)
{
- for(unsigned int i=0;i<m_pAliases->count();i++)
+ for(unsigned int i = 0; i < m_pAliases->count(); i++)
{
- AliasEditorTreeWidgetItem *pItem=m_pAliases->at(i);
- if(pItem->buffer().indexOf(szSearch,0,Qt::CaseInsensitive) != -1)
+ AliasEditorTreeWidgetItem * pItem = m_pAliases->at(i);
+ if(pItem->buffer().indexOf(szSearch, 0, Qt::CaseInsensitive) != -1)
{
- pItem->setBackground(0, QColor(255,0,0,128));
- if (bReplace) ((QString &)pItem->buffer()).replace(szSearch,szReplace,Qt::CaseInsensitive);
+ pItem->setBackground(0, QColor(255, 0, 0, 128));
+ if(bReplace)
+ ((QString &)pItem->buffer()).replace(szSearch, szReplace, Qt::CaseInsensitive);
openParentItems(pItem);
- } else {
- pItem->setBackground(0, QColor(255,255,255));
+ }
+ else
+ {
+ pItem->setBackground(0, QColor(255, 255, 255));
}
}
}
@@ -634,28 +658,31 @@ void AliasEditorWidget::slotFind()
bool bOk;
QString szSearch = QInputDialog::getText(this,
- __tr2qs_ctx("Find in Aliases","editor"),
- __tr2qs_ctx("Please enter the text to be searched for. The matching aliases will be highlighted.","editor"),
- QLineEdit::Normal,
- "",
- &bOk);
+ __tr2qs_ctx("Find in Aliases", "editor"),
+ __tr2qs_ctx("Please enter the text to be searched for. The matching aliases will be highlighted.", "editor"),
+ QLineEdit::Normal,
+ "",
+ &bOk);
g_pAliasEditorModule->unlock();
- if(!bOk)return;
- if(szSearch.isEmpty())return;
+ if(!bOk)
+ return;
+ if(szSearch.isEmpty())
+ return;
m_pEditor->setFindText(szSearch);
searchReplace(szSearch);
}
-void AliasEditorWidget::slotFindWord(const QString &szSearch)
+void AliasEditorWidget::slotFindWord(const QString & szSearch)
{
m_pEditor->setFindText(szSearch);
}
void AliasEditorWidget::recursiveCollapseNamespaces(AliasEditorTreeWidgetItem * it)
{
- if(!it)return;
- for (int i=0;i<it->childCount();i++)
+ if(!it)
+ return;
+ for(int i = 0; i < it->childCount(); i++)
{
if(it->child(i)->childCount())
{
@@ -667,22 +694,23 @@ void AliasEditorWidget::recursiveCollapseNamespaces(AliasEditorTreeWidgetItem *
void AliasEditorWidget::slotCollapseNamespaces()
{
- for (int i=0;i<m_pTreeWidget->topLevelItemCount();i++)
+ for(int i = 0; i < m_pTreeWidget->topLevelItemCount(); i++)
{
- if (m_pTreeWidget->topLevelItem(i)->childCount()){
+ if(m_pTreeWidget->topLevelItem(i)->childCount())
+ {
m_pTreeWidget->topLevelItem(i)->setExpanded(false);
recursiveCollapseNamespaces((AliasEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i));
}
}
}
-void AliasEditorWidget::slotReplaceAll(const QString &szFind,const QString &szReplace)
+void AliasEditorWidget::slotReplaceAll(const QString & szFind, const QString & szReplace)
{
m_pEditor->setFindText(szReplace);
- searchReplace(szFind,true,szReplace);
+ searchReplace(szFind, true, szReplace);
}
-void AliasEditorWidget::getExportAliasBuffer(QString &buffer,AliasEditorTreeWidgetItem * it)
+void AliasEditorWidget::getExportAliasBuffer(QString & buffer, AliasEditorTreeWidgetItem * it)
{
QString szBuf = it->buffer();
KviCommandFormatter::blockFromBuffer(szBuf);
@@ -702,7 +730,7 @@ void AliasEditorWidget::exportAll()
void AliasEditorWidget::exportSelectedSepFiles()
{
- exportAliases (true,true);
+ exportAliases(true, true);
}
void AliasEditorWidget::exportSelected()
@@ -710,70 +738,75 @@ void AliasEditorWidget::exportSelected()
exportAliases(true);
}
-void AliasEditorWidget::exportSelectionInSinglesFiles(KviPointerList<AliasEditorTreeWidgetItem> *l)
+void AliasEditorWidget::exportSelectionInSinglesFiles(KviPointerList<AliasEditorTreeWidgetItem> * l)
{
- if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))m_szDir += KVI_PATH_SEPARATOR;
- if (!l->first())
+ if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))
+ m_szDir += KVI_PATH_SEPARATOR;
+ if(!l->first())
{
g_pAliasEditorModule->lock();
- QMessageBox::warning(this,__tr2qs_ctx("Warning While Exporting - KVIrc","editor"),__tr2qs_ctx("Must select an entry from the list to export!","editor"),__tr2qs_ctx("OK","editor"));
+ QMessageBox::warning(this, __tr2qs_ctx("Warning While Exporting - KVIrc", "editor"), __tr2qs_ctx("Must select an entry from the list to export!", "editor"), __tr2qs_ctx("OK", "editor"));
g_pAliasEditorModule->unlock();
return;
}
g_pAliasEditorModule->lock();
if(!KviFileDialog::askForDirectoryName(
- m_szDir,
- __tr2qs_ctx("Choose a Directory - KVIrc","editor"),
- m_szDir,
- QString(),
- false,
- true,
- this
- )
- ){
+ m_szDir,
+ __tr2qs_ctx("Choose a Directory - KVIrc", "editor"),
+ m_szDir,
+ QString(),
+ false,
+ true,
+ this))
+ {
g_pAliasEditorModule->unlock();
return;
}
- if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))m_szDir += KVI_PATH_SEPARATOR;
+ if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))
+ m_szDir += KVI_PATH_SEPARATOR;
- bool bReplaceAll=false;
+ bool bReplaceAll = false;
- for(AliasEditorTreeWidgetItem * it = l->first();it;it = l->next())
+ for(AliasEditorTreeWidgetItem * it = l->first(); it; it = l->next())
{
QString tmp;
- getExportAliasBuffer(tmp,it);
- QString szFileName=buildFullItemName(it);
+ getExportAliasBuffer(tmp, it);
+ QString szFileName = buildFullItemName(it);
szFileName += ".kvs";
- szFileName.replace("::","_");
- QString szCompletePath=m_szDir+szFileName;
- if (KviFileUtils::fileExists(szCompletePath) && !bReplaceAll)
+ szFileName.replace("::", "_");
+ QString szCompletePath = m_szDir + szFileName;
+ if(KviFileUtils::fileExists(szCompletePath) && !bReplaceAll)
{
QString szMsg;
- szMsg = QString(__tr2qs_ctx("The file \"%1\" exists. Do you want to replace it?","editor")).arg(szFileName);
- int ret = QMessageBox::question(this,__tr2qs_ctx("Confirm Replacing File - KVIrc","editor"),szMsg,__tr2qs_ctx("Yes","editor"),__tr2qs_ctx("Yes to All","editor"),__tr2qs_ctx("No","editor"));
- if (ret!=2)
+ szMsg = QString(__tr2qs_ctx("The file \"%1\" exists. Do you want to replace it?", "editor")).arg(szFileName);
+ int ret = QMessageBox::question(this, __tr2qs_ctx("Confirm Replacing File - KVIrc", "editor"), szMsg, __tr2qs_ctx("Yes", "editor"), __tr2qs_ctx("Yes to All", "editor"), __tr2qs_ctx("No", "editor"));
+ if(ret != 2)
{
- KviFileUtils::writeFile(szCompletePath,tmp);
- if (ret==1) bReplaceAll=true;
+ KviFileUtils::writeFile(szCompletePath, tmp);
+ if(ret == 1)
+ bReplaceAll = true;
}
- } else {
- KviFileUtils::writeFile(szCompletePath,tmp);
+ }
+ else
+ {
+ KviFileUtils::writeFile(szCompletePath, tmp);
}
}
g_pAliasEditorModule->unlock();
}
-void AliasEditorWidget::exportAliases(bool bSelectedOnly,bool bSingleFiles)
+void AliasEditorWidget::exportAliases(bool bSelectedOnly, bool bSingleFiles)
{
saveLastEditedItem();
KviPointerList<AliasEditorTreeWidgetItem> l;
l.setAutoDelete(false);
- if (bSelectedOnly) appendSelectedAliasItems(&l);
- if (bSingleFiles)
+ if(bSelectedOnly)
+ appendSelectedAliasItems(&l);
+ if(bSingleFiles)
{
exportSelectionInSinglesFiles(&l);
return;
@@ -781,89 +814,93 @@ void AliasEditorWidget::exportAliases(bool bSelectedOnly,bool bSingleFiles)
QString szOut;
int count;
- if (bSelectedOnly)
+ if(bSelectedOnly)
+ {
+ count = l.count();
+ buildAliasesFile(&l, szOut);
+ }
+ else
{
- count=l.count();
- buildAliasesFile(&l,szOut);
- } else {
- count=m_pAliases->count();
- buildAliasesFile(m_pAliases,szOut);
+ count = m_pAliases->count();
+ buildAliasesFile(m_pAliases, szOut);
}
QString szNameFile;
if(szOut.isEmpty())
{
g_pAliasEditorModule->lock();
- QMessageBox::warning(this,__tr2qs_ctx("Warning While Exporting - KVIrc","editor"),__tr2qs_ctx("The exported file could be empty: cowardly refusing to write it.","editor"),__tr2qs_ctx("OK","editor"));
+ QMessageBox::warning(this, __tr2qs_ctx("Warning While Exporting - KVIrc", "editor"), __tr2qs_ctx("The exported file could be empty: cowardly refusing to write it.", "editor"), __tr2qs_ctx("OK", "editor"));
g_pAliasEditorModule->unlock();
return;
}
QString szName = m_szDir;
- if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))szName += KVI_PATH_SEPARATOR;
+ if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))
+ szName += KVI_PATH_SEPARATOR;
QString szFile;
g_pAliasEditorModule->lock();
- if (count==1)
+ if(count == 1)
{
- QString tmp=buildFullItemName(l.at(0));
- szNameFile = tmp.replace("::","_");
- } else {
- szNameFile="aliases";
+ QString tmp = buildFullItemName(l.at(0));
+ szNameFile = tmp.replace("::", "_");
+ }
+ else
+ {
+ szNameFile = "aliases";
}
szName += szNameFile;
szName += ".kvs";
if(!KviFileDialog::askForSaveFileName(
- szFile,
- __tr2qs_ctx("Choose a Filename - KVIrc","editor"),
- szName,
- KVI_FILTER_SCRIPT,
- false,
- true,
- true,
- this
- ))
+ szFile,
+ __tr2qs_ctx("Choose a Filename - KVIrc", "editor"),
+ szName,
+ KVI_FILTER_SCRIPT,
+ false,
+ true,
+ true,
+ this))
{
g_pAliasEditorModule->unlock();
return;
}
- m_szDir=QFileInfo(szFile).absolutePath();
+ m_szDir = QFileInfo(szFile).absolutePath();
g_pAliasEditorModule->unlock();
- if(!KviFileUtils::writeFile(szFile,szOut))
+ if(!KviFileUtils::writeFile(szFile, szOut))
{
g_pAliasEditorModule->lock();
- QMessageBox::warning(this,__tr2qs_ctx("Writing to File Failed - KVIrc","editor"),__tr2qs_ctx("Unable to write to the aliases file.","editor"),__tr2qs_ctx("OK","editor"));
+ QMessageBox::warning(this, __tr2qs_ctx("Writing to File Failed - KVIrc", "editor"), __tr2qs_ctx("Unable to write to the aliases file.", "editor"), __tr2qs_ctx("OK", "editor"));
g_pAliasEditorModule->unlock();
}
}
-void AliasEditorWidget::buildAliasesFile(KviPointerList<AliasEditorTreeWidgetItem> *l, QString & szBuffer)
+void AliasEditorWidget::buildAliasesFile(KviPointerList<AliasEditorTreeWidgetItem> * l, QString & szBuffer)
{
- for(AliasEditorTreeWidgetItem * it = l->first();it;it = l->next())
+ for(AliasEditorTreeWidgetItem * it = l->first(); it; it = l->next())
{
QString tmp;
- getExportAliasBuffer(tmp,it);
+ getExportAliasBuffer(tmp, it);
szBuffer += tmp;
szBuffer += "\n";
}
}
-void AliasEditorWidget::saveProperties(KviConfigurationFile *cfg)
+void AliasEditorWidget::saveProperties(KviConfigurationFile * cfg)
{
- cfg->writeEntry("Sizes",m_pSplitter->sizes());
+ cfg->writeEntry("Sizes", m_pSplitter->sizes());
QString szName;
if(m_pLastEditedItem)
szName = buildFullItemName(m_pLastEditedItem);
- cfg->writeEntry("LastAlias",szName);
+ cfg->writeEntry("LastAlias", szName);
}
-void AliasEditorWidget::loadProperties(KviConfigurationFile *cfg)
+void AliasEditorWidget::loadProperties(KviConfigurationFile * cfg)
{
QList<int> def;
def.append(20);
def.append(80);
- m_pSplitter->setSizes(cfg->readIntListEntry("Sizes",def));
- QString tmp = cfg->readEntry("LastAlias",QString());
+ m_pSplitter->setSizes(cfg->readIntListEntry("Sizes", def));
+ QString tmp = cfg->readEntry("LastAlias", QString());
AliasEditorTreeWidgetItem * it = findItem(tmp);
activateItem(it);
@@ -871,51 +908,51 @@ void AliasEditorWidget::loadProperties(KviConfigurationFile *cfg)
void AliasEditorWidget::appendSelectedAliasItems(KviPointerList<AliasEditorTreeWidgetItem> * l)
{
- QList<QTreeWidgetItem *> list=m_pTreeWidget->selectedItems();
- for(int i=0;i<list.count();i++)
+ QList<QTreeWidgetItem *> list = m_pTreeWidget->selectedItems();
+ for(int i = 0; i < list.count(); i++)
{
- if (((AliasEditorTreeWidgetItem *)list.at(i))->isAlias())
+ if(((AliasEditorTreeWidgetItem *)list.at(i))->isAlias())
{
l->append((AliasEditorTreeWidgetItem *)list.at(i));
- } else {
- appendSelectedAliasItemsRecursive(l,list.at(i));
+ }
+ else
+ {
+ appendSelectedAliasItemsRecursive(l, list.at(i));
}
}
}
-void AliasEditorWidget::appendSelectedAliasItemsRecursive(KviPointerList<AliasEditorTreeWidgetItem> * l,QTreeWidgetItem * pStartFrom)
+void AliasEditorWidget::appendSelectedAliasItemsRecursive(KviPointerList<AliasEditorTreeWidgetItem> * l, QTreeWidgetItem * pStartFrom)
{
- for (int i=0;i<pStartFrom->childCount();i++)
+ for(int i = 0; i < pStartFrom->childCount(); i++)
{
- if (((AliasEditorTreeWidgetItem *)pStartFrom->child(i))->isAlias())
+ if(((AliasEditorTreeWidgetItem *)pStartFrom->child(i))->isAlias())
l->append(((AliasEditorTreeWidgetItem *)pStartFrom->child(i)));
else
- appendSelectedAliasItemsRecursive(l,pStartFrom->child(i));
+ appendSelectedAliasItemsRecursive(l, pStartFrom->child(i));
}
}
-
void AliasEditorWidget::appendSelectedItems(KviPointerList<AliasEditorTreeWidgetItem> * l)
{
- QList<QTreeWidgetItem *> list=m_pTreeWidget->selectedItems();
- for(int i=0;i<list.count();i++)
+ QList<QTreeWidgetItem *> list = m_pTreeWidget->selectedItems();
+ for(int i = 0; i < list.count(); i++)
{
l->append((AliasEditorTreeWidgetItem *)list.at(i));
/* if (!((AliasEditorTreeWidgetItem *)list.at(i))->isAlias())
appendSelectedAliasItemsRecursive(l,list.at(i));*/
}
-
}
-void AliasEditorWidget::appendSelectedItemsRecursive(KviPointerList<AliasEditorTreeWidgetItem> * l,QTreeWidgetItem * pStartFrom)
+void AliasEditorWidget::appendSelectedItemsRecursive(KviPointerList<AliasEditorTreeWidgetItem> * l, QTreeWidgetItem * pStartFrom)
{
- for (int i=0;i<pStartFrom->childCount();i++)
+ for(int i = 0; i < pStartFrom->childCount(); i++)
{
l->append(((AliasEditorTreeWidgetItem *)pStartFrom->child(i)));
- if (!((AliasEditorTreeWidgetItem *)pStartFrom->child(i))->isAlias())
- appendSelectedAliasItemsRecursive(l,pStartFrom->child(i));
+ if(!((AliasEditorTreeWidgetItem *)pStartFrom->child(i))->isAlias())
+ appendSelectedAliasItemsRecursive(l, pStartFrom->child(i));
}
}
-void AliasEditorWidget::removeItemChildren(AliasEditorTreeWidgetItem *it)
+void AliasEditorWidget::removeItemChildren(AliasEditorTreeWidgetItem * it)
{
while(it->childCount() > 0)
{
@@ -927,36 +964,38 @@ void AliasEditorWidget::removeItemChildren(AliasEditorTreeWidgetItem *it)
}
}
-bool AliasEditorWidget::removeItem(AliasEditorTreeWidgetItem *it,bool * pbYesToAll,bool)
+bool AliasEditorWidget::removeItem(AliasEditorTreeWidgetItem * it, bool * pbYesToAll, bool)
{
- if(!it)return true;
+ if(!it)
+ return true;
QString szMsg;
QString szName = it->name();
if(!*pbYesToAll)
{
if(it->isAlias())
- szMsg = QString(__tr2qs_ctx("Do you really want to remove the alias \"%1\"?","editor")).arg(szName);
- else {
- szMsg = QString(__tr2qs_ctx("Do you really want to remove the namespace \"%1\"?","editor")).arg(szName);
+ szMsg = QString(__tr2qs_ctx("Do you really want to remove the alias \"%1\"?", "editor")).arg(szName);
+ else
+ {
+ szMsg = QString(__tr2qs_ctx("Do you really want to remove the namespace \"%1\"?", "editor")).arg(szName);
szMsg += "<br>";
- szMsg += __tr2qs_ctx("Please note that all the child items will be deleted too.","editor");
+ szMsg += __tr2qs_ctx("Please note that all the child items will be deleted too.", "editor");
}
g_pAliasEditorModule->lock();
- int ret = QMessageBox::question(this,__tr2qs_ctx("Confirm Removing Item - KVIrc","editor"),szMsg,__tr2qs_ctx("Yes","editor"),__tr2qs_ctx("Yes to All","editor"),__tr2qs_ctx("No","editor"));
+ int ret = QMessageBox::question(this, __tr2qs_ctx("Confirm Removing Item - KVIrc", "editor"), szMsg, __tr2qs_ctx("Yes", "editor"), __tr2qs_ctx("Yes to All", "editor"), __tr2qs_ctx("No", "editor"));
g_pAliasEditorModule->unlock();
switch(ret)
{
case 0:
// nothing
- break;
+ break;
case 1:
*pbYesToAll = true;
- break;
+ break;
default:
return false;
- break;
+ break;
}
}
@@ -964,7 +1003,7 @@ bool AliasEditorWidget::removeItem(AliasEditorTreeWidgetItem *it,bool * pbYesToA
m_pLastEditedItem = 0;
if(it == m_pLastClickedItem)
m_pLastClickedItem = 0;
- if (it->childCount())
+ if(it->childCount())
removeItemChildren(it);
delete it;
m_pAliases->removeRef(it);
@@ -977,13 +1016,14 @@ void AliasEditorWidget::removeSelectedItems()
l.setAutoDelete(false);
appendSelectedItems(&l);
bool bYesToAll = false;
- for(AliasEditorTreeWidgetItem *it = l.first();it;it = l.next())
+ for(AliasEditorTreeWidgetItem * it = l.first(); it; it = l.next())
{
- if(!removeItem(it,&bYesToAll,false))return;
+ if(!removeItem(it, &bYesToAll, false))
+ return;
}
}
-QString AliasEditorWidget::askForAliasName(const QString &szAction,const QString &szText,const QString &szInitialText)
+QString AliasEditorWidget::askForAliasName(const QString & szAction, const QString & szText, const QString & szInitialText)
{
bool bOk = false;
QString szNewName;
@@ -991,20 +1031,21 @@ QString AliasEditorWidget::askForAliasName(const QString &szAction,const QString
{
g_pAliasEditorModule->lock();
szNewName = QInputDialog::getText(this,
- szAction,
- szText,
- QLineEdit::Normal,
- szInitialText,
- &bOk);
+ szAction,
+ szText,
+ QLineEdit::Normal,
+ szInitialText,
+ &bOk);
g_pAliasEditorModule->unlock();
- if(!bOk)return QString();
+ if(!bOk)
+ return QString();
if(szNewName.isEmpty())
{
g_pAliasEditorModule->lock();
QMessageBox::warning(this,
- __tr2qs_ctx("Invalid or Missing Name - KVIrc","editor"),
- __tr2qs_ctx("You must specify a valid name for the alias.","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Invalid or Missing Name - KVIrc", "editor"),
+ __tr2qs_ctx("You must specify a valid name for the alias.", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
continue;
}
@@ -1015,34 +1056,34 @@ QString AliasEditorWidget::askForAliasName(const QString &szAction,const QString
{
g_pAliasEditorModule->lock();
QMessageBox::information(this,
- __tr2qs_ctx("Invalid Name - KVIrc","editor"),
- __tr2qs_ctx("Aliases names can contain only letters, digits, underscores and '::' namespace separators.","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Invalid Name - KVIrc", "editor"),
+ __tr2qs_ctx("Aliases names can contain only letters, digits, underscores and '::' namespace separators.", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
}
// make sure that we have only doubled "::" and not ":" or ":::..."
QString tmp = szNewName;
- tmp.replace("::","@"); // @ is not allowed by the rule above
- if(tmp.indexOf(":",Qt::CaseInsensitive) != -1)
+ tmp.replace("::", "@"); // @ is not allowed by the rule above
+ if(tmp.indexOf(":", Qt::CaseInsensitive) != -1)
{
g_pAliasEditorModule->lock();
QMessageBox::information(this,
- __tr2qs_ctx("Invalid Name - KVIrc","editor"),
- __tr2qs_ctx("Stray ':' character in alias name: did you mean ...<namespace>::<name>?","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Invalid Name - KVIrc", "editor"),
+ __tr2qs_ctx("Stray ':' character in alias name: did you mean ...<namespace>::<name>?", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
}
- if(tmp.indexOf("@@",Qt::CaseInsensitive) != -1)
+ if(tmp.indexOf("@@", Qt::CaseInsensitive) != -1)
{
g_pAliasEditorModule->lock();
QMessageBox::information(this,
- __tr2qs_ctx("Invalid Name - KVIrc","editor"),
- __tr2qs_ctx("Found an empty namespace in alias name.","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Invalid Name - KVIrc", "editor"),
+ __tr2qs_ctx("Found an empty namespace in alias name.", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
@@ -1051,7 +1092,7 @@ QString AliasEditorWidget::askForAliasName(const QString &szAction,const QString
return szNewName;
}
-QString AliasEditorWidget::askForNamespaceName(const QString &szAction,const QString &szText,const QString &szInitialText)
+QString AliasEditorWidget::askForNamespaceName(const QString & szAction, const QString & szText, const QString & szInitialText)
{
bool bOk = false;
QString szNewName;
@@ -1059,20 +1100,21 @@ QString AliasEditorWidget::askForNamespaceName(const QString &szAction,const QSt
{
g_pAliasEditorModule->lock();
szNewName = QInputDialog::getText(this,
- szAction,
- szText,
- QLineEdit::Normal,
- szInitialText,
- &bOk);
+ szAction,
+ szText,
+ QLineEdit::Normal,
+ szInitialText,
+ &bOk);
g_pAliasEditorModule->unlock();
- if(!bOk)return QString();
+ if(!bOk)
+ return QString();
if(szNewName.isEmpty())
{
g_pAliasEditorModule->lock();
QMessageBox::warning(this,
- __tr2qs_ctx("Invalid or Missing Name - KVIrc","editor"),
- __tr2qs_ctx("You must specify a valid name for the namespace.","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Invalid or Missing Name - KVIrc", "editor"),
+ __tr2qs_ctx("You must specify a valid name for the namespace.", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
continue;
}
@@ -1083,34 +1125,34 @@ QString AliasEditorWidget::askForNamespaceName(const QString &szAction,const QSt
{
g_pAliasEditorModule->lock();
QMessageBox::information(this,
- __tr2qs_ctx("Invalid Name - KVIrc","editor"),
- __tr2qs_ctx("Namespace names can contain only letters, digits, underscores and '::' namespace separators.","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Invalid Name - KVIrc", "editor"),
+ __tr2qs_ctx("Namespace names can contain only letters, digits, underscores and '::' namespace separators.", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
}
// make sure that we have only doubled "::" and not ":" or ":::..."
QString tmp = szNewName;
- tmp.replace("::","@"); // @ is not allowed by the rule above
- if(tmp.indexOf(":",Qt::CaseInsensitive) != -1)
+ tmp.replace("::", "@"); // @ is not allowed by the rule above
+ if(tmp.indexOf(":", Qt::CaseInsensitive) != -1)
{
g_pAliasEditorModule->lock();
QMessageBox::information(this,
- __tr2qs_ctx("Invalid Name - KVIrc","editor"),
- __tr2qs_ctx("Stray ':' character in namespace name: did you mean... <namespace>::<name>?","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Invalid Name - KVIrc", "editor"),
+ __tr2qs_ctx("Stray ':' character in namespace name: did you mean... <namespace>::<name>?", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
}
- if(tmp.indexOf("@@",Qt::CaseInsensitive) != -1)
+ if(tmp.indexOf("@@", Qt::CaseInsensitive) != -1)
{
g_pAliasEditorModule->lock();
QMessageBox::information(this,
- __tr2qs_ctx("Invalid Name - KVIrc","editor"),
- __tr2qs_ctx("Found an empty namespace in namespace name.","editor"),
- __tr2qs_ctx("OK, Let me try again...","editor"));
+ __tr2qs_ctx("Invalid Name - KVIrc", "editor"),
+ __tr2qs_ctx("Found an empty namespace in namespace name.", "editor"),
+ __tr2qs_ctx("OK, Let me try again...", "editor"));
g_pAliasEditorModule->unlock();
szNewName = "";
continue;
@@ -1130,32 +1172,38 @@ void AliasEditorWidget::openParentItems(QTreeWidgetItem * it)
void AliasEditorWidget::activateItem(QTreeWidgetItem * it)
{
- if (!it) return;
+ if(!it)
+ return;
openParentItems(it);
m_pTreeWidget->setCurrentItem(it);
}
void AliasEditorWidget::newAlias()
{
- QString szNewName = askForAliasName(__tr2qs_ctx("Enter a Filename - KVIrc","editor"),__tr2qs_ctx("Please enter the new name for the alias.","editor"),"myfunction");
- if(szNewName.isEmpty())return;
- newItem(szNewName,AliasEditorTreeWidgetItem::Alias);
+ QString szNewName = askForAliasName(__tr2qs_ctx("Enter a Filename - KVIrc", "editor"), __tr2qs_ctx("Please enter the new name for the alias.", "editor"), "myfunction");
+ if(szNewName.isEmpty())
+ return;
+ newItem(szNewName, AliasEditorTreeWidgetItem::Alias);
}
void AliasEditorWidget::newNamespace()
{
- QString szName = askForNamespaceName(__tr2qs_ctx("Enter a Filename - KVIrc","editor"),__tr2qs_ctx("Please enter the new name for the namespace.","editor"),"mynamespace");
- if(szName.isEmpty())return;
- newItem(szName,AliasEditorTreeWidgetItem::Namespace);
+ QString szName = askForNamespaceName(__tr2qs_ctx("Enter a Filename - KVIrc", "editor"), __tr2qs_ctx("Please enter the new name for the namespace.", "editor"), "mynamespace");
+ if(szName.isEmpty())
+ return;
+ newItem(szName, AliasEditorTreeWidgetItem::Namespace);
}
-void AliasEditorWidget::newItem(QString &szName,AliasEditorTreeWidgetItem::Type eType)
+void AliasEditorWidget::newItem(QString & szName, AliasEditorTreeWidgetItem::Type eType)
{
if(m_pLastClickedItem)
- if(!itemExists(m_pLastClickedItem)) m_pLastClickedItem=0;
- if(m_pLastClickedItem) buildFullItemPath(m_pLastClickedItem,szName);
- int idx=1;
+ if(!itemExists(m_pLastClickedItem))
+ m_pLastClickedItem = 0;
+ if(m_pLastClickedItem)
+ buildFullItemPath(m_pLastClickedItem, szName);
+ int idx = 1;
QString szTmp;
- if(findItem(szName)) szName.append("1");
+ if(findItem(szName))
+ szName.append("1");
while(findItem(szName))
{
szTmp.setNum(idx);
@@ -1164,7 +1212,7 @@ void AliasEditorWidget::newItem(QString &szName,AliasEditorTreeWidgetItem::Type
idx++;
}
AliasEditorTreeWidgetItem * it;
- it=createFullItem(szName);
+ it = createFullItem(szName);
it->setType(eType);
m_pAliases->append(it);
activateItem(it);
@@ -1175,49 +1223,48 @@ void AliasEditorWidget::commit()
m_bSaving = true;
saveLastEditedItem();
KviKvsAliasManager::instance()->clear();
- for(unsigned int i=0;i<m_pAliases->count();i++)
+ for(unsigned int i = 0; i < m_pAliases->count(); i++)
{
//don't save empty aliases or namespace names
if(m_pAliases->at(i)->buffer().isEmpty())
continue;
QString szName = buildFullItemName(m_pAliases->at(i));
- KviKvsScript * a = new KviKvsScript(szName,m_pAliases->at(i)->buffer());
- KviKvsAliasManager::instance()->add(szName,a);
+ KviKvsScript * a = new KviKvsScript(szName, m_pAliases->at(i)->buffer());
+ KviKvsAliasManager::instance()->add(szName, a);
}
g_pApp->saveAliases();
m_bSaving = false;
}
-
AliasEditorWindow::AliasEditorWindow()
-: KviWindow(KviWindow::ScriptEditor,"aliaseditor",0)
+ : KviWindow(KviWindow::ScriptEditor, "aliaseditor", 0)
{
g_pAliasEditorWindow = this;
- setFixedCaption(__tr2qs_ctx("Alias Editor","editor"));
+ setFixedCaption(__tr2qs_ctx("Alias Editor", "editor"));
QGridLayout * g = new QGridLayout();
m_pEditor = new AliasEditorWidget(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);
}
@@ -1247,17 +1294,17 @@ QPixmap * AliasEditorWindow::myIconPtr()
return g_pIconManager->getSmallIcon(KviIconManager::AliasEditor);
}
-void AliasEditorWindow::getConfigGroupName(QString &szName)
+void AliasEditorWindow::getConfigGroupName(QString & szName)
{
szName = "aliaseditor";
}
-void AliasEditorWindow::saveProperties(KviConfigurationFile *cfg)
+void AliasEditorWindow::saveProperties(KviConfigurationFile * cfg)
{
m_pEditor->saveProperties(cfg);
}
-void AliasEditorWindow::loadProperties(KviConfigurationFile *cfg)
+void AliasEditorWindow::loadProperties(KviConfigurationFile * cfg)
{
m_pEditor->loadProperties(cfg);
}