mainform.ui.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  1. /****************************************************************************
  2. ** ui.h extension file, included from the uic-generated form implementation.
  3. **
  4. ** If you wish to add, delete or rename slots use Qt Designer which will
  5. ** update this file, preserving your code. Create an init() slot in place of
  6. ** a constructor, and a destroy() slot in place of a destructor.
  7. *****************************************************************************/
  8. /*
  9. ktigcc - TIGCC IDE for KDE
  10. Copyright (C) 2004-2006 Kevin Kofler
  11. Copyright (C) 2006 Joey Adams
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2, or (at your option)
  15. any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software Foundation,
  22. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. */
  24. #include <qlabel.h>
  25. #include <qstatusbar.h>
  26. #include <qtimer.h>
  27. #include <qdatetime.h>
  28. #include <qdragobject.h>
  29. #include <qassistantclient.h>
  30. #include <kparts/factory.h>
  31. #include <klibloader.h>
  32. #include <kate/document.h>
  33. #include <kate/view.h>
  34. #include <kconfig.h>
  35. #include <ktexteditor/configinterfaceextension.h>
  36. #include <kaboutdata.h>
  37. #include <khelpmenu.h>
  38. #include <kfiledialog.h>
  39. #include <kurl.h>
  40. #include <kmessagebox.h>
  41. #include <cstdio>
  42. #include <cstdlib>
  43. #include "tpr.h"
  44. using std::puts;
  45. using std::exit;
  46. enum {TIGCCOpenProjectFileFilter=0,TIGCCSaveProjectFilter};
  47. static const char *TIGCCFileFilters[2]=
  48. {
  49. "*.tpr *.h *.c *.s *.asm *.txt|All TIGCC Files (*.tpr *.h *.c *.s *.asm *.txt)\n*.tpr|TIGCC Projects (*.tpr)\n*.h|Header Files (*.h)\n*.c|C Files (*.c)\n*.s|GNU Assembly Files (*.s)\n*.asm|A68k Assembly Files (*.asm)\nText Files (*.txt)\n*.*|All Files (*.*)",
  50. "*.tpr|TIGCC Projects (*.tpr)\n*.*|All Files (*.*)"
  51. };
  52. static const char *TIGCCProjectDirectory="/usr/local/tigcc/projects";
  53. static QString lastDirectory;
  54. extern const char *tigcc_base;
  55. extern const char *quill_drv;
  56. extern char tempdir[];
  57. extern void write_temp_file(const char *filename, const char *data, const size_t len);
  58. extern void delete_temp_file(const char *filename);
  59. extern void force_qt_assistant_page(int n);
  60. extern KAboutData *pabout;
  61. #define IS_CATEGORY(item) ((item) && ((item)==hFilesListItem \
  62. || (item)==cFilesListItem \
  63. || (item)==sFilesListItem \
  64. || (item)==asmFilesListItem \
  65. || (item)==qllFilesListItem \
  66. || (item)==oFilesListItem \
  67. || (item)==aFilesListItem \
  68. || (item)==txtFilesListItem \
  69. || (item)==othFilesListItem))
  70. #define IS_EDITABLE_CATEGORY(item) ((item) && ((item)==hFilesListItem \
  71. || (item)==cFilesListItem \
  72. || (item)==sFilesListItem \
  73. || (item)==asmFilesListItem \
  74. || (item)==qllFilesListItem \
  75. || (item)==txtFilesListItem))
  76. #define IS_FOLDER(item) ((item) && (item)->rtti()==0x716CC0)
  77. #define IS_FILE(item) ((item) && (item)->rtti()==0x716CC1)
  78. // All the methods are inline because otherwise QT Designer will mistake them
  79. // for slots of the main form.
  80. class ListViewFolder : public QListViewItem {
  81. public:
  82. ListViewFolder(QListView *parent) : QListViewItem(parent)
  83. {
  84. setPixmap(0,QPixmap::fromMimeSource("folder1.png"));
  85. setDragEnabled(TRUE);
  86. setDropEnabled(TRUE);
  87. }
  88. ListViewFolder(QListViewItem *parent) : QListViewItem(parent)
  89. {
  90. setPixmap(0,QPixmap::fromMimeSource("folder1.png"));
  91. setDragEnabled(TRUE);
  92. setDropEnabled(TRUE);
  93. }
  94. ListViewFolder(QListView *parent, QListViewItem *after)
  95. : QListViewItem(parent, after)
  96. {
  97. setPixmap(0,QPixmap::fromMimeSource("folder1.png"));
  98. setDropEnabled(TRUE);
  99. setDragEnabled(TRUE);
  100. }
  101. ListViewFolder(QListViewItem *parent, QListViewItem *after)
  102. : QListViewItem(parent, after)
  103. {
  104. setPixmap(0,QPixmap::fromMimeSource("folder1.png"));
  105. setDragEnabled(TRUE);
  106. setDropEnabled(TRUE);
  107. }
  108. virtual int rtti(void) const {return 0x716CC0;}
  109. protected:
  110. };
  111. class ListViewFile : public QListViewItem {
  112. public:
  113. ListViewFile(QListView *parent) : QListViewItem(parent),
  114. cursorLine(1), cursorCol(0)
  115. {
  116. setPixmap(0,QPixmap::fromMimeSource("filex.png"));
  117. setDragEnabled(TRUE);
  118. setDropEnabled(TRUE);
  119. setRenameEnabled(0,TRUE);
  120. }
  121. ListViewFile(QListViewItem *parent) : QListViewItem(parent),
  122. cursorLine(1), cursorCol(0)
  123. {
  124. setPixmap(0,QPixmap::fromMimeSource("filex.png"));
  125. setDragEnabled(TRUE);
  126. setDropEnabled(TRUE);
  127. setRenameEnabled(0,TRUE);
  128. }
  129. ListViewFile(QListView *parent, QListViewItem *after)
  130. : QListViewItem(parent, after), cursorLine(1), cursorCol(0)
  131. {
  132. setPixmap(0,QPixmap::fromMimeSource("filex.png"));
  133. setDropEnabled(TRUE);
  134. setDragEnabled(TRUE);
  135. setRenameEnabled(0,TRUE);
  136. }
  137. ListViewFile(QListViewItem *parent, QListViewItem *after)
  138. : QListViewItem(parent, after), cursorLine(1), cursorCol(0)
  139. {
  140. setPixmap(0,QPixmap::fromMimeSource("filex.png"));
  141. setDragEnabled(TRUE);
  142. setDropEnabled(TRUE);
  143. setRenameEnabled(0,TRUE);
  144. }
  145. virtual int rtti(void) const {return 0x716CC1;}
  146. QString textBuffer;
  147. unsigned int cursorLine, cursorCol;
  148. QString fileName; // full name of the file
  149. protected:
  150. };
  151. // These should be instance variables in clean C++, but QT Designer won't let me
  152. // touch the class definition, so this is all I can do. And there is only one
  153. // instance of MainForm anyway.
  154. static QListViewItem *rootListItem;
  155. static QListViewItem *hFilesListItem;
  156. static QListViewItem *cFilesListItem;
  157. static QListViewItem *sFilesListItem;
  158. static QListViewItem *asmFilesListItem;
  159. static QListViewItem *qllFilesListItem;
  160. static QListViewItem *oFilesListItem;
  161. static QListViewItem *aFilesListItem;
  162. static QListViewItem *txtFilesListItem;
  163. static QListViewItem *othFilesListItem;
  164. static QListViewItem *currentListItem;
  165. static bool currentListItemEditable;
  166. static QLabel *leftStatusLabel;
  167. static QLabel *rowStatusLabel;
  168. static QLabel *colStatusLabel;
  169. static QLabel *charsStatusLabel;
  170. static QLabel *rightStatusLabel;
  171. static Kate::View* m_view;
  172. static KHelpMenu *khelpmenu;
  173. static QPopupMenu *te_popup;
  174. static QAssistantClient *assistant;
  175. static int fileCount=0, hFileCount=0, cFileCount=0, sFileCount=0, asmFileCount=0, qllFileCount=0, oFileCount=0, aFileCount=0, txtFileCount=0, othFileCount=0;
  176. static tprSettings settings;
  177. static tprLibOpts libopts;
  178. class DnDListView : public QListView {
  179. private:
  180. public:
  181. DnDListView ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )
  182. : QListView(parent,name,f) {}
  183. protected:
  184. virtual QDragObject *dragObject() {
  185. QListViewItem *currItem=selectedItem();
  186. if (currItem==rootListItem || currItem->parent()==rootListItem)
  187. return NULL;
  188. QStoredDrag *storedDrag=new QStoredDrag("x-ktigcc-dnd", this);
  189. static QByteArray data(sizeof(QListViewItem*));
  190. data.duplicate(reinterpret_cast<char *>(&currItem),
  191. sizeof(QListViewItem*));
  192. storedDrag->setEncodedData(data);
  193. return storedDrag;
  194. }
  195. virtual void dropEvent (QDropEvent *e) {
  196. if (e->source()==this && e->provides("x-ktigcc-dnd")) {
  197. QListViewItem *currItem;
  198. currItem = *reinterpret_cast<QListViewItem * const *>((const char *)e->encodedData("x-ktigcc-dnd"));
  199. if (IS_FOLDER(currItem) && !IS_CATEGORY(currItem)) {
  200. // dropping folder
  201. // can only drop on folder or category
  202. QPoint vp=contentsToViewport(e->pos());
  203. QListViewItem *item=itemAt(vp);
  204. if (IS_FOLDER(item)) {
  205. // need same category
  206. QListViewItem *srcCategory=currItem;
  207. while (srcCategory->parent()->rtti()==0x716CC0) srcCategory=srcCategory->parent();
  208. QListViewItem *destCategory=item;
  209. while (destCategory->parent()->rtti()==0x716CC0) destCategory=destCategory->parent();
  210. if (srcCategory == destCategory) {
  211. // can't move folder into itself
  212. for (QListViewItem *destFolder=item; destFolder->rtti()==0x716CC0; destFolder=destFolder->parent()) {
  213. if (destFolder==currItem) goto ignore;
  214. }
  215. // move folder
  216. e->accept();
  217. currItem->parent()->takeItem(currItem);
  218. item->insertItem(currItem);
  219. } else {ignore: e->ignore();}
  220. } else e->ignore();
  221. } else if (IS_FILE(currItem)) {
  222. // dropping file
  223. QPoint vp=contentsToViewport(e->pos());
  224. QListViewItem *item=itemAt(vp);
  225. if (IS_FOLDER(item)) {
  226. // drop on folder
  227. // move file
  228. e->accept();
  229. currItem->parent()->takeItem(currItem);
  230. item->insertItem(currItem);
  231. } else if (IS_FILE(item)) {
  232. // drop on file
  233. // need same parent, but different items
  234. if (currItem->parent() == item->parent()
  235. && currItem != item) {
  236. // reorder files
  237. // figure out which one is the first
  238. for (QListViewItem *i=currItem->parent()->firstChild();i;
  239. i=i->nextSibling()) {
  240. if (i==currItem) {
  241. // currItem is first, move currItem after item
  242. e->accept();
  243. currItem->moveItem(item);
  244. break;
  245. } else if (i==item) {
  246. // item is first, move currItem before item
  247. e->accept();
  248. currItem->moveItem(item);
  249. item->moveItem(currItem);
  250. break;
  251. }
  252. }
  253. } else e->ignore();
  254. } else e->ignore();
  255. } else e->ignore();
  256. } else e->ignore();
  257. }
  258. virtual void dragEnterEvent (QDragEnterEvent *e) {
  259. if (e->source()==this&&(e->provides("x-ktigcc-dnd")))
  260. e->accept();
  261. }
  262. virtual void dragMoveEvent (QDragMoveEvent *e) {
  263. if (e->source()==this && e->provides("x-ktigcc-dnd")) {
  264. QListViewItem *currItem;
  265. currItem = *reinterpret_cast<QListViewItem * const *>((const char *)e->encodedData("x-ktigcc-dnd"));
  266. if (IS_FOLDER(currItem) && !IS_CATEGORY(currItem)) {
  267. // dropping folder
  268. // can only drop on folder or category
  269. QPoint vp=contentsToViewport(e->pos());
  270. QListViewItem *item=itemAt(vp);
  271. if (IS_FOLDER(item)) {
  272. // need same category
  273. QListViewItem *srcCategory=currItem;
  274. while (srcCategory->parent()->rtti()==0x716CC0) srcCategory=srcCategory->parent();
  275. QListViewItem *destCategory=item;
  276. while (destCategory->parent()->rtti()==0x716CC0) destCategory=destCategory->parent();
  277. if (srcCategory == destCategory) {
  278. // can't move folder into itself
  279. for (QListViewItem *destFolder=item; destFolder->rtti()==0x716CC0; destFolder=destFolder->parent()) {
  280. if (destFolder==currItem) goto ignore;
  281. }
  282. e->accept();
  283. } else {ignore: e->ignore();}
  284. } else e->ignore();
  285. } else if (IS_FILE(currItem)) {
  286. // dropping file
  287. QPoint vp=contentsToViewport(e->pos());
  288. QListViewItem *item=itemAt(vp);
  289. if (IS_FOLDER(item)) {
  290. // drop on folder
  291. e->accept();
  292. } else if (IS_FILE(item)) {
  293. // drop on file
  294. // need same parent, but different items
  295. if (currItem->parent() == item->parent()
  296. && currItem != item) e->accept(); else e->ignore();
  297. } else e->ignore();
  298. } else e->ignore();
  299. } else e->ignore();
  300. }
  301. };
  302. void MainForm::init()
  303. {
  304. fileNewFolderAction->setEnabled(FALSE);
  305. KParts::Factory* factory = (KParts::Factory *)
  306. KLibLoader::self()->factory ("libkatepart");
  307. if (!factory) exit(1);
  308. KTextEditor::Document *doc = (KTextEditor::Document *)
  309. factory->createPart( 0, "", this, "", "KTextEditor::Document" );
  310. m_view = (Kate::View *) doc->createView( splitter, 0L );
  311. m_view->setEnabled(FALSE);
  312. m_view->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding,0,0));
  313. write_temp_file("config.tmp","[Kate Renderer Defaults]\nSchema=ktigcc - Grayed Out\n",0);
  314. KConfig kconfig(QString(tempdir)+"/config.tmp",true);
  315. m_view->getDoc()->readConfig(&kconfig);
  316. delete_temp_file("config.tmp");
  317. m_view->getDoc()->setHlMode(0);
  318. connect(m_view,SIGNAL(cursorPositionChanged()),this,SLOT(m_view_cursorPositionChanged()));
  319. connect(m_view->getDoc(),SIGNAL(textChanged()),this,SLOT(m_view_textChanged()));
  320. te_popup = new QPopupMenu(this);
  321. te_popup->insertItem("&Open file at cursor",0);
  322. te_popup->insertItem("&Find symbol declaration",1);
  323. te_popup->insertSeparator();
  324. te_popup->insertItem("&Undo",2);
  325. te_popup->insertItem("&Redo",3);
  326. te_popup->insertSeparator();
  327. te_popup->insertItem("&Clear",4);
  328. te_popup->insertItem("Cu&t",5);
  329. te_popup->insertItem("Cop&y",6);
  330. te_popup->insertItem("&Paste",7);
  331. te_popup->insertSeparator();
  332. te_popup->insertItem("&Select all",8);
  333. te_popup->insertSeparator();
  334. te_popup->insertItem("&Increase indent",9);
  335. te_popup->insertItem("&Decrease indent",10);
  336. m_view->installPopup(te_popup);
  337. connect(te_popup,SIGNAL(aboutToShow()),this,SLOT(te_popup_aboutToShow()));
  338. QValueList<int> list;
  339. list.append(150);
  340. list.append(500);
  341. splitter->setSizes(list);
  342. leftStatusLabel=new QLabel("0 Files Total",this);
  343. leftStatusLabel->setMaximumWidth(splitter->sizes().first());
  344. statusBar()->addWidget(leftStatusLabel,1);
  345. rowStatusLabel=new QLabel("",this);
  346. rowStatusLabel->setAlignment(Qt::AlignRight);
  347. statusBar()->addWidget(rowStatusLabel,1);
  348. rowStatusLabel->hide();
  349. colStatusLabel=new QLabel("",this);
  350. colStatusLabel->setAlignment(Qt::AlignRight);
  351. statusBar()->addWidget(colStatusLabel,1);
  352. colStatusLabel->hide();
  353. charsStatusLabel=new QLabel("",this);
  354. statusBar()->addWidget(charsStatusLabel,1);
  355. charsStatusLabel->hide();
  356. rightStatusLabel=new QLabel("",this);
  357. rightStatusLabel->setMaximumWidth(splitter->sizes().last());
  358. statusBar()->addWidget(rightStatusLabel,1);
  359. statusBar()->setSizeGripEnabled(FALSE);
  360. fileTree->setSorting(-1);
  361. fileTree->setColumnWidthMode(0,QListView::Maximum);
  362. fileTree->header()->hide();
  363. rootListItem=new QListViewItem(fileTree);
  364. rootListItem->setText(0,"Project1");
  365. rootListItem->setPixmap(0,QPixmap::fromMimeSource("tpr.png"));
  366. rootListItem->setOpen(TRUE);
  367. rootListItem->setDragEnabled(TRUE);
  368. QListViewItem *folderListItem=new ListViewFolder(rootListItem);
  369. hFilesListItem=folderListItem;
  370. folderListItem->setText(0,"Header Files");
  371. folderListItem=new ListViewFolder(rootListItem,folderListItem);
  372. cFilesListItem=folderListItem;
  373. folderListItem->setText(0,"C Files");
  374. folderListItem=new ListViewFolder(rootListItem,folderListItem);
  375. sFilesListItem=folderListItem;
  376. folderListItem->setText(0,"GNU Assembly Files");
  377. char a68k_path[strlen(tigcc_base)+10];
  378. sprintf(a68k_path, "%s/bin/a68k", tigcc_base);
  379. if(access(a68k_path, F_OK) != -1) {
  380. folderListItem=new ListViewFolder(rootListItem,folderListItem);
  381. asmFilesListItem=folderListItem;
  382. folderListItem->setText(0,"A68k Assembly Files");
  383. } else {
  384. qllFilesListItem=NULL;
  385. fileNewQuillSourceFileAction->setVisible(FALSE);
  386. }
  387. if (quill_drv) {
  388. folderListItem=new ListViewFolder(rootListItem,folderListItem);
  389. qllFilesListItem=folderListItem;
  390. folderListItem->setText(0,"Quill Files");
  391. } else {
  392. qllFilesListItem=NULL;
  393. fileNewQuillSourceFileAction->setVisible(FALSE);
  394. }
  395. folderListItem=new ListViewFolder(rootListItem,folderListItem);
  396. oFilesListItem=folderListItem;
  397. folderListItem->setText(0,"Object Files");
  398. folderListItem=new ListViewFolder(rootListItem,folderListItem);
  399. aFilesListItem=folderListItem;
  400. folderListItem->setText(0,"Archive Files");
  401. folderListItem=new ListViewFolder(rootListItem,folderListItem);
  402. txtFilesListItem=folderListItem;
  403. folderListItem->setText(0,"Text Files");
  404. folderListItem=new ListViewFolder(rootListItem,folderListItem);
  405. othFilesListItem=folderListItem;
  406. folderListItem->setText(0,"Other Files");
  407. khelpmenu=new KHelpMenu(this,pabout);
  408. assistant = new QAssistantClient("",this);
  409. QStringList args(QString("-profile"));
  410. args.append(QString("%1/doc/html/qt-assistant.adp").arg(tigcc_base));
  411. assistant->setArguments(args);
  412. lastDirectory=TIGCCProjectDirectory;
  413. startTimer(100);
  414. }
  415. void MainForm::destroy()
  416. {
  417. Kate::Document *doc=m_view->getDoc();
  418. delete m_view;
  419. delete doc;
  420. delete te_popup;
  421. delete leftStatusLabel;
  422. delete rowStatusLabel;
  423. delete colStatusLabel;
  424. delete charsStatusLabel;
  425. delete rightStatusLabel;
  426. delete rootListItem;
  427. delete khelpmenu;
  428. delete assistant;
  429. }
  430. void MainForm::te_popup_aboutToShow()
  431. {
  432. te_popup->setItemEnabled(0,findOpenFileAtCursorAction->isEnabled());
  433. te_popup->setItemEnabled(1,findFindSymbolDeclarationAction->isEnabled());
  434. te_popup->setItemEnabled(2,editUndoAction->isEnabled());
  435. te_popup->setItemEnabled(3,editRedoAction->isEnabled());
  436. te_popup->setItemEnabled(4,editClearAction->isEnabled());
  437. te_popup->setItemEnabled(5,editCutAction->isEnabled());
  438. te_popup->setItemEnabled(6,editCopyAction->isEnabled());
  439. te_popup->setItemEnabled(7,editPasteAction->isEnabled());
  440. te_popup->setItemEnabled(8,editSelectAllAction->isEnabled());
  441. te_popup->setItemEnabled(9,editIncreaseIndentAction->isEnabled());
  442. te_popup->setItemEnabled(10,editDecreaseIndentAction->isEnabled());
  443. }
  444. void MainForm::fileNewProject()
  445. {
  446. rootListItem->setText(0,"Project1");
  447. fileTreeClicked(rootListItem);
  448. QListViewItem *f, *next;
  449. for (f=hFilesListItem->firstChild();f;f=next) {
  450. next=f->nextSibling();
  451. delete f;
  452. }
  453. for (f=cFilesListItem->firstChild();f;f=next) {
  454. next=f->nextSibling();
  455. delete f;
  456. }
  457. for (f=sFilesListItem->firstChild();f;f=next) {
  458. next=f->nextSibling();
  459. delete f;
  460. }
  461. if (asmFilesListItem) {
  462. for (f=asmFilesListItem->firstChild();f;f=next) {
  463. next=f->nextSibling();
  464. delete f;
  465. }
  466. }
  467. if (qllFilesListItem) {
  468. for (f=qllFilesListItem->firstChild();f;f=next) {
  469. next=f->nextSibling();
  470. delete f;
  471. }
  472. }
  473. for (f=oFilesListItem->firstChild();f;f=next) {
  474. next=f->nextSibling();
  475. delete f;
  476. }
  477. for (f=aFilesListItem->firstChild();f;f=next) {
  478. next=f->nextSibling();
  479. delete f;
  480. }
  481. for (f=txtFilesListItem->firstChild();f;f=next) {
  482. next=f->nextSibling();
  483. delete f;
  484. }
  485. for (f=othFilesListItem->firstChild();f;f=next) {
  486. next=f->nextSibling();
  487. delete f;
  488. }
  489. fileCount=cFileCount=hFileCount=sFileCount=asmFileCount=qllFileCount=oFileCount=aFileCount=txtFileCount=othFileCount=0;
  490. updateLeftStatusLabel();
  491. }
  492. QString MainForm::SGetFileName(int mode,short fileFilter,const QString &caption,QWidget *parent)
  493. {
  494. QString ret;
  495. if (static_cast<KFileDialog::OperationMode>(mode)==KFileDialog::Opening)
  496. ret=KFileDialog::getOpenFileName(lastDirectory,TIGCCFileFilters[fileFilter],parent,caption);
  497. else
  498. ret=KFileDialog::getSaveFileName(lastDirectory,TIGCCFileFilters[fileFilter],parent,caption);
  499. if (!ret.isNull())
  500. {
  501. KURL dir;
  502. dir.setPath(ret);
  503. dir.setFileName("");
  504. lastDirectory=dir.path();
  505. }
  506. return ret;
  507. }
  508. //no mode, since it you can't save multiple.
  509. QStringList MainForm::SGetFileName_Multiple(short fileFilter,const QString &caption,QWidget *parent)
  510. {
  511. QStringList ret;
  512. ret=KFileDialog::getOpenFileNames(lastDirectory,TIGCCFileFilters[fileFilter],parent,caption);
  513. if (!ret.empty())
  514. {
  515. KURL dir;
  516. dir.setPath(ret[0]);
  517. dir.setFileName("");
  518. lastDirectory=dir.path();
  519. }
  520. return ret;
  521. }
  522. void MainForm::openFile(QListViewItem * category, QListViewItem * parent, const QString &fileCaption, const QString &fileName)
  523. {
  524. QListViewItem *item=NULL, *next=parent->firstChild();
  525. for (; next; next=item->nextSibling())
  526. item=next;
  527. ListViewFile *newFile=item?new ListViewFile(parent,item)
  528. :new ListViewFile(parent);
  529. newFile->setText(0,fileCaption);
  530. newFile->setPixmap(0,QPixmap::fromMimeSource(
  531. category==cFilesListItem||category==qllFilesListItem?"filec.png":
  532. category==hFilesListItem?"fileh.png":
  533. category==sFilesListItem||category==asmFilesListItem?"files.png":
  534. category==txtFilesListItem?"filet.png":"filex.png"));
  535. if (IS_EDITABLE_CATEGORY(category)) {
  536. QString fileText=loadFileText(fileName);
  537. if (fileText.isNull()) {
  538. KMessageBox::sorry(this,QString("Can't open \'%1\'").arg(fileName),"Warning");
  539. fileText="";
  540. }
  541. newFile->textBuffer=fileText;
  542. }
  543. newFile->fileName=fileName;
  544. fileCount++;
  545. (category==hFilesListItem?hFileCount:category==cFilesListItem?cFileCount:
  546. category==sFilesListItem?sFileCount:category==asmFilesListItem?asmFileCount:
  547. category==qllFilesListItem?qllFileCount:category==oFilesListItem?oFileCount:
  548. category==aFilesListItem?aFileCount:category==txtFilesListItem?txtFileCount:
  549. othFileCount)++;
  550. }
  551. void MainForm::fileOpen_addList(QListViewItem *category,void *fileListV,void *dir)
  552. {
  553. int i,e;
  554. KURL tmp;
  555. TPRFileList *fileList=(TPRFileList*)fileListV;
  556. e=fileList->path.count();
  557. if (e) category->setOpen(TRUE);
  558. for (i=0;i<e;i++)
  559. {
  560. tmp=*reinterpret_cast<const KURL *>(dir);
  561. tmp.setFileName(fileList->path[i]);
  562. openFile(category,category,fileList->path[i],tmp.path());
  563. }
  564. updateLeftStatusLabel();
  565. }
  566. void MainForm::fileOpen()
  567. {
  568. TPRDataStruct TPRData;
  569. QString fileName=SGetFileName(KFileDialog::Opening,TIGCCOpenProjectFileFilter,"Open Project/File",this);
  570. KURL dir;
  571. dir.setPath(fileName);
  572. int ret=loadTPR(fileName, &TPRData);
  573. if (ret == -1) {
  574. KMessageBox::error(this,QString("Can't open \'%1\'").arg(fileName));
  575. return;
  576. }
  577. if (ret > 0) {
  578. KMessageBox::error(this,QString("Error at line %2 of \'%1\'").arg(fileName).arg(ret));
  579. return;
  580. }
  581. if (TPRData.asm_files.path.count() && !asmFilesListItem) {
  582. KMessageBox::error(this,"This project needs A68k, which is not installed.");
  583. return;
  584. }
  585. if (TPRData.quill_files.path.count() && !qllFilesListItem) {
  586. KMessageBox::error(this,"This project needs quill.drv, which is not installed.");
  587. return;
  588. }
  589. fileNewProject();
  590. fileOpen_addList(hFilesListItem,&TPRData.h_files,&dir);
  591. fileOpen_addList(cFilesListItem,&TPRData.c_files,&dir);
  592. fileOpen_addList(qllFilesListItem,&TPRData.quill_files,&dir);
  593. fileOpen_addList(sFilesListItem,&TPRData.s_files,&dir);
  594. fileOpen_addList(asmFilesListItem,&TPRData.asm_files,&dir);
  595. fileOpen_addList(oFilesListItem,&TPRData.o_files,&dir);
  596. fileOpen_addList(aFilesListItem,&TPRData.a_files,&dir);
  597. fileOpen_addList(txtFilesListItem,&TPRData.txt_files,&dir);
  598. fileOpen_addList(othFilesListItem,&TPRData.oth_files,&dir);
  599. settings=TPRData.settings;
  600. libopts=TPRData.libopts;
  601. }
  602. void MainForm::fileSave()
  603. {
  604. }
  605. void MainForm::fileSaveAs()
  606. {
  607. QString fileName=SGetFileName(KFileDialog::Saving,TIGCCSaveProjectFilter,"Save Project",this);
  608. }
  609. void MainForm::filePrint()
  610. {
  611. }
  612. void MainForm::editUndo()
  613. {
  614. }
  615. void MainForm::editRedo()
  616. {
  617. }
  618. void MainForm::editCut()
  619. {
  620. }
  621. void MainForm::editCopy()
  622. {
  623. }
  624. void MainForm::editPaste()
  625. {
  626. }
  627. void MainForm::editFind()
  628. {
  629. }
  630. void MainForm::findFindSymbolDeclaration()
  631. {
  632. }
  633. void MainForm::helpDocumentation()
  634. {
  635. assistant->openAssistant();
  636. }
  637. void MainForm::helpContents()
  638. {
  639. force_qt_assistant_page(0);
  640. assistant->openAssistant();
  641. }
  642. void MainForm::helpIndex()
  643. {
  644. force_qt_assistant_page(1);
  645. assistant->openAssistant();
  646. }
  647. void MainForm::helpSearch()
  648. {
  649. force_qt_assistant_page(3);
  650. assistant->openAssistant();
  651. }
  652. void MainForm::helpNews()
  653. {
  654. }
  655. void MainForm::helpAbout()
  656. {
  657. khelpmenu->aboutApplication();
  658. }
  659. void MainForm::updateSizes()
  660. {
  661. int leftSize=splitter->sizes().first();
  662. int rightSize=splitter->sizes().last();
  663. int totalSize=leftSize+rightSize;
  664. int mySize=size().width();
  665. leftStatusLabel->setMaximumWidth(leftSize*mySize/totalSize);
  666. rightStatusLabel->setMaximumWidth(rightSize*mySize/totalSize-10>0?
  667. rightSize*mySize/totalSize-10:0);
  668. }
  669. void MainForm::resizeEvent(QResizeEvent *event)
  670. {
  671. QMainWindow::resizeEvent(event);
  672. if (event->size()==event->oldSize()) return;
  673. updateSizes();
  674. }
  675. void MainForm::timerEvent(QTimerEvent *event)
  676. {
  677. static int lastSplitterPos=-1;
  678. QMainWindow::timerEvent(event);
  679. if (lastSplitterPos==splitter->sizes().first()) return;
  680. lastSplitterPos=splitter->sizes().first();
  681. updateSizes();
  682. }
  683. void MainForm::fileTreeClicked(QListViewItem *item)
  684. {
  685. if (!item) return;
  686. if (IS_FOLDER(currentListItem))
  687. currentListItem->setPixmap(0,QPixmap::fromMimeSource("folder1.png"));
  688. if (IS_FILE(currentListItem)) {
  689. if (currentListItemEditable) {
  690. static_cast<ListViewFile *>(currentListItem)->textBuffer=m_view->getDoc()->text();
  691. m_view->cursorPositionReal(&(static_cast<ListViewFile *>(currentListItem)->cursorLine),
  692. &(static_cast<ListViewFile *>(currentListItem)->cursorCol));
  693. }
  694. }
  695. if (IS_FOLDER(item)) {
  696. item->setPixmap(0,QPixmap::fromMimeSource("folder2.png"));
  697. fileNewFolderAction->setEnabled(TRUE);
  698. m_view->setEnabled(FALSE);
  699. m_view->getDoc()->setText("");
  700. write_temp_file("config.tmp","[Kate Renderer Defaults]\nSchema=ktigcc - Grayed Out\n",0);
  701. KConfig kconfig(QString(tempdir)+"/config.tmp",true);
  702. m_view->getDoc()->readConfig(&kconfig);
  703. delete_temp_file("config.tmp");
  704. m_view->getDoc()->setHlMode(0);
  705. } else if (IS_FILE(item)) {
  706. fileNewFolderAction->setEnabled(TRUE);
  707. m_view->setEnabled(TRUE);
  708. QListViewItem *category=item->parent();
  709. while (category->parent()->rtti()==0x716CC0) category=category->parent();
  710. if (IS_EDITABLE_CATEGORY(category)) {
  711. m_view->getDoc()->setText(static_cast<ListViewFile *>(item)->textBuffer);
  712. const char *buffer=static_cast<ListViewFile *>(item)->textBuffer;
  713. write_temp_file("config.tmp","[Kate Renderer Defaults]\nSchema=kate - Normal\n",0);
  714. KConfig kconfig(QString(tempdir)+"/config.tmp",true);
  715. m_view->getDoc()->readConfig(&kconfig);
  716. delete_temp_file("config.tmp");
  717. uint cnt=m_view->getDoc()->hlModeCount(), i;
  718. for (i=0; i<cnt; i++) {
  719. if (!m_view->getDoc()->hlModeName(i).compare(
  720. ((category==sFilesListItem||(category==hFilesListItem&&buffer&&*buffer=='|'))?
  721. "GNU Assembler 68k":
  722. (category==asmFilesListItem||(category==hFilesListItem&&buffer&&*buffer==';'))?
  723. "Motorola Assembler 68k":
  724. (category==cFilesListItem||category==qllFilesListItem||category==hFilesListItem)?
  725. "C":
  726. "None"))) break;
  727. }
  728. if (i==cnt) i=0;
  729. m_view->getDoc()->setHlMode(i);
  730. m_view->setCursorPositionReal(static_cast<ListViewFile *>(item)->cursorLine,
  731. static_cast<ListViewFile *>(item)->cursorCol);
  732. currentListItemEditable=TRUE;
  733. } else {
  734. m_view->getDoc()->setText("");
  735. write_temp_file("config.tmp","[Kate Renderer Defaults]\nSchema=ktigcc - Grayed Out\n",0);
  736. KConfig kconfig(QString(tempdir)+"/config.tmp",true);
  737. m_view->getDoc()->readConfig(&kconfig);
  738. delete_temp_file("config.tmp");
  739. m_view->getDoc()->setHlMode(0);
  740. currentListItemEditable=FALSE;
  741. }
  742. } else {
  743. fileNewFolderAction->setEnabled(FALSE);
  744. m_view->setEnabled(FALSE);
  745. m_view->getDoc()->setText("");
  746. write_temp_file("config.tmp","[Kate Renderer Defaults]\nSchema=ktigcc - Grayed Out\n",0);
  747. KConfig kconfig(QString(tempdir)+"/config.tmp",true);
  748. m_view->getDoc()->readConfig(&kconfig);
  749. delete_temp_file("config.tmp");
  750. m_view->getDoc()->setHlMode(0);
  751. }
  752. currentListItem=item;
  753. updateLeftStatusLabel();
  754. updateRightStatusLabel();
  755. }
  756. void MainForm::fileNewFolder()
  757. {
  758. if (IS_FILE(currentListItem))
  759. currentListItem=currentListItem->parent();
  760. QListViewItem *item=NULL, *next=currentListItem->firstChild();
  761. for (; IS_FOLDER(next); next=item->nextSibling())
  762. item=next;
  763. QListViewItem *newFolder=item?new ListViewFolder(currentListItem,item)
  764. :new ListViewFolder(currentListItem);
  765. newFolder->setText(0,"NewFolder");
  766. newFolder->setRenameEnabled(0,TRUE);
  767. currentListItem->setOpen(TRUE);
  768. fileTreeClicked(newFolder);
  769. newFolder->startRename(0);
  770. }
  771. #define unused_col __attribute__((unused)) col /* stupid QT designer... */
  772. void MainForm::fileTreeContextMenuRequested(QListViewItem *item,
  773. const QPoint &pos,
  774. int unused_col)
  775. {
  776. fileTreeClicked(item);
  777. if (IS_FOLDER(item)) {
  778. QPopupMenu menu;
  779. menu.insertItem("New &Folder",0);
  780. menu.insertItem("New F&ile",1);
  781. QListViewItem *category=item;
  782. while (category->parent()->rtti()==0x716CC0) category=category->parent();
  783. if (category==oFilesListItem || category==aFilesListItem
  784. || category==othFilesListItem) menu.setItemEnabled(1,FALSE);
  785. if (!IS_CATEGORY(item)) {
  786. menu.insertSeparator();
  787. menu.insertItem("&Remove",2);
  788. menu.insertItem("Re&name",3);
  789. }
  790. switch (menu.exec(pos)) {
  791. case 0:
  792. fileNewFolder();
  793. break;
  794. case 1:
  795. newFile(item);
  796. break;
  797. case 2:
  798. delete item;
  799. currentListItem=NULL;
  800. fileTreeClicked(fileTree->currentItem());
  801. break;
  802. case 3:
  803. item->startRename(0);
  804. }
  805. }
  806. }
  807. void MainForm::newFile( QListViewItem *parent, QString text, const char *iconName )
  808. {
  809. QListViewItem *item=NULL, *next=parent->firstChild();
  810. for (; next; next=item->nextSibling())
  811. item=next;
  812. ListViewFile *newFile=item?new ListViewFile(parent,item)
  813. :new ListViewFile(parent);
  814. newFile->setText(0,"New File");
  815. newFile->setPixmap(0,QPixmap::fromMimeSource(iconName));
  816. parent->setOpen(TRUE);
  817. newFile->textBuffer=text;
  818. fileTreeClicked(newFile);
  819. newFile->startRename(0);
  820. m_view->getDoc()->setText(text);
  821. fileCount++;
  822. QListViewItem *category=parent;
  823. while (category->parent()->rtti()==0x716CC0) category=category->parent();
  824. (category==hFilesListItem?hFileCount:category==cFilesListItem?cFileCount:
  825. category==sFilesListItem?sFileCount:category==asmFilesListItem?asmFileCount:
  826. category==qllFilesListItem?qllFileCount:category==oFilesListItem?oFileCount:
  827. category==aFilesListItem?aFileCount:category==txtFilesListItem?txtFileCount:
  828. othFileCount)++;
  829. updateLeftStatusLabel();
  830. }
  831. void MainForm::newFile( QListViewItem *parent )
  832. {
  833. QListViewItem *category=parent;
  834. while (category->parent()->rtti()==0x716CC0) category=category->parent();
  835. newFile(parent,category==txtFilesListItem?"":
  836. ((category==hFilesListItem?"// Header File\n//":
  837. category==cFilesListItem?"// C Source File\n//":
  838. category==sFilesListItem?"| Assembly Source File\n|":
  839. category==asmFilesListItem?"; Assembly Source File\n;":
  840. category==qllFilesListItem?"// Quill Source File\n//":"???\n")
  841. +QString(" Created ")
  842. +QDateTime::currentDateTime ().toString(Qt::LocalDate)+"\n"+
  843. QString(category==cFilesListItem?(cFileCount?
  844. "\n#include <tigcclib.h>\n":
  845. "\n// Delete or comment out the items you do not need.\n"
  846. "#define COMMENT_STRING \"Place your comment here.\"\n"
  847. "#define COMMENT_PROGRAM_NAME "
  848. "\"Place your program name here.\"\n"
  849. "#define COMMENT_VERSION_STRING "
  850. "\"Place your version string here.\"\n"
  851. "#define COMMENT_VERSION_NUMBER 0,0,0,0 "
  852. "/* major, minor, revision, subrevision */\n"
  853. "#define COMMENT_AUTHORS "
  854. "\"Place your author name(s) here.\"\n"
  855. "#define COMMENT_BW_ICON \\\n"
  856. "\t{0b0000000000000000, \\\n"
  857. "\t 0b0000000000000000, \\\n"
  858. "\t 0b0000000000000000, \\\n"
  859. "\t 0b0000000000000000, \\\n"
  860. "\t 0b0000000000000000, \\\n"
  861. "\t 0b0000000000000000, \\\n"
  862. "\t 0b0000000000000000, \\\n"
  863. "\t 0b0000000000000000, \\\n"
  864. "\t 0b0000000000000000, \\\n"
  865. "\t 0b0000000000000000, \\\n"
  866. "\t 0b0000000000000000, \\\n"
  867. "\t 0b0000000000000000, \\\n"
  868. "\t 0b0000000000000000, \\\n"
  869. "\t 0b0000000000000000, \\\n"
  870. "\t 0b0000000000000000, \\\n"
  871. "\t 0b0000000000000000}\n"
  872. "#define COMMENT_GRAY_ICON \\\n"
  873. "\t{0b0000000000000000, \\\n"
  874. "\t 0b0000000000000000, \\\n"
  875. "\t 0b0000000000000000, \\\n"
  876. "\t 0b0000000000000000, \\\n"
  877. "\t 0b0000000000000000, \\\n"
  878. "\t 0b0000000000000000, \\\n"
  879. "\t 0b0000000000000000, \\\n"
  880. "\t 0b0000000000000000, \\\n"
  881. "\t 0b0000000000000000, \\\n"
  882. "\t 0b0000000000000000, \\\n"
  883. "\t 0b0000000000000000, \\\n"
  884. "\t 0b0000000000000000, \\\n"
  885. "\t 0b0000000000000000, \\\n"
  886. "\t 0b0000000000000000, \\\n"
  887. "\t 0b0000000000000000, \\\n"
  888. "\t 0b0000000000000000}, \\\n"
  889. "\t{0b0000000000000000, \\\n"
  890. "\t 0b0000000000000000, \\\n"
  891. "\t 0b0000000000000000, \\\n"
  892. "\t 0b0000000000000000, \\\n"
  893. "\t 0b0000000000000000, \\\n"
  894. "\t 0b0000000000000000, \\\n"
  895. "\t 0b0000000000000000, \\\n"
  896. "\t 0b0000000000000000, \\\n"
  897. "\t 0b0000000000000000, \\\n"
  898. "\t 0b0000000000000000, \\\n"
  899. "\t 0b0000000000000000, \\\n"
  900. "\t 0b0000000000000000, \\\n"
  901. "\t 0b0000000000000000, \\\n"
  902. "\t 0b0000000000000000, \\\n"
  903. "\t 0b0000000000000000, \\\n"
  904. "\t 0b0000000000000000}\n\n#include <tigcclib.h>\n\n"
  905. "// Main Function\nvoid _main(void)\n{\n"
  906. "\t// Place your code here.\n}\n"):"")),
  907. category==cFilesListItem||category==qllFilesListItem
  908. ?"filec.png":
  909. category==hFilesListItem?"fileh.png":
  910. category==sFilesListItem||category==asmFilesListItem
  911. ?"files.png":
  912. category==txtFilesListItem?"filet.png":"filex.png");
  913. }
  914. void MainForm::fileNewCHeader()
  915. {
  916. newFile(hFilesListItem,"// Header File\n// Created "+QDateTime::currentDateTime ().toString(Qt::LocalDate)+"\n","fileh.png");
  917. }
  918. void MainForm::fileNewGNUAssemblyHeader()
  919. {
  920. newFile(hFilesListItem,"| Header File\n| Created "+QDateTime::currentDateTime ().toString(Qt::LocalDate)+"\n","fileh.png");
  921. }
  922. void MainForm::fileNewA68kAssemblyHeader()
  923. {
  924. newFile(hFilesListItem,"; Header File\n; Created "+QDateTime::currentDateTime ().toString(Qt::LocalDate)+"\n","fileh.png");
  925. }
  926. void MainForm::fileNewCSourceFile()
  927. {
  928. newFile(cFilesListItem,"// C Source File\n// Created "+QDateTime::currentDateTime ().toString(Qt::LocalDate)+"\n","filec.png");
  929. }
  930. void MainForm::fileNewGNUAssemblySourceFile()
  931. {
  932. newFile(sFilesListItem,"| Assembly Source File\n| Created "+QDateTime::currentDateTime ().toString(Qt::LocalDate)+"\n","files.png");
  933. }
  934. void MainForm::fileNewA68kAssemblySourceFile()
  935. {
  936. newFile(asmFilesListItem,"; Assembly Source File\n; Created "+QDateTime::currentDateTime ().toString(Qt::LocalDate)+"\n","files.png");
  937. }
  938. void MainForm::fileNewQuillSourceFile()
  939. {
  940. newFile(qllFilesListItem,"// Quill Source File\n// Created "+QDateTime::currentDateTime ().toString(Qt::LocalDate)+"\n","filec.png");
  941. }
  942. void MainForm::fileNewTextFile()
  943. {
  944. newFile(txtFilesListItem,"","filet.png");
  945. }
  946. void MainForm::updateLeftStatusLabel()
  947. {
  948. QString text=QString::number(fileCount)+QString(" File")
  949. +QString(fileCount!=1?"s":"")+QString(" Total");
  950. QListViewItem *category=currentListItem;
  951. if (IS_FOLDER(currentListItem)||IS_FILE(currentListItem)) {
  952. while (category->parent()->rtti()==0x716CC0) category=category->parent();
  953. text+=QString(", ")+QString::number(category==hFilesListItem?hFileCount:
  954. category==cFilesListItem?cFileCount:
  955. category==sFilesListItem?sFileCount:
  956. category==asmFilesListItem?asmFileCount:
  957. category==qllFilesListItem?qllFileCount:
  958. category==oFilesListItem?oFileCount:
  959. category==aFilesListItem?aFileCount:
  960. category==txtFilesListItem?txtFileCount:
  961. othFileCount)
  962. +QString(" in Category");
  963. }
  964. leftStatusLabel->setText(text);
  965. }
  966. void MainForm::updateRightStatusLabel()
  967. {
  968. int leftSize=splitter->sizes().first();
  969. int rightSize=splitter->sizes().last();
  970. int totalSize=leftSize+rightSize;
  971. int mySize=size().width();
  972. int rightStatusSize=rightSize*mySize/totalSize-10>0?
  973. rightSize*mySize/totalSize-10:0;
  974. if (currentListItem==rootListItem) {
  975. rowStatusLabel->hide();
  976. colStatusLabel->hide();
  977. charsStatusLabel->hide();
  978. rightStatusLabel->setMaximumWidth(rightStatusSize);
  979. rightStatusLabel->setText("project file name");
  980. } else if (IS_FOLDER(currentListItem)) {
  981. rowStatusLabel->hide();
  982. colStatusLabel->hide();
  983. charsStatusLabel->hide();
  984. rightStatusLabel->setMaximumWidth(rightStatusSize);
  985. rightStatusLabel->setText("");
  986. } else if (IS_FILE(currentListItem)) {
  987. QListViewItem *category=currentListItem;
  988. while (category->parent()->rtti()==0x716CC0) category=category->parent();
  989. if (category==hFilesListItem||category==cFilesListItem
  990. ||category==sFilesListItem||category==asmFilesListItem
  991. ||category==qllFilesListItem||category==txtFilesListItem) {
  992. unsigned int line, col;
  993. m_view->cursorPositionReal(&line,&col);
  994. rowStatusLabel->show();
  995. rowStatusLabel->setMaximumWidth(30);
  996. rowStatusLabel->setText(QString("%1").arg(line));
  997. colStatusLabel->show();
  998. colStatusLabel->setMaximumWidth(30);
  999. colStatusLabel->setText(QString("%1").arg(col+1));
  1000. charsStatusLabel->show();
  1001. charsStatusLabel->setMaximumWidth(100);
  1002. charsStatusLabel->setText(QString("%1 Characters").arg(m_view->getDoc()->text().length()));
  1003. rightStatusLabel->setMaximumWidth(rightStatusSize-160);
  1004. } else {
  1005. rowStatusLabel->hide();
  1006. colStatusLabel->hide();
  1007. charsStatusLabel->hide();
  1008. rightStatusLabel->setMaximumWidth(rightStatusSize);
  1009. }
  1010. rightStatusLabel->setText(static_cast<ListViewFile *>(currentListItem)->fileName);
  1011. }
  1012. }
  1013. void MainForm::m_view_cursorPositionChanged()
  1014. {
  1015. unsigned int line, col;
  1016. m_view->cursorPositionReal(&line,&col);
  1017. rowStatusLabel->setText(QString("%1").arg(line));
  1018. colStatusLabel->setText(QString("%1").arg(col+1));
  1019. }
  1020. void MainForm::m_view_textChanged()
  1021. {
  1022. charsStatusLabel->setText(QString("%1 Characters").arg(m_view->getDoc()->text().length()));
  1023. }
  1024. // Yes, this is an ugly hack... Any better suggestions?
  1025. #define QListView DnDListView