int main( int argc, char **argv )
{
	KCmdLineArgs::init( argc, argv, "klistviewtest", 0, ki18n("K3ListViewTest"), "1.0", ki18n("klistview test app"));
	KApplication app;
	KDialog dialog;
	K3ListView *view = new K3ListView();
  dialog.setMainWidget(view);
	view->setSelectionModeExt( K3ListView::FileManager );
	view->setDragEnabled( true );
	view->setItemsMovable( false );
	view->setAcceptDrops( true );
	view->addColumn("Column 1");
	view->addColumn("Column 2");
	view->addColumn("Column 3");

	new K3ListViewItem( view, "Item 1");
	new K3ListViewItem( view, "Item 1");
	new K3ListViewItem( view, "Item 1");
	new K3ListViewItem( view, "Item 1");
	new K3ListViewItem( view, "Item 1");
	new K3ListViewItem( view, "Item 1");
	new K3ListViewItem( view, "Item 1");
	new K3ListViewItem( view, "Item 1");
	new K3ListViewItem( view, "Item 1");
	new K3ListViewItem( view, "Item 2", "Some more", "Hi Mom :)" );

	view->restoreLayout( KGlobal::config().data(), "ListView" );

	new K3ListViewItem( view, "Item 3" );

	dialog.exec();
	view->saveLayout( KGlobal::config().data(), "ListView" );

	return 0;
}
Exemple #2
0
		QString key() {
			Q3ListViewItem* item = keysListpr->selectedItem();

			if(item)
				return item->text(2);
			return "";
		}
Exemple #3
0
		KGpgSelKey(QWidget *parent, const char *name, QString preselected,
			const KGpgMe& gpg):
		     KDialog(parent) {

			// Dialog options
			setObjectName(name);
			setModal(true);
			setCaption(i18n("Private Key List"));
			setButtons(Ok | Cancel);

			QString keyname;
			QVBoxLayout* vbox;
			QWidget* page = new QWidget(this);
			QLabel* labeltxt;
			KIconLoader* loader = KIconLoader::global();
			QPixmap keyPair = KIcon("kgpg_key2").pixmap(20, 20);

			setMinimumSize(350,100);
			keysListpr = new K3ListView(page);
			keysListpr->setRootIsDecorated(true);
			keysListpr->addColumn(i18n("Name"));
			keysListpr->addColumn(i18n("Email"));
			keysListpr->addColumn(i18n("ID"));
			keysListpr->setShowSortIndicator(true);
			keysListpr->setFullWidth(true);
			keysListpr->setAllColumnsShowFocus(true);

			labeltxt = new QLabel(i18n("Choose a secret key:"),page);
			vbox = new QVBoxLayout(page);

			KGpgKeyList list = gpg.keys(true);

			for(KGpgKeyList::iterator it = list.begin(); it != list.end(); ++it) {
				QString name = gpg.checkForUtf8((*it).name);
				K3ListViewItem *item = new
					K3ListViewItem(keysListpr, name, (*it).email, (*it).id);
				item->setPixmap(0,keyPair);
				if(preselected == (*it).id) {
					keysListpr->setSelected(item, true);
					keysListpr->setCurrentItem(item);
				}
			}
			if(!keysListpr->selectedItem()) {
				keysListpr->setSelected(keysListpr->firstChild(), true);
				keysListpr->setCurrentItem(keysListpr->firstChild());
			}
			vbox->addWidget(labeltxt);
			vbox->addWidget(keysListpr);
			setMainWidget(page);
		};