Browse Source

Implement "New Style" and "New List" buttons in syntax highlighting customization.

git-svn-id: file:///var/svn/tigccpp/trunk@799 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 18 years ago
parent
commit
cb08ea8f2d
1 changed files with 33 additions and 2 deletions
  1. 33 2
      ktigcc/preferencesdlg.ui.h

+ 33 - 2
ktigcc/preferencesdlg.ui.h

@@ -37,6 +37,8 @@
 #include <qaccel.h>
 #include <qcolor.h>
 #include <qvaluelist.h>
+#include <qapplication.h>
+#include <qeventloop.h>
 #include <knuminput.h>
 #include <kfontdialog.h>
 #include <kcolordialog.h>
@@ -488,12 +490,41 @@ void Preferences::syntaxListViewAccel_activated(int id)
 
 void Preferences::newStyleButton_clicked()
 {
-
+  Syn_CustomStyle newStyle;
+  newStyle.name="New Style";
+  preferences.syn->customStyles.append(newStyle);
+  QListViewItem *rootListItem=syntaxListView->firstChild();
+  QListViewItem *customStylesItem=rootListItem->firstChild();
+  QListViewItem *item=customStylesItem->firstChild();
+  while (item && item->nextSibling()) item=item->nextSibling();
+  item=new RenamableKListViewItem(customStylesItem,item,newStyle.name);
+  syntaxListView->setCurrentItem(item);
+  syntaxListView->setSelected(item,TRUE);
+  // startRename won't work properly if I don't do this. :-/
+  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
+  syntaxListView->ensureItemVisible(item);
+  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
+  item->startRename(0);
 }
 
 void Preferences::newListButton_clicked()
 {
-
+  Syn_WordList newList;
+  newList.name="New List";
+  preferences.syn->wordLists.append(newList);
+  QListViewItem *rootListItem=syntaxListView->firstChild();
+  QListViewItem *customStylesItem=rootListItem->firstChild();
+  QListViewItem *wordListsItem=customStylesItem->nextSibling();
+  QListViewItem *item=wordListsItem->firstChild();
+  while (item && item->nextSibling()) item=item->nextSibling();
+  item=new RenamableKListViewItem(wordListsItem,item,newList.name);
+  syntaxListView->setCurrentItem(item);
+  syntaxListView->setSelected(item,TRUE);
+  // startRename won't work properly if I don't do this. :-/
+  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
+  syntaxListView->ensureItemVisible(item);
+  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
+  item->startRename(0);
 }
 
 void Preferences::editButton_clicked()