4 * Copyright (c) 2007 VOROSKOI Andras <voroskoi@frugalware.org>
6 * Copyright: See COPYING file that comes with this distribution.
11 #include <qlistview.h>
13 #include <qtabwidget.h>
16 #include <qapplication.h>
17 #include <qmessagebox.h>
18 #include <qstatusbar.h>
20 #include "mainwidget.h"
21 #include "kfpm_pacman.h"
23 extern QPtrList
<PM_DB
> syncs
;
25 MainWidget::MainWidget(QWidget
* parent
, const char * name
, WFlags f
) : QWidget (parent
, name
)
28 QVBoxLayout
*topLayout
= new QVBoxLayout(this);
29 Q_CHECK_PTR(topLayout
);
32 QPopupMenu
*file
= new QPopupMenu(this);
34 file
->insertItem( "E&xit", qApp
, SLOT(quit()), CTRL
+Key_Q
);
36 QPopupMenu
*help
= new QPopupMenu(this);
38 help
->insertItem( "&About", this, SLOT(about()) );
39 help
->insertItem( "About &Qt", this, SLOT(aboutQt()) );
41 QMenuBar
*menubar
= new QMenuBar(this);
43 menubar
->insertItem( "&File", file
);
44 menubar
->insertItem( "&Help", help
);
46 topLayout
->setMenuBar(menubar
);
49 groupsview
= new QListView(this);
50 Q_CHECK_PTR(groupsview
);
51 groupsview
->addColumn("Groups");
54 QListView
*packages
= new QListView(this);
55 Q_CHECK_PTR(packages
);
56 packages
->addColumn("Name");
57 packages
->addColumn("Version");
58 packages
->addColumn("Desctiption");
61 QListBox
*info
= new QListBox(this);
63 info
->setColumnMode(QListBox::FixedNumber
);
66 QTabWidget
*pkgdetails
= new QTabWidget(this);
67 Q_CHECK_PTR(pkgdetails
);
68 pkgdetails
->addTab(info
, "Info");
71 QHBoxLayout
*leftgrouplist
= new QHBoxLayout(topLayout
);
72 Q_CHECK_PTR(leftgrouplist
);
73 leftgrouplist
->addWidget(groupsview
);
75 QVBoxLayout
*details
= new QVBoxLayout(leftgrouplist
);
77 details
->addWidget(packages
);
78 details
->addWidget(pkgdetails
);
81 this->statusbar
= new QStatusBar(this);
82 Q_CHECK_PTR(statusbar
);
84 topLayout
->addWidget(statusbar
);
87 void MainWidget::about()
89 QMessageBox::about(this, "Kfpm for Frugalware",
90 "Kfpm is a graphical fronted for libpacman.\n");
93 void MainWidget::aboutQt()
95 QMessageBox::aboutQt(this, "About Qt");
98 void MainWidget::getGroupList(QListView
*parent
) {
100 QStringList groupnames
= akarmi
.sync_group(akarmi
.getSync());
101 for (QStringList::Iterator it
= groupnames
.begin(); it
!= groupnames
.end(); it
++) {
102 (void) new QListViewItem(parent
, *it
);