~ubuntu-branches/ubuntu/karmic/codelite/karmic

« back to all changes in this revision

Viewing changes to QmakePlugin/qmakesettingstab.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-08-15 17:42:43 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090815174243-nlb9ikgigbiybz12
Tags: 1.0.2893+dfsg-0ubuntu1
* debian/rules:
  + Tidy up get-orig-source rule
* debian/control:
  + Bump Standards-Version
  + Change Maintainer email address to @ubuntu.com
  + Drop cdbs build-dependency
* debian/copyright:
  + Update to DEP-5 format
* debian/patches/00_add-fPIC.patch:
  + Dropped, fix upstream
* Closes LP: #413992

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "qmakesettingstab.h"
 
2
#include <wx/dir.h>
 
3
#include "procutils.h"
 
4
#include <wx/filename.h>
 
5
#include "qmakeconf.h"
 
6
 
 
7
QmakeSettingsTab::QmakeSettingsTab( wxWindow* parent, const wxString &name )
 
8
                : QmakeSettingsTabBase( parent )
 
9
                , m_name(name)
 
10
{
 
11
 
 
12
}
 
13
 
 
14
void QmakeSettingsTab::Load(QmakeConf* conf)
 
15
{
 
16
        m_filePickerQmakeExec->SetPath(conf->Read(m_name + wxT("/qmake")));
 
17
        m_comboBoxQmakespec->Append( GetSpecList(conf->Read(m_name + wxT("/qmake")) ) );
 
18
        m_comboBoxQmakespec->SetValue(conf->Read(m_name + wxT("/qmakespec")));
 
19
        m_textCtrlQtdir->SetValue(conf->Read(m_name + wxT("/qtdir")));
 
20
}
 
21
 
 
22
void QmakeSettingsTab::Save(QmakeConf* conf)
 
23
{
 
24
        conf->Write(m_name + wxT("/qmake"),     m_filePickerQmakeExec->GetPath());
 
25
        conf->Write(m_name + wxT("/qmakespec"), m_comboBoxQmakespec->GetValue());
 
26
        conf->Write(m_name + wxT("/qtdir"),     m_textCtrlQtdir->GetValue());
 
27
        conf->Flush();
 
28
}
 
29
 
 
30
wxArrayString QmakeSettingsTab::GetSpecList(const wxString& qmakePath)
 
31
{
 
32
        wxArrayString specs;
 
33
 
 
34
        if ( qmakePath.IsEmpty() == false && wxFileName::FileExists(qmakePath) ) {
 
35
                wxArrayString cmdOutput;
 
36
 
 
37
                ProcUtils::SafeExecuteCommand(wxString::Format(wxT("\"%s\" -query QT_INSTALL_DATA"), qmakePath.c_str()), cmdOutput);
 
38
                if ( cmdOutput.IsEmpty() == false ) {
 
39
                        wxFileName    installData ( cmdOutput.Item(0).Trim().Trim(false), wxEmptyString );
 
40
                        wxArrayString files;
 
41
 
 
42
                        installData.AppendDir(wxT("mkspecs"));
 
43
                        wxDir::GetAllFiles(installData.GetFullPath(), &files, wxT("*.conf"), wxDIR_DEFAULT);
 
44
 
 
45
                        for ( size_t i=0; i<files.GetCount(); i++) {
 
46
 
 
47
                                wxFileName fn(files.Item(i));
 
48
                                if ( specs.Index(fn.GetDirs().Last()) == wxNOT_FOUND ) {
 
49
                                        specs.Add( fn.GetDirs().Last() );
 
50
                                }
 
51
                        }
 
52
                }
 
53
        }
 
54
        return specs;
 
55
}
 
56
 
 
57
void QmakeSettingsTab::OnFileSelected(wxFileDirPickerEvent& event)
 
58
{
 
59
        m_comboBoxQmakespec->Clear();
 
60
        m_comboBoxQmakespec->Append( GetSpecList(m_filePickerQmakeExec->GetPath()) );
 
61
}