kexi
KexiStartupDialogTemplatesPage.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "KexiStartupDialogTemplatesPage.h"
00021
00022 #include <core/kexi.h>
00023 #include <core/kexitemplateloader.h>
00024 #include "KexiProjectSelector.h"
00025 #include "KexiOpenExistingFile.h"
00026 #include "KexiConnSelector.h"
00027 #include "KexiConnSelectorBase.h"
00028
00029 #include <qheader.h>
00030
00031 #include <kdebug.h>
00032 #include <kiconloader.h>
00033
00034 #ifdef KEXI_SHOW_UNIMPLEMENTED
00035 #define KEXI_STARTUP_SHOW_TEMPLATES
00036 #define KEXI_STARTUP_SHOW_RECENT
00037 #endif
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00052 class TemplateItem : public KListViewItem
00053 {
00054 public:
00055 TemplateItem(QListView* parent, const QString& aFilename,
00056 const QString& name, const QString& description, const QPixmap& icon,
00057 const QValueList<KexiProjectData::ObjectInfo>& aAutoopenObjects)
00058 : KListViewItem(parent, name + "\n" + description)
00059 , autoopenObjects(aAutoopenObjects)
00060 , filename(aFilename)
00061 {
00062 setPixmap(0, icon);
00063 }
00064 ~TemplateItem() {}
00065
00066 QValueList<KexiProjectData::ObjectInfo> autoopenObjects;
00067 QString filename;
00068 };
00069
00070
00071
00072 KexiStartupDialogTemplatesPage::KexiStartupDialogTemplatesPage( QWidget * parent )
00073 : KListView(parent, "KexiStartupDialogTemplatesPage")
00074 , m_popuplated(false)
00075 {
00076 addColumn(QString::null);
00077 header()->hide();
00078 setColumnWidthMode(0, Maximum);
00079 setResizeMode(LastColumn);
00080 setItemMargin(6);
00081 connect(this,SIGNAL(executed(QListViewItem*)), this, SLOT(slotExecuted(QListViewItem*)));
00082 }
00083
00084 KexiStartupDialogTemplatesPage::~KexiStartupDialogTemplatesPage()
00085 {
00086 }
00087
00088 void KexiStartupDialogTemplatesPage::populate()
00089 {
00090 if (m_popuplated)
00091 return;
00092 m_popuplated = true;
00093 KexiTemplateInfo::List list = KexiTemplateLoader::loadListInfo();
00094 foreach( QValueList<KexiTemplateInfo>::ConstIterator, it, list ) {
00095 new TemplateItem(this, (*it).filename, (*it).name,
00096 (*it).description, (*it).icon, (*it).autoopenObjects);
00097 }
00098 if (firstChild())
00099 setSelected(firstChild(), true);
00100
00101
00102
00103
00104
00105
00106
00107
00108 }
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 QString KexiStartupDialogTemplatesPage::selectedFileName() const
00136 {
00137 TemplateItem* templateItem = static_cast<TemplateItem*>(selectedItem());
00138 return templateItem ? templateItem->filename : QString::null;
00139 }
00140
00141 QValueList<KexiProjectData::ObjectInfo>
00142 KexiStartupDialogTemplatesPage::autoopenObjectsForSelectedTemplate() const
00143 {
00144 TemplateItem* templateItem = static_cast<TemplateItem*>(selectedItem());
00145 return templateItem ? templateItem->autoopenObjects : QValueList<KexiProjectData::ObjectInfo>();
00146 }
00147
00148 void KexiStartupDialogTemplatesPage::slotExecuted(QListViewItem* item)
00149 {
00150 TemplateItem* templateItem = static_cast<TemplateItem*>(item);
00151 if (!templateItem)
00152 return;
00153
00154 emit selected(templateItem->filename);
00155 }
00156
00157 #include "KexiStartupDialogTemplatesPage.moc"
|